fix(ui): duplicate schedule warning (#295)

* fix(ui): duplicate schedule warning

* fix(ui): duplicate schedule warning

* fix(ui): duplicate schedules

* fix(ui): schedule limit loophole refactored

* fix(ui): schedule bypass hooks

* fix(ui): useEnforceScheduleLimit hook created

* fix(ui): added useCallback to hook

* fix(ui): updated jsdoc comment on hook

* fix(ui): updated jsdoc comments on hook
This commit is contained in:
adityamkk
2024-10-22 23:10:54 -05:00
committed by GitHub
parent b00bf6c180
commit 7346720894
4 changed files with 66 additions and 27 deletions

View File

@@ -7,6 +7,7 @@ import { openReportWindow } from '@shared/util/openReportWindow';
import Divider from '@views/components/common/Divider';
import List from '@views/components/common/List';
import Text from '@views/components/common/Text/Text';
import { useEnforceScheduleLimit } from '@views/hooks/useEnforceScheduleLimit';
import useSchedules, { getActiveSchedule, replaceSchedule, switchSchedule } from '@views/hooks/useSchedules';
import { getUpdatedAtDateTimeString } from '@views/lib/getUpdatedAtDateTimeString';
import useKC_DABR_WASM from 'kc-dabr-wasm';
@@ -62,6 +63,13 @@ export default function PopupMain(): JSX.Element {
// const [isRefreshing, setIsRefreshing] = useState(false);
const [funny, setFunny] = useState<string>('');
const enforceScheduleLimit = useEnforceScheduleLimit();
const handleAddSchedule = () => {
if (enforceScheduleLimit()) {
createSchedule('New Schedule');
}
};
useEffect(() => {
const randomIndex = Math.floor(Math.random() * splashText.length);
setFunny(
@@ -128,7 +136,7 @@ export default function PopupMain(): JSX.Element {
variant='filled'
color='ut-burntorange'
className='h-fit p-0 btn'
onClick={() => createSchedule('New Schedule')}
onClick={handleAddSchedule}
>
<AddSchedule className='h-6 w-6' />
</Button>