From 2ac383f0dfb1d5215e250e0377096b73a6477446 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Mon, 26 Aug 2024 17:53:58 +0200 Subject: [PATCH] . --- .../app/quotes/components/QuotesDataTable.tsx | 16 ++++++++------ client/src/app/quotes/edit.tsx | 22 +++++++++++++------ client/src/locales/en.json | 1 + client/src/locales/es.json | 1 + 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/client/src/app/quotes/components/QuotesDataTable.tsx b/client/src/app/quotes/components/QuotesDataTable.tsx index 6befe70..8e04cef 100644 --- a/client/src/app/quotes/components/QuotesDataTable.tsx +++ b/client/src/app/quotes/components/QuotesDataTable.tsx @@ -253,15 +253,17 @@ export const QuotesDataTable = ({ ); } - console.log(data); - if (data?.total_items === 0 && !isFiltered) { return ( - navigate("add", { relative: "path" })} - /> + + + navigate("add", { relative: "path" })} + /> + + ); } diff --git a/client/src/app/quotes/edit.tsx b/client/src/app/quotes/edit.tsx index 931799a..9c5197f 100644 --- a/client/src/app/quotes/edit.tsx +++ b/client/src/app/quotes/edit.tsx @@ -13,7 +13,7 @@ import { Button, Form, Tabs, TabsContent, TabsList, TabsTrigger } from "@/ui"; import { CurrencyData, IGetQuote_Response_DTO, Language } from "@shared/contexts"; import { t } from "i18next"; import { useEffect, useMemo, useState } from "react"; -import { SubmitHandler, useForm } from "react-hook-form"; +import { useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import { toast } from "react-toastify"; import { QuotePricesResume } from "./components"; @@ -130,7 +130,7 @@ export const QuoteEdit = () => { isDirty, }); - const onSubmit: SubmitHandler = async (data) => { + const onSubmit = async (data: QuoteDataForm, shouldRedirect: boolean) => { // Transformación del form -> typo de request mutate(data, { @@ -143,6 +143,9 @@ export const QuoteEdit = () => { onSuccess: () => { reset(getValues()); toast.success("Cotización guardada"); + if (shouldRedirect) { + navigate("/quotes"); + } //clear(); }, }); @@ -240,7 +243,7 @@ export const QuoteEdit = () => { return (
- + onSubmit(data, false))}>
@@ -252,19 +255,24 @@ export const QuoteEdit = () => {
navigate("/quotes")} /> + +
diff --git a/client/src/locales/en.json b/client/src/locales/en.json index bd44bf8..36e3b44 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -6,6 +6,7 @@ "no": "No", "yes": "Yes", "save": "Save", + "save_close": "Save and Close", "accept": "OK", "discard": "Discard", "hide": "Hide", diff --git a/client/src/locales/es.json b/client/src/locales/es.json index febe514..f3a8e8b 100644 --- a/client/src/locales/es.json +++ b/client/src/locales/es.json @@ -6,6 +6,7 @@ "no": "No", "yes": "Sí", "save": "Guardar", + "save_close": "Guardar y Cerrar", "accept": "Aceptar", "discard": "Decartar", "hide": "Ocultar",