Skip to content

Commit

Permalink
fix: Tickets are being shown in user preferred time format (calcom#11349
Browse files Browse the repository at this point in the history
)

Co-authored-by: Udit Takkar <[email protected]>
  • Loading branch information
harsh11101 and Udit Takkar authored Sep 22, 2023
1 parent 5e44967 commit 5940f9b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/web/pages/booking/[uid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ export default function Success(props: SuccessProps) {

const isGmail = !!attendees.find((attendee) => attendee.email.includes("gmail.com"));

const [is24h, setIs24h] = useState(isBrowserLocale24h());
const [is24h, setIs24h] = useState(
props?.userTimeFormat ? props.userTimeFormat === 24 : isBrowserLocale24h()
);
const { data: session } = useSession();

const [date, setDate] = useState(dayjs.utc(props.bookingInfo.startTime));
Expand Down Expand Up @@ -215,7 +217,7 @@ export default function Success(props: SuccessProps) {
// TODO: Add payment details
});
setDate(date.tz(localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()));
setIs24h(!!getIs24hClockFromLocalStorage());
setIs24h(props?.userTimeFormat ? props.userTimeFormat === 24 : !!getIs24hClockFromLocalStorage());
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [eventType, needsConfirmation]);

Expand Down Expand Up @@ -1006,10 +1008,12 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
const ssr = await ssrInit(context);
const session = await getServerSession(context);
let tz: string | null = null;
let userTimeFormat: number | null = null;

if (session) {
const user = await ssr.viewer.me.fetch();
tz = user.timeZone;
userTimeFormat = user.timeFormat;
}

const parsedQuery = querySchema.safeParse(context.query);
Expand Down Expand Up @@ -1150,6 +1154,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
bookingInfo,
paymentStatus: payment,
...(tz && { tz }),
userTimeFormat,
},
};
}
Expand Down

0 comments on commit 5940f9b

Please sign in to comment.