Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Default number of recurring event occurrences should be configurable #18600

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/features/bookings/Booker/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type StoreInitializeType = {
teamMemberEmail?: string | null;
crmOwnerRecordType?: string | null;
crmAppSlug?: string | null;
occurenceCount?: number | null;
};

type SeatedEventData = {
Expand Down Expand Up @@ -274,6 +275,7 @@ export const useBookerStore = create<BookerStore>((set, get) => ({
teamMemberEmail,
crmOwnerRecordType,
crmAppSlug,
occurenceCount = null,
}: StoreInitializeType) => {
const selectedDateInStore = get().selectedDate;

Expand All @@ -289,6 +291,7 @@ export const useBookerStore = create<BookerStore>((set, get) => ({
get().timezone === timezone &&
get().rescheduledBy === rescheduledBy &&
get().teamMemberEmail === teamMemberEmail &&
get().occurenceCount === occurenceCount &&
get().crmOwnerRecordType === crmOwnerRecordType &&
get().crmAppSlug
)
Expand Down Expand Up @@ -365,9 +368,9 @@ export const useBookerStore = create<BookerStore>((set, get) => ({
setBookingData: (bookingData: GetBookingType | null | undefined) => {
set({ bookingData: bookingData ?? null });
},
recurringEventCount: null,
recurringEventCount: parseInt(getQueryParam("cal.occurenceCount") ?? "1"),
setRecurringEventCount: (recurringEventCount: number | null) => set({ recurringEventCount }),
occurenceCount: null,
occurenceCount: parseInt(getQueryParam("cal.occurenceCount") ?? "1"),
setOccurenceCount: (occurenceCount: number | null) => set({ occurenceCount }),
rescheduleUid: null,
bookingData: null,
Expand Down Expand Up @@ -405,6 +408,7 @@ export const useInitializeBookerStore = ({
teamMemberEmail,
crmOwnerRecordType,
crmAppSlug,
occurenceCount = null,
}: StoreInitializeType) => {
const initializeStore = useBookerStore((state) => state.initialize);
useEffect(() => {
Expand All @@ -426,6 +430,7 @@ export const useInitializeBookerStore = ({
teamMemberEmail,
crmOwnerRecordType,
crmAppSlug,
occurenceCount,
});
}, [
initializeStore,
Expand All @@ -446,5 +451,6 @@ export const useInitializeBookerStore = ({
teamMemberEmail,
crmOwnerRecordType,
crmAppSlug,
occurenceCount,
]);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't we just set the recurring occurenceCount to minimum of occurenceCount, event.recurringEvent.count while occurentCount having default value 1.

  state.occurenceCount || 1,
  setOccurenceCount(Math.min(occurenceCount, event.recurringEvent.count));

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const EventOccurences = ({ event }: { event: Pick<BookerEvent, "recurring
type="number"
min="1"
max={event.recurringEvent.count}
defaultValue={occurenceCount || event.recurringEvent.count}
defaultValue={occurenceCount || 1}
data-testid="occurrence-input"
onChange={(event) => {
const pattern = /^(?=.*[0-9])\S+$/;
Expand Down
Loading