From a4df2404809b1031d490747446da09eefd2aa355 Mon Sep 17 00:00:00 2001 From: Adrian Andersen Date: Sun, 18 Feb 2024 23:24:22 +0100 Subject: [PATCH 1/4] feat(Class): hide slot and popularity info if not present --- src/components/modals/BookingPopupModal.tsx | 15 +++++---------- src/components/modals/ClassInfo/ClassInfo.tsx | 12 ++++++------ src/components/schedule/class/ClassCard.tsx | 5 ++++- .../schedule/class/ClassPopularityMeter.tsx | 4 ++-- src/lib/helpers/popularity.ts | 4 ++++ 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/components/modals/BookingPopupModal.tsx b/src/components/modals/BookingPopupModal.tsx index cc9b9c85..234781f0 100644 --- a/src/components/modals/BookingPopupModal.tsx +++ b/src/components/modals/BookingPopupModal.tsx @@ -5,6 +5,7 @@ import DialogContent from "@mui/material/DialogContent"; import DialogContentText from "@mui/material/DialogContentText"; import React, { useState } from "react"; +import { hasWaitingList } from "@/lib/helpers/popularity"; import { useUserSessions } from "@/lib/hooks/useUserSessions"; import { useUserSessionsIndex } from "@/lib/hooks/useUserSessionsIndex"; import { BookingPopupAction, ChainIdentifier, RezervoClass } from "@/types/chain"; @@ -67,7 +68,7 @@ const BookingPopupModal = ({ ) : ( <> Booking for {classDescription} har allerede åpnet. Vil du{" "} - {_class.availableSlots > 0 ? "booke timen nå" : "sette deg på venteliste"}? + {hasWaitingList(_class) ? "sette deg på venteliste" : "booke timen nå"}? )} @@ -78,19 +79,13 @@ const BookingPopupModal = ({ Nei takk : _class.availableSlots > 0 ? : - } - color={isCancellation ? "error" : _class.availableSlots > 0 ? "primary" : "warning"} + startIcon={isCancellation ? : hasWaitingList(_class) ? : } + color={isCancellation ? "error" : hasWaitingList(_class) ? "warning" : "primary"} variant={"outlined"} onClick={isCancellation ? cancelBooking : book} loading={bookingLoading} > - {isCancellation - ? "Avbestill" - : _class.availableSlots > 0 - ? "Book nå" - : "Sett på venteliste"} + {isCancellation ? "Avbestill" : hasWaitingList(_class) ? "Sett på venteliste" : "Book nå"} diff --git a/src/components/modals/ClassInfo/ClassInfo.tsx b/src/components/modals/ClassInfo/ClassInfo.tsx index d1190309..2fabf825 100644 --- a/src/components/modals/ClassInfo/ClassInfo.tsx +++ b/src/components/modals/ClassInfo/ClassInfo.tsx @@ -27,7 +27,7 @@ import ConfirmCancellation from "@/components/schedule/class/ConfirmCancellation import { NoShowBadgeIcon } from "@/components/utils/NoShowBadgeIcon"; import { PlannedNotBookedBadgeIcon } from "@/components/utils/PlannedNotBookedBadgeIcon"; import { isClassInThePast } from "@/lib/helpers/date"; -import { stringifyClassPopularity } from "@/lib/helpers/popularity"; +import { hasWaitingList, stringifyClassPopularity } from "@/lib/helpers/popularity"; import { classConfigRecurrentId, classRecurrentId } from "@/lib/helpers/recurrentId"; import { useUserConfig } from "@/lib/hooks/useUserConfig"; import { useUserSessions } from "@/lib/hooks/useUserSessions"; @@ -206,7 +206,7 @@ export default function ClassInfo({ )} - {((!_class.isBookable && !isInThePast) || _class.isCancelled) && ( + {_class.totalSlots !== null && ((!_class.isBookable && !isInThePast) || _class.isCancelled) && ( )} - {!_class.isCancelled && ( + {!_class.isCancelled && _class.totalSlots !== null && _class.availableSlots !== null && ( 0 ? : } - color={_class.availableSlots > 0 ? "primary" : "warning"} + startIcon={hasWaitingList(_class) ? : } + color={hasWaitingList(_class) ? "warning" : "primary"} sx={{ mt: 2, mr: 1 }} variant={"outlined"} disabled={isInThePast || !_class.isBookable} onClick={() => book()} loading={bookingLoading} > - {_class.availableSlots > 0 ? "Book nå" : "Sett meg på venteliste"} + {hasWaitingList(_class) ? "Sett meg på venteliste" : "Book nå"} ) )} diff --git a/src/components/schedule/class/ClassCard.tsx b/src/components/schedule/class/ClassCard.tsx index 4521512c..d980ec48 100644 --- a/src/components/schedule/class/ClassCard.tsx +++ b/src/components/schedule/class/ClassCard.tsx @@ -226,7 +226,9 @@ const ClassCard = ({ ) : ( - + _class.totalSlots !== null && ( + + ) )} {showScheduleAction && ( 0 ? StatusColors.ACTIVE : StatusColors.WAITLIST} + rippleColor={hasWaitingList(_class) ? StatusColors.WAITLIST : StatusColors.ACTIVE} > {popularityIcon} diff --git a/src/lib/helpers/popularity.ts b/src/lib/helpers/popularity.ts index 2d2677e4..6219d0a0 100644 --- a/src/lib/helpers/popularity.ts +++ b/src/lib/helpers/popularity.ts @@ -41,3 +41,7 @@ export function stringifyClassPopularity(_class: RezervoClass, historicPopularit } return classPopularityInfo; } + +export function hasWaitingList(_class: RezervoClass): boolean { + return _class.availableSlots === null ? (_class?.waitingListCount ?? 0) > 0 : _class.availableSlots <= 0; +} From b1d18d993a47bbf19df5cf233666867833116498 Mon Sep 17 00:00:00 2001 From: Adrian Andersen Date: Tue, 20 Feb 2024 14:36:32 +0100 Subject: [PATCH 2/4] feat(RezervoClass): make room optional --- src/types/chain.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/chain.ts b/src/types/chain.ts index 4f7d253a..0e67adeb 100644 --- a/src/types/chain.ts +++ b/src/types/chain.ts @@ -59,7 +59,7 @@ export type RezervoClassBase = { location: { id: string; studio: string; - room: string; + room: string | null; }; isBookable: boolean; isCancelled: boolean; From ad6312dbb28d0e6f9e00dbf019cc3713d93d007c Mon Sep 17 00:00:00 2001 From: Adrian Andersen Date: Sat, 2 Mar 2024 14:33:03 +0100 Subject: [PATCH 3/4] feat(Sats): allow Sats images --- next.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/next.config.js b/next.config.js index 5e1cf0f9..a9afaef3 100644 --- a/next.config.js +++ b/next.config.js @@ -45,6 +45,10 @@ const nextConfig = withPWA({ protocol: "https", hostname: "storage.googleapis.com", }, + { + protocol: "https", + hostname: "images.ctfassets.net", + }, ], }, }); From 85a75c301822e20a98ed02f7662db83f237463c9 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Sun, 17 Mar 2024 23:33:54 +0100 Subject: [PATCH 4/4] feat(Sats): use waitlist count for class popularity --- src/components/schedule/class/ClassCard.tsx | 2 +- .../schedule/class/ClassPopularityMeter.tsx | 4 +++- src/lib/helpers/popularity.ts | 15 +++++++++++++-- src/types/chain.ts | 4 ++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/schedule/class/ClassCard.tsx b/src/components/schedule/class/ClassCard.tsx index d980ec48..4865cc56 100644 --- a/src/components/schedule/class/ClassCard.tsx +++ b/src/components/schedule/class/ClassCard.tsx @@ -226,7 +226,7 @@ const ClassCard = ({ ) : ( - _class.totalSlots !== null && ( + (_class.totalSlots !== null || (_class.isBookable && _class.waitingListCount !== null)) && ( ) )} diff --git a/src/components/schedule/class/ClassPopularityMeter.tsx b/src/components/schedule/class/ClassPopularityMeter.tsx index 05832da8..95b11cd1 100644 --- a/src/components/schedule/class/ClassPopularityMeter.tsx +++ b/src/components/schedule/class/ClassPopularityMeter.tsx @@ -38,7 +38,9 @@ const ClassPopularityMeter = ({ if (_class.isBookable) { return (