Skip to content

Commit

Permalink
Value trimmed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexter committed Nov 1, 2023
1 parent d6cc1a5 commit 7ed50b5
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/routes/m/[identifier]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
PersonStore,
EditPersonStore,
type auth_person_set_input,
type Person$result
} from '$houdini';
import { PersonStore, EditPersonStore, type auth_person_set_input } from '$houdini';
import { fail } from '@sveltejs/kit';
import type { Actions } from './$types';
import type { PageServerLoad } from './$types';
Expand Down Expand Up @@ -40,17 +35,19 @@ export const actions: Actions = {
const formData = await event.request.formData();

const { id: userId, ...dirtyData } = Object.fromEntries(
Array.from(formData.entries()).filter(([key, value]) => {
if (key === 'password' && value === '') return false;
if (key === 'id') return true;
Array.from(formData.entries())
.filter(([key, value]) => {
if (key === 'password' && value === '') return false;
if (key === 'id') return true;

if (person[key as keyof typeof person] !== value) return true;
})
if (person[key as keyof typeof person] !== value) return true;
})
.map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value])
) as auth_person_set_input;

// Fix all boolean keys

for (let [key, value] of Object.entries(person)) {
for (const [key, value] of Object.entries(person)) {
if (typeof value === 'boolean') {
const booleanKey = key as BooleanKey;
dirtyData[booleanKey] = booleanKey in dirtyData;
Expand Down

0 comments on commit 7ed50b5

Please sign in to comment.