chore: improve event-type atom desc, data fetch (#16890)
This commit is contained in:
1 parent
b283f1f8cd
commit
9d3be8de03
3 files changed
+83
-33
No files matched your search
@@ -3,6 +3,7 @@ import { Controller, useFormContext } from "react-hook-form";
|
||||
import type { UseFormGetValues, UseFormSetValue, Control, FormState } from "react-hook-form";
|
||||
import type { MultiValue } from "react-select";
|
||||
|
||||
import { useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
|
||||
import Locations from "@calcom/features/eventtypes/components/Locations";
|
||||
import type { EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";
|
||||
@@ -11,7 +12,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
import { slugify } from "@calcom/lib/slugify";
|
||||
import turndown from "@calcom/lib/turndownService";
|
||||
import { Label, Select, SettingsToggle, Skeleton, TextField, Editor } from "@calcom/ui";
|
||||
import { Label, Select, SettingsToggle, Skeleton, TextField, Editor, TextAreaField } from "@calcom/ui";
|
||||
|
||||
export type EventSetupTabProps = Pick<
|
||||
EventTypeSetupProps,
|
||||
@@ -19,6 +20,7 @@ export type EventSetupTabProps = Pick<
|
||||
>;
|
||||
export const EventSetupTab = (props: EventSetupTabProps & { urlPrefix: string; hasOrgBranding: boolean }) => {
|
||||
const { t } = useLocale();
|
||||
const isPlatform = useIsPlatform();
|
||||
const formMethods = useFormContext<FormValues>();
|
||||
const { eventType, team, urlPrefix, hasOrgBranding } = props;
|
||||
const [multipleDuration, setMultipleDuration] = useState(
|
||||
@@ -66,38 +68,51 @@ export const EventSetupTab = (props: EventSetupTabProps & { urlPrefix: string; h
|
||||
{...formMethods.register("title")}
|
||||
/>
|
||||
<div>
|
||||
<Label htmlFor="editor">
|
||||
{t("description")}
|
||||
{(isManagedEventType || isChildrenManagedEventType) && shouldLockIndicator("description")}
|
||||
</Label>
|
||||
<Editor
|
||||
getText={() => md.render(formMethods.getValues("description") || "")}
|
||||
setText={(value: string) =>
|
||||
formMethods.setValue("description", turndown(value), { shouldDirty: true })
|
||||
}
|
||||
excludedToolbarItems={["blockType"]}
|
||||
placeholder={t("quick_video_meeting")}
|
||||
editable={!descriptionLockedProps.disabled}
|
||||
firstRender={firstRender}
|
||||
setFirstRender={setFirstRender}
|
||||
/>
|
||||
{isPlatform ? (
|
||||
<TextAreaField
|
||||
{...formMethods.register("description", {
|
||||
disabled: descriptionLockedProps.disabled,
|
||||
})}
|
||||
placeholder={t("quick_video_meeting")}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Label htmlFor="editor">
|
||||
{t("description")}
|
||||
{(isManagedEventType || isChildrenManagedEventType) && shouldLockIndicator("description")}
|
||||
</Label>
|
||||
<Editor
|
||||
getText={() => md.render(formMethods.getValues("description") || "")}
|
||||
setText={(value: string) =>
|
||||
formMethods.setValue("description", turndown(value), { shouldDirty: true })
|
||||
}
|
||||
excludedToolbarItems={["blockType"]}
|
||||
placeholder={t("quick_video_meeting")}
|
||||
editable={!descriptionLockedProps.disabled}
|
||||
firstRender={firstRender}
|
||||
setFirstRender={setFirstRender}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<TextField
|
||||
required
|
||||
label={t("URL")}
|
||||
label={isPlatform ? "Slug" : t("URL")}
|
||||
{...(isManagedEventType || isChildrenManagedEventType ? urlLockedProps : {})}
|
||||
defaultValue={eventType.slug}
|
||||
data-testid="event-slug"
|
||||
addOnLeading={
|
||||
<>
|
||||
{urlPrefix}/
|
||||
{!isManagedEventType
|
||||
? team
|
||||
? (hasOrgBranding ? "" : "team/") + team.slug
|
||||
: formMethods.getValues("users")[0].username
|
||||
: t("username_placeholder")}
|
||||
/
|
||||
</>
|
||||
isPlatform ? undefined : (
|
||||
<>
|
||||
{urlPrefix}/
|
||||
{!isManagedEventType
|
||||
? team
|
||||
? (hasOrgBranding ? "" : "team/") + team.slug
|
||||
: formMethods.getValues("users")[0].username
|
||||
: t("username_placeholder")}
|
||||
/
|
||||
</>
|
||||
)
|
||||
}
|
||||
{...formMethods.register("slug", {
|
||||
setValueAs: (v) => slugify(v),
|
||||
|
||||
Reference in new issue
Block a user