feat(frontend): start settings

This commit is contained in:
sam 2024-11-24 17:36:02 +01:00
parent 0c78cd25b0
commit c179669799
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
13 changed files with 301 additions and 17 deletions

View file

@ -52,3 +52,15 @@ export type ValidationError = {
allowed_values?: any[];
actual_value?: any;
};
/**
* Returns the first error for the value `key` in `error`.
* @param error The error object to traverse.
* @param key The JSON key to find.
*/
export const firstErrorFor = (error: RawApiError, key: string): ValidationError | undefined => {
if (!error.errors) return undefined;
const field = error.errors.find((e) => e.key == key);
if (!field?.errors) return undefined;
return field.errors.length != 0 ? field.errors[0] : undefined;
};