Skip to content

Commit

Permalink
feat: limit schedules to 10 (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
Razboy20 authored Oct 5, 2024
1 parent 99c982d commit 290b841
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/views/components/calendar/CalendarSchedules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -17,19 +19,41 @@ 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,{' '}
<span className='text-ut-burntorange'>please consider removing some unused schedules</span> you
may have.
</>
),
// eslint-disable-next-line react/no-unstable-nested-components
buttons: close => (
<Button variant='filled' color='ut-burntorange' onClick={close}>
I Understand
</Button>
),
});

return;
}

createSchedule('New Schedule');
};

return (
<div className='min-w-full w-0 items-center'>
<div className='m0 m-b-2 w-full flex justify-between'>
<Text variant='h3' className='text-nowrap'>
MY SCHEDULES
</Text>
<Button
variant='single'
color='theme-black'
className='h-fit p-0 btn'
onClick={() => createSchedule('New Schedule')}
>
<Button variant='single' color='theme-black' className='h-fit p-0 btn' onClick={handleAddSchedule}>
<AddSchedule className='h-6 w-6' />
</Button>
</div>
Expand Down

0 comments on commit 290b841

Please sign in to comment.