@digitaldefiance/express-suite-react-components 5.0.2 → 5.0.4
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 +5 -4
- package/src/auth/AdminRoute.d.ts +8 -0
- package/src/auth/AdminRoute.d.ts.map +1 -0
- package/src/auth/AdminRoute.js +28 -0
- 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} +3 -2
- package/src/auth/index.d.ts.map +1 -0
- package/src/auth/index.js +12 -0
- package/src/components/ApiAccess.d.ts +16 -0
- package/src/components/ApiAccess.d.ts.map +1 -0
- package/src/components/ApiAccess.js +77 -0
- package/src/components/BackupCodeLoginForm.d.ts +43 -0
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
- package/src/components/BackupCodeLoginForm.js +139 -0
- package/src/components/BackupCodesForm.d.ts +26 -0
- package/src/components/BackupCodesForm.d.ts.map +1 -0
- package/src/components/BackupCodesForm.js +120 -0
- package/src/components/CategoryMenu.d.ts +17 -0
- package/src/components/CategoryMenu.d.ts.map +1 -0
- package/src/components/CategoryMenu.js +65 -0
- package/src/components/ChangePasswordForm.d.ts +26 -0
- package/src/components/ChangePasswordForm.d.ts.map +1 -0
- package/src/components/ChangePasswordForm.js +78 -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 +13 -0
- package/src/components/DropdownMenu.d.ts.map +1 -0
- package/src/components/DropdownMenu.js +63 -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/FakeEmailAdminPanel.d.ts +23 -0
- package/src/components/FakeEmailAdminPanel.d.ts.map +1 -0
- package/src/components/FakeEmailAdminPanel.js +147 -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 +61 -0
- package/src/components/LoginForm.d.ts +44 -0
- package/src/components/LoginForm.d.ts.map +1 -0
- package/src/components/LoginForm.js +123 -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 +100 -0
- package/src/components/RegisterForm.d.ts.map +1 -0
- package/src/components/RegisterForm.js +306 -0
- package/src/components/ResetPasswordForm.d.ts +23 -0
- package/src/components/ResetPasswordForm.d.ts.map +1 -0
- package/src/components/ResetPasswordForm.js +78 -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/T.d.ts +7 -0
- package/src/components/T.d.ts.map +1 -0
- package/src/components/T.js +13 -0
- package/src/components/TDiv.d.ts +9 -0
- package/src/components/TDiv.d.ts.map +1 -0
- package/src/components/TDiv.js +14 -0
- package/src/components/TImgAlt.d.ts +10 -0
- package/src/components/TImgAlt.d.ts.map +1 -0
- package/src/components/TImgAlt.js +14 -0
- package/src/components/TopMenu.d.ts +50 -0
- package/src/components/TopMenu.d.ts.map +1 -0
- package/src/components/TopMenu.js +79 -0
- package/src/components/TotpSetupForm.d.ts +24 -0
- package/src/components/TotpSetupForm.d.ts.map +1 -0
- package/src/components/TotpSetupForm.js +82 -0
- package/src/components/TotpVerificationForm.d.ts +23 -0
- package/src/components/TotpVerificationForm.d.ts.map +1 -0
- package/src/components/TotpVerificationForm.js +66 -0
- package/src/components/TranslatedTitle.d.ts +8 -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 +113 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +269 -0
- package/src/components/VerifyEmailPage.d.ts +24 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -0
- package/src/components/VerifyEmailPage.js +81 -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 +35 -0
- package/src/contexts/AuthProvider.d.ts +19 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +514 -0
- package/src/contexts/I18nProvider.d.ts +27 -0
- package/src/contexts/I18nProvider.d.ts.map +1 -0
- package/src/contexts/I18nProvider.js +60 -0
- package/src/contexts/MenuContext.d.ts +28 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +307 -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/auth-context.d.ts +172 -0
- package/src/contexts/auth-context.d.ts.map +1 -0
- package/src/contexts/auth-context.js +13 -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 +9 -0
- package/src/hooks/useAuthenticatedApi.d.ts +34 -0
- package/src/hooks/useAuthenticatedApi.d.ts.map +1 -0
- package/src/hooks/useAuthenticatedApi.js +46 -0
- package/src/hooks/useBackupCodes.d.ts +15 -0
- package/src/hooks/useBackupCodes.d.ts.map +1 -0
- package/src/hooks/useBackupCodes.js +74 -0
- package/src/hooks/useEmailVerification.d.ts +10 -0
- package/src/hooks/useEmailVerification.d.ts.map +1 -0
- package/src/hooks/useEmailVerification.js +40 -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 +48 -0
- package/src/hooks/useUserSettings.d.ts.map +1 -0
- package/src/hooks/useUserSettings.js +171 -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 +8 -0
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IAppConfig.js +2 -0
- package/src/interfaces/ICategoryConfig.d.ts +41 -0
- package/src/interfaces/ICategoryConfig.d.ts.map +1 -0
- package/src/interfaces/ICategoryConfig.js +2 -0
- package/src/interfaces/IMenuConfig.d.ts +28 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/IMenuOption.d.ts +82 -0
- package/src/interfaces/IMenuOption.d.ts.map +1 -0
- package/src/interfaces/IMenuOption.js +2 -0
- package/src/interfaces/{index.ts → index.d.ts} +1 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +7 -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 +126 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +471 -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 +20 -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/ForgotPasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ForgotPasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ForgotPasswordFormWrapper.js +29 -0
- package/src/wrappers/LoginFormWrapper.d.ts +21 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
- package/src/wrappers/LoginFormWrapper.js +72 -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 +20 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
- package/src/wrappers/RegisterFormWrapper.js +51 -0
- package/src/wrappers/ResetPasswordFormWrapper.d.ts +9 -0
- package/src/wrappers/ResetPasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ResetPasswordFormWrapper.js +34 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts +29 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
- package/src/wrappers/UserSettingsFormWrapper.js +95 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
- package/src/wrappers/VerifyEmailPageWrapper.js +21 -0
- package/src/wrappers/{index.tsx → index.d.ts} +1 -10
- package/src/wrappers/index.d.ts.map +1 -0
- package/src/wrappers/index.js +24 -0
- package/LICENSE +0 -21
- package/src/auth/AdminRoute.tsx +0 -54
- 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 -175
- package/src/components/BackupCodeLoginForm.tsx +0 -489
- package/src/components/BackupCodesForm.tsx +0 -287
- package/src/components/CategoryMenu.tsx +0 -155
- package/src/components/ChangePasswordForm.tsx +0 -273
- 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 -105
- package/src/components/ExpirationSecondsSelector.tsx +0 -60
- package/src/components/FakeEmailAdminPanel.tsx +0 -374
- package/src/components/Flag.tsx +0 -52
- package/src/components/ForgotPasswordForm.tsx +0 -174
- package/src/components/LoginForm.tsx +0 -468
- package/src/components/LogoutPage.tsx +0 -21
- package/src/components/RegisterForm.tsx +0 -1169
- package/src/components/ResetPasswordForm.tsx +0 -247
- package/src/components/SideMenu.tsx +0 -46
- package/src/components/SideMenuListItem.tsx +0 -75
- package/src/components/T.tsx +0 -24
- package/src/components/TDiv.tsx +0 -26
- package/src/components/TImgAlt.tsx +0 -28
- package/src/components/TopMenu.tsx +0 -252
- package/src/components/TotpSetupForm.tsx +0 -188
- package/src/components/TotpVerificationForm.tsx +0 -148
- package/src/components/TranslatedTitle.tsx +0 -31
- package/src/components/UserLanguageSelector.tsx +0 -45
- package/src/components/UserMenu.tsx +0 -15
- package/src/components/UserSettingsForm.tsx +0 -904
- package/src/components/VerifyEmailPage.tsx +0 -222
- package/src/components/__tests__/RegisterForm.totp.spec.tsx +0 -377
- package/src/components/__tests__/TotpSetupForm.spec.tsx +0 -258
- package/src/components/__tests__/TotpVerificationForm.spec.tsx +0 -259
- package/src/components/__tests__/UserSettingsForm.totp.spec.tsx +0 -396
- package/src/contexts/AuthProvider.spec.tsx +0 -1284
- package/src/contexts/AuthProvider.tsx +0 -977
- package/src/contexts/I18nProvider.tsx +0 -164
- package/src/contexts/MenuContext.tsx +0 -426
- package/src/contexts/SuiteConfigProvider.tsx +0 -93
- package/src/contexts/ThemeProvider.tsx +0 -67
- package/src/hooks/useAuthenticatedApi.tsx +0 -67
- package/src/hooks/useBackupCodes.ts +0 -105
- package/src/hooks/useEmailVerification.ts +0 -54
- package/src/hooks/useExpiringValue.ts +0 -78
- package/src/hooks/useLocalStorage.ts +0 -18
- package/src/hooks/useUserSettings.ts +0 -271
- package/src/interfaces/IAppConfig.ts +0 -7
- package/src/interfaces/ICategoryConfig.ts +0 -41
- package/src/interfaces/IMenuConfig.ts +0 -28
- package/src/interfaces/IMenuOption.ts +0 -79
- package/src/services/__mocks__/authService.ts +0 -14
- package/src/services/__tests__/authService.totp.property.spec.ts +0 -360
- package/src/services/__tests__/authService.totp.spec.ts +0 -439
- package/src/services/api.ts +0 -13
- package/src/services/authService.ts +0 -692
- 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 -34
- package/src/wrappers/BackupCodesWrapper.tsx +0 -28
- package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -34
- package/src/wrappers/ForgotPasswordFormWrapper.tsx +0 -45
- package/src/wrappers/LoginFormWrapper.tsx +0 -108
- package/src/wrappers/LogoutPageWrapper.tsx +0 -30
- package/src/wrappers/RegisterFormWrapper.tsx +0 -109
- package/src/wrappers/ResetPasswordFormWrapper.tsx +0 -57
- package/src/wrappers/UserSettingsFormWrapper.tsx +0 -140
- package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
- package/src/wrappers/__tests__/LoginFormWrapper.totp.spec.tsx +0 -339
package/src/auth/AdminRoute.tsx
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode, useContext } from 'react';
|
|
2
|
-
import { Navigate, useLocation } from 'react-router';
|
|
3
|
-
import { AuthContext } from '../contexts/AuthProvider';
|
|
4
|
-
import { useI18n } from '../contexts';
|
|
5
|
-
import {
|
|
6
|
-
SuiteCoreComponentId,
|
|
7
|
-
SuiteCoreStringKey,
|
|
8
|
-
SuiteCoreStringKeyValue,
|
|
9
|
-
} from '@digitaldefiance/suite-core-lib';
|
|
10
|
-
import { useAuth } from '../contexts/AuthProvider';
|
|
11
|
-
|
|
12
|
-
interface AdminRouteProps {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
redirectTo?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const AdminRoute: FC<AdminRouteProps> = ({ children, redirectTo }) => {
|
|
18
|
-
const { admin } = useAuth();
|
|
19
|
-
const { tComponent } = useI18n();
|
|
20
|
-
const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
|
|
21
|
-
const location = useLocation();
|
|
22
|
-
|
|
23
|
-
if (isCheckingAuth) {
|
|
24
|
-
return (
|
|
25
|
-
<div>
|
|
26
|
-
{tComponent<SuiteCoreStringKeyValue>(
|
|
27
|
-
SuiteCoreComponentId,
|
|
28
|
-
SuiteCoreStringKey.Common_CheckingAuthentication
|
|
29
|
-
)}
|
|
30
|
-
...
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!isAuthenticated) {
|
|
36
|
-
return (
|
|
37
|
-
<Navigate
|
|
38
|
-
to={redirectTo ?? '/login'}
|
|
39
|
-
state={{ from: location }}
|
|
40
|
-
replace
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!admin) {
|
|
46
|
-
return (
|
|
47
|
-
<Navigate to={redirectTo ?? '/'} state={{ from: location }} replace />
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return <>{children}</>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default AdminRoute;
|
package/src/auth/Private.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode, useContext } from 'react';
|
|
2
|
-
import { AuthContext } from '../contexts/AuthProvider';
|
|
3
|
-
export interface PrivateProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const Private: FC<PrivateProps> = ({
|
|
8
|
-
children,
|
|
9
|
-
}) => {
|
|
10
|
-
const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
|
|
11
|
-
|
|
12
|
-
if (isCheckingAuth || !isAuthenticated) {
|
|
13
|
-
return <></>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return <>{children}</>;
|
|
17
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode, useContext } from 'react';
|
|
2
|
-
import { Navigate, useLocation } from 'react-router';
|
|
3
|
-
import { AuthContext } from '../contexts/AuthProvider';
|
|
4
|
-
import { useI18n } from '../contexts';
|
|
5
|
-
import { SuiteCoreComponentId, SuiteCoreStringKey, SuiteCoreStringKeyValue } from '@digitaldefiance/suite-core-lib';
|
|
6
|
-
|
|
7
|
-
interface PrivateRouteProps {
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
redirectTo?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const PrivateRoute: FC<PrivateRouteProps> = ({ children, redirectTo }) => {
|
|
13
|
-
const { tComponent } = useI18n();
|
|
14
|
-
const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
|
|
15
|
-
const location = useLocation();
|
|
16
|
-
|
|
17
|
-
if (isCheckingAuth) {
|
|
18
|
-
return <div>{tComponent<SuiteCoreStringKeyValue>(SuiteCoreComponentId, SuiteCoreStringKey.Common_CheckingAuthentication)}...</div>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!isAuthenticated) {
|
|
22
|
-
return <Navigate to={redirectTo ?? "/login"} state={{ from: location }} replace />;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return <>{children}</>;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default PrivateRoute;
|
package/src/auth/UnAuth.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode, useContext } from 'react';
|
|
2
|
-
import { AuthContext } from '../contexts/AuthProvider';
|
|
3
|
-
|
|
4
|
-
export interface UnAuthProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const UnAuth: FC<UnAuthProps> = ({ children }) => {
|
|
9
|
-
const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
|
|
10
|
-
|
|
11
|
-
if (isCheckingAuth || isAuthenticated) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return <>{children}</>;
|
|
16
|
-
};
|
package/src/auth/UnAuthRoute.tsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode, useContext } from 'react';
|
|
2
|
-
import { Navigate, useLocation } from 'react-router';
|
|
3
|
-
import { AuthContext, useI18n } from '../contexts';
|
|
4
|
-
import { SuiteCoreComponentId, SuiteCoreStringKey, SuiteCoreStringKeyValue } from '@digitaldefiance/suite-core-lib';
|
|
5
|
-
|
|
6
|
-
export interface UnAuthRouteProps {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
redirectTo?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const UnAuthRoute: FC<UnAuthRouteProps> = ({
|
|
12
|
-
children,
|
|
13
|
-
redirectTo = '/dashboard',
|
|
14
|
-
}) => {
|
|
15
|
-
const { isAuthenticated, isCheckingAuth } = useContext(AuthContext);
|
|
16
|
-
const { tComponent } = useI18n();
|
|
17
|
-
const location = useLocation();
|
|
18
|
-
|
|
19
|
-
if (isCheckingAuth) {
|
|
20
|
-
return <div>{tComponent<SuiteCoreStringKeyValue>(SuiteCoreComponentId, SuiteCoreStringKey.Common_CheckingAuthentication)}...</div>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (isAuthenticated) {
|
|
24
|
-
return <Navigate to={redirectTo ?? "/dashboard"} state={{ from: location }} replace />;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return <>{children}</>;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default UnAuthRoute;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SuiteCoreComponentId,
|
|
3
|
-
SuiteCoreStringKey,
|
|
4
|
-
SuiteCoreStringKeyValue,
|
|
5
|
-
} from '@digitaldefiance/suite-core-lib';
|
|
6
|
-
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
|
7
|
-
import {
|
|
8
|
-
Box,
|
|
9
|
-
Button,
|
|
10
|
-
Dialog,
|
|
11
|
-
DialogActions,
|
|
12
|
-
DialogContent,
|
|
13
|
-
DialogTitle,
|
|
14
|
-
styled,
|
|
15
|
-
TextField,
|
|
16
|
-
Typography,
|
|
17
|
-
} from '@mui/material';
|
|
18
|
-
import { FC, useState } from 'react';
|
|
19
|
-
import { useAuth, useI18n } from '../contexts';
|
|
20
|
-
|
|
21
|
-
const ApiAccessContainer = styled(Box)(({ theme }) => ({
|
|
22
|
-
display: 'flex',
|
|
23
|
-
flexDirection: 'column',
|
|
24
|
-
alignItems: 'center',
|
|
25
|
-
justifyContent: 'center',
|
|
26
|
-
minHeight: '100vh',
|
|
27
|
-
backgroundColor: theme.palette.background.default,
|
|
28
|
-
padding: theme.spacing(3),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
const ApiAccessContent = styled(Box)(({ theme }) => ({
|
|
32
|
-
maxWidth: '600px',
|
|
33
|
-
width: '100%',
|
|
34
|
-
backgroundColor: theme.palette.background.paper,
|
|
35
|
-
borderRadius: theme.shape.borderRadius,
|
|
36
|
-
padding: theme.spacing(4),
|
|
37
|
-
boxShadow: theme.shadows[3],
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
const ApiAccessTitle = styled(Typography)(({ theme }) => ({
|
|
41
|
-
marginBottom: theme.spacing(3),
|
|
42
|
-
color: theme.palette.primary.main,
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
export interface ApiAccessProps {
|
|
46
|
-
token?: string | null;
|
|
47
|
-
labels?: {
|
|
48
|
-
title?: string;
|
|
49
|
-
tokenNotAvailable?: string;
|
|
50
|
-
copyButton?: string;
|
|
51
|
-
notificationTitle?: string;
|
|
52
|
-
copied?: string;
|
|
53
|
-
copyFailed?: string;
|
|
54
|
-
ok?: string;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const ApiAccess: FC<ApiAccessProps> = ({
|
|
59
|
-
token: tokenProp,
|
|
60
|
-
labels = {},
|
|
61
|
-
}) => {
|
|
62
|
-
const { token: authToken } = useAuth();
|
|
63
|
-
const token = tokenProp !== undefined ? tokenProp : authToken;
|
|
64
|
-
const { tComponent } = useI18n();
|
|
65
|
-
const [dialogOpen, setDialogOpen] = useState(false);
|
|
66
|
-
const [isError, setIsError] = useState(false);
|
|
67
|
-
|
|
68
|
-
const translatedLabels = {
|
|
69
|
-
title:
|
|
70
|
-
labels.title ||
|
|
71
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
72
|
-
SuiteCoreComponentId,
|
|
73
|
-
SuiteCoreStringKey.ApiAccess_Title
|
|
74
|
-
),
|
|
75
|
-
tokenNotAvailable:
|
|
76
|
-
labels.tokenNotAvailable ||
|
|
77
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
78
|
-
SuiteCoreComponentId,
|
|
79
|
-
SuiteCoreStringKey.ApiAccess_TokenNotAvailable
|
|
80
|
-
),
|
|
81
|
-
copyButton:
|
|
82
|
-
labels.copyButton ||
|
|
83
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
84
|
-
SuiteCoreComponentId,
|
|
85
|
-
SuiteCoreStringKey.Common_CopyToClipboard
|
|
86
|
-
),
|
|
87
|
-
notificationTitle:
|
|
88
|
-
labels.notificationTitle ||
|
|
89
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
90
|
-
SuiteCoreComponentId,
|
|
91
|
-
SuiteCoreStringKey.Common_Notification
|
|
92
|
-
),
|
|
93
|
-
copied:
|
|
94
|
-
labels.copied ||
|
|
95
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
96
|
-
SuiteCoreComponentId,
|
|
97
|
-
SuiteCoreStringKey.Common_CopiedToClipboard
|
|
98
|
-
),
|
|
99
|
-
copyFailed:
|
|
100
|
-
labels.copyFailed ||
|
|
101
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
102
|
-
SuiteCoreComponentId,
|
|
103
|
-
SuiteCoreStringKey.Error_FailedToCopy
|
|
104
|
-
),
|
|
105
|
-
ok:
|
|
106
|
-
labels.ok ||
|
|
107
|
-
tComponent<SuiteCoreStringKeyValue>(
|
|
108
|
-
SuiteCoreComponentId,
|
|
109
|
-
SuiteCoreStringKey.Common_OK
|
|
110
|
-
),
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const copyToClipboard = async () => {
|
|
114
|
-
if (token) {
|
|
115
|
-
try {
|
|
116
|
-
await navigator.clipboard.writeText(token);
|
|
117
|
-
setIsError(false);
|
|
118
|
-
setDialogOpen(true);
|
|
119
|
-
} catch {
|
|
120
|
-
setIsError(true);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const handleClose = () => {
|
|
126
|
-
setDialogOpen(false);
|
|
127
|
-
setIsError(false);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<ApiAccessContainer>
|
|
132
|
-
<ApiAccessContent>
|
|
133
|
-
<ApiAccessTitle variant="h4" align="center">
|
|
134
|
-
{translatedLabels.title}
|
|
135
|
-
</ApiAccessTitle>
|
|
136
|
-
<TextField
|
|
137
|
-
fullWidth
|
|
138
|
-
multiline
|
|
139
|
-
rows={4}
|
|
140
|
-
value={token || translatedLabels.tokenNotAvailable}
|
|
141
|
-
slotProps={{
|
|
142
|
-
input: {
|
|
143
|
-
readOnly: true,
|
|
144
|
-
},
|
|
145
|
-
}}
|
|
146
|
-
variant="outlined"
|
|
147
|
-
margin="normal"
|
|
148
|
-
/>
|
|
149
|
-
<Button
|
|
150
|
-
variant="contained"
|
|
151
|
-
color="primary"
|
|
152
|
-
startIcon={<ContentCopyIcon />}
|
|
153
|
-
onClick={copyToClipboard}
|
|
154
|
-
fullWidth
|
|
155
|
-
style={{ marginTop: '16px' }}
|
|
156
|
-
>
|
|
157
|
-
{translatedLabels.copyButton}
|
|
158
|
-
</Button>
|
|
159
|
-
</ApiAccessContent>
|
|
160
|
-
<Dialog open={dialogOpen} onClose={handleClose}>
|
|
161
|
-
<DialogTitle>{translatedLabels.notificationTitle}</DialogTitle>
|
|
162
|
-
<DialogContent>
|
|
163
|
-
{isError ? translatedLabels.copyFailed : translatedLabels.copied}
|
|
164
|
-
</DialogContent>
|
|
165
|
-
<DialogActions>
|
|
166
|
-
<Button onClick={handleClose} color="primary">
|
|
167
|
-
{translatedLabels.ok}
|
|
168
|
-
</Button>
|
|
169
|
-
</DialogActions>
|
|
170
|
-
</Dialog>
|
|
171
|
-
</ApiAccessContainer>
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export default ApiAccess;
|