fix(onboarding): return to welcome before administrator creation (#7012)

This commit is contained in:
Thomas authored and GitHub committed 2026-10-03 22:34:05 +02:00
1 parent b40f000dd5
commit 83ae98847a
3 files changed
+55 -6

No files matched your search

+33 -4
View File
@@ -2,7 +2,7 @@
import { useEffect, useRef, useState } from "react";
import { Alert, Button, Stack, Text, TextInput } from "@mantine/core";
import { IconArrowRight, IconShieldCheck, IconUserPlus } from "@tabler/icons-react";
import { IconArrowLeft, IconArrowRight, IconShieldCheck, IconUserPlus } from "@tabler/icons-react";
import type { z } from "zod/v4";
import { clientApi } from "@homarr/api/client";
@@ -36,11 +36,12 @@ const AccountShell = ({
);
export const AccountSetup = ({ environment }: OnboardingStudioProps) => {
if (environment.currentStep === "user") return <CredentialsSetup />;
if (environment.currentStep === "user") return <CredentialsSetup canReturnToWelcome={!environment.hasUsers} />;
return <ExternalGroupSetup />;
};
const CredentialsSetup = () => {
const CredentialsSetup = ({ canReturnToWelcome }: { canReturnToWelcome: boolean }) => {
const navigationT = useI18n("init.studio");
const t = useI18n("init.studio.account");
const [requiresSignIn, setRequiresSignIn] = useState(false);
const [submitError, setSubmitError] = useState<string | null>(null);
@@ -54,6 +55,16 @@ const CredentialsSetup = () => {
showErrorNotification({ title: t("errorTitle"), message });
},
});
const returnToWelcome = clientApi.onboard.returnToWelcome.useMutation({
async onSuccess() {
sounds.swoosh();
await revalidatePathActionAsync("/init");
},
onError() {
sounds.error();
showErrorNotification({ title: t("errorTitle"), message: t("unknownError") });
},
});
const form = useZodForm(userInitSchema, {
initialValues: { username: "", password: "", confirmPassword: "" },
});
@@ -119,9 +130,27 @@ const CredentialsSetup = () => {
{submitError}
</Alert>
) : null}
<Button type="submit" size="md" loading={form.submitting} rightSection={<IconArrowRight size={18} />}>
<Button
type="submit"
size="md"
loading={form.submitting}
disabled={returnToWelcome.isPending}
rightSection={<IconArrowRight size={18} />}
>
{t("create")}
</Button>
{canReturnToWelcome && (
<Button
type="button"
variant="default"
leftSection={<IconArrowLeft size={18} />}
loading={returnToWelcome.isPending}
disabled={form.submitting}
onClick={() => returnToWelcome.mutate()}
>
{navigationT("back")}
</Button>
)}
</Stack>
</form>
</AccountShell>