Still refactoring...
This commit is contained in:
parent
f4ba7afb69
commit
b375cfbdd7
|
@ -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 () => {
|
||||
|
|
|
@ -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>
|
||||
<User values={user} />
|
||||
<Show when={!!user()}>
|
||||
<User values={user} />
|
||||
</Show>
|
||||
</CheckCredentials>
|
||||
</main>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue