admin: Superforms + Zod validation, three-address-defaults schema, profiles toast fix
- Add Superforms + Zod 4 for all admin form validation - Replace address isDefault with three separate boolean defaults (Mailing, Billing, Shipping) - Update profiles page with three-checkbox address form and toast improvements - Convert all admin page server actions to pass request directly to crud - Export superFormErrorsToFieldErrors helper for profiles server actions - Regenerate Prisma client for new schema fields
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
<h1 class="mb-6 text-2xl font-semibold text-gray-900 dark:text-gray-100">Reset Password</h1>
|
||||
|
||||
{#if form?.error}
|
||||
<div class="mb-4 rounded-lg border border-red-200 bg-red-50 p-3 text-red-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300">
|
||||
<div
|
||||
class="mb-4 rounded-lg border border-red-200 bg-red-50 p-3 text-red-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
||||
>
|
||||
{form.error}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -89,8 +89,7 @@ describe('reset-password page server action', () => {
|
||||
resetPassword.mockReset();
|
||||
});
|
||||
|
||||
const invokeDefault = (url: URL, request: Request) =>
|
||||
actions.default({ request, url } as any);
|
||||
const invokeDefault = (url: URL, request: Request) => actions.default({ request, url } as any);
|
||||
|
||||
it('returns fail(400) when token is missing', async () => {
|
||||
const url = createUrl('/reset-password');
|
||||
@@ -120,10 +119,7 @@ describe('reset-password page server action', () => {
|
||||
it('returns fail(400) when password is empty', async () => {
|
||||
const url = createUrl('/reset-password', { token: 'token-1' });
|
||||
|
||||
const result = await invokeDefault(
|
||||
url,
|
||||
createFormRequest({ password: '', password2: '' })
|
||||
);
|
||||
const result = await invokeDefault(url, createFormRequest({ password: '', password2: '' }));
|
||||
expect(isActionFailure(result)).toBe(true);
|
||||
if (isActionFailure(result)) {
|
||||
expect(result.data).toEqual({ error: 'Password must be at least 8 characters.' });
|
||||
@@ -181,10 +177,7 @@ describe('reset-password page server action', () => {
|
||||
const url = createUrl('/reset-password', { token: 'token-1' });
|
||||
|
||||
const err = await Promise.resolve(
|
||||
invokeDefault(
|
||||
url,
|
||||
createFormRequest({ password: 'longenough1', password2: 'longenough1' })
|
||||
)
|
||||
invokeDefault(url, createFormRequest({ password: 'longenough1', password2: 'longenough1' }))
|
||||
).catch((e: unknown) => e);
|
||||
expect(isRedirect(err)).toBe(true);
|
||||
if (isRedirect(err)) {
|
||||
|
||||
Reference in New Issue
Block a user