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,127 +0,0 @@
|
|
|
1
|
-
import { MsalProvider } from "@azure/msal-react";
|
|
2
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import i18next, { TFunction, i18n } from "i18next";
|
|
4
|
-
import LanguageDetector from "i18next-browser-languagedetector";
|
|
5
|
-
import I18NextHttpBackend from "i18next-http-backend";
|
|
6
|
-
import moment from "moment";
|
|
7
|
-
import "moment/locale/cs";
|
|
8
|
-
import { createContext, useContext, useState } from "react";
|
|
9
|
-
import { initReactI18next, useTranslation } from "react-i18next";
|
|
10
|
-
import { Outlet, RouterProvider, createBrowserRouter } from "react-router-dom";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
import { zodI18nMap } from "zod-i18n-map";
|
|
13
|
-
import zodCsTranslations from "zod-i18n-map/locales/cs/zod.json";
|
|
14
|
-
import zodEnTranslations from "zod-i18n-map/locales/en/zod.json";
|
|
15
|
-
import { Layout } from "../components/Layout";
|
|
16
|
-
import { ErrorPage } from "../components/layout/ErrorPage";
|
|
17
|
-
import { LayoutSnackbar } from "../components/layout/LayoutSnackbar";
|
|
18
|
-
import { useSnackbar } from "../hooks/UseSnackbar";
|
|
19
|
-
import { LayoutPaletteColorOptions } from "../models/LayoutPaletteColorOptions";
|
|
20
|
-
import { LayoutRoute } from "../models/LayoutRoute";
|
|
21
|
-
import { Snackbar } from "../models/Snackbar";
|
|
22
|
-
import { User } from "../models/User";
|
|
23
|
-
import { pca } from "../utils/Auth";
|
|
24
|
-
import { UserProvider } from "./UserContext";
|
|
25
|
-
|
|
26
|
-
const queryClient = new QueryClient();
|
|
27
|
-
|
|
28
|
-
i18next
|
|
29
|
-
.use(initReactI18next)
|
|
30
|
-
.use(LanguageDetector)
|
|
31
|
-
.use(I18NextHttpBackend)
|
|
32
|
-
.init({ fallbackLng: "en" });
|
|
33
|
-
|
|
34
|
-
i18next.addResourceBundle("en", "zod", zodEnTranslations);
|
|
35
|
-
i18next.addResourceBundle("cs", "zod", zodCsTranslations);
|
|
36
|
-
|
|
37
|
-
z.setErrorMap(zodI18nMap);
|
|
38
|
-
|
|
39
|
-
declare module "moment" {
|
|
40
|
-
interface Moment {
|
|
41
|
-
formatDate(): string;
|
|
42
|
-
formatDateTime(): string;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare global {
|
|
47
|
-
interface Error {
|
|
48
|
-
innerException?: string;
|
|
49
|
-
status?: number;
|
|
50
|
-
traceIdentifier?: string;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
moment.fn.formatDate = function (): string {
|
|
55
|
-
if (!this.isValid()) return "";
|
|
56
|
-
return this.format("YYYY-MM-DD");
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
moment.fn.formatDateTime = function (): string {
|
|
60
|
-
if (!this.isValid()) return "";
|
|
61
|
-
return this.format("YYYY-MM-DD HH:mm");
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export interface GetRoutesParams {
|
|
65
|
-
user: User;
|
|
66
|
-
t: TFunction<"translation", undefined>;
|
|
67
|
-
i18n: i18n;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
interface LayoutContextInterface {
|
|
71
|
-
user: User;
|
|
72
|
-
t: TFunction<"translation", undefined>;
|
|
73
|
-
i18n: i18n;
|
|
74
|
-
snackbar: (snackbar: Snackbar) => void;
|
|
75
|
-
notification: (notification: Snackbar) => void;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const LayoutContext = createContext({} as LayoutContextInterface);
|
|
79
|
-
|
|
80
|
-
interface LayoutProviderProps {
|
|
81
|
-
getRoutes: (params: GetRoutesParams) => LayoutRoute[];
|
|
82
|
-
appVersion: string;
|
|
83
|
-
colors: LayoutPaletteColorOptions;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const LayoutProvider: React.FC<LayoutProviderProps> = ({ getRoutes, appVersion, colors }) => {
|
|
87
|
-
const { t, i18n } = useTranslation();
|
|
88
|
-
const [user, setUser] = useState<User>({} as User);
|
|
89
|
-
const { snackbar, setSnackbar, displaySnackbar, notification, notifications, setNotifications } = useSnackbar();
|
|
90
|
-
|
|
91
|
-
if (moment.locale() !== i18n.resolvedLanguage) {
|
|
92
|
-
moment.locale(i18n.resolvedLanguage);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const routes: LayoutRoute[] = getRoutes({ user, i18n, t });
|
|
96
|
-
|
|
97
|
-
const router = createBrowserRouter([
|
|
98
|
-
{
|
|
99
|
-
element:
|
|
100
|
-
<MsalProvider instance={pca}>
|
|
101
|
-
<QueryClientProvider client={queryClient}>
|
|
102
|
-
<UserProvider setUser={setUser}>
|
|
103
|
-
<LayoutContext.Provider value={{ user, t, i18n, snackbar: displaySnackbar, notification }}>
|
|
104
|
-
<Layout
|
|
105
|
-
routes={routes}
|
|
106
|
-
appVersion={appVersion}
|
|
107
|
-
colors={colors}
|
|
108
|
-
user={user}
|
|
109
|
-
notifications={notifications}
|
|
110
|
-
setNotifications={setNotifications}
|
|
111
|
-
>
|
|
112
|
-
<Outlet />
|
|
113
|
-
<LayoutSnackbar snackbar={snackbar} setSnackbar={setSnackbar} />
|
|
114
|
-
</Layout>
|
|
115
|
-
</LayoutContext.Provider>
|
|
116
|
-
</UserProvider>
|
|
117
|
-
</QueryClientProvider>
|
|
118
|
-
</MsalProvider>,
|
|
119
|
-
children: routes,
|
|
120
|
-
errorElement: <ErrorPage />
|
|
121
|
-
},
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
|
-
return <RouterProvider router={router} />;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const useLayout = () => useContext(LayoutContext);
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { EventType, EventMessage, AuthenticationResult } from "@azure/msal-browser";
|
|
2
|
-
import { createContext, Dispatch, SetStateAction, useEffect, useCallback } from "react";
|
|
3
|
-
import { User } from "../models/User";
|
|
4
|
-
import { pca } from "../utils/Auth";
|
|
5
|
-
|
|
6
|
-
export const USER_DATA_FETCHED_EVENT = "userDataFetched";
|
|
7
|
-
|
|
8
|
-
export interface UserDataFetchedEvent {
|
|
9
|
-
user: Partial<User>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface MicrosoftIdTokenPayload {
|
|
13
|
-
sub: string;
|
|
14
|
-
name: string;
|
|
15
|
-
mail: string;
|
|
16
|
-
department?: string;
|
|
17
|
-
employeeId?: string;
|
|
18
|
-
groups?: Array<string>;
|
|
19
|
-
companyName?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function decodeJwt<T>(token: string): T {
|
|
23
|
-
const base64Payload = token.split(".")[1];
|
|
24
|
-
const base64 = base64Payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
25
|
-
const padding = base64.length % 4 === 0 ? "" : "=".repeat(4 - (base64.length % 4));
|
|
26
|
-
const payload = decodeURIComponent(
|
|
27
|
-
atob(base64 + padding)
|
|
28
|
-
.split("")
|
|
29
|
-
.map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
|
|
30
|
-
.join("")
|
|
31
|
-
);
|
|
32
|
-
return JSON.parse(payload) as T;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface UserProviderProps {
|
|
36
|
-
setUser: Dispatch<SetStateAction<User>>;
|
|
37
|
-
children?: React.ReactNode;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const UserProvider = ({ children, setUser }: UserProviderProps) => {
|
|
41
|
-
const processAccount = useCallback(() => {
|
|
42
|
-
const account = pca.getActiveAccount();
|
|
43
|
-
if (account?.idToken) {
|
|
44
|
-
const idTokenPayload = decodeJwt<MicrosoftIdTokenPayload>(account.idToken);
|
|
45
|
-
const userData: User = {
|
|
46
|
-
id: idTokenPayload.sub,
|
|
47
|
-
name: idTokenPayload.name.split("/")[0],
|
|
48
|
-
email: idTokenPayload.mail,
|
|
49
|
-
groups: idTokenPayload.groups ?? [],
|
|
50
|
-
department: idTokenPayload.department || "",
|
|
51
|
-
employeeId: idTokenPayload.employeeId || "",
|
|
52
|
-
companyName: idTokenPayload.companyName,
|
|
53
|
-
};
|
|
54
|
-
setUser(userData);
|
|
55
|
-
window.dispatchEvent(new CustomEvent<UserDataFetchedEvent>(USER_DATA_FETCHED_EVENT, { detail: { user: userData } }));
|
|
56
|
-
}
|
|
57
|
-
}, [setUser]);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
processAccount();
|
|
61
|
-
|
|
62
|
-
const callbackId = pca.addEventCallback((event: EventMessage) => {
|
|
63
|
-
if (event.eventType === EventType.ACQUIRE_TOKEN_SUCCESS) {
|
|
64
|
-
const payload = event.payload as AuthenticationResult;
|
|
65
|
-
if (payload.account) {
|
|
66
|
-
pca.setActiveAccount(payload.account);
|
|
67
|
-
processAccount();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return () => {
|
|
73
|
-
if (callbackId) {
|
|
74
|
-
pca.removeEventCallback(callbackId);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}, [processAccount]);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<UserContext.Provider value={null}>
|
|
81
|
-
{children}
|
|
82
|
-
</UserContext.Provider>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export interface UserContextValue { }
|
|
87
|
-
|
|
88
|
-
export const UserContext = createContext(null);
|
package/src/hooks/FormHooks.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createFormHook, createFormHookContexts } from "@tanstack/react-form";
|
|
2
|
-
import { FormAutocomplete as Autocomplete } from "../components/form/FormAutocomplete";
|
|
3
|
-
import { FormCheckbox as Checkbox } from "../components/form/FormCheckbox";
|
|
4
|
-
import { FormDatePicker as DatePicker } from "../components/form/FormDatePicker";
|
|
5
|
-
import { FormDateTimePicker as DateTimePicker } from "../components/form/FormDateTimePicker";
|
|
6
|
-
import { FormNumberField as NumberField } from "../components/form/FormNumberField";
|
|
7
|
-
import { FormRadioGroup as RadioGroup } from "../components/form/FormRadioGroup";
|
|
8
|
-
import { FormSlider as Slider } from "../components/form/FormSlider";
|
|
9
|
-
import { FormSubmitButton as SubmitButton } from "../components/form/FormSubmitButton";
|
|
10
|
-
import { FormSwitch as Switch } from "../components/form/FormSwitch";
|
|
11
|
-
import { FormTextField as TextField } from "../components/form/FormTextField";
|
|
12
|
-
|
|
13
|
-
export const { fieldContext, useFieldContext, formContext, useFormContext } = createFormHookContexts();
|
|
14
|
-
|
|
15
|
-
export const { useAppForm: useLayoutForm, withForm: withLayoutForm } =
|
|
16
|
-
createFormHook({
|
|
17
|
-
fieldComponents: {
|
|
18
|
-
TextField,
|
|
19
|
-
NumberField,
|
|
20
|
-
Autocomplete,
|
|
21
|
-
Checkbox,
|
|
22
|
-
Switch,
|
|
23
|
-
RadioGroup,
|
|
24
|
-
Slider,
|
|
25
|
-
DatePicker,
|
|
26
|
-
DateTimePicker,
|
|
27
|
-
},
|
|
28
|
-
formComponents: {
|
|
29
|
-
SubmitButton,
|
|
30
|
-
},
|
|
31
|
-
fieldContext,
|
|
32
|
-
formContext,
|
|
33
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import moment from "moment";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import useLocalStorageState from "use-local-storage-state";
|
|
4
|
-
import { Snackbar } from "../models/Snackbar";
|
|
5
|
-
import Notification from "../models/Notification";
|
|
6
|
-
|
|
7
|
-
export const useSnackbar = () => {
|
|
8
|
-
const [snackbar, setSnackbar] = useState<Snackbar>({} as Snackbar);
|
|
9
|
-
const [notifications, setNotifications] = useLocalStorageState<Notification[]>("notifications");
|
|
10
|
-
|
|
11
|
-
const displaySnackbar = (newSnackbar: Snackbar) => {
|
|
12
|
-
setSnackbar(newSnackbar);
|
|
13
|
-
notification(newSnackbar);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const notification = (notification: Snackbar) => {
|
|
17
|
-
setNotifications(oldNotifications => {
|
|
18
|
-
let newNotifications: Notification[] = [];
|
|
19
|
-
if (oldNotifications) {
|
|
20
|
-
newNotifications = oldNotifications;
|
|
21
|
-
}
|
|
22
|
-
newNotifications.unshift({ ...notification, dateTime: moment().format("YYYY-MM-DD HH:mm:ss.SSS"), isRead: false });
|
|
23
|
-
return newNotifications.slice(0, 10);
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return { snackbar, setSnackbar, displaySnackbar, notification, notifications, setNotifications };
|
|
28
|
-
};
|
package/src/hooks/UseUser.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { queryOptions } from "@tanstack/react-query";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { getAccessToken } from "../utils/Auth";
|
|
4
|
-
|
|
5
|
-
const QUERY_KEY = "user";
|
|
6
|
-
|
|
7
|
-
const api = axios.create({
|
|
8
|
-
baseURL: "https://graph.microsoft.com/v1.0/",
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
api.interceptors.request.use(async (config) => {
|
|
12
|
-
config.headers.Authorization = `Bearer ${await getAccessToken(["User.Read"])}`;
|
|
13
|
-
return config;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const graphQueries = {
|
|
17
|
-
sessionUserPhoto: () =>
|
|
18
|
-
queryOptions({
|
|
19
|
-
queryKey: [QUERY_KEY, "me", "photo"],
|
|
20
|
-
queryFn: async () => await api.request<Blob>({
|
|
21
|
-
method: "GET",
|
|
22
|
-
url: "/me/photo/$value",
|
|
23
|
-
responseType: "blob",
|
|
24
|
-
}).then(response => response.data),
|
|
25
|
-
staleTime: Infinity,
|
|
26
|
-
gcTime: Infinity,
|
|
27
|
-
select: data => URL.createObjectURL(data),
|
|
28
|
-
}),
|
|
29
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { TypographyWithIcon } from './components/layout/TypographyWithIcon';
|
|
2
|
-
export { LayoutDialog } from './components/layout/LayoutDialog';
|
|
3
|
-
|
|
4
|
-
export { TableContainer } from './components/dataGrid/TableContainer';
|
|
5
|
-
export { GridToolbar, GridToolbarProps } from './components/dataGrid/GridToolbar';
|
|
6
|
-
export { ChipInputCell } from './components/dataGrid/ChipInputCell';
|
|
7
|
-
export { EditableColumnHeader } from './components/dataGrid/EditableColumnHeader';
|
|
8
|
-
|
|
9
|
-
export { LayoutContext, LayoutProvider, useLayout, GetRoutesParams } from './contexts/LayoutContext';
|
|
10
|
-
|
|
11
|
-
export { useFieldContext, useFormContext, useLayoutForm, withLayoutForm } from './hooks/FormHooks';
|
|
12
|
-
|
|
13
|
-
export { User } from './models/User';
|
|
14
|
-
export { Error } from './models/Error';
|
|
15
|
-
export { PeoplesoftEmployee } from './models/PeoplesoftEmployee';
|
|
16
|
-
export { PeoplesoftDepartment } from './models/PeoplesoftDepartment';
|
|
17
|
-
export { LayoutPaletteColorOptions } from './models/LayoutPaletteColorOptions';
|
|
18
|
-
export { LayoutRoute } from './models/LayoutRoute';
|
|
19
|
-
|
|
20
|
-
export * from './utils/Helpers';
|
|
21
|
-
export * from './utils/Fetches';
|
|
22
|
-
export { getAccessToken, hasRole } from './utils/Auth';
|
|
23
|
-
|
|
24
|
-
export { default as useLocalStorageState } from 'use-local-storage-state';
|
|
25
|
-
|
|
26
|
-
export { pca } from "./utils/Auth";
|
|
27
|
-
export { AuthenticationResult, EventMessage, EventType } from "@azure/msal-browser";
|
package/src/models/Error.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import { NonIndexRouteObject } from "react-router-dom";
|
|
3
|
-
|
|
4
|
-
interface CustomNonIndexRouteObject extends NonIndexRouteObject {
|
|
5
|
-
title?: string;
|
|
6
|
-
icon?: ReactNode;
|
|
7
|
-
pageTitle?: string;
|
|
8
|
-
showInMenu?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
divider?: boolean;
|
|
11
|
-
authenticated?: boolean;
|
|
12
|
-
children?: LayoutRoute[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type LayoutRoute = CustomNonIndexRouteObject;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PeoplesoftEmployee } from "./PeoplesoftEmployee";
|
|
2
|
-
|
|
3
|
-
export interface PeoplesoftDepartment {
|
|
4
|
-
departmentId: string;
|
|
5
|
-
description: string;
|
|
6
|
-
managerId: string;
|
|
7
|
-
managerRecordNumber: string;
|
|
8
|
-
treeLevel: number;
|
|
9
|
-
upperDepartmentId: string;
|
|
10
|
-
companyCode: string;
|
|
11
|
-
location: string;
|
|
12
|
-
salLocation: string;
|
|
13
|
-
plantId: string;
|
|
14
|
-
manager: PeoplesoftEmployee;
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { EmployeeCategoryGroup } from "./types/EmployeeCategoryGroup";
|
|
2
|
-
import { EmployeeStatus } from "./types/EmployeeStatus";
|
|
3
|
-
|
|
4
|
-
export interface PeoplesoftEmployee {
|
|
5
|
-
badgeId: string;
|
|
6
|
-
category: string;
|
|
7
|
-
categoryGroup: EmployeeCategoryGroup;
|
|
8
|
-
companyCode: string;
|
|
9
|
-
contactPhone: string;
|
|
10
|
-
departmentId: string;
|
|
11
|
-
departmentDescription: string;
|
|
12
|
-
emailString: string;
|
|
13
|
-
employeeId: string;
|
|
14
|
-
extensionNumber: string;
|
|
15
|
-
firstName: string;
|
|
16
|
-
gender: string;
|
|
17
|
-
hiredDate: string;
|
|
18
|
-
lastName: string;
|
|
19
|
-
managerId: string;
|
|
20
|
-
middleName: string;
|
|
21
|
-
name: string;
|
|
22
|
-
nameTitleCase: string;
|
|
23
|
-
nfcSn: string;
|
|
24
|
-
plantId: string;
|
|
25
|
-
position: string;
|
|
26
|
-
previousEmployeeIds?: string;
|
|
27
|
-
reHiredDate?: string;
|
|
28
|
-
recordNumber: number;
|
|
29
|
-
status: EmployeeStatus;
|
|
30
|
-
supervisorId: string;
|
|
31
|
-
terminationDate?: string;
|
|
32
|
-
terminationFutureDate?: string;
|
|
33
|
-
type: string;
|
|
34
|
-
upperDepartmentId: string;
|
|
35
|
-
}
|
package/src/models/Snackbar.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AlertColor } from "@mui/material";
|
|
2
|
-
|
|
3
|
-
export interface Snackbar {
|
|
4
|
-
/** The message to be displayed. */
|
|
5
|
-
title: string;
|
|
6
|
-
/** The severity level determining its color and icon. This can be 'error', 'warning', 'info', or 'success'. This property is optional. */
|
|
7
|
-
severity?: AlertColor;
|
|
8
|
-
/** Additional description to be displayed. This property is optional. */
|
|
9
|
-
description?: string;
|
|
10
|
-
/**
|
|
11
|
-
* The duration in milliseconds before the Snackbar automatically hides.
|
|
12
|
-
* If not specified, the duration defaults are: 15000ms for 'error', 10000ms for 'warning',
|
|
13
|
-
* and 5000ms for other severities. This property is optional.
|
|
14
|
-
*/
|
|
15
|
-
duration?: number
|
|
16
|
-
}
|
package/src/models/User.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
|
|
3
|
-
export const UserSchema = z.object({
|
|
4
|
-
id: z.string(),
|
|
5
|
-
name: z.string(),
|
|
6
|
-
email: z.string().email(),
|
|
7
|
-
department: z.string(),
|
|
8
|
-
employeeId: z.string(),
|
|
9
|
-
groups: z.array(z.string()),
|
|
10
|
-
companyName: z.string().optional(),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export type User = z.infer<typeof UserSchema>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type EmployeeCategoryGroup = "IDL" | "DL" | "FI"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type EmployeeStatus = "Active" | "Terminated" | "LeaveOfAbsence"
|
package/src/utils/Auth.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { Configuration, NavigationOptions } from "@azure/msal-browser";
|
|
2
|
-
import { NavigationClient, PublicClientApplication } from "@azure/msal-browser";
|
|
3
|
-
import { NavigateFunction } from "react-router-dom";
|
|
4
|
-
import { User } from "../models/User";
|
|
5
|
-
|
|
6
|
-
const msalConfig: Configuration = {
|
|
7
|
-
auth: {
|
|
8
|
-
clientId: process.env.REACT_APP_MICROSOFT_CLIENT_ID!,
|
|
9
|
-
authority: `https://login.microsoftonline.com/${process.env.REACT_APP_MICROSOFT_TENANT_ID!}`,
|
|
10
|
-
redirectUri: window.location.origin + "/",
|
|
11
|
-
navigateToLoginRequestUrl: false,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const pca = new PublicClientApplication(msalConfig);
|
|
16
|
-
|
|
17
|
-
export class CustomNavigationClient extends NavigationClient {
|
|
18
|
-
private navigate: NavigateFunction;
|
|
19
|
-
|
|
20
|
-
constructor(navigate: NavigateFunction) {
|
|
21
|
-
super();
|
|
22
|
-
this.navigate = navigate;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async navigateInternal(url: string, options: NavigationOptions) {
|
|
26
|
-
const relativePath = url.replace(window.location.origin, "");
|
|
27
|
-
if (options.noHistory) {
|
|
28
|
-
this.navigate(relativePath, { replace: true });
|
|
29
|
-
} else {
|
|
30
|
-
this.navigate(relativePath);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const getAccount = () => {
|
|
38
|
-
const account = pca.getActiveAccount();
|
|
39
|
-
if (!account) throw new Error("No active account. User not signed in.");
|
|
40
|
-
return account;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const getAccessToken = async (scopes: string[]): Promise<string> => {
|
|
44
|
-
const account = getAccount();
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
const { accessToken } = await pca.acquireTokenSilent({ scopes, account });
|
|
48
|
-
return accessToken;
|
|
49
|
-
} catch {
|
|
50
|
-
const { accessToken } = await pca.acquireTokenPopup({ scopes, account });
|
|
51
|
-
return accessToken;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const hasRole = (user: User, roles: string[]): boolean => {
|
|
56
|
-
if (!user.groups || user.groups.length === 0) return false;
|
|
57
|
-
return roles.some(role => user.groups.includes(role));
|
|
58
|
-
};
|
package/src/utils/Fetches.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { getAccessToken } from "./Auth";
|
|
2
|
-
|
|
3
|
-
export const fetchGet = async (url: string, scopes: string[], signal: AbortSignal | undefined): Promise<any> => {
|
|
4
|
-
const initReq: RequestInit = await getRequestInit("GET", scopes, null, signal);
|
|
5
|
-
|
|
6
|
-
const response: Response = await fetch(url, initReq);
|
|
7
|
-
if (!response.ok)
|
|
8
|
-
throw await response.json();
|
|
9
|
-
|
|
10
|
-
return response.json();
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const fetchFileGet = async (url: string, scopes: string[], signal: AbortSignal | undefined): Promise<Blob> => {
|
|
14
|
-
const initReq: RequestInit = await getRequestInit("GET", scopes, null, signal);
|
|
15
|
-
|
|
16
|
-
const response: Response = await fetch(url, initReq);
|
|
17
|
-
if (!response.ok)
|
|
18
|
-
throw await response.json();
|
|
19
|
-
|
|
20
|
-
return response.blob();
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const fetchPost = async (url: string, scopes: string[], data: unknown): Promise<any> => {
|
|
24
|
-
const initReq: RequestInit = await getRequestInit("POST", scopes, data);
|
|
25
|
-
|
|
26
|
-
const response: Response = await fetch(url, initReq);
|
|
27
|
-
if (!response.ok)
|
|
28
|
-
throw await response.json();
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
return response.json();
|
|
32
|
-
} catch {
|
|
33
|
-
return response;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const fetchPut = async (url: string, scopes: string[], data: unknown): Promise<any> => {
|
|
38
|
-
const initReq: RequestInit = await getRequestInit("PUT", scopes, data);
|
|
39
|
-
|
|
40
|
-
const response: Response = await fetch(url, initReq);
|
|
41
|
-
if (!response.ok)
|
|
42
|
-
throw await response.json();
|
|
43
|
-
|
|
44
|
-
return response;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const fetchDelete = async (url: string, scopes: string[]): Promise<any> => {
|
|
48
|
-
const initReq: RequestInit = await getRequestInit("DELETE", scopes);
|
|
49
|
-
|
|
50
|
-
const response: Response = await fetch(url, initReq);
|
|
51
|
-
if (!response.ok)
|
|
52
|
-
throw await response.json();
|
|
53
|
-
|
|
54
|
-
return response;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const getRequestInit = async (method: string, scopes: string[], data?: unknown, signal?: AbortSignal): Promise<RequestInit> => {
|
|
58
|
-
const request: RequestInit = {
|
|
59
|
-
method: method,
|
|
60
|
-
signal: signal,
|
|
61
|
-
credentials: "include"
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
if (data) {
|
|
65
|
-
if (data instanceof FormData)
|
|
66
|
-
request.body = data;
|
|
67
|
-
else
|
|
68
|
-
request.body = JSON.stringify(data);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (data instanceof FormData)
|
|
72
|
-
request.headers = {
|
|
73
|
-
"Authorization": `Bearer ${await getAccessToken(scopes)}`
|
|
74
|
-
};
|
|
75
|
-
else {
|
|
76
|
-
request.headers = {
|
|
77
|
-
"Content-Type": "application/json",
|
|
78
|
-
"Authorization": `Bearer ${await getAccessToken(scopes)}`
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return request;
|
|
83
|
-
};
|
package/src/utils/FormUtils.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AnyFieldApi } from "@tanstack/react-form";
|
|
2
|
-
|
|
3
|
-
export type FormOmittedProps =
|
|
4
|
-
"name" |
|
|
5
|
-
"value" |
|
|
6
|
-
"onChange" |
|
|
7
|
-
"onBlur" |
|
|
8
|
-
"error" |
|
|
9
|
-
"helperText" |
|
|
10
|
-
"renderInput" |
|
|
11
|
-
"type" |
|
|
12
|
-
"aria-label";
|
|
13
|
-
|
|
14
|
-
export const getFieldStatus = (field: AnyFieldApi) => {
|
|
15
|
-
const { meta } = field.state;
|
|
16
|
-
|
|
17
|
-
const isTouched = meta.isTouched;
|
|
18
|
-
const hasError = !!meta.errors?.length;
|
|
19
|
-
const helperText = meta.errors?.[0]?.message;
|
|
20
|
-
|
|
21
|
-
return { isTouched, hasError, helperText };
|
|
22
|
-
}
|
package/src/utils/Helpers.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { uuidv7 as newGuid } from "uuidv7";
|
|
2
|
-
|
|
3
|
-
type Environment = "qas" | "dev" | "prd" | "localhost";
|
|
4
|
-
|
|
5
|
-
export const environment: Environment = (() => {
|
|
6
|
-
if (window.location.href.includes("localhost")) return "localhost";
|
|
7
|
-
else if (window.location.href.includes("dev")) return "dev";
|
|
8
|
-
else if (window.location.href.includes("qas")) return "qas";
|
|
9
|
-
else return "prd";
|
|
10
|
-
})();
|
|
11
|
-
|
|
12
|
-
export { newGuid };
|
|
13
|
-
|
|
14
|
-
export class Platform {
|
|
15
|
-
static readonly isAndroid = /android/i.test(navigator.userAgent);
|
|
16
|
-
static readonly isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
17
|
-
static readonly isWindows = /windows/i.test(navigator.userAgent);
|
|
18
|
-
static readonly isMacOS = /Macintosh|MacIntel|MacPPC|Mac68K/.test(navigator.userAgent);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const getContrastTextColor = (color: string) => {
|
|
22
|
-
const r = parseInt(color.substring(1, 3), 16);
|
|
23
|
-
const g = parseInt(color.substring(3, 5), 16);
|
|
24
|
-
const b = parseInt(color.substring(5, 7), 16);
|
|
25
|
-
const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
|
26
|
-
return (yiq >= 128) ? "black" : "white";
|
|
27
|
-
};
|