From 65aea64a3690bd88c15ecf3795688126f8d4bb43 Mon Sep 17 00:00:00 2001 From: rhahao <26148770+rhahao@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:51:05 +0300 Subject: [PATCH] fix(dashboard): enforce admin role for initial setup --- src/features/dashboard/initial_setup/useInitialSetup.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/features/dashboard/initial_setup/useInitialSetup.tsx b/src/features/dashboard/initial_setup/useInitialSetup.tsx index deefbf983d..b411edcea2 100644 --- a/src/features/dashboard/initial_setup/useInitialSetup.tsx +++ b/src/features/dashboard/initial_setup/useInitialSetup.tsx @@ -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 });