permissions on FE for email settings

This commit is contained in:
Alex Holliday committed 2025-11-21 14:26:41 -08:00
1 parent 710d506de2
commit 3c71583324
3 files changed
+21 -10

No files matched your search

+16 -7
View File
@@ -20,6 +20,11 @@ import { systemSettingsSchema } from "@/validation/zod";
const SettingsPage = () => {
type FormValues = z.infer<typeof systemSettingsSchema>;
const user = useAppSelector((state) => state.auth.user);
const orgPermissions = user?.org?.permissions || [];
const hasMaster = orgPermissions.includes("master");
const theme = useTheme();
const dispatch = useAppDispatch();
const timezone = useAppSelector((state) => state.ui.timezone);
@@ -35,7 +40,9 @@ const SettingsPage = () => {
const { post, loading: posting } = usePost<Partial<FormValues>, any>();
const { patch, loading: patching } = usePatch<Partial<FormValues>, any>();
const { response, loading } = useGet<ApiResponse<any>>("/settings");
const { response, loading } = useGet<ApiResponse<any>>(
hasMaster ? "/settings" : null
);
const settings = response?.data || {};
const initialSettings = useMemo(() => settings, [settings]);
@@ -84,12 +91,14 @@ const SettingsPage = () => {
</Stack>
}
/>
<SettingsForm
onSubmit={onSubmit}
onTest={onTest}
initialData={initialSettings}
loading={posting || loading || patching}
/>
{hasMaster && (
<SettingsForm
onSubmit={onSubmit}
onTest={onTest}
initialData={initialSettings}
loading={posting || loading || patching}
/>
)}
</BasePage>
);
};
+3 -1
View File
@@ -1,5 +1,6 @@
import Stack from "@mui/material/Stack";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { Button, TextInput, Switch, TextLink } from "@/components/inputs";
import { ConfigBox } from "@/components/design-elements";
@@ -11,7 +12,8 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useForm, Controller, type SubmitHandler } from "react-hook-form";
import { useInitForm } from "@/hooks/forms/UseInitSettingsForm";
import { useEffect } from "react";
import { Typography } from "@mui/material";
import { useAppSelector } from "@/hooks/AppHooks";
type FormValues = z.infer<typeof systemSettingsSchema>;
export const SettingsForm = ({