From 8ad1c63acc6bf4a74c93b0a4f6ef1f9b211fb0f3 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Thu, 11 Jul 2024 20:49:06 +0200 Subject: [PATCH] . --- client/package.json | 1 + client/src/App.tsx | 1 + client/src/app/quotes/edit.tsx | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/package.json b/client/package.json index dd50aa8..f6d3835 100644 --- a/client/package.json +++ b/client/package.json @@ -58,6 +58,7 @@ "react-day-picker": "^8.10.1", "react-dom": "^18.2.0", "react-hook-form": "^7.51.5", + "react-hook-form-persist": "^3.0.0", "react-i18next": "^14.1.2", "react-resizable-panels": "^2.0.19", "react-router-dom": "^6.23.1", diff --git a/client/src/App.tsx b/client/src/App.tsx index 2aa71da..5afdf39 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -4,6 +4,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; import { Suspense } from "react"; import { ToastContainer } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; import { Routes } from "./Routes"; import { LoadingOverlay, TailwindIndicator } from "./components"; import { createAxiosAuthActions, createAxiosDataProvider } from "./lib/axios"; diff --git a/client/src/app/quotes/edit.tsx b/client/src/app/quotes/edit.tsx index 77cbf69..c1efbdc 100644 --- a/client/src/app/quotes/edit.tsx +++ b/client/src/app/quotes/edit.tsx @@ -13,7 +13,9 @@ import { CurrencyData, IUpdateQuote_Request_DTO, MoneyValue } from "@shared/cont import { t } from "i18next"; import { useEffect, useState } from "react"; import { SubmitHandler, useForm } from "react-hook-form"; +import useFormPersist from "react-hook-form-persist"; import { useNavigate } from "react-router-dom"; +import { toast } from "react-toastify"; import { QuoteDetailsCardEditor, QuoteGeneralCardEditor } from "./components/editors"; import { useQuotes } from "./hooks"; @@ -90,6 +92,9 @@ export const QuoteEdit = () => { }); const { watch, getValues, setValue, formState } = form; + + const { clear } = useFormPersist("quote-edit", { watch, setValue, storage: window.localStorage }); + const { isSubmitting } = formState; const onSubmit: SubmitHandler = async (data) => { @@ -101,7 +106,8 @@ export const QuoteEdit = () => { }, //onSettled: () => {}, onSuccess: () => { - //alert("guardado"); + toast("Guardado!"); + clear(); }, }); }; @@ -209,7 +215,7 @@ export const QuoteEdit = () => { {t("quotes.create.tabs.general")} {t("quotes.create.tabs.items")} - {t("quotes.create.tabs.history")} + {/* {t("quotes.create.tabs.history")}*/}