refactor: Update UserCreateStepperComponent
To use ErrorDisplay component
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback, useMemo, useState } from "react";
|
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Card,
|
Card,
|
||||||
@@ -12,12 +11,14 @@ import {
|
|||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { IconUserCheck } from "@tabler/icons-react";
|
import { IconUserCheck } from "@tabler/icons-react";
|
||||||
|
import { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import { clientApi } from "@homarr/api/client";
|
import { clientApi } from "@homarr/api/client";
|
||||||
import { useForm, zodResolver } from "@homarr/form";
|
import { useForm, zodResolver } from "@homarr/form";
|
||||||
import { useScopedI18n } from "@homarr/translation/client";
|
import { useScopedI18n } from "@homarr/translation/client";
|
||||||
import { validation, z } from "@homarr/validation";
|
import { validation, z } from "@homarr/validation";
|
||||||
|
|
||||||
|
import { ErrorDisplay } from "~/components/utils";
|
||||||
import { StepperNavigationComponent } from "./stepper-navigation.component";
|
import { StepperNavigationComponent } from "./stepper-navigation.component";
|
||||||
|
|
||||||
export const UserCreateStepperComponent = () => {
|
export const UserCreateStepperComponent = () => {
|
||||||
@@ -38,7 +39,8 @@ export const UserCreateStepperComponent = () => {
|
|||||||
const hasNext = active < stepperMax;
|
const hasNext = active < stepperMax;
|
||||||
const hasPrevious = active > 0;
|
const hasPrevious = active > 0;
|
||||||
|
|
||||||
const { mutateAsync, isPending } = clientApi.user.create.useMutation();
|
const { mutateAsync, isPending, isError, error } =
|
||||||
|
clientApi.user.create.useMutation();
|
||||||
|
|
||||||
const generalForm = useForm({
|
const generalForm = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@@ -107,6 +109,7 @@ export const UserCreateStepperComponent = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Title mb="md">{t("title")}</Title>
|
<Title mb="md">{t("title")}</Title>
|
||||||
|
<ErrorDisplay hidden={!isError} message={error?.message} my="lg" />
|
||||||
<Stepper
|
<Stepper
|
||||||
active={active}
|
active={active}
|
||||||
onStepClick={setActive}
|
onStepClick={setActive}
|
||||||
|
|||||||
Reference in New Issue
Block a user