From 0a2e2759080b94b91389539e8e8718fb223fab1e Mon Sep 17 00:00:00 2001 From: Mehul Date: Wed, 24 Jan 2024 16:25:31 +0530 Subject: [PATCH] fix: UI mismatch with form state (#10651) * fix: UI mismatch with form state * Fix: Sync form state with ui for more fields & slight code refactor * Ensure Stripe app is enabled to disable seats --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Hariom Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Joe Au-Yeung --- .../components/eventtype/EventAdvancedTab.tsx | 174 ++++++++---------- .../web/components/eventtype/EventAppsTab.tsx | 13 +- .../components/eventtype/EventLimitsTab.tsx | 74 +++----- .../eventtype/EventRecurringTab.tsx | 6 +- .../components/eventtype/EventSetupTab.tsx | 69 +++---- .../eventtype/EventTypeSingleLayout.tsx | 97 ++++++---- .../components/eventtype/EventWebhooksTab.tsx | 10 +- .../eventtype/RecurringEventController.tsx | 7 +- apps/web/pages/event-types/[type]/index.tsx | 27 ++- .../calendars/DestinationCalendarSelector.tsx | 1 - .../webhooks/components/WebhookListItem.tsx | 8 +- 11 files changed, 235 insertions(+), 251 deletions(-) diff --git a/apps/web/components/eventtype/EventAdvancedTab.tsx b/apps/web/components/eventtype/EventAdvancedTab.tsx index 7f31b48fd0..bfe7ccf9df 100644 --- a/apps/web/components/eventtype/EventAdvancedTab.tsx +++ b/apps/web/components/eventtype/EventAdvancedTab.tsx @@ -55,8 +55,8 @@ export const EventAdvancedTab = ({ eventType, team }: Pick { + formMethods.getValues().bookingFields.forEach(({ name }) => { bookingFields[name] = `${name} input`; }); const eventNameObject: EventNameObjectType = { attendeeName: t("scheduler"), - eventType: eventType.title, - eventName: eventType.eventName, - host: eventType.users[0]?.name || "Nameless", + eventType: formMethods.getValues("title"), + eventName: formMethods.getValues("eventName"), + host: formMethods.getValues("users")[0]?.name || "Nameless", bookingFields: bookingFields, t, }; - const [requiresConfirmation, setRequiresConfirmation] = useState(eventType.requiresConfirmation); - const placeholderHashedLink = `${CAL_URL}/d/${hashedUrl}/${eventType.slug}`; + const [requiresConfirmation, setRequiresConfirmation] = useState( + formMethods.getValues("requiresConfirmation") + ); + const placeholderHashedLink = `${CAL_URL}/d/${hashedUrl}/${formMethods.getValues("slug")}`; const seatsEnabled = formMethods.watch("seatsPerTimeSlotEnabled"); - const noShowFeeEnabled = eventType.metadata?.apps?.stripe?.paymentOption === "HOLD"; + const noShowFeeEnabled = + formMethods.getValues("metadata")?.apps?.stripe?.enabled === true && + formMethods.getValues("metadata")?.apps?.stripe?.paymentOption === "HOLD"; useEffect(() => { - !hashedUrl && setHashedUrl(generateHashedLink(eventType.users[0]?.id ?? team?.id)); - }, [eventType.users, hashedUrl, team?.id]); + !hashedUrl && setHashedUrl(generateHashedLink(formMethods.getValues("users")[0]?.id ?? team?.id)); + }, [formMethods.getValues("users"), hashedUrl, team?.id]); const toggleGuests = (enabled: boolean) => { const bookingFields = formMethods.getValues("bookingFields"); @@ -108,7 +112,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick setShowEventNameTip(false); - const setEventName = (value: string) => formMethods.setValue("eventName", value); return (
{/** @@ -145,12 +148,9 @@ export const EventAdvancedTab = ({ eventType, team }: Pick
( @@ -203,15 +202,13 @@ export const EventAdvancedTab = ({ eventType, team }: Pick ( ( ( <>
+