mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: reports; improved+simplifed modals; extractError funcction;
refactor: change jwt claims to lowercase; use response dtos for sensitive data fix: nullify user on token clears; change appsettings.dev View_Internal_API_Key
This commit is contained in:
@@ -24,6 +24,25 @@ export function extractDateFromUUIDv7(uuid?: string): Date | null {
|
||||
return new Date(parseInt(timestampHex, 16));
|
||||
}
|
||||
|
||||
export function extractError(resData: unknown): string | null {
|
||||
if (!resData || typeof resData !== 'object') return null;
|
||||
|
||||
const data = resData as { errors?: unknown; message?: unknown };
|
||||
|
||||
if (data.errors && typeof data.errors === 'object') {
|
||||
return Object.values(data.errors as Record<string, unknown>)
|
||||
.flat()
|
||||
.filter((v) => typeof v === 'string')
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
if (typeof data.message === 'string') {
|
||||
return data.message;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function dateToRelativeString(
|
||||
date: Date,
|
||||
useSuffix = true,
|
||||
|
||||
Reference in New Issue
Block a user