@digitaldefiance/express-suite-react-components 2.9.7 → 2.9.9
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/package.json +6 -5
- package/src/auth/Private.d.ts +6 -0
- package/src/auth/Private.d.ts.map +1 -0
- package/src/auth/Private.js +14 -0
- package/src/auth/PrivateRoute.d.ts +8 -0
- package/src/auth/PrivateRoute.d.ts.map +1 -0
- package/src/auth/PrivateRoute.js +23 -0
- package/src/auth/UnAuth.d.ts +6 -0
- package/src/auth/UnAuth.d.ts.map +1 -0
- package/src/auth/UnAuth.js +14 -0
- package/src/auth/UnAuthRoute.d.ts +8 -0
- package/src/auth/UnAuthRoute.d.ts.map +1 -0
- package/src/auth/UnAuthRoute.js +22 -0
- package/src/auth/{index.ts → index.d.ts} +2 -1
- package/src/auth/index.d.ts.map +1 -0
- package/src/auth/index.js +10 -0
- package/src/components/ApiAccess.d.ts +16 -0
- package/src/components/ApiAccess.d.ts.map +1 -0
- package/src/components/ApiAccess.js +70 -0
- package/src/components/BackupCodeLoginForm.d.ts +43 -0
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
- package/src/components/BackupCodeLoginForm.js +106 -0
- package/src/components/BackupCodesForm.d.ts +26 -0
- package/src/components/BackupCodesForm.d.ts.map +1 -0
- package/src/components/BackupCodesForm.js +108 -0
- package/src/components/ChangePasswordForm.d.ts +26 -0
- package/src/components/ChangePasswordForm.d.ts.map +1 -0
- package/src/components/ChangePasswordForm.js +66 -0
- package/src/components/ConfirmationDialog.d.ts +13 -0
- package/src/components/ConfirmationDialog.d.ts.map +1 -0
- package/src/components/ConfirmationDialog.js +10 -0
- package/src/components/CurrencyCodeSelector.d.ts +9 -0
- package/src/components/CurrencyCodeSelector.d.ts.map +1 -0
- package/src/components/CurrencyCodeSelector.js +31 -0
- package/src/components/CurrencyInput.d.ts +13 -0
- package/src/components/CurrencyInput.d.ts.map +1 -0
- package/src/components/CurrencyInput.js +22 -0
- package/src/components/DashboardPage.d.ts +8 -0
- package/src/components/DashboardPage.d.ts.map +1 -0
- package/src/components/DashboardPage.js +10 -0
- package/src/components/DropdownMenu.d.ts +9 -0
- package/src/components/DropdownMenu.d.ts.map +1 -0
- package/src/components/DropdownMenu.js +56 -0
- package/src/components/ExpirationSecondsSelector.d.ts +13 -0
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -0
- package/src/components/ExpirationSecondsSelector.js +32 -0
- package/src/components/Flag.d.ts +20 -0
- package/src/components/Flag.d.ts.map +1 -0
- package/src/components/Flag.js +43 -0
- package/src/components/ForgotPasswordForm.d.ts +18 -0
- package/src/components/ForgotPasswordForm.d.ts.map +1 -0
- package/src/components/ForgotPasswordForm.js +54 -0
- package/src/components/LoginForm.d.ts +44 -0
- package/src/components/LoginForm.d.ts.map +1 -0
- package/src/components/LoginForm.js +99 -0
- package/src/components/LogoutPage.d.ts +8 -0
- package/src/components/LogoutPage.d.ts.map +1 -0
- package/src/components/LogoutPage.js +16 -0
- package/src/components/RegisterForm.d.ts +54 -0
- package/src/components/RegisterForm.d.ts.map +1 -0
- package/src/components/RegisterForm.js +105 -0
- package/src/components/ResetPasswordForm.d.ts +23 -0
- package/src/components/ResetPasswordForm.d.ts.map +1 -0
- package/src/components/ResetPasswordForm.js +68 -0
- package/src/components/SideMenu.d.ts +8 -0
- package/src/components/SideMenu.d.ts.map +1 -0
- package/src/components/SideMenu.js +25 -0
- package/src/components/SideMenuListItem.d.ts +13 -0
- package/src/components/SideMenuListItem.d.ts.map +1 -0
- package/src/components/SideMenuListItem.js +44 -0
- package/src/components/TopMenu.d.ts +24 -0
- package/src/components/TopMenu.d.ts.map +1 -0
- package/src/components/TopMenu.js +42 -0
- package/src/components/TranslatedTitle.d.ts +7 -0
- package/src/components/TranslatedTitle.d.ts.map +1 -0
- package/src/components/TranslatedTitle.js +15 -0
- package/src/components/UserLanguageSelector.d.ts +4 -0
- package/src/components/UserLanguageSelector.d.ts.map +1 -0
- package/src/components/UserLanguageSelector.js +31 -0
- package/src/components/UserMenu.d.ts +4 -0
- package/src/components/UserMenu.d.ts.map +1 -0
- package/src/components/UserMenu.js +12 -0
- package/src/components/UserSettingsForm.d.ts +56 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +93 -0
- package/src/components/VerifyEmailPage.d.ts +23 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -0
- package/src/components/VerifyEmailPage.js +61 -0
- package/src/components/{index.ts → index.d.ts} +1 -1
- package/src/components/index.d.ts.map +1 -0
- package/src/components/index.js +28 -0
- package/src/contexts/AuthProvider.d.ts +152 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +446 -0
- package/src/contexts/I18nProvider.d.ts +16 -0
- package/src/contexts/I18nProvider.d.ts.map +1 -0
- package/src/contexts/I18nProvider.js +46 -0
- package/src/contexts/MenuContext.d.ts +20 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +244 -0
- package/src/contexts/SuiteConfigProvider.d.ts +44 -0
- package/src/contexts/SuiteConfigProvider.d.ts.map +1 -0
- package/src/contexts/SuiteConfigProvider.js +43 -0
- package/src/contexts/ThemeProvider.d.ts +15 -0
- package/src/contexts/ThemeProvider.d.ts.map +1 -0
- package/src/contexts/ThemeProvider.js +36 -0
- package/src/contexts/{index.ts → index.d.ts} +1 -0
- package/src/contexts/index.d.ts.map +1 -0
- package/src/contexts/index.js +8 -0
- package/src/hooks/{index.ts → index.d.ts} +1 -0
- package/src/hooks/index.d.ts.map +1 -0
- package/src/hooks/index.js +8 -0
- package/src/hooks/useBackupCodes.d.ts +15 -0
- package/src/hooks/useBackupCodes.d.ts.map +1 -0
- package/src/hooks/useBackupCodes.js +70 -0
- package/src/hooks/useEmailVerification.d.ts +10 -0
- package/src/hooks/useEmailVerification.d.ts.map +1 -0
- package/src/hooks/useEmailVerification.js +36 -0
- package/src/hooks/useExpiringValue.d.ts +14 -0
- package/src/hooks/useExpiringValue.d.ts.map +1 -0
- package/src/hooks/useExpiringValue.js +53 -0
- package/src/hooks/useLocalStorage.d.ts +2 -0
- package/src/hooks/useLocalStorage.d.ts.map +1 -0
- package/src/hooks/useLocalStorage.js +15 -0
- package/src/hooks/useUserSettings.d.ts +46 -0
- package/src/hooks/useUserSettings.d.ts.map +1 -0
- package/src/hooks/useUserSettings.js +152 -0
- package/src/{index.ts → index.d.ts} +1 -1
- package/src/index.d.ts.map +1 -0
- package/src/index.js +12 -0
- package/src/interfaces/IAppConfig.d.ts +6 -0
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IAppConfig.js +2 -0
- package/src/interfaces/IMenuConfig.d.ts +11 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/IMenuOption.d.ts +58 -0
- package/src/interfaces/IMenuOption.d.ts.map +1 -0
- package/src/interfaces/IMenuOption.js +2 -0
- package/src/interfaces/index.d.ts +4 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +6 -0
- package/src/services/__mocks__/authService.d.ts +21 -0
- package/src/services/__mocks__/authService.d.ts.map +1 -0
- package/src/services/__mocks__/authService.js +15 -0
- package/src/services/api.d.ts +3 -0
- package/src/services/api.d.ts.map +1 -0
- package/src/services/api.js +14 -0
- package/src/services/authService.d.ts +72 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +347 -0
- package/src/services/authenticatedApi.d.ts +3 -0
- package/src/services/authenticatedApi.d.ts.map +1 -0
- package/src/services/authenticatedApi.js +18 -0
- package/src/services/index.d.ts +4 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +6 -0
- package/src/types/MenuType.d.ts +11 -0
- package/src/types/MenuType.d.ts.map +1 -0
- package/src/types/MenuType.js +12 -0
- package/src/types/expirationSeconds.d.ts +3 -0
- package/src/types/expirationSeconds.d.ts.map +1 -0
- package/src/types/expirationSeconds.js +17 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +4 -0
- package/src/types/translation.d.ts +10 -0
- package/src/types/translation.d.ts.map +1 -0
- package/src/types/translation.js +9 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +8 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodeLoginWrapper.js +21 -0
- package/src/wrappers/BackupCodesWrapper.d.ts +7 -0
- package/src/wrappers/BackupCodesWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodesWrapper.js +17 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ChangePasswordFormWrapper.js +21 -0
- package/src/wrappers/LoginFormWrapper.d.ts +9 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
- package/src/wrappers/LoginFormWrapper.js +43 -0
- package/src/wrappers/LogoutPageWrapper.d.ts +9 -0
- package/src/wrappers/LogoutPageWrapper.d.ts.map +1 -0
- package/src/wrappers/LogoutPageWrapper.js +21 -0
- package/src/wrappers/RegisterFormWrapper.d.ts +9 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
- package/src/wrappers/RegisterFormWrapper.js +26 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts +8 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
- package/src/wrappers/UserSettingsFormWrapper.js +24 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
- package/src/wrappers/VerifyEmailPageWrapper.js +20 -0
- package/src/wrappers/{index.tsx → index.d.ts} +1 -8
- package/src/wrappers/index.d.ts.map +1 -0
- package/src/wrappers/index.js +20 -0
- package/LICENSE +0 -21
- package/src/auth/Private.tsx +0 -17
- package/src/auth/PrivateRoute.tsx +0 -28
- package/src/auth/UnAuth.tsx +0 -16
- package/src/auth/UnAuthRoute.tsx +0 -30
- package/src/components/ApiAccess.tsx +0 -134
- package/src/components/BackupCodeLoginForm.tsx +0 -314
- package/src/components/BackupCodesForm.tsx +0 -198
- package/src/components/ChangePasswordForm.tsx +0 -182
- package/src/components/ConfirmationDialog.tsx +0 -48
- package/src/components/CurrencyCodeSelector.tsx +0 -60
- package/src/components/CurrencyInput.tsx +0 -80
- package/src/components/DashboardPage.tsx +0 -24
- package/src/components/DropdownMenu.tsx +0 -92
- package/src/components/ExpirationSecondsSelector.tsx +0 -65
- package/src/components/Flag.tsx +0 -53
- package/src/components/ForgotPasswordForm.tsx +0 -120
- package/src/components/LoginForm.tsx +0 -307
- package/src/components/LogoutPage.tsx +0 -21
- package/src/components/RegisterForm.tsx +0 -354
- package/src/components/ResetPasswordForm.tsx +0 -164
- package/src/components/SideMenu.tsx +0 -46
- package/src/components/SideMenuListItem.tsx +0 -74
- package/src/components/TopMenu.tsx +0 -149
- package/src/components/TranslatedTitle.tsx +0 -22
- package/src/components/UserLanguageSelector.tsx +0 -45
- package/src/components/UserMenu.tsx +0 -15
- package/src/components/UserSettingsForm.tsx +0 -328
- package/src/components/VerifyEmailPage.tsx +0 -133
- package/src/contexts/AuthProvider.spec.tsx +0 -1060
- package/src/contexts/AuthProvider.tsx +0 -741
- package/src/contexts/I18nProvider.tsx +0 -85
- package/src/contexts/MenuContext.tsx +0 -310
- package/src/contexts/SuiteConfigProvider.tsx +0 -93
- package/src/contexts/ThemeProvider.tsx +0 -67
- package/src/hooks/useBackupCodes.ts +0 -85
- package/src/hooks/useEmailVerification.ts +0 -39
- package/src/hooks/useExpiringValue.ts +0 -78
- package/src/hooks/useLocalStorage.ts +0 -18
- package/src/hooks/useUserSettings.ts +0 -216
- package/src/interfaces/IAppConfig.ts +0 -5
- package/src/interfaces/IMenuConfig.ts +0 -11
- package/src/interfaces/IMenuOption.ts +0 -55
- package/src/interfaces/index.ts +0 -3
- package/src/services/__mocks__/authService.ts +0 -14
- package/src/services/api.ts +0 -13
- package/src/services/authService.ts +0 -422
- package/src/services/authenticatedApi.ts +0 -17
- package/src/services/index.ts +0 -3
- package/src/types/MenuType.ts +0 -15
- package/src/types/expirationSeconds.ts +0 -18
- package/src/types/index.ts +0 -1
- package/src/types/translation.ts +0 -20
- package/src/wrappers/BackupCodeLoginWrapper.tsx +0 -35
- package/src/wrappers/BackupCodesWrapper.tsx +0 -28
- package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -31
- package/src/wrappers/LoginFormWrapper.tsx +0 -59
- package/src/wrappers/LogoutPageWrapper.tsx +0 -30
- package/src/wrappers/RegisterFormWrapper.tsx +0 -48
- package/src/wrappers/UserSettingsFormWrapper.tsx +0 -39
- package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
Dialog,
|
|
4
|
-
DialogActions,
|
|
5
|
-
DialogContent,
|
|
6
|
-
DialogContentText,
|
|
7
|
-
DialogTitle,
|
|
8
|
-
} from '@mui/material';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
|
|
11
|
-
export interface ConfirmationDialogProps {
|
|
12
|
-
open: boolean;
|
|
13
|
-
title: string;
|
|
14
|
-
message: string;
|
|
15
|
-
confirmText?: string;
|
|
16
|
-
cancelText?: string;
|
|
17
|
-
onConfirm: () => void;
|
|
18
|
-
onCancel: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const ConfirmationDialog: React.FC<ConfirmationDialogProps> = ({
|
|
22
|
-
open,
|
|
23
|
-
title,
|
|
24
|
-
message,
|
|
25
|
-
confirmText = 'Confirm',
|
|
26
|
-
cancelText = 'Cancel',
|
|
27
|
-
onConfirm,
|
|
28
|
-
onCancel,
|
|
29
|
-
}) => {
|
|
30
|
-
return (
|
|
31
|
-
<Dialog open={open} onClose={onCancel}>
|
|
32
|
-
<DialogTitle>{title}</DialogTitle>
|
|
33
|
-
<DialogContent>
|
|
34
|
-
<DialogContentText>{message}</DialogContentText>
|
|
35
|
-
</DialogContent>
|
|
36
|
-
<DialogActions>
|
|
37
|
-
<Button onClick={onCancel} color="primary">
|
|
38
|
-
{cancelText}
|
|
39
|
-
</Button>
|
|
40
|
-
<Button onClick={onConfirm} color="primary">
|
|
41
|
-
{confirmText}
|
|
42
|
-
</Button>
|
|
43
|
-
</DialogActions>
|
|
44
|
-
</Dialog>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default ConfirmationDialog;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { CurrencyCode } from '@digitaldefiance/i18n-lib';
|
|
2
|
-
import { MenuItem, TextField } from '@mui/material';
|
|
3
|
-
import { Field, FieldProps } from 'formik';
|
|
4
|
-
import { ChangeEvent, FC } from 'react';
|
|
5
|
-
|
|
6
|
-
export interface CurrencyCodeSelectorProps {
|
|
7
|
-
name: string;
|
|
8
|
-
label: string;
|
|
9
|
-
onCurrencyChange?: (code: string) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const CurrencyCodeSelector: FC<CurrencyCodeSelectorProps> = ({
|
|
13
|
-
name,
|
|
14
|
-
label,
|
|
15
|
-
onCurrencyChange,
|
|
16
|
-
}) => {
|
|
17
|
-
return (
|
|
18
|
-
<Field name={name}>
|
|
19
|
-
{({ field, form }: FieldProps) => (
|
|
20
|
-
<TextField
|
|
21
|
-
select
|
|
22
|
-
fullWidth
|
|
23
|
-
label={label}
|
|
24
|
-
{...field}
|
|
25
|
-
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
26
|
-
const selectedCode = event.target.value;
|
|
27
|
-
form.setFieldValue(name, selectedCode);
|
|
28
|
-
onCurrencyChange?.(selectedCode);
|
|
29
|
-
}}
|
|
30
|
-
error={form.touched[name] && Boolean(form.errors[name])}
|
|
31
|
-
helperText={form.touched[name] && (form.errors[name] as string)}
|
|
32
|
-
sx={{
|
|
33
|
-
'& .MuiSelect-select': {
|
|
34
|
-
paddingRight: '32px',
|
|
35
|
-
},
|
|
36
|
-
'& .MuiOutlinedInput-root': {
|
|
37
|
-
'& fieldset': {
|
|
38
|
-
borderColor: 'rgba(0, 0, 0, 0.23)',
|
|
39
|
-
},
|
|
40
|
-
'&:hover fieldset': {
|
|
41
|
-
borderColor: 'rgba(0, 0, 0, 0.87)',
|
|
42
|
-
},
|
|
43
|
-
'&.Mui-focused fieldset': {
|
|
44
|
-
borderColor: 'primary.main',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
{CurrencyCode.getAll().map((code: string) => (
|
|
50
|
-
<MenuItem key={code} value={code}>
|
|
51
|
-
{code}
|
|
52
|
-
</MenuItem>
|
|
53
|
-
))}
|
|
54
|
-
</TextField>
|
|
55
|
-
)}
|
|
56
|
-
</Field>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default CurrencyCodeSelector;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { TextField } from '@mui/material';
|
|
2
|
-
import { NumericFormat } from 'react-number-format';
|
|
3
|
-
import { getCurrencyFormat } from '@digitaldefiance/i18n-lib';
|
|
4
|
-
|
|
5
|
-
export interface CurrencyInputProps {
|
|
6
|
-
value: number;
|
|
7
|
-
onChange: (value: number) => void;
|
|
8
|
-
currencyCode?: string;
|
|
9
|
-
locale?: string;
|
|
10
|
-
label: string;
|
|
11
|
-
error?: boolean;
|
|
12
|
-
helperText?: string;
|
|
13
|
-
name: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const CurrencyInput: React.FC<CurrencyInputProps> = ({
|
|
17
|
-
value,
|
|
18
|
-
onChange,
|
|
19
|
-
currencyCode = 'USD',
|
|
20
|
-
locale = 'en-US',
|
|
21
|
-
label,
|
|
22
|
-
error,
|
|
23
|
-
helperText,
|
|
24
|
-
name,
|
|
25
|
-
}) => {
|
|
26
|
-
const format = getCurrencyFormat(locale, currencyCode);
|
|
27
|
-
|
|
28
|
-
if (format.position === 'infix') {
|
|
29
|
-
const [whole, decimal] = value.toString().split('.');
|
|
30
|
-
const displayValue = `${whole}${format.symbol}${format.decimalSeparator}${
|
|
31
|
-
decimal || '00'
|
|
32
|
-
}`;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<NumericFormat
|
|
36
|
-
customInput={TextField}
|
|
37
|
-
fullWidth
|
|
38
|
-
margin="normal"
|
|
39
|
-
label={label}
|
|
40
|
-
value={displayValue}
|
|
41
|
-
thousandSeparator={format.groupSeparator}
|
|
42
|
-
decimalSeparator={format.decimalSeparator}
|
|
43
|
-
decimalScale={2}
|
|
44
|
-
fixedDecimalScale
|
|
45
|
-
valueIsNumericString
|
|
46
|
-
onValueChange={(values) => {
|
|
47
|
-
onChange(values.floatValue || 0);
|
|
48
|
-
}}
|
|
49
|
-
error={error}
|
|
50
|
-
helperText={helperText}
|
|
51
|
-
name={name}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<NumericFormat
|
|
58
|
-
customInput={TextField}
|
|
59
|
-
fullWidth
|
|
60
|
-
margin="normal"
|
|
61
|
-
label={label}
|
|
62
|
-
value={value}
|
|
63
|
-
thousandSeparator={format.groupSeparator}
|
|
64
|
-
decimalSeparator={format.decimalSeparator}
|
|
65
|
-
decimalScale={2}
|
|
66
|
-
fixedDecimalScale
|
|
67
|
-
prefix={format.position === 'prefix' ? format.symbol + ' ' : undefined}
|
|
68
|
-
suffix={format.position === 'postfix' ? ' ' + format.symbol : undefined}
|
|
69
|
-
valueIsNumericString
|
|
70
|
-
onValueChange={(values) => {
|
|
71
|
-
onChange(values.floatValue || 0);
|
|
72
|
-
}}
|
|
73
|
-
error={error}
|
|
74
|
-
helperText={helperText}
|
|
75
|
-
name={name}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default CurrencyInput;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Box, Container, Typography } from '@mui/material';
|
|
2
|
-
import { FC, ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
export interface DashboardPageProps {
|
|
5
|
-
title?: string;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const DashboardPage: FC<DashboardPageProps> = ({ title = 'Dashboard', children }) => {
|
|
10
|
-
return (
|
|
11
|
-
<Container maxWidth="md">
|
|
12
|
-
<Box my={4}>
|
|
13
|
-
<Typography variant="h4" component="h1" gutterBottom align="center">
|
|
14
|
-
{title}
|
|
15
|
-
</Typography>
|
|
16
|
-
<Box display="flex" justifyContent="center" mt={3}>
|
|
17
|
-
{children}
|
|
18
|
-
</Box>
|
|
19
|
-
</Box>
|
|
20
|
-
</Container>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default DashboardPage;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Box, Fade, IconButton, Menu, MenuItem } from '@mui/material';
|
|
2
|
-
import { FC, MouseEvent, ReactElement, useCallback, useState } from 'react';
|
|
3
|
-
import { useNavigate } from 'react-router-dom';
|
|
4
|
-
import { MenuType } from '../types/MenuType';
|
|
5
|
-
import { IMenuOption } from '../interfaces/IMenuOption';
|
|
6
|
-
import { useMenu } from '../contexts/MenuContext';
|
|
7
|
-
|
|
8
|
-
interface DropdownMenuProps {
|
|
9
|
-
menuType: MenuType;
|
|
10
|
-
menuIcon: ReactElement;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DropdownMenu: FC<DropdownMenuProps> = ({ menuType, menuIcon }) => {
|
|
14
|
-
const { getMenuOptions } = useMenu();
|
|
15
|
-
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
16
|
-
const navigate = useNavigate();
|
|
17
|
-
const handleClose = useCallback(() => {
|
|
18
|
-
setAnchorEl(null);
|
|
19
|
-
}, []);
|
|
20
|
-
const handleMenuItemClick = useCallback(
|
|
21
|
-
(option: IMenuOption) => (event: React.MouseEvent<HTMLElement>) => {
|
|
22
|
-
event.stopPropagation();
|
|
23
|
-
if (option.action) {
|
|
24
|
-
option.action();
|
|
25
|
-
} else if (option.link !== undefined) {
|
|
26
|
-
if (
|
|
27
|
-
typeof option.link === 'object' &&
|
|
28
|
-
'pathname' in option.link &&
|
|
29
|
-
'state' in option.link
|
|
30
|
-
) {
|
|
31
|
-
navigate(option.link.pathname, { state: option.link.state });
|
|
32
|
-
} else {
|
|
33
|
-
navigate(option.link);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
handleClose(); // Call handleClose after handling the click
|
|
37
|
-
},
|
|
38
|
-
[navigate, handleClose], // Add handleClose to the dependency array
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const handleClick = useCallback((event: MouseEvent<HTMLElement>) => {
|
|
42
|
-
setAnchorEl(event.currentTarget);
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
const menuItems = getMenuOptions(menuType, false);
|
|
46
|
-
|
|
47
|
-
if (menuItems.length === 0) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Box>
|
|
53
|
-
<IconButton color="inherit" onClick={handleClick}>
|
|
54
|
-
{menuIcon}
|
|
55
|
-
</IconButton>
|
|
56
|
-
<Menu
|
|
57
|
-
anchorEl={anchorEl}
|
|
58
|
-
open={Boolean(anchorEl)}
|
|
59
|
-
onClose={handleClose}
|
|
60
|
-
TransitionComponent={Fade}
|
|
61
|
-
sx={{
|
|
62
|
-
'& .MuiPopover-paper': {
|
|
63
|
-
opacity: 0.5,
|
|
64
|
-
overflow: 'visible',
|
|
65
|
-
},
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
{menuItems.map((option) => (
|
|
69
|
-
<MenuItem
|
|
70
|
-
key={option.id}
|
|
71
|
-
component="li"
|
|
72
|
-
onClick={handleMenuItemClick(option)}
|
|
73
|
-
sx={{
|
|
74
|
-
display: 'flex',
|
|
75
|
-
alignItems: 'center',
|
|
76
|
-
'& > svg': {
|
|
77
|
-
marginRight: 2,
|
|
78
|
-
width: 24,
|
|
79
|
-
height: 24,
|
|
80
|
-
},
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
83
|
-
{option.icon}
|
|
84
|
-
{option.label}
|
|
85
|
-
</MenuItem>
|
|
86
|
-
))}
|
|
87
|
-
</Menu>
|
|
88
|
-
</Box>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default DropdownMenu;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { MenuItem, TextField } from '@mui/material';
|
|
2
|
-
import { FormikProps } from 'formik';
|
|
3
|
-
import { ChangeEvent, FC } from 'react';
|
|
4
|
-
|
|
5
|
-
export interface ExpirationSecondsSelectorProps {
|
|
6
|
-
name: string;
|
|
7
|
-
label: string;
|
|
8
|
-
formik: FormikProps<any>;
|
|
9
|
-
optionValues: number[];
|
|
10
|
-
optionNames: string[];
|
|
11
|
-
onChange?: (value: number) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ExpirationSecondsSelector: FC<ExpirationSecondsSelectorProps> = ({
|
|
15
|
-
name,
|
|
16
|
-
label,
|
|
17
|
-
formik,
|
|
18
|
-
optionValues,
|
|
19
|
-
optionNames,
|
|
20
|
-
onChange,
|
|
21
|
-
}) => {
|
|
22
|
-
return (
|
|
23
|
-
<TextField
|
|
24
|
-
select
|
|
25
|
-
fullWidth
|
|
26
|
-
label={label}
|
|
27
|
-
name={name}
|
|
28
|
-
value={formik.values[name] ?? ''}
|
|
29
|
-
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
30
|
-
const selectedValue = event.target.value;
|
|
31
|
-
formik.setFieldValue(name, selectedValue);
|
|
32
|
-
if (onChange) {
|
|
33
|
-
onChange(parseInt(selectedValue));
|
|
34
|
-
}
|
|
35
|
-
}}
|
|
36
|
-
error={formik.touched[name] && Boolean(formik.errors[name])}
|
|
37
|
-
helperText={formik.touched[name] && (formik.errors[name] as string)}
|
|
38
|
-
sx={{
|
|
39
|
-
mt: 1,
|
|
40
|
-
'& .MuiSelect-select': {
|
|
41
|
-
paddingRight: '32px',
|
|
42
|
-
},
|
|
43
|
-
'& .MuiOutlinedInput-root': {
|
|
44
|
-
'& fieldset': {
|
|
45
|
-
borderColor: 'rgba(0, 0, 0, 0.23)',
|
|
46
|
-
},
|
|
47
|
-
'&:hover fieldset': {
|
|
48
|
-
borderColor: 'rgba(0, 0, 0, 0.87)',
|
|
49
|
-
},
|
|
50
|
-
'&.Mui-focused fieldset': {
|
|
51
|
-
borderColor: 'primary.main',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
{optionNames.map((name: string, index: number) => (
|
|
57
|
-
<MenuItem key={name} value={optionValues[index]}>
|
|
58
|
-
{name}
|
|
59
|
-
</MenuItem>
|
|
60
|
-
))}
|
|
61
|
-
</TextField>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default ExpirationSecondsSelector;
|
package/src/components/Flag.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { CoreLanguageCode } from '@digitaldefiance/i18n-lib';
|
|
2
|
-
import { getFlagCode } from '@digitaldefiance/suite-core-lib';
|
|
3
|
-
import { Box, SxProps, Theme } from '@mui/material';
|
|
4
|
-
import { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
export interface FlagProps {
|
|
7
|
-
language: string;
|
|
8
|
-
sx?: SxProps<Theme>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A simple component to display a flag icon for a given language.
|
|
13
|
-
*
|
|
14
|
-
* Props:
|
|
15
|
-
* language: The language to display a flag for, as a StringLanguages enum value.
|
|
16
|
-
* sx: Optional styles to apply to the component.
|
|
17
|
-
*
|
|
18
|
-
* Returns a Box component with an SVG flag icon from flagcdn.com as a ::before pseudo-element.
|
|
19
|
-
* The flag is sized to 1.5rem by default, but can be overridden by passing a custom sx prop.
|
|
20
|
-
* The component also includes an aria-label for accessibility, set to `Flag for <language>`.
|
|
21
|
-
*/
|
|
22
|
-
export const Flag: FC<FlagProps> = ({ language, sx }) => {
|
|
23
|
-
const flagContent = getFlagCode(language);
|
|
24
|
-
if (!flagContent) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return (
|
|
28
|
-
<Box
|
|
29
|
-
component="span"
|
|
30
|
-
aria-label={`Flag for ${language}`}
|
|
31
|
-
sx={{
|
|
32
|
-
fontSize: '1.5rem',
|
|
33
|
-
lineHeight: 1,
|
|
34
|
-
verticalAlign: 'middle',
|
|
35
|
-
'&::before': {
|
|
36
|
-
content: `" "`,
|
|
37
|
-
display: 'inline-block',
|
|
38
|
-
width: '1em',
|
|
39
|
-
height: '1em',
|
|
40
|
-
backgroundImage: `url(https://flagcdn.com/${flagContent.toLowerCase()}.svg)`,
|
|
41
|
-
backgroundSize: 'contain',
|
|
42
|
-
backgroundRepeat: 'no-repeat',
|
|
43
|
-
backgroundPosition: 'center',
|
|
44
|
-
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
45
|
-
borderRadius: '2px',
|
|
46
|
-
},
|
|
47
|
-
...sx,
|
|
48
|
-
}}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default Flag;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Alert, Box, Button, Container, TextField, Typography } from '@mui/material';
|
|
2
|
-
import { useFormik } from 'formik';
|
|
3
|
-
import { FC, useState } from 'react';
|
|
4
|
-
import * as Yup from 'yup';
|
|
5
|
-
import { SuiteCoreComponentId, SuiteCoreStringKey } from '@digitaldefiance/suite-core-lib';
|
|
6
|
-
import { useI18n } from '../contexts';
|
|
7
|
-
|
|
8
|
-
export interface ForgotPasswordFormValues {
|
|
9
|
-
email: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ForgotPasswordFormProps {
|
|
13
|
-
onSubmit: (values: ForgotPasswordFormValues) => Promise<void>;
|
|
14
|
-
emailValidation?: Yup.StringSchema;
|
|
15
|
-
labels?: {
|
|
16
|
-
title?: string;
|
|
17
|
-
email?: string;
|
|
18
|
-
sendResetLink?: string;
|
|
19
|
-
successMessage?: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const ForgotPasswordForm: FC<ForgotPasswordFormProps> = ({
|
|
24
|
-
onSubmit,
|
|
25
|
-
emailValidation,
|
|
26
|
-
labels = {},
|
|
27
|
-
}) => {
|
|
28
|
-
const { tComponent } = useI18n();
|
|
29
|
-
const [success, setSuccess] = useState(false);
|
|
30
|
-
const [apiError, setApiError] = useState<string>('');
|
|
31
|
-
|
|
32
|
-
const validation = {
|
|
33
|
-
email: emailValidation || Yup.string()
|
|
34
|
-
.email(tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.Validation_InvalidEmail))
|
|
35
|
-
.required(tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.Validation_Required)),
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const translatedLabels = {
|
|
39
|
-
title: labels.title || tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.ForgotPassword_Title),
|
|
40
|
-
email: labels.email || tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.Common_Email),
|
|
41
|
-
sendResetLink: labels.sendResetLink || tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.ForgotPassword_SendResetLink),
|
|
42
|
-
successMessage: labels.successMessage || tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.PasswordReset_Success),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const formik = useFormik<ForgotPasswordFormValues>({
|
|
46
|
-
initialValues: {
|
|
47
|
-
email: '',
|
|
48
|
-
},
|
|
49
|
-
validationSchema: Yup.object({
|
|
50
|
-
email: validation.email,
|
|
51
|
-
}),
|
|
52
|
-
onSubmit: async (values) => {
|
|
53
|
-
try {
|
|
54
|
-
await onSubmit(values);
|
|
55
|
-
setSuccess(true);
|
|
56
|
-
setApiError('');
|
|
57
|
-
} catch (error: any) {
|
|
58
|
-
setApiError(error.response?.data?.message || tComponent<SuiteCoreStringKey>(SuiteCoreComponentId, SuiteCoreStringKey.ForgotPassword_Error));
|
|
59
|
-
setSuccess(false);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<Container maxWidth="sm">
|
|
66
|
-
<Box
|
|
67
|
-
sx={{
|
|
68
|
-
mt: 8,
|
|
69
|
-
display: 'flex',
|
|
70
|
-
flexDirection: 'column',
|
|
71
|
-
alignItems: 'center',
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
<Typography variant="h4" component="h1" gutterBottom>
|
|
75
|
-
{translatedLabels.title}
|
|
76
|
-
</Typography>
|
|
77
|
-
|
|
78
|
-
<Box component="form" onSubmit={formik.handleSubmit} sx={{ mt: 1, width: '100%' }}>
|
|
79
|
-
<TextField
|
|
80
|
-
fullWidth
|
|
81
|
-
id="email"
|
|
82
|
-
name="email"
|
|
83
|
-
label={translatedLabels.email}
|
|
84
|
-
value={formik.values.email}
|
|
85
|
-
onChange={formik.handleChange}
|
|
86
|
-
onBlur={formik.handleBlur}
|
|
87
|
-
error={Boolean(formik.touched.email && formik.errors.email)}
|
|
88
|
-
helperText={formik.touched.email && formik.errors.email}
|
|
89
|
-
margin="normal"
|
|
90
|
-
/>
|
|
91
|
-
|
|
92
|
-
{apiError && (
|
|
93
|
-
<Alert severity="error" sx={{ mt: 2, mb: 2 }}>
|
|
94
|
-
{apiError}
|
|
95
|
-
</Alert>
|
|
96
|
-
)}
|
|
97
|
-
|
|
98
|
-
{success && (
|
|
99
|
-
<Alert severity="success" sx={{ mt: 2, mb: 2 }}>
|
|
100
|
-
{translatedLabels.successMessage}
|
|
101
|
-
</Alert>
|
|
102
|
-
)}
|
|
103
|
-
|
|
104
|
-
<Button
|
|
105
|
-
type="submit"
|
|
106
|
-
fullWidth
|
|
107
|
-
variant="contained"
|
|
108
|
-
color="primary"
|
|
109
|
-
sx={{ mt: 3, mb: 2 }}
|
|
110
|
-
disabled={formik.isSubmitting}
|
|
111
|
-
>
|
|
112
|
-
{translatedLabels.sendResetLink}
|
|
113
|
-
</Button>
|
|
114
|
-
</Box>
|
|
115
|
-
</Box>
|
|
116
|
-
</Container>
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default ForgotPasswordForm;
|