mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-30 09:15:42 +03:00
feat: user application dashboard (#727)
Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
@@ -54,6 +54,13 @@ export function createForm<T extends z.ZodType<any, any>>(schema: T, initialValu
|
||||
inputs[input as keyof z.infer<T>].error = null;
|
||||
}
|
||||
}
|
||||
// Update the input values with the parsed data
|
||||
for (const key in result.data) {
|
||||
if (Object.prototype.hasOwnProperty.call(inputs, key)) {
|
||||
inputs[key as keyof z.infer<T>].value = result.data[key];
|
||||
}
|
||||
}
|
||||
|
||||
return inputs;
|
||||
});
|
||||
return success ? data() : null;
|
||||
|
||||
11
frontend/src/lib/utils/zod-util.ts
Normal file
11
frontend/src/lib/utils/zod-util.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import z from 'zod/v4';
|
||||
|
||||
export const optionalString = z
|
||||
.string()
|
||||
.transform((v) => (v === '' ? undefined : v))
|
||||
.optional();
|
||||
|
||||
export const optionalUrl = z
|
||||
.url()
|
||||
.optional()
|
||||
.or(z.literal('').transform(() => undefined));
|
||||
Reference in New Issue
Block a user