Skip to content

Commit

Permalink
add project operation schema for archival etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Oct 30, 2024
1 parent 53c621d commit 24070cb
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { redirect } from '@sveltejs/kit';
import { prisma } from 'sil.appbuilder.portal.common';
import { pruneProjects } from '$lib/projects/common';
import type { PageServerLoad } from './$types';
import { superValidate } from 'sveltekit-superforms';
import { valibot } from 'sveltekit-superforms/adapters';
import * as v from 'valibot';
import { idSchema } from '$lib/valibot';

const bulkProjectOperationSchema = v.object({
operation: v.picklist(['archive', 'reactivate', 'rebuild/republish']),
projects: v.array(v.object({ Id: idSchema, OwnerId: idSchema, Archived: v.boolean() }))
});

export const load = (async ({ params, url, locals }) => {
const userId = (await locals.auth())?.user.userId;
Expand Down Expand Up @@ -53,5 +62,7 @@ export const load = (async ({ params, url, locals }) => {
}
});
// TODO: Likely need to paginate
return { projects: pruneProjects(projects) };
return { projects: pruneProjects(projects), form: superValidate({
operation: 'rebuild/republish'
}, valibot(bulkProjectOperationSchema)) };
}) satisfies PageServerLoad;

0 comments on commit 24070cb

Please sign in to comment.