From 290b8415170bca631e5d71b08d88db80b02163f0 Mon Sep 17 00:00:00 2001 From: Razboy20 Date: Sat, 5 Oct 2024 13:27:44 -0500 Subject: [PATCH] feat: limit schedules to 10 (#272) --- .../components/calendar/CalendarSchedules.tsx | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/views/components/calendar/CalendarSchedules.tsx b/src/views/components/calendar/CalendarSchedules.tsx index 4320239b..6a505242 100644 --- a/src/views/components/calendar/CalendarSchedules.tsx +++ b/src/views/components/calendar/CalendarSchedules.tsx @@ -9,6 +9,8 @@ import React from 'react'; import AddSchedule from '~icons/material-symbols/add'; +import { usePrompt } from '../common/DialogProvider/DialogProvider'; + /** * Renders a component that displays a list of schedules. * @@ -17,6 +19,33 @@ import AddSchedule from '~icons/material-symbols/add'; */ export function CalendarSchedules() { const [, schedules] = useSchedules(); + const showDialog = usePrompt(); + + const handleAddSchedule = () => { + if (schedules.length >= 10) { + showDialog({ + title: `You have 10 active schedules!`, + + description: ( + <> + To encourage organization,{' '} + please consider removing some unused schedules you + may have. + + ), + // eslint-disable-next-line react/no-unstable-nested-components + buttons: close => ( + + ), + }); + + return; + } + + createSchedule('New Schedule'); + }; return (
@@ -24,12 +53,7 @@ export function CalendarSchedules() { MY SCHEDULES -