moved user sanitation to helper.js
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { BASE_API_URI } from "$lib/utils/constants";
|
import { BASE_API_URI } from "$lib/utils/constants";
|
||||||
import { formatError } from "$lib/utils/helpers";
|
import { formatError, userDatesFromRFC3339 } from "$lib/utils/helpers";
|
||||||
import { fail, redirect } from "@sveltejs/kit";
|
import { fail, redirect } from "@sveltejs/kit";
|
||||||
import { toRFC3339 } from "$lib/utils/utils";
|
import { toRFC3339 } from "$lib/utils/helpers";
|
||||||
|
|
||||||
/** @type {import('./$types').PageServerLoad} */
|
/** @type {import('./$types').PageServerLoad} */
|
||||||
export async function load({ locals, params }) {
|
export async function load({ locals, params }) {
|
||||||
@@ -36,6 +36,7 @@ export const actions = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
/** @type {Partial<App.Locals['user']>} */
|
/** @type {Partial<App.Locals['user']>} */
|
||||||
const updateData = {
|
const updateData = {
|
||||||
id: Number(formData.get("id")),
|
id: Number(formData.get("id")),
|
||||||
@@ -111,31 +112,7 @@ export const actions = {
|
|||||||
|
|
||||||
const response = await res.json();
|
const response = await res.json();
|
||||||
locals.user = response;
|
locals.user = response;
|
||||||
|
userDatesFromRFC3339(locals.user);
|
||||||
// Format dates
|
|
||||||
if (locals.user.date_of_birth) {
|
|
||||||
locals.user.date_of_birth = response.date_of_birth.split("T")[0];
|
|
||||||
}
|
|
||||||
if (locals.user.membership?.start_date) {
|
|
||||||
locals.user.membership.start_date =
|
|
||||||
locals.user.membership.start_date.split("T")[0];
|
|
||||||
}
|
|
||||||
if (locals.user.membership?.end_date) {
|
|
||||||
locals.user.membership.end_date =
|
|
||||||
locals.user.membership.end_date.split("T")[0];
|
|
||||||
}
|
|
||||||
if (locals.user.bank_account?.mandate_date_signed) {
|
|
||||||
locals.user.bank_account.mandate_date_signed =
|
|
||||||
locals.user.bank_account.mandate_date_signed.split("T")[0];
|
|
||||||
}
|
|
||||||
if (locals.user.licence?.issued_date) {
|
|
||||||
locals.user.licence.issued_date =
|
|
||||||
locals.user.licence.issued_date.split("T")[0];
|
|
||||||
}
|
|
||||||
if (locals.user.licence?.expiration_date) {
|
|
||||||
locals.user.licence.expiration_date =
|
|
||||||
locals.user.licence.expiration_date.split("T")[0];
|
|
||||||
}
|
|
||||||
throw redirect(303, `/auth/about/${response.id}`);
|
throw redirect(303, `/auth/about/${response.id}`);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user