Skip to content

Commit

Permalink
fix(dashboard): enforce admin role for initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Nov 10, 2024
1 parent 5d3feff commit 65aea64
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/features/dashboard/initial_setup/useInitialSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import { useMemo, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { settingsState } from '@states/settings';
import { dbAppSettingsUpdate } from '@services/dexie/settings';
import useCurrentUser from '@hooks/useCurrentUser';

const useInitialSetup = () => {
const { isAdmin } = useCurrentUser();

const settings = useRecoilValue(settingsState);

const [currentStep, setCurrentStep] = useState(1);

const open = useMemo(() => {
return settings.cong_settings.cong_new ?? false;
}, [settings]);
const isNew = settings.cong_settings.cong_new ?? false;

return isNew && isAdmin;
}, [settings, isAdmin]);

const handleClose = async () => {
await dbAppSettingsUpdate({ 'cong_settings.cong_new': false });
Expand Down

0 comments on commit 65aea64

Please sign in to comment.