From b375cfbdd758dfa8c7a3b9bfe261c7f617a7d0e5 Mon Sep 17 00:00:00 2001 From: evlist Date: Fri, 24 Feb 2023 20:35:12 +0100 Subject: [PATCH] Still refactoring... --- src/components/user/User.tsx | 25 ++++--------------------- src/routes/user/[id].tsx | 6 ++++-- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/components/user/User.tsx b/src/components/user/User.tsx index 05b86a0..a0013ed 100644 --- a/src/components/user/User.tsx +++ b/src/components/user/User.tsx @@ -94,31 +94,14 @@ const User: Component = (props) => { return errors; }; + const credentials = adminCredentials(); + const { database } = credentials || { database: null }; + const { form, data, setData, setInitialValues, reset } = createForm({ onSubmit: submitHandler, extend: reporter(), validate: validationHandler, - initialValues: getValues(), - }); - - createEffect(() => { - console.log({ caller: 'user / createEffect', values: getValues() }); - if (isNew()) { - const credentials = adminCredentials(); - if (!credentials) { - return; - } - const { database } = credentials; - setData('database', database); - } else { - setInitialValues(getValues()); - reset(); - console.log({ - caller: 'user / createEffect', - values: getValues(), - data: data(), - }); - } + initialValues: getValues() || { database }, }); const createUserHandler = async () => { diff --git a/src/routes/user/[id].tsx b/src/routes/user/[id].tsx index 0d58370..13430ec 100644 --- a/src/routes/user/[id].tsx +++ b/src/routes/user/[id].tsx @@ -1,6 +1,6 @@ import { useParams } from 'solid-start'; import User from '~/components/user'; -import { createEffect, createSignal } from 'solid-js'; +import { createEffect, createSignal, Show } from 'solid-js'; import { adminCredentials, CheckCredentials } from '~/components/credentials'; import { get } from '~/lib/get'; @@ -23,7 +23,9 @@ export default () => {

User

- + + +
);