Auth redirects, language switch, basic profile
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Timestamp } from '../types/Timestamp';
|
||||
|
||||
/**
|
||||
* Convert date to nicer format
|
||||
* @param date Timestamp in question
|
||||
* @returns Formatted string
|
||||
*/
|
||||
const convertDate = (date: Timestamp): string => {
|
||||
return new Date(date.date).toLocaleString(navigator.languages[0] ?? 'de-DE', {
|
||||
timeZone: date.timezone,
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
hour12: false,
|
||||
minute: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
export default convertDate;
|
||||
@@ -1,5 +1,10 @@
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
export enum ERRORS {
|
||||
NOT_FOUND = 'NotFound',
|
||||
UNAUTHORIZED = 'Unauthorized',
|
||||
}
|
||||
|
||||
/**
|
||||
* Return translated error
|
||||
* @param error Error object
|
||||
@@ -18,9 +23,9 @@ const handleError = (
|
||||
|
||||
if (error.code) {
|
||||
switch (error.code) {
|
||||
case 'NotFound':
|
||||
case ERRORS.NOT_FOUND:
|
||||
return t(error.code, { context: `${error.entity}:${context}` });
|
||||
case 'Unauthorized':
|
||||
case ERRORS.UNAUTHORIZED:
|
||||
return t(error.code, { context });
|
||||
default:
|
||||
return t('Unknown', { context });
|
||||
|
||||
Reference in New Issue
Block a user