all the haul
This commit is contained in:
@@ -37,13 +37,13 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||
try {
|
||||
const rolesResult = await optima.users.fetchRoles(
|
||||
accessToken,
|
||||
user.id,
|
||||
user.id
|
||||
);
|
||||
return { ...user, roleDetails: rolesResult?.data ?? [] };
|
||||
} catch {
|
||||
return { ...user, roleDetails: [] };
|
||||
}
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -66,21 +66,30 @@ export const actions: Actions = {
|
||||
|
||||
const formData = await request.formData();
|
||||
const id = (formData.get("id") as string)?.trim();
|
||||
const name = (formData.get("name") as string)?.trim();
|
||||
const firstName = (formData.get("firstName") as string)?.trim();
|
||||
const lastName = (formData.get("lastName") as string)?.trim();
|
||||
const image = (formData.get("image") as string)?.trim() || undefined;
|
||||
const rolesJson = (formData.get("roles") as string)?.trim();
|
||||
const permissionsJson = (formData.get("permissions") as string)?.trim();
|
||||
|
||||
if (!id || !name) {
|
||||
return fail(400, { message: "User ID and name are required." });
|
||||
if (!id) {
|
||||
return fail(400, { message: "User ID is required." });
|
||||
}
|
||||
|
||||
const updates: {
|
||||
name: string;
|
||||
firstName?: string | null;
|
||||
lastName?: string | null;
|
||||
image?: string;
|
||||
roles?: string[];
|
||||
permissions?: string[];
|
||||
} = { name, image };
|
||||
} = { image };
|
||||
|
||||
if (formData.has("firstName")) {
|
||||
updates.firstName = firstName || null;
|
||||
}
|
||||
if (formData.has("lastName")) {
|
||||
updates.lastName = lastName || null;
|
||||
}
|
||||
|
||||
if (rolesJson) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user