From f5b205f90cc943522c2ce2bd6237ac903a478967 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Thu, 9 Nov 2023 11:38:36 +0100 Subject: [PATCH 1/2] api/clients.post (checkIsClient): Fix opposite condition for the patch parameter. previously, when patch was true, it was requiring the values in the fields. and vice versa. It turns out the "patch" variable was negated for some reason. --- server/api/clients.post.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/api/clients.post.ts b/server/api/clients.post.ts index 97df465..486e35b 100644 --- a/server/api/clients.post.ts +++ b/server/api/clients.post.ts @@ -28,10 +28,10 @@ export function checkIsClient( }); } - if (!(typeof value.name === "string" || value.name === null || (!patch && value.name === undefined))) errors.set("name", "is not string or null"); - if (!(typeof value.address === "string" || value.address === null || (!patch && value.address === undefined))) errors.set("address", "is not string or null"); - if (!(typeof value.phone === "string" || value.phone === null || (!patch && value.phone === undefined))) errors.set("phone", "is not string or null"); - if (!(typeof value.email === "string" || value.email === null || (!patch && value.email === undefined))) errors.set("email", "is not string or null"); + if (!(typeof value.name === "string" || value.name === null || (patch && value.name === undefined))) errors.set("name", "is not string or null"); + if (!(typeof value.address === "string" || value.address === null || (patch && value.address === undefined))) errors.set("address", "is not string or null"); + if (!(typeof value.phone === "string" || value.phone === null || (patch && value.phone === undefined))) errors.set("phone", "is not string or null"); + if (!(typeof value.email === "string" || value.email === null || (patch && value.email === undefined))) errors.set("email", "is not string or null"); for (const i in value as Partial>) if (!clientKeys.includes(i)) errors.set(i, `excessive property`); From 500a9ad59505c7b9d005b36e5f0c4b59d390332c Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Thu, 9 Nov 2023 11:35:12 +0100 Subject: [PATCH 2/2] page/client: Don't default form to undefined. This fixes an issue when user does not click the form field. it is not being defined, meaning the field will not be updated. --- pages/client/[id].vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/client/[id].vue b/pages/client/[id].vue index b64c240..ee7f852 100644 --- a/pages/client/[id].vue +++ b/pages/client/[id].vue @@ -55,10 +55,10 @@ function updatePagedListVModel(element: Array) { const editMode = ref(route.query?.edit === "1"); function editorFields(): Array { return [ - { key: "name", type: "text", label: "Name", value: client.value.name ?? undefined }, - { key: "address", type: "text", label: "Address", value: client.value.address ?? undefined }, - { key: "phone", type: "text", label: "Phone", value: client.value.phone ?? undefined }, - { key: "email", type: "text", label: "E-mail", value: client.value.email ?? undefined }, + { key: "name", type: "text", label: "Name", value: client.value.name ?? "" }, + { key: "address", type: "text", label: "Address", value: client.value.address ?? "" }, + { key: "phone", type: "text", label: "Phone", value: client.value.phone ?? "" }, + { key: "email", type: "text", label: "E-mail", value: client.value.email ?? "" }, ]; }