From b1a5bf902d7b19bf3707f1179ffbcf656e18a0f2 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Fri, 5 Apr 2024 11:19:17 +0200 Subject: [PATCH] feat: added loader to create-production --- src/components/landing-page/create-production.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/landing-page/create-production.tsx b/src/components/landing-page/create-production.tsx index f8fe0cd0..9d8c0ffd 100644 --- a/src/components/landing-page/create-production.tsx +++ b/src/components/landing-page/create-production.tsx @@ -13,6 +13,7 @@ import { } from "./form-elements.tsx"; import { API } from "../../api/api.ts"; import { useGlobalState } from "../../global-state/context-provider.tsx"; +import { Loader } from "../loader/loader.tsx"; type FormValues = { productionName: string; @@ -33,6 +34,7 @@ export const CreateProduction = () => { const [createdProductionId, setCreatedProductionId] = useState( null ); + const [loading, setLoading] = useState(false); const { formState: { errors }, control, @@ -49,6 +51,7 @@ export const CreateProduction = () => { }); const onSubmit: SubmitHandler = (value) => { + setLoading(true); API.createProduction({ name: value.productionName, lines: [{ name: value.defaultLine }, ...value.lines], @@ -76,6 +79,10 @@ export const CreateProduction = () => { } }, [createdProductionId, dispatch, reset]); + if (loading) { + return ; + } + return ( Create Production