Split 401

This commit is contained in:
2024-07-28 03:04:26 +02:00
parent 73c7dc1b5e
commit 96bdbfc62a
15 changed files with 77 additions and 75 deletions
@@ -19,7 +19,7 @@ const ErrorComponent: FC<Props> = ({ error, context, color = 'error.main' }) =>
switch (error.code) {
case ERRORS.NOT_FOUND:
return <Typography color={color}>{t(error.code, { context: `${error.entity}:${context}` })}</Typography>;
case ERRORS.UNAUTHORIZED:
case ERRORS.NOT_ALLOWED:
return <Typography color={color}>{t(error.code, { context })}</Typography>;
case ERRORS.FAILED_UPDATE:
return error.fields.map((field: string, index: number) => (
@@ -1,6 +1,7 @@
export enum ERRORS {
NOT_FOUND = 'NotFound',
UNAUTHORIZED = 'Unauthorized',
NOT_ALLOWED = 'NotAllowed',
FAILED_UPDATE = 'FailedUpdate',
MISSING_FIELD = 'MissingField',
DUPLICATE = 'Duplicate',
@@ -71,11 +71,9 @@ const UserMenu: FC<Props> = ({ anchorEl, handleClose }) => {
</MenuItem>,
]
) : register ? (
<>
<RegisterDialog open={register} onClose={() => setRegister(false)} />
</>
<RegisterDialog open={register} onClose={() => setRegister(false)} />
) : (
<>
<Box>
<LoginForm handleClose={_handleClose} />
<Box sx={{ padding: 1 }}>
<Trans i18nKey="Register prompt">
@@ -92,7 +90,7 @@ const UserMenu: FC<Props> = ({ anchorEl, handleClose }) => {
<Typography component="span" />
</Trans>
</Box>
</>
</Box>
)}
</Menu>
);