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

EPICSYSTEM-224: Create an empty landing page for staff with create staff button #9

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions compliance-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { AuthProvider } from "react-oidc-context";
import { OidcConfig } from "@/utils/config";
import { theme } from "@/styles/theme";
import RouterProviderWithAuthContext from "@/router";
import ModalProvider from "@/components/Shared/Modals/ModalProvider";
import SnackBarProvider from "@/components/Shared/SnackBarProvider";

const queryClient = new QueryClient();

Expand All @@ -15,6 +17,8 @@ function App() {
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
<AuthProvider {...OidcConfig}>
<ModalProvider />
<SnackBarProvider />
<RouterProviderWithAuthContext />
</AuthProvider>
</ThemeProvider>
Expand Down
15 changes: 15 additions & 0 deletions compliance-web/src/components/Shared/Modals/ModalProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { Box, Modal } from "@mui/material";
import { useModal } from "@/store/modalStore";

const ModalProvider: React.FC = () => {
const { modalContent, setClose, isOpen } = useModal();

return (
<Modal open={isOpen} onClose={setClose}>
<Box>{modalContent}</Box>
</Modal>
);
};

export default ModalProvider;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Assessment, Settings, List } from "@mui/icons-material";
import { FormatListBulletedRounded, AssessmentRounded, SettingsRounded } from "@mui/icons-material";

export interface RouteMenuItem {
routeName: string;
Expand All @@ -11,7 +11,7 @@ export default function RouteItemsList() {
const routeMenuItems: RouteMenuItem[] = [
{
routeName: "C&E Database",
icon: <List />,
icon: <FormatListBulletedRounded />,
subRoutes: [
{
routeName: "Case Files",
Expand All @@ -30,11 +30,11 @@ export default function RouteItemsList() {
{
routeName: "IR Board",
path: "/ir-board",
icon: <Assessment sx={{ transform: "rotate(180deg)" }} />,
icon: <AssessmentRounded sx={{ transform: "rotate(180deg)" }} />,
},
{
routeName: "Admin",
icon: <Settings />,
icon: <SettingsRounded />,
subRoutes: [
{
routeName: "Staff",
Expand Down
27 changes: 27 additions & 0 deletions compliance-web/src/components/Shared/SnackBarProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { Snackbar, Alert } from "@mui/material";
import { useSnackbar } from "@/store/snackbarStore";

const SnackBarProvider: React.FC = () => {
const { isOpen, setClose, severity, message } = useSnackbar();

return (
<Snackbar
open={isOpen}
autoHideDuration={3000}
onClose={setClose}
anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
>
<Alert
onClose={setClose}
severity={severity}
variant="filled"
sx={{ width: "100%" }}
>
{message}
</Alert>
</Snackbar>
);
};

export default SnackBarProvider;
26 changes: 20 additions & 6 deletions compliance-web/src/routes/_authenticated/admin/staff.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import ComingSoon from '@/components/Shared/ComingSoon';
import { createFileRoute } from '@tanstack/react-router'
import { AddRounded } from "@mui/icons-material";
import { Box, Button, Stack, Typography } from "@mui/material";
import { createFileRoute } from "@tanstack/react-router";
import { BCPalette } from "epic.theme";

export const Route = createFileRoute('/_authenticated/admin/staff')({
component: Staff
})
export const Route = createFileRoute("/_authenticated/admin/staff")({
component: Staff,
});

function Staff() {
return <ComingSoon />;
return (
<>
<Stack>
<Box display={"flex"} justifyContent={"space-between"} alignItems={"center"}>
<Typography variant="h5" sx={{ color: BCPalette.typography.link }}>
Staff
</Typography>
<Button startIcon={<AddRounded />}>Staff Member</Button>
</Box>
{/* <Box sx={{ background: BCPalette.theme.gray[30], marginTop: "1.5rem" }}>Table</Box> */}
</Stack>
</>
);
}
31 changes: 31 additions & 0 deletions compliance-web/src/store/modalStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {create} from 'zustand'

// Define the store state and actions
interface ModalStore {
isOpen: boolean
modalContent: React.ReactNode | null
setOpen: (modal: React.ReactNode) => Promise<void>
setClose: () => void
}

// Create the Zustand store
export const useModal = create<ModalStore>((set) => ({
isOpen: false,
modalContent: null,

setOpen: async (modal) => {
if (modal) {
set(() => ({
modalContent: modal,
isOpen: true,
}))
}
},

setClose: () => {
set({
isOpen: false,
modalContent: null,
})
},
}))
31 changes: 31 additions & 0 deletions compliance-web/src/store/snackbarStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { create } from "zustand";

interface SnackbarState {
isOpen: boolean;
severity: "success" | "error" | "warning" | "info";
message: string;
setOpen: (
message: string,
severity?: "success" | "error" | "warning" | "info",
) => void;
setClose: () => void;
}

export const useSnackbar = create<SnackbarState>((set) => ({
isOpen: false,
severity: "success", // default severity
message: "",
setOpen: (message, severity = "success") =>
set({ isOpen: true, message, severity }),
setClose: () => set({ isOpen: false }),
}));

// Helper function to notify with different severities
export const notify = {
success: (message: string) =>
useSnackbar.getState().setOpen(message, "success"),
error: (message: string) => useSnackbar.getState().setOpen(message, "error"),
warning: (message: string) =>
useSnackbar.getState().setOpen(message, "warning"),
info: (message: string) => useSnackbar.getState().setOpen(message, "info"),
};
Loading