From 0402e463286760cbff113bfc25920aabe26250f5 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 15 Nov 2022 13:39:06 +0000 Subject: [PATCH] Reformat /booking attendees, add guests to success page, fix i18n (#5532) --- .../components/booking/BookingListItem.tsx | 80 +++++++++---------- .../components/booking/pages/BookingPage.tsx | 2 +- apps/web/pages/cancel/[uid].tsx | 2 +- apps/web/pages/success.tsx | 12 ++- apps/web/public/static/locales/ar/common.json | 2 +- apps/web/public/static/locales/cs/common.json | 2 +- apps/web/public/static/locales/en/common.json | 2 +- apps/web/public/static/locales/es/common.json | 2 +- apps/web/public/static/locales/fr/common.json | 2 +- apps/web/public/static/locales/it/common.json | 2 +- apps/web/public/static/locales/ja/common.json | 2 +- apps/web/public/static/locales/ko/common.json | 2 +- apps/web/public/static/locales/nl/common.json | 2 +- apps/web/public/static/locales/pl/common.json | 2 +- .../public/static/locales/pt-BR/common.json | 2 +- apps/web/public/static/locales/pt/common.json | 2 +- apps/web/public/static/locales/ro/common.json | 2 +- apps/web/public/static/locales/ru/common.json | 2 +- apps/web/public/static/locales/sr/common.json | 2 +- apps/web/public/static/locales/sv/common.json | 2 +- apps/web/public/static/locales/tr/common.json | 2 +- apps/web/public/static/locales/vi/common.json | 2 +- .../public/static/locales/zh-CN/common.json | 2 +- 23 files changed, 65 insertions(+), 69 deletions(-) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 7819faa307..48692cf6e8 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -471,8 +471,9 @@ const FirstAttendee = ({ user: UserProps; currentEmail: string | null | undefined; }) => { + const { t } = useLocale(); return user.email === currentEmail ? ( -
You
+
{t("you")}
) : ( = ({ email, children }) => { +type AttendeeProps = { + name?: string; + email: string; +}; + +const Attendee = ({ email, name }: AttendeeProps) => { return ( - e.stopPropagation()}> - {children} + e.stopPropagation()}> + {name || email} ); }; -interface AttendeeProps { - name: string; - email: string; -} - const DisplayAttendees = ({ attendees, user, @@ -504,42 +505,33 @@ const DisplayAttendees = ({ }: { attendees: AttendeeProps[]; user: UserProps | null; - currentEmail: string | null | undefined; + currentEmail?: string | null; }) => { - if (attendees.length === 1) { - return ( -
- {user && } -  and  - {attendees[0].name} -
- ); - } else if (attendees.length === 2) { - return ( -
- {user && } - ,  - {attendees[0].name} -
 and 
- {attendees[1].name} -
- ); - } else { - return ( -
- {user && } - ,  - {attendees[0].name} -  &  - ( -

{attendee.name}

- ))}> -
{attendees.length - 1} more
-
-
- ); - } + const { t } = useLocale(); + return ( +
+ {user && } + {attendees.length > 1 ? ,  :  {t("and")} } + + {attendees.length > 1 && ( + <> +
 {t("and")} 
+ {attendees.length > 2 ? ( + ( +

+ +

+ ))}> +
{t("plus_more", { count: attendees.length - 1 })}
+
+ ) : ( + + )} + + )} +
+ ); }; const Tag = ({ children, className = "" }: React.PropsWithChildren<{ className?: string }>) => { diff --git a/apps/web/components/booking/pages/BookingPage.tsx b/apps/web/components/booking/pages/BookingPage.tsx index 254ce386e5..944786dc38 100644 --- a/apps/web/components/booking/pages/BookingPage.tsx +++ b/apps/web/components/booking/pages/BookingPage.tsx @@ -515,7 +515,7 @@ const BookingPage = ({

{timeFormatted}

))}>

- {t("plus_more", { count: recurringStrings.length - 5 })} + + {t("plus_more", { count: recurringStrings.length - 5 })}

diff --git a/apps/web/pages/cancel/[uid].tsx b/apps/web/pages/cancel/[uid].tsx index 43fd77cecd..467c93d3b4 100644 --- a/apps/web/pages/cancel/[uid].tsx +++ b/apps/web/pages/cancel/[uid].tsx @@ -110,7 +110,7 @@ export default function Type(props: inferSSRProps) { "-ml-4 block w-full text-center", moreEventsVisible ? "hidden" : "" )}> - {t("plus_more", { count: props.recurringInstances.length - 1 })} + + {t("plus_more", { count: props.recurringInstances.length - 1 })} {props.booking?.eventType.recurringEvent?.count && diff --git a/apps/web/pages/success.tsx b/apps/web/pages/success.tsx index 5fb9fa8172..47858b6190 100644 --- a/apps/web/pages/success.tsx +++ b/apps/web/pages/success.tsx @@ -369,9 +369,9 @@ export default function Success(props: SuccessProps) {

{bookingInfo.user.email}

)} - {bookingInfo?.attendees.map((attendee, index) => ( + {bookingInfo?.attendees.map((attendee) => (
-

{attendee.name}

+ {attendee.name &&

{attendee.name}

}

{attendee.email}

))} @@ -667,7 +667,7 @@ export function RecurringBookings({ - {t("plus_more", { count: recurringBookingsSorted.length - 4 })} + + {t("plus_more", { count: recurringBookingsSorted.length - 4 })} {eventType.recurringEvent?.count && @@ -738,6 +738,7 @@ const getEventTypesFromDB = async (id: number) => { }, }, metadata: true, + seatsPerTimeSlot: true, seatsShowAttendees: true, }, }); @@ -777,7 +778,7 @@ const schema = z.object({ const handleSeatsEventTypeOnBooking = ( eventType: { - seatsPerTimeSlot?: boolean | null; + seatsPerTimeSlot?: number | null; seatsShowAttendees: boolean | null; [x: string | number | symbol]: unknown; }, @@ -789,6 +790,8 @@ const handleSeatsEventTypeOnBooking = ( if (eventType?.seatsPerTimeSlot !== null) { // @TODO: right now bookings with seats doesn't save every description that its entered by every user delete booking.description; + } else { + return; } if (!eventType.seatsShowAttendees) { const attendee = booking?.attendees?.find((a) => a.email === email); @@ -895,6 +898,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { }, }, }); + if (bookingInfo !== null && email) { handleSeatsEventTypeOnBooking(eventType, bookingInfo, email); } diff --git a/apps/web/public/static/locales/ar/common.json b/apps/web/public/static/locales/ar/common.json index 8cf50926d6..b341565b86 100644 --- a/apps/web/public/static/locales/ar/common.json +++ b/apps/web/public/static/locales/ar/common.json @@ -597,7 +597,7 @@ "monthly_other": "أشهر", "yearly_one": "سنة", "yearly_other": "سنوات", - "plus_more": "+ {{count}} أكثر", + "plus_more": "{{count}} أكثر", "max": "الحد الأقصى", "single_theme": "سمة واحدة", "brand_color": "لون العلامة التجارية", diff --git a/apps/web/public/static/locales/cs/common.json b/apps/web/public/static/locales/cs/common.json index ee403f7a42..fdf0bccd83 100644 --- a/apps/web/public/static/locales/cs/common.json +++ b/apps/web/public/static/locales/cs/common.json @@ -597,7 +597,7 @@ "monthly_other": "měs.", "yearly_one": "rok", "yearly_other": "roky/let", - "plus_more": "+ ještě {{count}}", + "plus_more": "ještě {{count}}", "max": "Max.", "single_theme": "Jednotná šablona", "brand_color": "Barva značky", diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 021c6813ca..f45f99f7c5 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -599,7 +599,7 @@ "monthly_other": "months", "yearly_one": "year", "yearly_other": "years", - "plus_more": "+ {{count}} more", + "plus_more": "{{count}} more", "max": "Max", "single_theme": "Single Theme", "brand_color": "Brand Color", diff --git a/apps/web/public/static/locales/es/common.json b/apps/web/public/static/locales/es/common.json index 4d5751ea5c..1a0cb24e78 100644 --- a/apps/web/public/static/locales/es/common.json +++ b/apps/web/public/static/locales/es/common.json @@ -596,7 +596,7 @@ "monthly_other": "meses", "yearly_one": "año", "yearly_other": "años", - "plus_more": "+ {{count}} más", + "plus_more": "{{count}} más", "max": "Máx.", "single_theme": "Tema", "brand_color": "Color de marca", diff --git a/apps/web/public/static/locales/fr/common.json b/apps/web/public/static/locales/fr/common.json index fe9e5aba5c..313897563b 100644 --- a/apps/web/public/static/locales/fr/common.json +++ b/apps/web/public/static/locales/fr/common.json @@ -596,7 +596,7 @@ "monthly_other": "mois", "yearly_one": "année", "yearly_other": "années", - "plus_more": "+ {{count}} de plus", + "plus_more": "{{count}} de plus", "max": "Max.", "single_theme": "Thème unique", "brand_color": "Couleur de la marque", diff --git a/apps/web/public/static/locales/it/common.json b/apps/web/public/static/locales/it/common.json index fa8d1be91e..28af07fdfc 100644 --- a/apps/web/public/static/locales/it/common.json +++ b/apps/web/public/static/locales/it/common.json @@ -596,7 +596,7 @@ "monthly_other": "mesi", "yearly_one": "anno", "yearly_other": "anni", - "plus_more": "+ altri {{count}}", + "plus_more": "altri {{count}}", "max": "Max", "single_theme": "Tema Singolo", "brand_color": "Colore del Marchio", diff --git a/apps/web/public/static/locales/ja/common.json b/apps/web/public/static/locales/ja/common.json index a8ff7f19b7..55cdc55bfd 100644 --- a/apps/web/public/static/locales/ja/common.json +++ b/apps/web/public/static/locales/ja/common.json @@ -596,7 +596,7 @@ "monthly_other": "月", "yearly_one": "年", "yearly_other": "年", - "plus_more": "+ {{count}} 回以上", + "plus_more": "{{count}} 回以上", "max": "最大", "single_theme": "シングルテーマ", "brand_color": "ブランドカラー", diff --git a/apps/web/public/static/locales/ko/common.json b/apps/web/public/static/locales/ko/common.json index 02cd36d742..451013b686 100644 --- a/apps/web/public/static/locales/ko/common.json +++ b/apps/web/public/static/locales/ko/common.json @@ -596,7 +596,7 @@ "monthly_other": "개월", "yearly_one": "년", "yearly_other": "년", - "plus_more": "+ {{count}} 이상", + "plus_more": "{{count}} 이상", "max": "최대", "single_theme": "단일 테마", "brand_color": "브랜드 색상", diff --git a/apps/web/public/static/locales/nl/common.json b/apps/web/public/static/locales/nl/common.json index 636932e382..f88566dd9b 100644 --- a/apps/web/public/static/locales/nl/common.json +++ b/apps/web/public/static/locales/nl/common.json @@ -596,7 +596,7 @@ "monthly_other": "maanden", "yearly_one": "jaar", "yearly_other": "jaar", - "plus_more": "Nog {{count}}", + "plus_more": "{{count}} meer", "max": "Max.", "single_theme": "Enkel Thema", "brand_color": "Merkkleur", diff --git a/apps/web/public/static/locales/pl/common.json b/apps/web/public/static/locales/pl/common.json index fc123cb9f5..f92cedd28f 100644 --- a/apps/web/public/static/locales/pl/common.json +++ b/apps/web/public/static/locales/pl/common.json @@ -596,7 +596,7 @@ "monthly_other": "miesiące", "yearly_one": "rok", "yearly_other": "lata", - "plus_more": "+ {{count}} więcej", + "plus_more": "{{count}} więcej", "max": "Maks.", "single_theme": "Pojedynczy motyw", "brand_color": "Kolor Marki", diff --git a/apps/web/public/static/locales/pt-BR/common.json b/apps/web/public/static/locales/pt-BR/common.json index 31b22644cd..5520252d5f 100644 --- a/apps/web/public/static/locales/pt-BR/common.json +++ b/apps/web/public/static/locales/pt-BR/common.json @@ -596,7 +596,7 @@ "monthly_other": "meses", "yearly_one": "ano", "yearly_other": "anos", - "plus_more": "+ {{count}} mais", + "plus_more": "{{count}} mais", "max": "Máx", "single_theme": "Tema", "brand_color": "Cor da Marca", diff --git a/apps/web/public/static/locales/pt/common.json b/apps/web/public/static/locales/pt/common.json index 470f73eb2d..ee8767a2c7 100644 --- a/apps/web/public/static/locales/pt/common.json +++ b/apps/web/public/static/locales/pt/common.json @@ -596,7 +596,7 @@ "monthly_other": "meses", "yearly_one": "ano", "yearly_other": "anos", - "plus_more": "+ {{count}} mais", + "plus_more": "{{count}} mais", "max": "Máximo", "single_theme": "Tema", "brand_color": "Cor da marca", diff --git a/apps/web/public/static/locales/ro/common.json b/apps/web/public/static/locales/ro/common.json index 5fbe4d787e..6ceba4b850 100644 --- a/apps/web/public/static/locales/ro/common.json +++ b/apps/web/public/static/locales/ro/common.json @@ -596,7 +596,7 @@ "monthly_other": "luni", "yearly_one": "an", "yearly_other": "ani", - "plus_more": "+ încă {{count}}", + "plus_more": "încă {{count}}", "max": "Max.", "single_theme": "Temă unică", "brand_color": "Culoare marcă", diff --git a/apps/web/public/static/locales/ru/common.json b/apps/web/public/static/locales/ru/common.json index 305410ea0d..7f449fb4d4 100644 --- a/apps/web/public/static/locales/ru/common.json +++ b/apps/web/public/static/locales/ru/common.json @@ -596,7 +596,7 @@ "monthly_other": "мес.", "yearly_one": "год", "yearly_other": "г.", - "plus_more": "+ еще {{count}}", + "plus_more": "еще {{count}}", "max": "Макс.", "single_theme": "Тема оформления", "brand_color": "Цвет бренда", diff --git a/apps/web/public/static/locales/sr/common.json b/apps/web/public/static/locales/sr/common.json index 4c439e5d0e..3d52f54cf8 100644 --- a/apps/web/public/static/locales/sr/common.json +++ b/apps/web/public/static/locales/sr/common.json @@ -597,7 +597,7 @@ "monthly_other": "meseci", "yearly_one": "godinu", "yearly_other": "godina", - "plus_more": "+ još {{count}}", + "plus_more": "još {{count}}", "max": "Maks.", "single_theme": "Tema", "brand_color": "Boja brenda", diff --git a/apps/web/public/static/locales/sv/common.json b/apps/web/public/static/locales/sv/common.json index 6d4960fe8b..025d13aa65 100644 --- a/apps/web/public/static/locales/sv/common.json +++ b/apps/web/public/static/locales/sv/common.json @@ -596,7 +596,7 @@ "monthly_other": "månader", "yearly_one": "år", "yearly_other": "år", - "plus_more": "+ {{count}} till", + "plus_more": "{{count}} till", "max": "Max", "single_theme": "Ett tema", "brand_color": "Primär färg", diff --git a/apps/web/public/static/locales/tr/common.json b/apps/web/public/static/locales/tr/common.json index 4710c19542..7eabeda97d 100644 --- a/apps/web/public/static/locales/tr/common.json +++ b/apps/web/public/static/locales/tr/common.json @@ -597,7 +597,7 @@ "monthly_other": "ay", "yearly_one": "yıl", "yearly_other": "yıl", - "plus_more": "+ {{count}} tane daha", + "plus_more": "{{count}} tane daha", "max": "Maks.", "single_theme": "Tek Tema", "brand_color": "Marka Rengi", diff --git a/apps/web/public/static/locales/vi/common.json b/apps/web/public/static/locales/vi/common.json index 3890439ea0..d00cb9212d 100644 --- a/apps/web/public/static/locales/vi/common.json +++ b/apps/web/public/static/locales/vi/common.json @@ -596,7 +596,7 @@ "monthly_other": "tháng", "yearly_one": "năm", "yearly_other": "năm", - "plus_more": "+ {{count}} nữa", + "plus_more": "{{count}} nữa", "max": "Tối đa", "single_theme": "Chủ đề đơn", "brand_color": "Màu thương hiệu", diff --git a/apps/web/public/static/locales/zh-CN/common.json b/apps/web/public/static/locales/zh-CN/common.json index 484238e3e2..1aeb63aeec 100644 --- a/apps/web/public/static/locales/zh-CN/common.json +++ b/apps/web/public/static/locales/zh-CN/common.json @@ -596,7 +596,7 @@ "monthly_other": "月", "yearly_one": "年", "yearly_other": "年", - "plus_more": "+ 另外 {{count}}", + "plus_more": "另外 {{count}}", "max": "最大", "single_theme": "主题", "brand_color": "品牌颜色",