Add back button to create account step

This commit is contained in:
Manuel
2023-08-21 21:15:56 +02:00
parent 3623d871f8
commit 480b27fea7
2 changed files with 27 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ export const OnboardingSteps = ({ isUpdate }: { isUpdate: boolean }) => {
</Stepper.Step> </Stepper.Step>
)} )}
<Stepper.Step label="Your account" description="Create an account"> <Stepper.Step label="Your account" description="Create an account">
<StepCreateAccount next={nextStep} /> <StepCreateAccount next={nextStep} previous={prevStep} />
</Stepper.Step> </Stepper.Step>
<Stepper.Step label="Docker import" description="Import applications from Docker"> <Stepper.Step label="Docker import" description="Import applications from Docker">
<StepDockerImport next={nextStep} /> <StepDockerImport next={nextStep} />

View File

@@ -1,5 +1,6 @@
import { Button, PasswordInput, Stack, TextInput, Title } from '@mantine/core'; import { Button, Group, PasswordInput, Stack, TextInput, Title } from '@mantine/core';
import { useForm } from '@mantine/form'; import { useForm } from '@mantine/form';
import { IconArrowLeft, IconArrowRight } from '@tabler/icons-react';
import { signIn } from 'next-auth/react'; import { signIn } from 'next-auth/react';
import { useState } from 'react'; import { useState } from 'react';
import { z } from 'zod'; import { z } from 'zod';
@@ -9,7 +10,13 @@ import { signUpFormSchema } from '~/validations/user';
import { OnboardingStepWrapper } from './common-wrapper'; import { OnboardingStepWrapper } from './common-wrapper';
export const StepCreateAccount = ({ next }: { next: () => void }) => { export const StepCreateAccount = ({
previous,
next,
}: {
previous: () => void;
next: () => void;
}) => {
const [isSigninIn, setIsSigninIn] = useState(false); const [isSigninIn, setIsSigninIn] = useState(false);
const { mutateAsync } = api.user.createOwnerAccount.useMutation(); const { mutateAsync } = api.user.createOwnerAccount.useMutation();
const { i18nZodResolver } = useI18nZodResolver(); const { i18nZodResolver } = useI18nZodResolver();
@@ -43,14 +50,13 @@ export const StepCreateAccount = ({ next }: { next: () => void }) => {
<Title order={2} align="center" mb="md"> <Title order={2} align="center" mb="md">
Create your administrator account Create your administrator account
</Title> </Title>
<form <form onSubmit={form.onSubmit(handleSubmit)}>
onSubmit={form.onSubmit(handleSubmit)}
>
<Stack> <Stack>
<TextInput <TextInput
size="md" size="md"
w="100%" w="100%"
label="Username" label="Username"
variant="filled"
withAsterisk withAsterisk
{...form.getInputProps('username')} {...form.getInputProps('username')}
/> />
@@ -59,6 +65,7 @@ export const StepCreateAccount = ({ next }: { next: () => void }) => {
size="md" size="md"
w="100%" w="100%"
label="Password" label="Password"
variant="filled"
withAsterisk withAsterisk
{...form.getInputProps('password')} {...form.getInputProps('password')}
/> />
@@ -67,12 +74,23 @@ export const StepCreateAccount = ({ next }: { next: () => void }) => {
size="md" size="md"
w="100%" w="100%"
label="Confirm password" label="Confirm password"
variant="filled"
withAsterisk withAsterisk
{...form.getInputProps('passwordConfirmation')} {...form.getInputProps('passwordConfirmation')}
/> />
<Button disabled={!form.isValid()} mt="sm" fullWidth type="submit" loading={isSigninIn}> <Group grow>
Continue <Button onClick={previous} leftIcon={<IconArrowLeft size="0.9rem" />} variant="default">
</Button> Back
</Button>
<Button
rightIcon={<IconArrowRight size="0.9rem" />}
disabled={!form.isValid()}
type="submit"
loading={isSigninIn}
>
Continue
</Button>
</Group>
</Stack> </Stack>
</form> </form>
</OnboardingStepWrapper> </OnboardingStepWrapper>