wcz-layout 6.7.2 → 8.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Approval-BTJTexDo.js +143 -0
- package/dist/Approval-BTJTexDo.js.map +1 -0
- package/dist/DialogsContext-DLqA8RJ_.js +7 -0
- package/dist/DialogsContext-DLqA8RJ_.js.map +1 -0
- package/dist/Email-C9qwj7GD.js +20 -0
- package/dist/Email-C9qwj7GD.js.map +1 -0
- package/dist/FileMeta-DDqUju1Y.js +19 -0
- package/dist/FileMeta-DDqUju1Y.js.map +1 -0
- package/dist/FileMeta-ILLTOjaM.d.ts +20 -0
- package/dist/NotificationContext-CgwUOeW0.js +7 -0
- package/dist/NotificationContext-CgwUOeW0.js.map +1 -0
- package/dist/RouterListItemButton-owZVvuC_.js +78 -0
- package/dist/RouterListItemButton-owZVvuC_.js.map +1 -0
- package/dist/User-CT_IDGuG.d.ts +15 -0
- package/dist/apiMiddleware-CtY4rOFU.js +23 -0
- package/dist/apiMiddleware-CtY4rOFU.js.map +1 -0
- package/dist/components.d.ts +118 -0
- package/dist/components.js +1554 -0
- package/dist/components.js.map +1 -0
- package/dist/data/client.d.ts +3111 -0
- package/dist/data/client.js +188 -0
- package/dist/data/client.js.map +1 -0
- package/dist/data/server.d.ts +19 -0
- package/dist/data/server.js +16 -0
- package/dist/data/server.js.map +1 -0
- package/dist/data.d.ts +7 -0
- package/dist/data.js +2 -0
- package/dist/env-ON-cyE3N.js +31 -0
- package/dist/env-ON-cyE3N.js.map +1 -0
- package/dist/file-BUdLb7H1.js +148 -0
- package/dist/file-BUdLb7H1.js.map +1 -0
- package/dist/file-Dsht7yOP.js +100 -0
- package/dist/file-Dsht7yOP.js.map +1 -0
- package/dist/hooks.d.ts +226 -0
- package/dist/hooks.js +1180 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +2106 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +47 -0
- package/dist/middleware.js +80 -0
- package/dist/middleware.js.map +1 -0
- package/dist/models.d.ts +474 -0
- package/dist/models.js +74 -0
- package/dist/models.js.map +1 -0
- package/dist/msalClient-CYiQAFnY.d.ts +15 -0
- package/dist/msalServer-B9sVqpQ2.js +47 -0
- package/dist/msalServer-B9sVqpQ2.js.map +1 -0
- package/dist/peoplesoft-BCjRje6b.js +240 -0
- package/dist/peoplesoft-BCjRje6b.js.map +1 -0
- package/dist/peoplesoft-Cze2ngGd.d.ts +1150 -0
- package/dist/queryClient-D64McLhZ.js +7 -0
- package/dist/queryClient-D64McLhZ.js.map +1 -0
- package/dist/useDialogs-BJVhBr8S.js +248 -0
- package/dist/useDialogs-BJVhBr8S.js.map +1 -0
- package/dist/utils-BMUmv2ws.js +191 -0
- package/dist/utils-BMUmv2ws.js.map +1 -0
- package/dist/utils-CvvyM8Xw.d.ts +56 -0
- package/dist/utils.d.ts +21 -0
- package/dist/utils.js +6 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +147 -0
- package/dist/vite.js.map +1 -0
- package/package.json +158 -62
- package/skills/client-db/SKILL.md +107 -0
- package/skills/data-grid/SKILL.md +147 -0
- package/skills/db-schema/SKILL.md +68 -0
- package/skills/dialogs/SKILL.md +79 -0
- package/skills/forms/SKILL.md +82 -0
- package/skills/general/SKILL.md +17 -0
- package/skills/notifications/SKILL.md +43 -0
- package/skills/routing/SKILL.md +123 -0
- package/skills/server-functions/SKILL.md +109 -0
- package/skills/services/SKILL.md +28 -0
- package/skills/services/docs/approval.md +204 -0
- package/skills/services/docs/email.md +32 -0
- package/skills/services/docs/file.md +85 -0
- package/skills/services/docs/peoplesoft.md +110 -0
- package/skills/start/SKILL.md +46 -0
- package/skills/start/steps/01-git-setup.md +10 -0
- package/skills/start/steps/02-project-name-setup.md +14 -0
- package/skills/start/steps/03-apm-setup.md +208 -0
- package/skills/start/steps/04-database-setup.md +37 -0
- package/skills/start/steps/05-entra-setup.md +59 -0
- package/skills/start/steps/06-vault-setup.md +53 -0
- package/skills/start/steps/07-generate-favicon.md +10 -0
- package/skills/start/steps/08-commit.md +15 -0
- package/dist/src/components/Layout.d.ts +0 -16
- package/dist/src/components/Layout.js +0 -122
- package/dist/src/components/Layout.js.map +0 -1
- package/dist/src/components/dataGrid/ChipInputCell.d.ts +0 -9
- package/dist/src/components/dataGrid/ChipInputCell.js +0 -17
- package/dist/src/components/dataGrid/ChipInputCell.js.map +0 -1
- package/dist/src/components/dataGrid/EditableColumnHeader.d.ts +0 -2
- package/dist/src/components/dataGrid/EditableColumnHeader.js +0 -7
- package/dist/src/components/dataGrid/EditableColumnHeader.js.map +0 -1
- package/dist/src/components/dataGrid/GridToolbar.d.ts +0 -8
- package/dist/src/components/dataGrid/GridToolbar.js +0 -40
- package/dist/src/components/dataGrid/GridToolbar.js.map +0 -1
- package/dist/src/components/dataGrid/TableContainer.d.ts +0 -3
- package/dist/src/components/dataGrid/TableContainer.js +0 -32
- package/dist/src/components/dataGrid/TableContainer.js.map +0 -1
- package/dist/src/components/form/FormAutocomplete.d.ts +0 -7
- package/dist/src/components/form/FormAutocomplete.js +0 -10
- package/dist/src/components/form/FormAutocomplete.js.map +0 -1
- package/dist/src/components/form/FormCheckbox.d.ts +0 -7
- package/dist/src/components/form/FormCheckbox.js +0 -11
- package/dist/src/components/form/FormCheckbox.js.map +0 -1
- package/dist/src/components/form/FormDatePicker.d.ts +0 -9
- package/dist/src/components/form/FormDatePicker.js +0 -19
- package/dist/src/components/form/FormDatePicker.js.map +0 -1
- package/dist/src/components/form/FormDateTimePicker.d.ts +0 -9
- package/dist/src/components/form/FormDateTimePicker.js +0 -19
- package/dist/src/components/form/FormDateTimePicker.js.map +0 -1
- package/dist/src/components/form/FormNumberField.d.ts +0 -12
- package/dist/src/components/form/FormNumberField.js +0 -12
- package/dist/src/components/form/FormNumberField.js.map +0 -1
- package/dist/src/components/form/FormRadioGroup.d.ts +0 -13
- package/dist/src/components/form/FormRadioGroup.js +0 -11
- package/dist/src/components/form/FormRadioGroup.js.map +0 -1
- package/dist/src/components/form/FormSlider.d.ts +0 -7
- package/dist/src/components/form/FormSlider.js +0 -11
- package/dist/src/components/form/FormSlider.js.map +0 -1
- package/dist/src/components/form/FormSubmitButton.d.ts +0 -5
- package/dist/src/components/form/FormSubmitButton.js +0 -13
- package/dist/src/components/form/FormSubmitButton.js.map +0 -1
- package/dist/src/components/form/FormSwitch.d.ts +0 -7
- package/dist/src/components/form/FormSwitch.js +0 -11
- package/dist/src/components/form/FormSwitch.js.map +0 -1
- package/dist/src/components/form/FormTextField.d.ts +0 -7
- package/dist/src/components/form/FormTextField.js +0 -11
- package/dist/src/components/form/FormTextField.js.map +0 -1
- package/dist/src/components/layout/AccountMenu.d.ts +0 -9
- package/dist/src/components/layout/AccountMenu.js +0 -44
- package/dist/src/components/layout/AccountMenu.js.map +0 -1
- package/dist/src/components/layout/DevelopmentBanner.d.ts +0 -7
- package/dist/src/components/layout/DevelopmentBanner.js +0 -29
- package/dist/src/components/layout/DevelopmentBanner.js.map +0 -1
- package/dist/src/components/layout/ErrorPage.d.ts +0 -2
- package/dist/src/components/layout/ErrorPage.js +0 -25
- package/dist/src/components/layout/ErrorPage.js.map +0 -1
- package/dist/src/components/layout/LayoutDialog.d.ts +0 -12
- package/dist/src/components/layout/LayoutDialog.js +0 -12
- package/dist/src/components/layout/LayoutDialog.js.map +0 -1
- package/dist/src/components/layout/LayoutSnackbar.d.ts +0 -8
- package/dist/src/components/layout/LayoutSnackbar.js +0 -25
- package/dist/src/components/layout/LayoutSnackbar.js.map +0 -1
- package/dist/src/components/layout/NavigationDrawer.d.ts +0 -11
- package/dist/src/components/layout/NavigationDrawer.js +0 -70
- package/dist/src/components/layout/NavigationDrawer.js.map +0 -1
- package/dist/src/components/layout/NotificationMenu.d.ts +0 -8
- package/dist/src/components/layout/NotificationMenu.js +0 -26
- package/dist/src/components/layout/NotificationMenu.js.map +0 -1
- package/dist/src/components/layout/TypographyWithIcon.d.ts +0 -7
- package/dist/src/components/layout/TypographyWithIcon.js +0 -22
- package/dist/src/components/layout/TypographyWithIcon.js.map +0 -1
- package/dist/src/components/layout/Unauthorized.d.ts +0 -2
- package/dist/src/components/layout/Unauthorized.js +0 -26
- package/dist/src/components/layout/Unauthorized.js.map +0 -1
- package/dist/src/contexts/LayoutContext.d.ts +0 -40
- package/dist/src/contexts/LayoutContext.js +0 -60
- package/dist/src/contexts/LayoutContext.js.map +0 -1
- package/dist/src/contexts/UserContext.d.ts +0 -24
- package/dist/src/contexts/UserContext.js +0 -55
- package/dist/src/contexts/UserContext.js.map +0 -1
- package/dist/src/hooks/FormHooks.d.ts +0 -46
- package/dist/src/hooks/FormHooks.js +0 -31
- package/dist/src/hooks/FormHooks.js.map +0 -1
- package/dist/src/hooks/UseSnackbar.d.ts +0 -10
- package/dist/src/hooks/UseSnackbar.js +0 -23
- package/dist/src/hooks/UseSnackbar.js.map +0 -1
- package/dist/src/hooks/UseUser.d.ts +0 -10
- package/dist/src/hooks/UseUser.js +0 -25
- package/dist/src/hooks/UseUser.js.map +0 -1
- package/dist/src/index.d.ts +0 -20
- package/dist/src/index.js +0 -15
- package/dist/src/index.js.map +0 -1
- package/dist/src/models/Error.d.ts +0 -6
- package/dist/src/models/Error.js +0 -2
- package/dist/src/models/Error.js.map +0 -1
- package/dist/src/models/KeycloakSettings.d.ts +0 -8
- package/dist/src/models/KeycloakSettings.js +0 -2
- package/dist/src/models/KeycloakSettings.js.map +0 -1
- package/dist/src/models/LayoutPaletteColorOptions.d.ts +0 -6
- package/dist/src/models/LayoutPaletteColorOptions.js +0 -2
- package/dist/src/models/LayoutPaletteColorOptions.js.map +0 -1
- package/dist/src/models/LayoutRoute.d.ts +0 -14
- package/dist/src/models/LayoutRoute.js +0 -2
- package/dist/src/models/LayoutRoute.js.map +0 -1
- package/dist/src/models/Notification.d.ts +0 -9
- package/dist/src/models/Notification.js +0 -2
- package/dist/src/models/Notification.js.map +0 -1
- package/dist/src/models/PeoplesoftDepartment.d.ts +0 -14
- package/dist/src/models/PeoplesoftDepartment.js +0 -2
- package/dist/src/models/PeoplesoftDepartment.js.map +0 -1
- package/dist/src/models/PeoplesoftEmployee.d.ts +0 -34
- package/dist/src/models/PeoplesoftEmployee.js +0 -2
- package/dist/src/models/PeoplesoftEmployee.js.map +0 -1
- package/dist/src/models/Snackbar.d.ts +0 -15
- package/dist/src/models/Snackbar.js +0 -2
- package/dist/src/models/Snackbar.js.map +0 -1
- package/dist/src/models/User.d.ts +0 -27
- package/dist/src/models/User.js +0 -11
- package/dist/src/models/User.js.map +0 -1
- package/dist/src/models/types/EmployeeCategoryGroup.d.ts +0 -1
- package/dist/src/models/types/EmployeeCategoryGroup.js +0 -2
- package/dist/src/models/types/EmployeeCategoryGroup.js.map +0 -1
- package/dist/src/models/types/EmployeeStatus.d.ts +0 -1
- package/dist/src/models/types/EmployeeStatus.js +0 -2
- package/dist/src/models/types/EmployeeStatus.js.map +0 -1
- package/dist/src/utils/Auth.d.ts +0 -12
- package/dist/src/utils/Auth.js +0 -49
- package/dist/src/utils/Auth.js.map +0 -1
- package/dist/src/utils/Fetches.d.ts +0 -5
- package/dist/src/utils/Fetches.js +0 -66
- package/dist/src/utils/Fetches.js.map +0 -1
- package/dist/src/utils/FormUtils.d.ts +0 -7
- package/dist/src/utils/FormUtils.js +0 -9
- package/dist/src/utils/FormUtils.js.map +0 -1
- package/dist/src/utils/Helpers.d.ts +0 -11
- package/dist/src/utils/Helpers.js +0 -26
- package/dist/src/utils/Helpers.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/components/Layout.tsx +0 -183
- package/src/components/dataGrid/ChipInputCell.tsx +0 -31
- package/src/components/dataGrid/EditableColumnHeader.tsx +0 -7
- package/src/components/dataGrid/GridToolbar.tsx +0 -63
- package/src/components/dataGrid/TableContainer.tsx +0 -39
- package/src/components/form/FormAutocomplete.tsx +0 -34
- package/src/components/form/FormCheckbox.tsx +0 -32
- package/src/components/form/FormDatePicker.tsx +0 -34
- package/src/components/form/FormDateTimePicker.tsx +0 -34
- package/src/components/form/FormNumberField.tsx +0 -33
- package/src/components/form/FormRadioGroup.tsx +0 -43
- package/src/components/form/FormSlider.tsx +0 -28
- package/src/components/form/FormSubmitButton.tsx +0 -29
- package/src/components/form/FormSwitch.tsx +0 -32
- package/src/components/form/FormTextField.tsx +0 -26
- package/src/components/layout/AccountMenu.tsx +0 -160
- package/src/components/layout/DevelopmentBanner.tsx +0 -54
- package/src/components/layout/ErrorPage.tsx +0 -34
- package/src/components/layout/LayoutDialog.tsx +0 -50
- package/src/components/layout/LayoutSnackbar.tsx +0 -44
- package/src/components/layout/NavigationDrawer.tsx +0 -131
- package/src/components/layout/NotificationMenu.tsx +0 -76
- package/src/components/layout/TypographyWithIcon.tsx +0 -35
- package/src/components/layout/Unauthorized.tsx +0 -37
- package/src/contexts/LayoutContext.tsx +0 -127
- package/src/contexts/UserContext.tsx +0 -88
- package/src/hooks/FormHooks.ts +0 -33
- package/src/hooks/UseSnackbar.tsx +0 -28
- package/src/hooks/UseUser.tsx +0 -29
- package/src/index.ts +0 -27
- package/src/models/Error.tsx +0 -6
- package/src/models/KeycloakSettings.ts +0 -8
- package/src/models/LayoutPaletteColorOptions.tsx +0 -7
- package/src/models/LayoutRoute.ts +0 -15
- package/src/models/Notification.ts +0 -10
- package/src/models/PeoplesoftDepartment.ts +0 -15
- package/src/models/PeoplesoftEmployee.ts +0 -35
- package/src/models/Snackbar.ts +0 -16
- package/src/models/User.ts +0 -13
- package/src/models/types/EmployeeCategoryGroup.ts +0 -1
- package/src/models/types/EmployeeStatus.ts +0 -1
- package/src/utils/Auth.ts +0 -58
- package/src/utils/Fetches.ts +0 -83
- package/src/utils/FormUtils.ts +0 -22
- package/src/utils/Helpers.ts +0 -27
- package/tsconfig.json +0 -29
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Container, Typography } from "@mui/material";
|
|
3
|
-
import { useRouteError } from "react-router-dom";
|
|
4
|
-
export const ErrorPage = () => {
|
|
5
|
-
const error = useRouteError();
|
|
6
|
-
const formatErrorMessage = (error) => {
|
|
7
|
-
if (typeof error === "string") {
|
|
8
|
-
return error;
|
|
9
|
-
}
|
|
10
|
-
else if (error instanceof Error) {
|
|
11
|
-
return error.message;
|
|
12
|
-
}
|
|
13
|
-
else if (typeof error === "object" && error !== null) {
|
|
14
|
-
return JSON.stringify(error, null, 2);
|
|
15
|
-
}
|
|
16
|
-
else if (typeof error === "number" || typeof error === "boolean") {
|
|
17
|
-
return error.toString();
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return "An unknown error occurred.";
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
return (_jsx(Container, { maxWidth: "sm", children: _jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", minHeight: "100vh", textAlign: "center", padding: 3, children: [_jsx(Typography, { variant: "h2", gutterBottom: true, children: "Oops!" }), _jsx(Typography, { variant: "h6", color: "textSecondary", gutterBottom: true, children: formatErrorMessage(error) })] }) }));
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=ErrorPage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorPage.js","sourceRoot":"","sources":["../../../../src/components/layout/ErrorPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,CAAC,MAAM,SAAS,GAAO,GAAG,EAAE;IAC9B,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAE9B,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAU,EAAE;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACjB,CAAC;aAAM,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC,OAAO,CAAC;QACzB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YACjE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC;aAAM,CAAC;YACJ,OAAO,4BAA4B,CAAC;QACxC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACH,KAAC,SAAS,IAAC,QAAQ,EAAC,IAAI,YACpB,MAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,aAAa,EAAC,QAAQ,EAAC,UAAU,EAAC,QAAQ,EAAC,cAAc,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aAClI,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,EAAC,YAAY,4BAExB,EACb,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,eAAe,EAAC,YAAY,kBACtD,kBAAkB,CAAC,KAAK,CAAC,GACjB,IACX,GACE,CACf,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Box, Container, Typography } from \"@mui/material\";\r\nimport { FC } from \"react\";\r\nimport { useRouteError } from \"react-router-dom\";\r\n\r\nexport const ErrorPage: FC = () => {\r\n const error = useRouteError();\r\n\r\n const formatErrorMessage = (error: unknown): string => {\r\n if (typeof error === \"string\") {\r\n return error;\r\n } else if (error instanceof Error) {\r\n return error.message;\r\n } else if (typeof error === \"object\" && error !== null) {\r\n return JSON.stringify(error, null, 2);\r\n } else if (typeof error === \"number\" || typeof error === \"boolean\") {\r\n return error.toString();\r\n } else {\r\n return \"An unknown error occurred.\";\r\n }\r\n };\r\n\r\n return (\r\n <Container maxWidth=\"sm\">\r\n <Box display=\"flex\" flexDirection=\"column\" alignItems=\"center\" justifyContent=\"center\" minHeight=\"100vh\" textAlign=\"center\" padding={3} >\r\n <Typography variant=\"h2\" gutterBottom>\r\n Oops!\r\n </Typography>\r\n <Typography variant=\"h6\" color=\"textSecondary\" gutterBottom>\r\n {formatErrorMessage(error)}\r\n </Typography>\r\n </Box>\r\n </Container>\r\n );\r\n};"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Breakpoint } from "@mui/material";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
|
-
interface DialogProps {
|
|
4
|
-
open: boolean;
|
|
5
|
-
onClose: (_event?: {}, reason?: "backdropClick" | "escapeKeyDown") => void;
|
|
6
|
-
title: string | ReactNode;
|
|
7
|
-
color?: "success" | "info" | "warning" | "error" | "primary" | "secondary" | "inherit" | "default";
|
|
8
|
-
maxWidth?: Breakpoint;
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export declare const LayoutDialog: React.FC<DialogProps>;
|
|
12
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Close } from "@mui/icons-material";
|
|
3
|
-
import { AppBar, Dialog, DialogTitle, Grid2, IconButton, Toolbar, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
4
|
-
export const LayoutDialog = ({ open, onClose, title, color, maxWidth, children }) => {
|
|
5
|
-
const theme = useTheme();
|
|
6
|
-
const fullscreen = useMediaQuery(theme.breakpoints.down("sm"));
|
|
7
|
-
return (_jsxs(Dialog, { open: open, onClose: onClose, fullScreen: fullscreen, fullWidth: true, maxWidth: maxWidth, children: [fullscreen ?
|
|
8
|
-
_jsx(AppBar, { sx: { position: "relative", bgcolor: `${color}.main` }, children: _jsxs(Toolbar, { children: [_jsx(Typography, { sx: { flex: 1 }, variant: "h6", children: title }), _jsx(IconButton, { onClick: onClose, children: _jsx(Close, { sx: { color: `${color}.contrastText` } }) })] }) })
|
|
9
|
-
:
|
|
10
|
-
_jsxs(Grid2, { container: true, justifyContent: "space-between", sx: { bgcolor: `${color}.main`, color: `${color}.contrastText` }, children: [_jsx(Grid2, { children: _jsx(DialogTitle, { children: title }) }), _jsx(Grid2, { size: 2, sx: { p: 1, textAlign: "right" }, children: _jsx(IconButton, { onClick: onClose, children: _jsx(Close, { fontSize: "small", sx: { color: `${color}.contrastText` } }) }) })] }), open ? children : null] }));
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=LayoutDialog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutDialog.js","sourceRoot":"","sources":["../../../../src/components/layout/LayoutDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAc,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAYzI,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvG,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAE/D,OAAO,CACH,MAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,QAAC,QAAQ,EAAE,QAAQ,aACrF,UAAU,CAAC,CAAC;gBACT,KAAC,MAAM,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,EAAE,YAC1D,MAAC,OAAO,eACJ,KAAC,UAAU,IAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,OAAO,EAAC,IAAI,YACpC,KAAK,GACG,EACb,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,YACxB,KAAC,KAAK,IAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,eAAe,EAAE,GAAI,GACxC,IACP,GACL;gBACT,CAAC;oBACD,MAAC,KAAK,IAAC,SAAS,QAAC,cAAc,EAAC,eAAe,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,eAAe,EAAE,aAC5G,KAAC,KAAK,cACF,KAAC,WAAW,cACP,KAAK,GACI,GACV,EAER,KAAC,KAAK,IAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,YAC5C,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,YACxB,KAAC,KAAK,IAAC,QAAQ,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,eAAe,EAAE,GAAI,GACzD,GACT,IACJ,EAGX,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IACjB,CACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Close } from \"@mui/icons-material\";\r\nimport { AppBar, Breakpoint, Dialog, DialogTitle, Grid2, IconButton, Toolbar, Typography, useMediaQuery, useTheme } from \"@mui/material\";\r\nimport { ReactNode } from \"react\";\r\n\r\ninterface DialogProps {\r\n open: boolean;\r\n onClose: (_event?: {}, reason?: \"backdropClick\" | \"escapeKeyDown\") => void;\r\n title: string | ReactNode;\r\n color?: \"success\" | \"info\" | \"warning\" | \"error\" | \"primary\" | \"secondary\" | \"inherit\" | \"default\";\r\n maxWidth?: Breakpoint;\r\n children?: ReactNode;\r\n}\r\n\r\nexport const LayoutDialog: React.FC<DialogProps> = ({ open, onClose, title, color, maxWidth, children }) => {\r\n const theme = useTheme();\r\n const fullscreen = useMediaQuery(theme.breakpoints.down(\"sm\"));\r\n\r\n return (\r\n <Dialog open={open} onClose={onClose} fullScreen={fullscreen} fullWidth maxWidth={maxWidth}>\r\n {fullscreen ?\r\n <AppBar sx={{ position: \"relative\", bgcolor: `${color}.main` }}>\r\n <Toolbar>\r\n <Typography sx={{ flex: 1 }} variant=\"h6\">\r\n {title}\r\n </Typography>\r\n <IconButton onClick={onClose}>\r\n <Close sx={{ color: `${color}.contrastText` }} />\r\n </IconButton>\r\n </Toolbar>\r\n </AppBar>\r\n :\r\n <Grid2 container justifyContent=\"space-between\" sx={{ bgcolor: `${color}.main`, color: `${color}.contrastText` }}>\r\n <Grid2>\r\n <DialogTitle>\r\n {title}\r\n </DialogTitle>\r\n </Grid2>\r\n\r\n <Grid2 size={2} sx={{ p: 1, textAlign: \"right\" }}>\r\n <IconButton onClick={onClose}>\r\n <Close fontSize=\"small\" sx={{ color: `${color}.contrastText` }} />\r\n </IconButton>\r\n </Grid2>\r\n </Grid2>\r\n }\r\n\r\n {open ? children : null}\r\n </Dialog >\r\n );\r\n};\r\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { Snackbar as SnackbarModel } from "../../models/Snackbar";
|
|
3
|
-
interface SnackbarProps {
|
|
4
|
-
snackbar: SnackbarModel;
|
|
5
|
-
setSnackbar: Dispatch<SetStateAction<SnackbarModel>>;
|
|
6
|
-
}
|
|
7
|
-
export declare const LayoutSnackbar: React.FC<SnackbarProps>;
|
|
8
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Alert, AlertTitle, Portal, Snackbar } from "@mui/material";
|
|
3
|
-
import { Fragment, useMemo } from "react";
|
|
4
|
-
export const LayoutSnackbar = ({ snackbar, setSnackbar }) => {
|
|
5
|
-
const handleOnSnackbarClose = (_event, reason) => {
|
|
6
|
-
if (reason === "clickaway")
|
|
7
|
-
return;
|
|
8
|
-
setSnackbar(prevSnackbar => ({ ...prevSnackbar, title: "" }));
|
|
9
|
-
};
|
|
10
|
-
const autoHideDuration = useMemo(() => {
|
|
11
|
-
if ((snackbar === null || snackbar === void 0 ? void 0 : snackbar.duration) === undefined) {
|
|
12
|
-
if ((snackbar === null || snackbar === void 0 ? void 0 : snackbar.severity) === "error")
|
|
13
|
-
return 15000;
|
|
14
|
-
if ((snackbar === null || snackbar === void 0 ? void 0 : snackbar.severity) === "warning")
|
|
15
|
-
return 10000;
|
|
16
|
-
return 5000;
|
|
17
|
-
}
|
|
18
|
-
return snackbar.duration;
|
|
19
|
-
}, [snackbar]);
|
|
20
|
-
return (_jsx(Portal, { children: _jsx(Snackbar, { open: !!(snackbar === null || snackbar === void 0 ? void 0 : snackbar.title), autoHideDuration: autoHideDuration, onClose: handleOnSnackbarClose, children: _jsx(Alert, { onClose: handleOnSnackbarClose, severity: snackbar === null || snackbar === void 0 ? void 0 : snackbar.severity, sx: { width: "100%" }, variant: "filled", children: (snackbar === null || snackbar === void 0 ? void 0 : snackbar.description) ?
|
|
21
|
-
_jsxs(Fragment, { children: [_jsx(AlertTitle, { children: snackbar === null || snackbar === void 0 ? void 0 : snackbar.title }), snackbar.description] })
|
|
22
|
-
:
|
|
23
|
-
snackbar === null || snackbar === void 0 ? void 0 : snackbar.title }) }) }));
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=LayoutSnackbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutSnackbar.js","sourceRoot":"","sources":["../../../../src/components/layout/LayoutSnackbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE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AE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAC,QAAQ,YACvG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,EAAC,CAAC;oBACpB,MAAC,QAAQ,eACL,KAAC,UAAU,cAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,GAAc,EACzC,QAAQ,CAAC,WAAW,IACd;oBACX,CAAC;wBACD,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,GAEf,GACD,GACN,CACZ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Alert, AlertTitle, Portal, Snackbar } from \"@mui/material\";\r\nimport { Dispatch, Fragment, SetStateAction, SyntheticEvent, useMemo } from \"react\";\r\nimport { Snackbar as SnackbarModel } from \"../../models/Snackbar\";\r\n\r\ninterface SnackbarProps {\r\n snackbar: SnackbarModel;\r\n setSnackbar: Dispatch<SetStateAction<SnackbarModel>>;\r\n}\r\n\r\nexport const LayoutSnackbar: React.FC<SnackbarProps> = ({ snackbar, setSnackbar }) => {\r\n\r\n const handleOnSnackbarClose = (_event?: SyntheticEvent | Event, reason?: string) => {\r\n if (reason === \"clickaway\") return;\r\n setSnackbar(prevSnackbar => ({ ...prevSnackbar, title: \"\" }));\r\n };\r\n\r\n const autoHideDuration = useMemo(() => {\r\n if (snackbar?.duration === undefined) {\r\n if (snackbar?.severity === \"error\")\r\n return 15000;\r\n if (snackbar?.severity === \"warning\")\r\n return 10000;\r\n return 5000;\r\n }\r\n return snackbar.duration;\r\n }, [snackbar]);\r\n\r\n return (\r\n <Portal>\r\n <Snackbar open={!!snackbar?.title} autoHideDuration={autoHideDuration} onClose={handleOnSnackbarClose}>\r\n <Alert onClose={handleOnSnackbarClose} severity={snackbar?.severity} sx={{ width: \"100%\" }} variant=\"filled\">\r\n {snackbar?.description ?\r\n <Fragment>\r\n <AlertTitle>{snackbar?.title}</AlertTitle>\r\n {snackbar.description}\r\n </Fragment>\r\n :\r\n snackbar?.title\r\n }\r\n </Alert>\r\n </Snackbar>\r\n </Portal>\r\n );\r\n};"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { LayoutRoute } from "../../models/LayoutRoute";
|
|
3
|
-
interface NavigationDrawerProps {
|
|
4
|
-
routes: LayoutRoute[];
|
|
5
|
-
appVersion: string;
|
|
6
|
-
open: boolean;
|
|
7
|
-
setOpen: (open: boolean) => void;
|
|
8
|
-
hasRoutes: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const NavigationDrawer: React.FC<NavigationDrawerProps>;
|
|
11
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronLeft, ChevronRight } from "@mui/icons-material";
|
|
3
|
-
import { Box, Divider, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Drawer as MuiDrawer, Tooltip, Typography } from "@mui/material";
|
|
4
|
-
import { styled, useTheme } from "@mui/material/styles";
|
|
5
|
-
import { Fragment } from "react";
|
|
6
|
-
import { useTranslation } from "react-i18next";
|
|
7
|
-
import { useLocation, useNavigate } from "react-router-dom";
|
|
8
|
-
const drawerWidth = 240;
|
|
9
|
-
const openedMixin = (theme) => ({
|
|
10
|
-
width: drawerWidth,
|
|
11
|
-
transition: theme.transitions.create("width", {
|
|
12
|
-
easing: theme.transitions.easing.sharp,
|
|
13
|
-
duration: theme.transitions.duration.enteringScreen,
|
|
14
|
-
}),
|
|
15
|
-
overflowX: "hidden",
|
|
16
|
-
});
|
|
17
|
-
const closedMixin = (theme) => ({
|
|
18
|
-
transition: theme.transitions.create("width", {
|
|
19
|
-
easing: theme.transitions.easing.sharp,
|
|
20
|
-
duration: theme.transitions.duration.leavingScreen,
|
|
21
|
-
}),
|
|
22
|
-
overflowX: "hidden",
|
|
23
|
-
width: `calc(${theme.spacing(7)} + 1px)`,
|
|
24
|
-
[theme.breakpoints.up("sm")]: {
|
|
25
|
-
width: `calc(${theme.spacing(8.4)} + 1px)`,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
29
|
-
display: "flex",
|
|
30
|
-
alignItems: "center",
|
|
31
|
-
justifyContent: "flex-end",
|
|
32
|
-
padding: theme.spacing(0, 1),
|
|
33
|
-
// necessary for content to be below app bar
|
|
34
|
-
...theme.mixins.toolbar,
|
|
35
|
-
}));
|
|
36
|
-
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== "open" })(({ theme, open }) => ({
|
|
37
|
-
width: drawerWidth,
|
|
38
|
-
flexShrink: 0,
|
|
39
|
-
whiteSpace: "nowrap",
|
|
40
|
-
boxSizing: "border-box",
|
|
41
|
-
...(open && {
|
|
42
|
-
...openedMixin(theme),
|
|
43
|
-
"& .MuiDrawer-paper": openedMixin(theme),
|
|
44
|
-
}),
|
|
45
|
-
...(!open && {
|
|
46
|
-
...closedMixin(theme),
|
|
47
|
-
"& .MuiDrawer-paper": closedMixin(theme),
|
|
48
|
-
}),
|
|
49
|
-
}));
|
|
50
|
-
const isExternalUrl = (url) => url.startsWith("http://") || url.startsWith("https://");
|
|
51
|
-
export const NavigationDrawer = ({ routes, appVersion, open, setOpen, hasRoutes }) => {
|
|
52
|
-
const theme = useTheme();
|
|
53
|
-
const { t } = useTranslation();
|
|
54
|
-
const navigate = useNavigate();
|
|
55
|
-
const location = useLocation();
|
|
56
|
-
const closeDrawer = () => setOpen(false);
|
|
57
|
-
const handleMenuItemClick = (item) => () => {
|
|
58
|
-
if (!item.path)
|
|
59
|
-
return console.error("Path is not defined for menu item", item);
|
|
60
|
-
setOpen(false);
|
|
61
|
-
if (location.pathname === item.path)
|
|
62
|
-
return window.location.reload();
|
|
63
|
-
if (isExternalUrl(item.path))
|
|
64
|
-
return window.open(item.path, "_blank");
|
|
65
|
-
navigate(item.path);
|
|
66
|
-
};
|
|
67
|
-
const menuItems = (_jsx(List, { children: routes.filter(route => route.showInMenu && !route.disabled).map(item => _jsxs(Fragment, { children: [_jsx(Tooltip, { title: item.title, placement: "right", disableInteractive: true, disableHoverListener: open, disableTouchListener: open, children: _jsx(ListItem, { disablePadding: true, sx: { display: "block" }, onClick: handleMenuItemClick(item), children: _jsxs(ListItemButton, { selected: location.pathname === item.path, children: [_jsx(ListItemIcon, { children: item.icon }), _jsx(ListItemText, { primary: item.title })] }) }) }), item.divider && _jsx(Divider, { sx: { my: 1 } })] }, item.path)) }));
|
|
68
|
-
return (_jsxs(Fragment, { children: [_jsxs(Drawer, { variant: "permanent", open: open, sx: { display: { xs: "none", sm: hasRoutes ? "inherit" : "none" } }, children: [_jsxs(DrawerHeader, { children: [_jsxs(Typography, { sx: { flexGrow: 1, textAlign: "center", marginLeft: 3 }, children: [t("Layout.Version"), ": ", appVersion] }), _jsx(IconButton, { onClick: closeDrawer, children: theme.direction === "rtl" ? _jsx(ChevronRight, {}) : _jsx(ChevronLeft, {}) })] }), _jsx(Divider, {}), menuItems] }), _jsx(MuiDrawer, { anchor: "left", open: open, onClose: closeDrawer, sx: { display: { xs: "inherit", sm: hasRoutes ? "none" : "inherit" } }, children: _jsxs(Box, { sx: { width: drawerWidth }, children: [_jsxs(Typography, { sx: { textAlign: "center", my: 1.5 }, children: [t("Layout.Version"), ": ", appVersion] }), menuItems] }) })] }));
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=NavigationDrawer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationDrawer.js","sourceRoot":"","sources":["../../../../src/components/layout/NavigationDrawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,IAAI,SAAS,EAAE,OAAO,E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aAAG,CAAC,CAAC,gBAAgB,CAAC,QAAI,UAAU,IAAc,EACjG,SAAS,IACR,GACE,IACL,CACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { ChevronLeft, ChevronRight } from \"@mui/icons-material\";\r\nimport { Box, Divider, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Drawer as MuiDrawer, Tooltip, Typography } from \"@mui/material\";\r\nimport { CSSObject, Theme, styled, useTheme } from \"@mui/material/styles\";\r\nimport React, { Fragment } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { useLocation, useNavigate } from \"react-router-dom\";\r\nimport { LayoutRoute } from \"../../models/LayoutRoute\";\r\n\r\nconst drawerWidth = 240;\r\n\r\nconst openedMixin = (theme: Theme): CSSObject => ({\r\n width: drawerWidth,\r\n transition: theme.transitions.create(\"width\", {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.enteringScreen,\r\n }),\r\n overflowX: \"hidden\",\r\n});\r\n\r\nconst closedMixin = (theme: Theme): CSSObject => ({\r\n transition: theme.transitions.create(\"width\", {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.leavingScreen,\r\n }),\r\n overflowX: \"hidden\",\r\n width: `calc(${theme.spacing(7)} + 1px)`,\r\n [theme.breakpoints.up(\"sm\")]: {\r\n width: `calc(${theme.spacing(8.4)} + 1px)`,\r\n },\r\n});\r\n\r\nconst DrawerHeader = styled(\"div\")(({ theme }) => ({\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-end\",\r\n padding: theme.spacing(0, 1),\r\n // necessary for content to be below app bar\r\n ...theme.mixins.toolbar,\r\n}));\r\n\r\nconst Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== \"open\" })(\r\n ({ theme, open }) => ({\r\n width: drawerWidth,\r\n flexShrink: 0,\r\n whiteSpace: \"nowrap\",\r\n boxSizing: \"border-box\",\r\n ...(open && {\r\n ...openedMixin(theme),\r\n \"& .MuiDrawer-paper\": openedMixin(theme),\r\n }),\r\n ...(!open && {\r\n ...closedMixin(theme),\r\n \"& .MuiDrawer-paper\": closedMixin(theme),\r\n }),\r\n }),\r\n);\r\n\r\nconst isExternalUrl = (url: string) => url.startsWith(\"http://\") || url.startsWith(\"https://\");\r\n\r\ninterface NavigationDrawerProps {\r\n routes: LayoutRoute[];\r\n appVersion: string;\r\n open: boolean;\r\n setOpen: (open: boolean) => void;\r\n hasRoutes: boolean;\r\n}\r\n\r\nexport const NavigationDrawer: React.FC<NavigationDrawerProps> = ({ routes, appVersion, open, setOpen, hasRoutes }) => {\r\n const theme = useTheme();\r\n const { t } = useTranslation();\r\n const navigate = useNavigate();\r\n const location = useLocation();\r\n\r\n const closeDrawer = () => setOpen(false);\r\n\r\n const handleMenuItemClick = (item: LayoutRoute) => () => {\r\n if (!item.path) return console.error(\"Path is not defined for menu item\", item);\r\n setOpen(false);\r\n\r\n if (location.pathname === item.path)\r\n return window.location.reload();\r\n\r\n if (isExternalUrl(item.path))\r\n return window.open(item.path, \"_blank\");\r\n\r\n navigate(item.path);\r\n };\r\n\r\n const menuItems = (\r\n <List>\r\n {routes.filter(route => route.showInMenu && !route.disabled).map(item =>\r\n <Fragment key={item.path}>\r\n <Tooltip title={item.title} placement=\"right\" disableInteractive disableHoverListener={open} disableTouchListener={open}>\r\n <ListItem disablePadding sx={{ display: \"block\" }} onClick={handleMenuItemClick(item)}>\r\n <ListItemButton selected={location.pathname === item.path}>\r\n <ListItemIcon>\r\n {item.icon}\r\n </ListItemIcon>\r\n <ListItemText primary={item.title} />\r\n </ListItemButton>\r\n </ListItem>\r\n </Tooltip>\r\n\r\n {item.divider && <Divider sx={{ my: 1 }} />}\r\n </Fragment>\r\n )}\r\n </List>\r\n );\r\n\r\n return (\r\n <Fragment>\r\n <Drawer variant=\"permanent\" open={open} sx={{ display: { xs: \"none\", sm: hasRoutes ? \"inherit\" : \"none\" } }}>\r\n <DrawerHeader>\r\n <Typography sx={{ flexGrow: 1, textAlign: \"center\", marginLeft: 3 }}>{t(\"Layout.Version\")}: {appVersion}</Typography>\r\n <IconButton onClick={closeDrawer}>\r\n {theme.direction === \"rtl\" ? <ChevronRight /> : <ChevronLeft />}\r\n </IconButton>\r\n </DrawerHeader>\r\n <Divider />\r\n {menuItems}\r\n </Drawer>\r\n\r\n <MuiDrawer anchor=\"left\" open={open} onClose={closeDrawer} sx={{ display: { xs: \"inherit\", sm: hasRoutes ? \"none\" : \"inherit\" } }}>\r\n <Box sx={{ width: drawerWidth }}>\r\n <Typography sx={{ textAlign: \"center\", my: 1.5 }}>{t(\"Layout.Version\")}: {appVersion}</Typography>\r\n {menuItems}\r\n </Box>\r\n </MuiDrawer>\r\n </Fragment>\r\n );\r\n};\r\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React, { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import Notification from "../../models/Notification";
|
|
3
|
-
interface NotificationMenuProps {
|
|
4
|
-
notifications: Notification[] | undefined;
|
|
5
|
-
setNotifications: Dispatch<SetStateAction<Notification[] | undefined>>;
|
|
6
|
-
}
|
|
7
|
-
export declare const NotificationMenu: React.FC<NotificationMenuProps>;
|
|
8
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Done, Error, Info, Notifications, NotificationsOff, Warning } from "@mui/icons-material";
|
|
3
|
-
import { Badge, Grid, IconButton, List, ListItem, ListItemIcon, ListItemText, Menu, Typography } from "@mui/material";
|
|
4
|
-
import { grey } from "@mui/material/colors";
|
|
5
|
-
import moment from "moment";
|
|
6
|
-
import { Fragment, useEffect, useState } from "react";
|
|
7
|
-
import { useTranslation } from "react-i18next";
|
|
8
|
-
import { TypographyWithIcon } from "./TypographyWithIcon";
|
|
9
|
-
export const NotificationMenu = ({ notifications, setNotifications }) => {
|
|
10
|
-
const { t } = useTranslation();
|
|
11
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
12
|
-
const open = Boolean(anchorEl);
|
|
13
|
-
const openMenu = (e) => setAnchorEl(e.currentTarget);
|
|
14
|
-
const closeMenu = () => setAnchorEl(null);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (open)
|
|
17
|
-
setAllNotificationsAsRead();
|
|
18
|
-
}, [open]);
|
|
19
|
-
const setAllNotificationsAsRead = () => {
|
|
20
|
-
const updatedNotifications = [...notifications || []].map(notification => ({ ...notification, isRead: true }));
|
|
21
|
-
setNotifications(updatedNotifications);
|
|
22
|
-
};
|
|
23
|
-
return (_jsxs(Fragment, { children: [_jsx(IconButton, { color: "inherit", onClick: openMenu, sx: { mr: 1 }, children: _jsx(Badge, { badgeContent: notifications === null || notifications === void 0 ? void 0 : notifications.filter(notification => !notification.isRead).length, color: "error", children: _jsx(Notifications, {}) }) }), _jsx(Menu, { anchorEl: anchorEl, open: open, onClose: closeMenu, sx: { height: 700, maxHeight: "calc(100vh - 50px)" }, children: _jsxs(List, { dense: true, sx: { width: 400, maxWidth: "calc(100vw - 50px)" }, children: [_jsx(ListItem, { children: _jsx(Typography, { variant: "h6", children: t("Layout.Notifications") }) }), notifications === null || notifications === void 0 ? void 0 : notifications.map(notification => _jsxs(ListItem, { sx: theme => ({ transition: "background-color 0.2s ease", cursor: "default", "&:hover": { bgcolor: theme.palette.mode === "dark" ? grey[800] : grey[200] } }), children: [_jsxs(ListItemIcon, { children: [notification.severity === "error" && _jsx(Error, { color: "error", fontSize: "large" }), notification.severity === "warning" && _jsx(Warning, { color: "warning", fontSize: "large" }), notification.severity === "info" && _jsx(Info, { color: "info", fontSize: "large" }), (notification.severity === "success" || !notification.severity) && _jsx(Done, { color: "success", fontSize: "large" })] }), _jsx(ListItemText, { primary: _jsx(Typography, { variant: "body1", children: notification.title }), secondary: _jsxs(Fragment, { children: [_jsx(Typography, { variant: "body2", children: notification.description }), _jsx(Typography, { variant: "caption", children: moment(notification.dateTime).fromNow() })] }) })] }, notification.dateTime)), !(notifications === null || notifications === void 0 ? void 0 : notifications.length) &&
|
|
24
|
-
_jsx(Grid, { container: true, justifyContent: "center", alignItems: "center", sx: { width: "100%", height: 200, maxHeight: "calc(100vh - 150px)" }, children: _jsx(Grid, { item: true, children: _jsx(TypographyWithIcon, { startIcon: _jsx(NotificationsOff, { color: "disabled" }), color: "text.secondary", children: t("Layout.NoNotificationsAtTheMoment") }) }) })] }) })] }));
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=NotificationMenu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationMenu.js","sourceRoot":"","sources":["../../../../src/components/layout/NotificationMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAc,EAAY,QAAQ,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,MAAM,CAAC,MAAM,gBAAgB,GAAoC,CAAC,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE,EAAE;IACrG,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC;IAC/B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAqB,IAAI,CAAC,CAAC;IACnE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAA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AY,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAc,IAC7E,GACX,KAbO,YAAY,CAAC,QAAQ,CAczB,CACd,EAEA,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,CAAA;4BACnB,KAAC,IAAI,IAAC,SAAS,QAAC,cAAc,EAAC,QAAQ,EAAC,UAAU,EAAC,QAAQ,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,qBAAqB,EAAE,YAC5H,KAAC,IAAI,IAAC,IAAI,kBACN,KAAC,kBAAkB,IAAC,SAAS,EAAE,KAAC,gBAAgB,IAAC,KAAK,EAAC,UAAU,GAAG,EAAE,KAAK,EAAC,gBAAgB,YAAE,CAAC,CAAC,mCAAmC,CAAC,GAAsB,GACvJ,GACJ,IAER,GACJ,IACA,CACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Done, Error, Info, Notifications, NotificationsOff, Warning } from \"@mui/icons-material\";\r\nimport { Badge, Grid, IconButton, List, ListItem, ListItemIcon, ListItemText, Menu, Typography } from \"@mui/material\";\r\nimport { grey } from \"@mui/material/colors\";\r\nimport moment from \"moment\";\r\nimport React, { Dispatch, Fragment, SetStateAction, useEffect, useState } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport Notification from \"../../models/Notification\";\r\nimport { TypographyWithIcon } from \"./TypographyWithIcon\";\r\n\r\ninterface NotificationMenuProps {\r\n notifications: Notification[] | undefined;\r\n setNotifications: Dispatch<SetStateAction<Notification[] | undefined>>;\r\n}\r\n\r\nexport const NotificationMenu: React.FC<NotificationMenuProps> = ({ notifications, setNotifications }) => {\r\n const { t } = useTranslation();\r\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\r\n const open = Boolean(anchorEl);\r\n\r\n const openMenu = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => setAnchorEl(e.currentTarget);\r\n const closeMenu = () => setAnchorEl(null);\r\n\r\n useEffect(() => {\r\n if (open)\r\n setAllNotificationsAsRead();\r\n }, [open]);\r\n\r\n const setAllNotificationsAsRead = () => {\r\n const updatedNotifications = [...notifications || []].map(notification => ({ ...notification, isRead: true }));\r\n setNotifications(updatedNotifications);\r\n };\r\n\r\n return (\r\n <Fragment>\r\n <IconButton color=\"inherit\" onClick={openMenu} sx={{ mr: 1 }}>\r\n <Badge badgeContent={notifications?.filter(notification => !notification.isRead).length} color=\"error\">\r\n <Notifications />\r\n </Badge>\r\n </IconButton>\r\n\r\n <Menu anchorEl={anchorEl} open={open} onClose={closeMenu} sx={{ height: 700, maxHeight: \"calc(100vh - 50px)\" }}>\r\n <List dense sx={{ width: 400, maxWidth: \"calc(100vw - 50px)\" }}>\r\n <ListItem>\r\n <Typography variant=\"h6\">{t(\"Layout.Notifications\")}</Typography>\r\n </ListItem>\r\n\r\n {notifications?.map(notification =>\r\n <ListItem key={notification.dateTime} sx={theme => ({ transition: \"background-color 0.2s ease\", cursor: \"default\", \"&:hover\": { bgcolor: theme.palette.mode === \"dark\" ? grey[800] : grey[200] } })}>\r\n <ListItemIcon>\r\n {notification.severity === \"error\" && <Error color=\"error\" fontSize=\"large\" />}\r\n {notification.severity === \"warning\" && <Warning color=\"warning\" fontSize=\"large\" />}\r\n {notification.severity === \"info\" && <Info color=\"info\" fontSize=\"large\" />}\r\n {(notification.severity === \"success\" || !notification.severity) && <Done color=\"success\" fontSize=\"large\" />}\r\n </ListItemIcon>\r\n\r\n <ListItemText primary={<Typography variant=\"body1\">{notification.title}</Typography>} secondary={\r\n <Fragment>\r\n <Typography variant=\"body2\">{notification.description}</Typography>\r\n <Typography variant=\"caption\">{moment(notification.dateTime).fromNow()}</Typography>\r\n </Fragment>\r\n } />\r\n </ListItem>\r\n )}\r\n\r\n {!notifications?.length &&\r\n <Grid container justifyContent=\"center\" alignItems=\"center\" sx={{ width: \"100%\", height: 200, maxHeight: \"calc(100vh - 150px)\" }}>\r\n <Grid item>\r\n <TypographyWithIcon startIcon={<NotificationsOff color=\"disabled\" />} color=\"text.secondary\">{t(\"Layout.NoNotificationsAtTheMoment\")}</TypographyWithIcon>\r\n </Grid>\r\n </Grid>\r\n }\r\n </List>\r\n </Menu>\r\n </Fragment>\r\n );\r\n};"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Stack, Typography } from "@mui/material";
|
|
3
|
-
const stackSxProps = [
|
|
4
|
-
"margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "m", "mt", "mr", "mb", "ml", "mx", "my",
|
|
5
|
-
"padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "p", "pt", "pr", "pb", "pl", "px", "py",
|
|
6
|
-
"flexGrow", "flexShrink", "flexBasis", "flexDirection", "alignItems", "justifyContent",
|
|
7
|
-
"position", "zIndex", "top", "right", "bottom", "left",
|
|
8
|
-
"gridGap", "gridColumnGap", "gridRowGap", "gridColumn", "gridRow", "gridAutoFlow",
|
|
9
|
-
"gap", "columnGap", "rowGap"
|
|
10
|
-
];
|
|
11
|
-
export const TypographyWithIcon = ({ startIcon, endIcon, children, sx, gutterBottom, ...props }) => {
|
|
12
|
-
const sxCopy = { ...sx };
|
|
13
|
-
const stackStyles = stackSxProps.reduce((acc, curr) => {
|
|
14
|
-
if (sxCopy && sxCopy[curr]) {
|
|
15
|
-
acc[curr] = sxCopy[curr];
|
|
16
|
-
delete sxCopy[curr];
|
|
17
|
-
}
|
|
18
|
-
return acc;
|
|
19
|
-
}, {});
|
|
20
|
-
return (_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: stackStyles, mb: gutterBottom ? 0.7 : undefined, children: [startIcon && startIcon, _jsx(Typography, { ...props, sx: sxCopy, children: children }), endIcon && endIcon] }));
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=TypographyWithIcon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":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EAAE,EAAoB,CAAC,CAAC;IAEzB,OAAO,CACH,MAAC,KAAK,IAAC,SAAS,EAAC,KAAK,EAAC,UAAU,EAAC,QAAQ,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,aACjG,SAAS,IAAI,SAAS,EACvB,KAAC,UAAU,OAAK,KAAK,EAAE,EAAE,EAAE,MAAM,YAAG,QAAQ,GAAc,EACzD,OAAO,IAAI,OAAO,IACf,CACX,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Stack, SxProps, Theme, Typography, TypographyProps } from \"@mui/material\";\r\n\r\nconst stackSxProps = [\r\n \"margin\", \"marginTop\", \"marginRight\", \"marginBottom\", \"marginLeft\", \"m\", \"mt\", \"mr\", \"mb\", \"ml\", \"mx\", \"my\",\r\n \"padding\", \"paddingTop\", \"paddingRight\", \"paddingBottom\", \"paddingLeft\", \"p\", \"pt\", \"pr\", \"pb\", \"pl\", \"px\", \"py\",\r\n \"flexGrow\", \"flexShrink\", \"flexBasis\", \"flexDirection\", \"alignItems\", \"justifyContent\",\r\n \"position\", \"zIndex\", \"top\", \"right\", \"bottom\", \"left\",\r\n \"gridGap\", \"gridColumnGap\", \"gridRowGap\", \"gridColumn\", \"gridRow\", \"gridAutoFlow\",\r\n \"gap\", \"columnGap\", \"rowGap\"\r\n];\r\n\r\ninterface TypographyWithIconProps extends TypographyProps {\r\n startIcon?: React.ReactNode;\r\n endIcon?: React.ReactNode;\r\n}\r\n\r\nexport const TypographyWithIcon: React.FC<TypographyWithIconProps> = ({ startIcon, endIcon, children, sx, gutterBottom, ...props }) => {\r\n const sxCopy = { ...sx };\r\n\r\n const stackStyles = stackSxProps.reduce((acc, curr) => {\r\n if (sxCopy && (sxCopy as any)[curr]) {\r\n (acc as any)[curr] = (sxCopy as any)[curr];\r\n delete (sxCopy as any)[curr];\r\n }\r\n return acc;\r\n }, {} as SxProps<Theme>);\r\n\r\n return (\r\n <Stack direction=\"row\" alignItems=\"center\" gap={1} sx={stackStyles} mb={gutterBottom ? 0.7 : undefined}>\r\n {startIcon && startIcon}\r\n <Typography {...props} sx={sxCopy}>{children}</Typography>\r\n {endIcon && endIcon}\r\n </Stack>\r\n );\r\n};"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box, CircularProgress, Typography } from "@mui/material";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
export const Unauthorized = () => {
|
|
6
|
-
const { t } = useTranslation();
|
|
7
|
-
const [isInitializingKeycloak, setIsInitializingKeycloak] = useState(false);
|
|
8
|
-
const [showComponent, setShowComponent] = useState(false);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const timer = setTimeout(() => {
|
|
11
|
-
setShowComponent(true);
|
|
12
|
-
}, 1000);
|
|
13
|
-
window.addEventListener("keycloakInitialization", handleInitialization);
|
|
14
|
-
return () => {
|
|
15
|
-
clearTimeout(timer);
|
|
16
|
-
window.removeEventListener("keycloakInitialization", handleInitialization);
|
|
17
|
-
};
|
|
18
|
-
}, []);
|
|
19
|
-
const handleInitialization = (event) => {
|
|
20
|
-
setIsInitializingKeycloak(event.detail.initializing);
|
|
21
|
-
};
|
|
22
|
-
if (!showComponent)
|
|
23
|
-
return null;
|
|
24
|
-
return (_jsx(Box, { sx: { position: "relative", height: { xs: "calc(100vh - 56px)", sm: "calc(100vh - 64px)" } }, children: _jsx(Box, { sx: { position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }, children: isInitializingKeycloak ? _jsx(CircularProgress, {}) : _jsx(Typography, { variant: "h6", children: t("Layout.Unauthorized") }) }) }));
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=Unauthorized.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Unauthorized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,oBAAoB,EAAE,EAAE,YAC7F,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAE,YACzF,sBAAsB,CAAC,CAAC,CAAC,KAAC,gBAAgB,KAAG,CAAC,CAAC,CAAC,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,YAAE,CAAC,CAAC,qBAAqB,CAAC,GAAc,GAC/G,GACJ,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Box, CircularProgress, Typography } from \"@mui/material\";\r\nimport React, { useEffect, useState } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\n\r\nexport const Unauthorized: React.FC = () => {\r\n const { t } = useTranslation();\r\n const [isInitializingKeycloak, setIsInitializingKeycloak] = useState(false);\r\n const [showComponent, setShowComponent] = useState(false);\r\n\r\n useEffect(() => {\r\n const timer = setTimeout(() => {\r\n setShowComponent(true);\r\n }, 1000);\r\n\r\n window.addEventListener(\"keycloakInitialization\", handleInitialization as EventListener);\r\n\r\n return () => {\r\n clearTimeout(timer);\r\n window.removeEventListener(\"keycloakInitialization\", handleInitialization as EventListener);\r\n };\r\n }, []);\r\n\r\n const handleInitialization = (event: CustomEvent) => {\r\n setIsInitializingKeycloak(event.detail.initializing);\r\n };\r\n\r\n if (!showComponent)\r\n return null;\r\n\r\n return (\r\n <Box sx={{ position: \"relative\", height: { xs: \"calc(100vh - 56px)\", sm: \"calc(100vh - 64px)\" } }}>\r\n <Box sx={{ position: \"absolute\", top: \"50%\", left: \"50%\", transform: \"translate(-50%, -50%)\" }}>\r\n {isInitializingKeycloak ? <CircularProgress /> : <Typography variant=\"h6\">{t(\"Layout.Unauthorized\")}</Typography>}\r\n </Box>\r\n </Box>\r\n );\r\n};"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { TFunction, i18n } from "i18next";
|
|
2
|
-
import "moment/locale/cs";
|
|
3
|
-
import { LayoutPaletteColorOptions } from "../models/LayoutPaletteColorOptions";
|
|
4
|
-
import { LayoutRoute } from "../models/LayoutRoute";
|
|
5
|
-
import { Snackbar } from "../models/Snackbar";
|
|
6
|
-
import { User } from "../models/User";
|
|
7
|
-
declare module "moment" {
|
|
8
|
-
interface Moment {
|
|
9
|
-
formatDate(): string;
|
|
10
|
-
formatDateTime(): string;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
declare global {
|
|
14
|
-
interface Error {
|
|
15
|
-
innerException?: string;
|
|
16
|
-
status?: number;
|
|
17
|
-
traceIdentifier?: string;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export interface GetRoutesParams {
|
|
21
|
-
user: User;
|
|
22
|
-
t: TFunction<"translation", undefined>;
|
|
23
|
-
i18n: i18n;
|
|
24
|
-
}
|
|
25
|
-
interface LayoutContextInterface {
|
|
26
|
-
user: User;
|
|
27
|
-
t: TFunction<"translation", undefined>;
|
|
28
|
-
i18n: i18n;
|
|
29
|
-
snackbar: (snackbar: Snackbar) => void;
|
|
30
|
-
notification: (notification: Snackbar) => void;
|
|
31
|
-
}
|
|
32
|
-
export declare const LayoutContext: import("react").Context<LayoutContextInterface>;
|
|
33
|
-
interface LayoutProviderProps {
|
|
34
|
-
getRoutes: (params: GetRoutesParams) => LayoutRoute[];
|
|
35
|
-
appVersion: string;
|
|
36
|
-
colors: LayoutPaletteColorOptions;
|
|
37
|
-
}
|
|
38
|
-
export declare const LayoutProvider: React.FC<LayoutProviderProps>;
|
|
39
|
-
export declare const useLayout: () => LayoutContextInterface;
|
|
40
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { MsalProvider } from "@azure/msal-react";
|
|
3
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
-
import i18next from "i18next";
|
|
5
|
-
import LanguageDetector from "i18next-browser-languagedetector";
|
|
6
|
-
import I18NextHttpBackend from "i18next-http-backend";
|
|
7
|
-
import moment from "moment";
|
|
8
|
-
import "moment/locale/cs";
|
|
9
|
-
import { createContext, useContext, useState } from "react";
|
|
10
|
-
import { initReactI18next, useTranslation } from "react-i18next";
|
|
11
|
-
import { Outlet, RouterProvider, createBrowserRouter } from "react-router-dom";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
import { zodI18nMap } from "zod-i18n-map";
|
|
14
|
-
import zodCsTranslations from "zod-i18n-map/locales/cs/zod.json";
|
|
15
|
-
import zodEnTranslations from "zod-i18n-map/locales/en/zod.json";
|
|
16
|
-
import { Layout } from "../components/Layout";
|
|
17
|
-
import { ErrorPage } from "../components/layout/ErrorPage";
|
|
18
|
-
import { LayoutSnackbar } from "../components/layout/LayoutSnackbar";
|
|
19
|
-
import { useSnackbar } from "../hooks/UseSnackbar";
|
|
20
|
-
import { pca } from "../utils/Auth";
|
|
21
|
-
import { UserProvider } from "./UserContext";
|
|
22
|
-
const queryClient = new QueryClient();
|
|
23
|
-
i18next
|
|
24
|
-
.use(initReactI18next)
|
|
25
|
-
.use(LanguageDetector)
|
|
26
|
-
.use(I18NextHttpBackend)
|
|
27
|
-
.init({ fallbackLng: "en" });
|
|
28
|
-
i18next.addResourceBundle("en", "zod", zodEnTranslations);
|
|
29
|
-
i18next.addResourceBundle("cs", "zod", zodCsTranslations);
|
|
30
|
-
z.setErrorMap(zodI18nMap);
|
|
31
|
-
moment.fn.formatDate = function () {
|
|
32
|
-
if (!this.isValid())
|
|
33
|
-
return "";
|
|
34
|
-
return this.format("YYYY-MM-DD");
|
|
35
|
-
};
|
|
36
|
-
moment.fn.formatDateTime = function () {
|
|
37
|
-
if (!this.isValid())
|
|
38
|
-
return "";
|
|
39
|
-
return this.format("YYYY-MM-DD HH:mm");
|
|
40
|
-
};
|
|
41
|
-
export const LayoutContext = createContext({});
|
|
42
|
-
export const LayoutProvider = ({ getRoutes, appVersion, colors }) => {
|
|
43
|
-
const { t, i18n } = useTranslation();
|
|
44
|
-
const [user, setUser] = useState({});
|
|
45
|
-
const { snackbar, setSnackbar, displaySnackbar, notification, notifications, setNotifications } = useSnackbar();
|
|
46
|
-
if (moment.locale() !== i18n.resolvedLanguage) {
|
|
47
|
-
moment.locale(i18n.resolvedLanguage);
|
|
48
|
-
}
|
|
49
|
-
const routes = getRoutes({ user, i18n, t });
|
|
50
|
-
const router = createBrowserRouter([
|
|
51
|
-
{
|
|
52
|
-
element: _jsx(MsalProvider, { instance: pca, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(UserProvider, { setUser: setUser, children: _jsx(LayoutContext.Provider, { value: { user, t, i18n, snackbar: displaySnackbar, notification }, children: _jsxs(Layout, { routes: routes, appVersion: appVersion, colors: colors, user: user, notifications: notifications, setNotifications: setNotifications, children: [_jsx(Outlet, {}), _jsx(LayoutSnackbar, { snackbar: snackbar, setSnackbar: setSnackbar })] }) }) }) }) }),
|
|
53
|
-
children: routes,
|
|
54
|
-
errorElement: _jsx(ErrorPage, {})
|
|
55
|
-
},
|
|
56
|
-
]);
|
|
57
|
-
return _jsx(RouterProvider, { router: router });
|
|
58
|
-
};
|
|
59
|
-
export const useLayout = () => useContext(LayoutContext);
|
|
60
|
-
//# sourceMappingURL=LayoutContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutContext.js","sourceRoot":"","sources":["../../../src/contexts/LayoutContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,OAA4B,MAAM,SAAS,CAAC;AACnD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,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ACrF,MAAC,MAAM,IACH,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,aAElC,KAAC,MAAM,KAAG,EACV,KAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,IAC3D,GACY,GACd,GACG,GACX;YACnB,QAAQ,EAAE,MAAM;YAChB,YAAY,EAAE,KAAC,SAAS,KAAG;SAC9B;KACJ,CAAC,CAAC;IAEH,OAAO,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,GAAI,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import { MsalProvider } from \"@azure/msal-react\";\r\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\r\nimport i18next, { TFunction, i18n } from \"i18next\";\r\nimport LanguageDetector from \"i18next-browser-languagedetector\";\r\nimport I18NextHttpBackend from \"i18next-http-backend\";\r\nimport moment from \"moment\";\r\nimport \"moment/locale/cs\";\r\nimport { createContext, useContext, useState } from \"react\";\r\nimport { initReactI18next, useTranslation } from \"react-i18next\";\r\nimport { Outlet, RouterProvider, createBrowserRouter } from \"react-router-dom\";\r\nimport { z } from \"zod\";\r\nimport { zodI18nMap } from \"zod-i18n-map\";\r\nimport zodCsTranslations from \"zod-i18n-map/locales/cs/zod.json\";\r\nimport zodEnTranslations from \"zod-i18n-map/locales/en/zod.json\";\r\nimport { Layout } from \"../components/Layout\";\r\nimport { ErrorPage } from \"../components/layout/ErrorPage\";\r\nimport { LayoutSnackbar } from \"../components/layout/LayoutSnackbar\";\r\nimport { useSnackbar } from \"../hooks/UseSnackbar\";\r\nimport { LayoutPaletteColorOptions } from \"../models/LayoutPaletteColorOptions\";\r\nimport { LayoutRoute } from \"../models/LayoutRoute\";\r\nimport { Snackbar } from \"../models/Snackbar\";\r\nimport { User } from \"../models/User\";\r\nimport { pca } from \"../utils/Auth\";\r\nimport { UserProvider } from \"./UserContext\";\r\n\r\nconst queryClient = new QueryClient();\r\n\r\ni18next\r\n .use(initReactI18next)\r\n .use(LanguageDetector)\r\n .use(I18NextHttpBackend)\r\n .init({ fallbackLng: \"en\" });\r\n\r\ni18next.addResourceBundle(\"en\", \"zod\", zodEnTranslations);\r\ni18next.addResourceBundle(\"cs\", \"zod\", zodCsTranslations);\r\n\r\nz.setErrorMap(zodI18nMap);\r\n\r\ndeclare module \"moment\" {\r\n interface Moment {\r\n formatDate(): string;\r\n formatDateTime(): string;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface Error {\r\n innerException?: string;\r\n status?: number;\r\n traceIdentifier?: string;\r\n }\r\n}\r\n\r\nmoment.fn.formatDate = function (): string {\r\n if (!this.isValid()) return \"\";\r\n return this.format(\"YYYY-MM-DD\");\r\n};\r\n\r\nmoment.fn.formatDateTime = function (): string {\r\n if (!this.isValid()) return \"\";\r\n return this.format(\"YYYY-MM-DD HH:mm\");\r\n};\r\n\r\nexport interface GetRoutesParams {\r\n user: User;\r\n t: TFunction<\"translation\", undefined>;\r\n i18n: i18n;\r\n}\r\n\r\ninterface LayoutContextInterface {\r\n user: User;\r\n t: TFunction<\"translation\", undefined>;\r\n i18n: i18n;\r\n snackbar: (snackbar: Snackbar) => void;\r\n notification: (notification: Snackbar) => void;\r\n}\r\n\r\nexport const LayoutContext = createContext({} as LayoutContextInterface);\r\n\r\ninterface LayoutProviderProps {\r\n getRoutes: (params: GetRoutesParams) => LayoutRoute[];\r\n appVersion: string;\r\n colors: LayoutPaletteColorOptions;\r\n}\r\n\r\nexport const LayoutProvider: React.FC<LayoutProviderProps> = ({ getRoutes, appVersion, colors }) => {\r\n const { t, i18n } = useTranslation();\r\n const [user, setUser] = useState<User>({} as User);\r\n const { snackbar, setSnackbar, displaySnackbar, notification, notifications, setNotifications } = useSnackbar();\r\n\r\n if (moment.locale() !== i18n.resolvedLanguage) {\r\n moment.locale(i18n.resolvedLanguage);\r\n }\r\n\r\n const routes: LayoutRoute[] = getRoutes({ user, i18n, t });\r\n\r\n const router = createBrowserRouter([\r\n {\r\n element:\r\n <MsalProvider instance={pca}>\r\n <QueryClientProvider client={queryClient}>\r\n <UserProvider setUser={setUser}>\r\n <LayoutContext.Provider value={{ user, t, i18n, snackbar: displaySnackbar, notification }}>\r\n <Layout\r\n routes={routes}\r\n appVersion={appVersion}\r\n colors={colors}\r\n user={user}\r\n notifications={notifications}\r\n setNotifications={setNotifications}\r\n >\r\n <Outlet />\r\n <LayoutSnackbar snackbar={snackbar} setSnackbar={setSnackbar} />\r\n </Layout>\r\n </LayoutContext.Provider>\r\n </UserProvider>\r\n </QueryClientProvider>\r\n </MsalProvider>,\r\n children: routes,\r\n errorElement: <ErrorPage />\r\n },\r\n ]);\r\n\r\n return <RouterProvider router={router} />;\r\n};\r\n\r\nexport const useLayout = () => useContext(LayoutContext);"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { User } from "../models/User";
|
|
3
|
-
export declare const USER_DATA_FETCHED_EVENT = "userDataFetched";
|
|
4
|
-
export interface UserDataFetchedEvent {
|
|
5
|
-
user: Partial<User>;
|
|
6
|
-
}
|
|
7
|
-
export interface MicrosoftIdTokenPayload {
|
|
8
|
-
sub: string;
|
|
9
|
-
name: string;
|
|
10
|
-
mail: string;
|
|
11
|
-
department?: string;
|
|
12
|
-
employeeId?: string;
|
|
13
|
-
groups?: Array<string>;
|
|
14
|
-
companyName?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare function decodeJwt<T>(token: string): T;
|
|
17
|
-
export interface UserProviderProps {
|
|
18
|
-
setUser: Dispatch<SetStateAction<User>>;
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
}
|
|
21
|
-
export declare const UserProvider: ({ children, setUser }: UserProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export interface UserContextValue {
|
|
23
|
-
}
|
|
24
|
-
export declare const UserContext: import("react").Context<null>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { EventType } from "@azure/msal-browser";
|
|
3
|
-
import { createContext, useEffect, useCallback } from "react";
|
|
4
|
-
import { pca } from "../utils/Auth";
|
|
5
|
-
export const USER_DATA_FETCHED_EVENT = "userDataFetched";
|
|
6
|
-
export function decodeJwt(token) {
|
|
7
|
-
const base64Payload = token.split(".")[1];
|
|
8
|
-
const base64 = base64Payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
9
|
-
const padding = base64.length % 4 === 0 ? "" : "=".repeat(4 - (base64.length % 4));
|
|
10
|
-
const payload = decodeURIComponent(atob(base64 + padding)
|
|
11
|
-
.split("")
|
|
12
|
-
.map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
|
|
13
|
-
.join(""));
|
|
14
|
-
return JSON.parse(payload);
|
|
15
|
-
}
|
|
16
|
-
export const UserProvider = ({ children, setUser }) => {
|
|
17
|
-
const processAccount = useCallback(() => {
|
|
18
|
-
var _a;
|
|
19
|
-
const account = pca.getActiveAccount();
|
|
20
|
-
if (account === null || account === void 0 ? void 0 : account.idToken) {
|
|
21
|
-
const idTokenPayload = decodeJwt(account.idToken);
|
|
22
|
-
const userData = {
|
|
23
|
-
id: idTokenPayload.sub,
|
|
24
|
-
name: idTokenPayload.name.split("/")[0],
|
|
25
|
-
email: idTokenPayload.mail,
|
|
26
|
-
groups: (_a = idTokenPayload.groups) !== null && _a !== void 0 ? _a : [],
|
|
27
|
-
department: idTokenPayload.department || "",
|
|
28
|
-
employeeId: idTokenPayload.employeeId || "",
|
|
29
|
-
companyName: idTokenPayload.companyName,
|
|
30
|
-
};
|
|
31
|
-
setUser(userData);
|
|
32
|
-
window.dispatchEvent(new CustomEvent(USER_DATA_FETCHED_EVENT, { detail: { user: userData } }));
|
|
33
|
-
}
|
|
34
|
-
}, [setUser]);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
processAccount();
|
|
37
|
-
const callbackId = pca.addEventCallback((event) => {
|
|
38
|
-
if (event.eventType === EventType.ACQUIRE_TOKEN_SUCCESS) {
|
|
39
|
-
const payload = event.payload;
|
|
40
|
-
if (payload.account) {
|
|
41
|
-
pca.setActiveAccount(payload.account);
|
|
42
|
-
processAccount();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return () => {
|
|
47
|
-
if (callbackId) {
|
|
48
|
-
pca.removeEventCallback(callbackId);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}, [processAccount]);
|
|
52
|
-
return (_jsx(UserContext.Provider, { value: null, children: children }));
|
|
53
|
-
};
|
|
54
|
-
export const UserContext = createContext(null);
|
|
55
|
-
//# sourceMappingURL=UserContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserContext.js","sourceRoot":"","sources":["../../../src/contexts/UserContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAsC,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,aAAa,EAA4B,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAgBzD,MAAM,UAAU,SAAS,CAAI,KAAa;IACtC,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC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AAc,CAAC,WAAW;aAC1C,CAAC;YACF,OAAO,CAAC,QAAQ,CAAC,CAAC;YAClB,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAuB,uBAAuB,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QACzH,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,SAAS,CAAC,GAAG,EAAE;QACX,cAAc,EAAE,CAAC;QAEjB,MAAM,UAAU,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAC,KAAmB,EAAE,EAAE;YAC5D,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,qBAAqB,EAAE,CAAC;gBACtD,MAAM,OAAO,GAAG,KAAK,CAAC,OAA+B,CAAC;gBACtD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBAClB,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;oBACtC,cAAc,EAAE,CAAC;gBACrB,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACR,IAAI,UAAU,EAAE,CAAC;gBACb,GAAG,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;YACxC,CAAC;QACL,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO,CACH,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAC5B,QAAQ,GACU,CAC1B,CAAC;AACN,CAAC,CAAC;AAIF,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { EventType, EventMessage, AuthenticationResult } from \"@azure/msal-browser\";\r\nimport { createContext, Dispatch, SetStateAction, useEffect, useCallback } from \"react\";\r\nimport { User } from \"../models/User\";\r\nimport { pca } from \"../utils/Auth\";\r\n\r\nexport const USER_DATA_FETCHED_EVENT = \"userDataFetched\";\r\n\r\nexport interface UserDataFetchedEvent {\r\n user: Partial<User>;\r\n}\r\n\r\nexport interface MicrosoftIdTokenPayload {\r\n sub: string;\r\n name: string;\r\n mail: string;\r\n department?: string;\r\n employeeId?: string;\r\n groups?: Array<string>;\r\n companyName?: string;\r\n}\r\n\r\nexport function decodeJwt<T>(token: string): T {\r\n const base64Payload = token.split(\".\")[1];\r\n const base64 = base64Payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\r\n const padding = base64.length % 4 === 0 ? \"\" : \"=\".repeat(4 - (base64.length % 4));\r\n const payload = decodeURIComponent(\r\n atob(base64 + padding)\r\n .split(\"\")\r\n .map((c) => \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2))\r\n .join(\"\")\r\n );\r\n return JSON.parse(payload) as T;\r\n}\r\n\r\nexport interface UserProviderProps {\r\n setUser: Dispatch<SetStateAction<User>>;\r\n children?: React.ReactNode;\r\n}\r\n\r\nexport const UserProvider = ({ children, setUser }: UserProviderProps) => {\r\n const processAccount = useCallback(() => {\r\n const account = pca.getActiveAccount();\r\n if (account?.idToken) {\r\n const idTokenPayload = decodeJwt<MicrosoftIdTokenPayload>(account.idToken);\r\n const userData: User = {\r\n id: idTokenPayload.sub,\r\n name: idTokenPayload.name.split(\"/\")[0],\r\n email: idTokenPayload.mail,\r\n groups: idTokenPayload.groups ?? [],\r\n department: idTokenPayload.department || \"\",\r\n employeeId: idTokenPayload.employeeId || \"\",\r\n companyName: idTokenPayload.companyName,\r\n };\r\n setUser(userData);\r\n window.dispatchEvent(new CustomEvent<UserDataFetchedEvent>(USER_DATA_FETCHED_EVENT, { detail: { user: userData } }));\r\n }\r\n }, [setUser]);\r\n\r\n useEffect(() => {\r\n processAccount();\r\n\r\n const callbackId = pca.addEventCallback((event: EventMessage) => {\r\n if (event.eventType === EventType.ACQUIRE_TOKEN_SUCCESS) {\r\n const payload = event.payload as AuthenticationResult;\r\n if (payload.account) {\r\n pca.setActiveAccount(payload.account);\r\n processAccount();\r\n }\r\n }\r\n });\r\n\r\n return () => {\r\n if (callbackId) {\r\n pca.removeEventCallback(callbackId);\r\n }\r\n };\r\n }, [processAccount]);\r\n\r\n return (\r\n <UserContext.Provider value={null}>\r\n {children}\r\n </UserContext.Provider>\r\n );\r\n};\r\n\r\nexport interface UserContextValue { }\r\n\r\nexport const UserContext = createContext(null);"]}
|