feat: option to enforce language for bookingPage (#18782)
* feature eventType specific language or bookingPage language * chore * fix type checks * chore * chore: remove log * improvement: this updates in DatePicker is not required with context provider method * added e2e tests for InterfaceLanguage feature * corrected prev merge conflict issues * update to align with hooks usage pattern * chore * unrelated auto-formatting changes * unrelated auto-formatting changes * unrelated auto-formatting changes * update to affect interfaceLanguage on success page * undone prettier changes * update test for success page translation * chore * return null from memo * fix typecheck error due to atom imports in useLocale * set default interfaceLanguage as null * updated to use null instead of constant * enhancements * fix latest unit test, use prop instead of useSession hook * fix build issue * chore * fix atom build issue * fix unit test with reqd mock * update to use server i18n rendering * nit * Move import localeOptions to EventSetupTabWebWrapper * make sure we only display interface language option in web app * using customI18nProvider --------- Co-authored-by: amrit <[email protected]> Co-authored-by: Tushar Bhatt <[email protected]> Co-authored-by: Tushar <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Ryukemeister <[email protected]> Co-authored-by: Rajiv Sahal <[email protected]> Co-authored-by: Benny Joo <[email protected]>
This commit is contained in:
26 files changed
+390
-21
No files matched your search
@@ -61,6 +61,7 @@ export type BookerEvent = Pick<
|
||||
| "autoTranslateDescriptionEnabled"
|
||||
| "disableCancelling"
|
||||
| "disableRescheduling"
|
||||
| "interfaceLanguage"
|
||||
> & {
|
||||
subsetOfUsers: BookerEventUser[];
|
||||
showInstantEventConnectNowModal: boolean;
|
||||
|
||||
@@ -18,7 +18,6 @@ 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 { Skeleton } from "@calcom/ui/components/skeleton";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Editor } from "@calcom/ui/components/editor";
|
||||
import { TextAreaField } from "@calcom/ui/components/form";
|
||||
@@ -26,6 +25,7 @@ import { Label } from "@calcom/ui/components/form";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import { SettingsToggle } from "@calcom/ui/components/form";
|
||||
import { Skeleton } from "@calcom/ui/components/skeleton";
|
||||
|
||||
export type EventSetupTabCustomClassNames = {
|
||||
wrapper?: string;
|
||||
@@ -58,12 +58,23 @@ export type EventSetupTabProps = Pick<
|
||||
customClassNames?: EventSetupTabCustomClassNames;
|
||||
};
|
||||
export const EventSetupTab = (
|
||||
props: EventSetupTabProps & { urlPrefix: string; hasOrgBranding: boolean; orgId?: number }
|
||||
props: EventSetupTabProps & {
|
||||
urlPrefix: string;
|
||||
hasOrgBranding: boolean;
|
||||
orgId?: number;
|
||||
localeOptions?: { value: string; label: string }[];
|
||||
}
|
||||
) => {
|
||||
const { t } = useLocale();
|
||||
const isPlatform = useIsPlatform();
|
||||
const formMethods = useFormContext<FormValues>();
|
||||
const { eventType, team, urlPrefix, hasOrgBranding, customClassNames, orgId } = props;
|
||||
|
||||
const interfaceLanguageOptions =
|
||||
props.localeOptions && props.localeOptions.length > 0
|
||||
? [{ label: t("visitors_browser_language"), value: "" }, ...props.localeOptions]
|
||||
: [];
|
||||
|
||||
const [multipleDuration, setMultipleDuration] = useState(
|
||||
formMethods.getValues("metadata")?.multipleDuration
|
||||
);
|
||||
@@ -161,6 +172,34 @@ export const EventSetupTab = (
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{!isPlatform && interfaceLanguageOptions.length > 0 && (
|
||||
<div>
|
||||
<Skeleton
|
||||
as={Label}
|
||||
loadingClassName="w-16"
|
||||
htmlFor="interfaceLanguage"
|
||||
className={customClassNames?.locationSection?.label}>
|
||||
{t("interface_language")}
|
||||
{shouldLockIndicator("interfaceLanguage")}
|
||||
</Skeleton>
|
||||
<Controller
|
||||
name="interfaceLanguage"
|
||||
control={formMethods.control}
|
||||
defaultValue={eventType.interfaceLanguage ?? ""}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<Select<{ label: string; value: string }>
|
||||
data-testid="event-interface-language"
|
||||
className="capitalize"
|
||||
options={interfaceLanguageOptions}
|
||||
onChange={(option) => {
|
||||
onChange(option?.value);
|
||||
}}
|
||||
value={interfaceLanguageOptions.find((option) => option.value === value)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<TextField
|
||||
required
|
||||
label={isPlatform ? "Slug" : t("URL")}
|
||||
|
||||
@@ -55,6 +55,7 @@ const getPublicEventSelect = (fetchAllUsers: boolean) => {
|
||||
id: true,
|
||||
title: true,
|
||||
description: true,
|
||||
interfaceLanguage: true,
|
||||
eventName: true,
|
||||
slug: true,
|
||||
isInstantEvent: true,
|
||||
@@ -527,6 +528,7 @@ export const getPublicEvent = async (
|
||||
assignAllTeamMembers: event.assignAllTeamMembers,
|
||||
disableCancelling: event.disableCancelling,
|
||||
disableRescheduling: event.disableRescheduling,
|
||||
interfaceLanguage: event.interfaceLanguage,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ export type FormValues = {
|
||||
eventTitle: string;
|
||||
eventName: string;
|
||||
slug: string;
|
||||
interfaceLanguage: string | null;
|
||||
isInstantEvent: boolean;
|
||||
instantMeetingParameters: string[];
|
||||
instantMeetingExpiryTimeOffsetInSeconds: number;
|
||||
|
||||
Reference in new issue
Block a user