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: limit schedules to 10 #272

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
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
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
Loading