Still refactoring...

This commit is contained in:
Eric van der Vlist 2023-02-24 20:35:12 +01:00
parent f4ba7afb69
commit b375cfbdd7
2 changed files with 8 additions and 23 deletions

View File

@ -94,31 +94,14 @@ const User: Component<Props> = (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 () => {

View File

@ -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 () => {
<main>
<h1>User</h1>
<CheckCredentials>
<Show when={!!user()}>
<User values={user} />
</Show>
</CheckCredentials>
</main>
);