From 1c9c4f896c566964e37902bebed6024438fe5023 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 25 Jul 2023 14:07:38 +0200 Subject: [PATCH] :sparkles: Updating deed types informations --- .../Layouts/DeedTypes/DeedTypesEdit/index.tsx | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx b/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx index 7b05fc31..fa27ed15 100644 --- a/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx +++ b/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx @@ -1,15 +1,16 @@ import DeedTypes from "@Front/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes"; +import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Form from "@Front/Components/DesignSystem/Form"; +import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField"; +import TextField from "@Front/Components/DesignSystem/Form/TextField"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard"; +import Module from "@Front/Config/Module"; import { DeedType } from "le-coffre-resources/dist/Admin"; import { useRouter } from "next/router"; import { useCallback, useEffect, useState } from "react"; import classes from "./classes.module.scss"; -import TextField from "@Front/Components/DesignSystem/Form/TextField"; -import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField"; -import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; export default function DeedTypesEdit() { const router = useRouter(); @@ -31,7 +32,27 @@ export default function DeedTypesEdit() { getDeedType(); }, [deedTypeUid]); - const onSubmitHandler = useCallback(async (e: React.FormEvent | null, values: { [key: string]: string }) => {}, []); + const onSubmitHandler = useCallback( + async (e: React.FormEvent | null, values: { [key: string]: string }) => { + try { + await DeedTypes.getInstance().put( + deedTypeUid as string, + DeedType.hydrate({ + name: values["name"], + description: values["description"], + }), + ); + router.push( + Module.getInstance() + .get() + .modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string), + ); + } catch (e) { + console.error(e); + } + }, + [deedTypeUid, router], + ); return (