Skip to content

Commit

Permalink
fix setup wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey committed Nov 7, 2024
1 parent b10fa04 commit 177f773
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/lib/components/admin/InviteUser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
let showUrl = $state(true);
$effect(() => {
$inspect(form);
if (form?.success && form?.sent !== undefined && config.smtp.enable) {
let toastConfig: ToastSettings;
if (form?.sent) {
Expand Down
6 changes: 1 addition & 5 deletions src/routes/setup-wizard/step/[step]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
$state.current = Number.parseInt($page.params.step) - 1;
});
$effect(() => {
if ($page.form?.success) next();
});
const next = () => {
if ($state.current + 1 < $state.total) {
$state.current = $state.current + 1;
Expand All @@ -43,7 +39,7 @@
</script>

<div transition:fade>
<SvelteComponent />
<SvelteComponent onSuccess={next} />

<div class="flex justify-between pt-4">
<!-- Button: Back -->
Expand Down
12 changes: 11 additions & 1 deletion src/routes/setup-wizard/step/[step]/CreateAccountStep.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import { getContext } from "svelte";
import type { Writable } from "svelte/store";
interface Props {
onSuccess: () => void;
}
let { onSuccess }: Props = $props();
let form: HTMLFormElement | undefined = $state();
const submit: Writable<() => void> = getContext("submit");
Expand All @@ -21,7 +26,12 @@
action="/signup"
method="POST"
use:enhance={() => {
return async ({ result }) => await applyAction(result);
return async ({ result }) => {
await applyAction(result);
if (result.type === "success" && result.data?.success) {
onSuccess();
}
};
}}
>
<CreateAccountForm hideActions />
Expand Down
8 changes: 8 additions & 0 deletions src/routes/setup-wizard/step/[step]/GlobalSettingsStep.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import { getContext } from "svelte";
import type { Writable } from "svelte/store";
interface Props {
onSuccess: () => void;
}
let { onSuccess }: Props = $props();
let config: Config = $state($page.data.config);
let form: HTMLFormElement | undefined = $state();
let sending = $state(false);
Expand Down Expand Up @@ -42,6 +47,9 @@
}

await applyAction(result);
if (result.type === "success" && result.data?.success) {
onSuccess();
}
};
}}
>
Expand Down
12 changes: 11 additions & 1 deletion src/routes/setup-wizard/step/[step]/InviteUsersStep.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import InviteUser from "$lib/components/admin/InviteUser.svelte";
import type { Group } from "@prisma/client";
interface Props {
onSuccess: () => void;
}
let { onSuccess }: Props = $props();
let config: Config = $derived($page.data.config);
const groups: Group[] = $page.data.groups;
</script>
Expand All @@ -19,7 +24,12 @@
action="/admin/users"
method="POST"
use:enhance={() => {
return async ({ result }) => await applyAction(result);
return async ({ result }) => {
await applyAction(result);
if (result.type === "success" && result.data?.success) {
onSuccess();
}
};
}}
>
<InviteUser {config} defaultGroup={groups[0]} vertical />
Expand Down

0 comments on commit 177f773

Please sign in to comment.