diff --git a/apps/web/components/booking/TimeOptions.tsx b/apps/web/components/booking/TimeOptions.tsx index 8cda05f822..502a068313 100644 --- a/apps/web/components/booking/TimeOptions.tsx +++ b/apps/web/components/booking/TimeOptions.tsx @@ -10,9 +10,10 @@ type Props = { onSelectTimeZone: (selectedTimeZone: string) => void; onToggle24hClock: (is24hClock: boolean) => void; timeFormat: string; + hideTimeFormatToggle?: boolean; }; -const TimeOptions: FC = ({ onToggle24hClock, onSelectTimeZone, timeFormat }) => { +const TimeOptions: FC = ({ onToggle24hClock, onSelectTimeZone, timeFormat, hideTimeFormatToggle }) => { const [selectedTimeZone, setSelectedTimeZone] = useState(""); const [is24hClock, setIs24hClock] = useState(timeFormat === "HH:mm" && true); const { t } = useLocale(); @@ -36,17 +37,19 @@ const TimeOptions: FC = ({ onToggle24hClock, onSelectTimeZone, timeFormat
{t("time_options")}
-
- - -
+ {!hideTimeFormatToggle && ( +
+ + +
+ )}
void; onChangeTimeZone: (newTimeZone: string) => void; timeZone?: string; timeFormat: string; + hideTimeFormatToggle?: boolean; }) { const [isTimeOptionsOpen, setIsTimeOptionsOpen] = useState(false); @@ -261,6 +263,7 @@ function TimezoneDropdown({ onSelectTimeZone={handleSelectTimeZone} onToggle24hClock={handleToggle24hClock} timeFormat={timeFormat} + hideTimeFormatToggle={hideTimeFormatToggle} /> @@ -293,7 +296,14 @@ const useRouterQuery = (name: T) => { export type Props = AvailabilityTeamPageProps | AvailabilityPageProps | DynamicAvailabilityPageProps; +const timeFormatTotimeFormatString = (timeFormat?: number | null) => { + if (!timeFormat) return null; + return timeFormat === 24 ? "HH:mm" : "h:mma"; +}; + const AvailabilityPage = ({ profile, eventType }: Props) => { + const { data: user } = trpc.useQuery(["viewer.me"]); + const timeFormatFromProfile = timeFormatTotimeFormatString(user?.timeFormat); const router = useRouter(); const isEmbed = useIsEmbed(); const query = dateQuerySchema.parse(router.query); @@ -306,7 +316,7 @@ const AvailabilityPage = ({ profile, eventType }: Props) => { const isBackgroundTransparent = useIsBackgroundTransparent(); const [timeZone, setTimeZone] = useState(); - const [timeFormat, setTimeFormat] = useState(detectBrowserTimeFormat); + const [timeFormat, setTimeFormat] = useState(timeFormatFromProfile || detectBrowserTimeFormat); const [isAvailableTimesVisible, setIsAvailableTimesVisible] = useState(); const [gateState, gateDispatcher] = useReducer( (state: GateState, newState: Partial) => ({ @@ -357,9 +367,12 @@ const AvailabilityPage = ({ profile, eventType }: Props) => { onChangeTimeFormat={setTimeFormat} timeZone={timeZone} onChangeTimeZone={setTimeZone} + // Currently we don't allow the user to change the timeformat when they're logged in, + // the only way to change it is if they go to their profile. + hideTimeFormatToggle={!!timeFormatFromProfile} /> ), - [timeZone, timeFormat] + [timeZone, timeFormat, timeFormatFromProfile] ); const rawSlug = profile.slug ? profile.slug.split("/") : []; if (rawSlug.length > 1) rawSlug.pop(); //team events have team name as slug, but user events have [user]/[type] as slug.