mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-08 14:35:49 +01:00
💄 Improve steps in user creation page
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Button, Card, Flex, Group, PasswordInput } from '@mantine/core';
|
import { Button, Card, Flex, Group, PasswordInput } from '@mantine/core';
|
||||||
import { useForm, zodResolver } from '@mantine/form';
|
import { useForm, zodResolver } from '@mantine/form';
|
||||||
import { IconArrowLeft, IconArrowRight, IconPassword } from '@tabler/icons-react';
|
import { IconArrowLeft, IconArrowRight, IconDice, IconKey } from '@tabler/icons-react';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
interface CreateAccountSecurityStepProps {
|
interface CreateAccountSecurityStepProps {
|
||||||
@@ -23,22 +23,25 @@ export const CreateAccountSecurityStep = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card mih={400}>
|
<Card mih={400}>
|
||||||
<Flex columnGap={10}>
|
<Flex columnGap={10} align="start">
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
icon={<IconPassword size="0.8rem" />}
|
icon={<IconKey size="0.8rem" />}
|
||||||
|
style={{
|
||||||
|
flexGrow: 1,
|
||||||
|
}}
|
||||||
label="Password"
|
label="Password"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
mb="md"
|
mb="md"
|
||||||
withAsterisk
|
withAsterisk
|
||||||
style={{
|
|
||||||
flexGrow: 1,
|
|
||||||
}}
|
|
||||||
{...form.getInputProps('password')}
|
{...form.getInputProps('password')}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
leftIcon={<IconDice size="1rem" />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
form.setFieldValue('password', randomString());
|
form.setFieldValue('password', randomString());
|
||||||
}}
|
}}
|
||||||
|
variant="default"
|
||||||
|
mt="xl"
|
||||||
>
|
>
|
||||||
Generate random
|
Generate random
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
import { Button, Card, Flex, Group, Stepper, Text, TextInput } from '@mantine/core';
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Flex,
|
||||||
|
Group,
|
||||||
|
PasswordInput,
|
||||||
|
Stepper,
|
||||||
|
Table,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
} from '@mantine/core';
|
||||||
import { useForm, zodResolver } from '@mantine/form';
|
import { useForm, zodResolver } from '@mantine/form';
|
||||||
import {
|
import {
|
||||||
IconArrowRight,
|
IconArrowLeft,
|
||||||
IconAt,
|
|
||||||
IconCheck,
|
IconCheck,
|
||||||
IconLock,
|
IconInfoCircle,
|
||||||
|
IconKey,
|
||||||
|
IconMail,
|
||||||
IconMailCheck,
|
IconMailCheck,
|
||||||
IconPremiumRights,
|
|
||||||
IconSignRight,
|
|
||||||
IconUser,
|
IconUser,
|
||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
@@ -49,10 +59,13 @@ const CreateNewUserPage = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const context = api.useContext();
|
const context = api.useContext();
|
||||||
const { mutateAsync, isSuccess } = api.user.createUser.useMutation({
|
const { mutateAsync, isSuccess, isLoading } = api.user.createUser.useMutation({
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
void context.user.getAll.invalidate();
|
void context.user.getAll.invalidate();
|
||||||
}
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
nextStep();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -79,7 +92,7 @@ const CreateNewUserPage = () => {
|
|||||||
<Stepper.Step
|
<Stepper.Step
|
||||||
allowStepClick={false}
|
allowStepClick={false}
|
||||||
allowStepSelect={false}
|
allowStepSelect={false}
|
||||||
icon={<IconLock />}
|
icon={<IconKey />}
|
||||||
label="Second step"
|
label="Second step"
|
||||||
description="Password"
|
description="Password"
|
||||||
>
|
>
|
||||||
@@ -99,10 +112,64 @@ const CreateNewUserPage = () => {
|
|||||||
description="Save to database"
|
description="Save to database"
|
||||||
>
|
>
|
||||||
<Card mih={400}>
|
<Card mih={400}>
|
||||||
<Text>
|
<Title order={5}>Review your inputs</Title>
|
||||||
User creation has been prepared. Do you want to create the user and store it in the
|
<Text mb="xl">
|
||||||
database?
|
After you submit your data to the database, the user will be able to log in. Are you
|
||||||
|
sure that you want to store this user in the database and activate the login?
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
<Table mb="lg" withBorder highlightOnHover>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Property</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Group spacing="xs">
|
||||||
|
<IconUser size="1rem" />
|
||||||
|
<Text>Username</Text>
|
||||||
|
</Group>
|
||||||
|
</td>
|
||||||
|
<td>{form.values.account.username}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Group spacing="xs">
|
||||||
|
<IconMail size="1rem" />
|
||||||
|
<Text>E-Mail</Text>
|
||||||
|
</Group>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{form.values.account.eMail ? (
|
||||||
|
<Text>{form.values.account.eMail}</Text>
|
||||||
|
) : (
|
||||||
|
<Group spacing="xs">
|
||||||
|
<IconInfoCircle size="1rem" color="orange" />
|
||||||
|
<Text color="orange">Not set</Text>
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Group spacing="xs">
|
||||||
|
<IconKey size="1rem" />
|
||||||
|
<Text>Password</Text>
|
||||||
|
</Group>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Group spacing="xs">
|
||||||
|
<IconCheck size="1rem" color="green" />
|
||||||
|
<Text color="green">Valid</Text>
|
||||||
|
</Group>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
<Flex justify="end" wrap="nowrap">
|
<Flex justify="end" wrap="nowrap">
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -116,18 +183,30 @@ const CreateNewUserPage = () => {
|
|||||||
email: form.values.account.eMail === '' ? undefined : form.values.account.eMail,
|
email: form.values.account.eMail === '' ? undefined : form.values.account.eMail,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
component={Link}
|
loading={isLoading}
|
||||||
href="/manage/users"
|
|
||||||
rightIcon={<IconCheck size="1rem" />}
|
rightIcon={<IconCheck size="1rem" />}
|
||||||
variant="light"
|
variant="light"
|
||||||
px="xl"
|
px="xl"
|
||||||
>
|
>
|
||||||
Finish
|
Confirm
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Card>
|
</Card>
|
||||||
</Stepper.Step>
|
</Stepper.Step>
|
||||||
<Stepper.Completed>Completed, click back button to get to previous step</Stepper.Completed>
|
<Stepper.Completed>
|
||||||
|
<Alert title="User was created" color="green" mb="md">
|
||||||
|
User has been created in the database. They can now log in.
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
component={Link}
|
||||||
|
leftIcon={<IconArrowLeft size="1rem" />}
|
||||||
|
variant="default"
|
||||||
|
href="/manage/users"
|
||||||
|
>
|
||||||
|
Go back to users
|
||||||
|
</Button>
|
||||||
|
</Stepper.Completed>
|
||||||
</Stepper>
|
</Stepper>
|
||||||
</MainLayout>
|
</MainLayout>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user