From 608169c2b9462823b8adcf1f83c00d97f982cc47 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Mon, 12 Aug 2024 12:54:43 +0200 Subject: [PATCH] . --- .../QuoteItemsSortableDataTableToolbar.tsx | 140 ++---------------- .../editors/QuoteDetailsCardEditor.tsx | 8 +- client/src/app/quotes/edit.tsx | 113 -------------- client/src/locales/en.json | 3 +- client/src/locales/es.json | 2 +- 5 files changed, 21 insertions(+), 245 deletions(-) diff --git a/client/src/app/quotes/components/QuoteItemsSortableDataTableToolbar.tsx b/client/src/app/quotes/components/QuoteItemsSortableDataTableToolbar.tsx index 6f41c66..629cc59 100644 --- a/client/src/app/quotes/components/QuoteItemsSortableDataTableToolbar.tsx +++ b/client/src/app/quotes/components/QuoteItemsSortableDataTableToolbar.tsx @@ -1,31 +1,7 @@ -import { - Button, - DropdownMenu, - DropdownMenuCheckboxItem, - DropdownMenuContent, - DropdownMenuTrigger, - Popover, - PopoverContent, - PopoverTrigger, - Separator, - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/ui"; +import { Button, Separator, Tooltip, TooltipContent, TooltipTrigger } from "@/ui"; import { Table } from "@tanstack/react-table"; import { t } from "i18next"; -import { - CalendarIcon, - CirclePlusIcon, - ClockIcon, - CopyPlusIcon, - ForwardIcon, - MoreVerticalIcon, - ReplyAllIcon, - ReplyIcon, - ScanIcon, - Trash2Icon, -} from "lucide-react"; +import { CirclePlusIcon, CopyPlusIcon, PackagePlusIcon, ScanIcon, Trash2Icon } from "lucide-react"; export const QuoteItemsSortableDataTableToolbar = ({ table }: { table: Table }) => { const selectedRowsCount = table.getSelectedRowModel().rows.length; @@ -89,112 +65,24 @@ export const QuoteItemsSortableDataTableToolbar = ({ table }: { table: Table - - Añadir fila + {t("common.append_empty_row_tooltip")} - - - - - - - - - -
-
Snooze until
-
- - - - -
-
-
- -
-
-
- Snooze + + + + {t("common.append_article_tooltip")}
-
- - - - - Reply - - - - - - Reply all - - - - - - Forward - -
- - - - - - - {table.getAllColumns().map((column) => { - return ( - column.toggleVisibility(!!value)} - > - {column.id} - - ); - })} - - +
); }; diff --git a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx index 1620458..adaa719 100644 --- a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx +++ b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx @@ -164,15 +164,15 @@ export const QuoteDetailsCardEditor = ({ const { table, row } = props; return [ { - label: "Duplicar", + label: t("common.duplicate_rows"), onClick: () => table.options.meta?.duplicateItems(row.index), }, { - label: "Insertar fila encima", + label: t("common.insert_row_above"), onClick: () => table.options.meta?.insertItem(row.index), }, { - label: "Insertar fila debajo", + label: t("common.insert_row_below"), onClick: () => table.options.meta?.insertItem(row.index + 1), }, @@ -180,7 +180,7 @@ export const QuoteDetailsCardEditor = ({ label: "-", }, { - label: "Eliminar", + label: t("common.remove_row"), shortcut: "⌘⌫", onClick: () => { table.options.meta?.deleteItems(row.index); diff --git a/client/src/app/quotes/edit.tsx b/client/src/app/quotes/edit.tsx index 5e376d8..ed37b3d 100644 --- a/client/src/app/quotes/edit.tsx +++ b/client/src/app/quotes/edit.tsx @@ -19,10 +19,6 @@ import { QuotePricesResume } from "./components"; import { QuoteDetailsCardEditor, QuoteGeneralCardEditor } from "./components/editors"; import { useQuotes } from "./hooks"; -/*type QuoteDataForm = Omit & { - items: IGetQuote_QuoteItem_Response_DTO; -};*/ - type QuoteDataForm = IGetQuote_Response_DTO; // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -37,15 +33,6 @@ export const QuoteEdit = () => { ); const [quoteLanguage, setQuoteLanguage] = useState(Language.createDefaultCode().object); - /*const { data: userIdentity } = useGetIdentity(); - console.log(userIdentity); - - const { flag } = useLocalization({ - locale: userIdentity?.language ?? "es-es", - }); - - console.log(flag);*/ - const { useOne, useUpdate } = useQuotes(); const { data, status, error: queryError } = useOne(quoteId); @@ -159,106 +146,6 @@ export const QuoteEdit = () => { }); }; - /* useEffect(() => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { unsubscribe } = watch((_, { name, type }) => { - const value = getValues(); - - console.log(name); - - if (name) { - if (name === "currency_code") { - setQuoteCurrency( - CurrencyData.createFromCode(value.currency_code ?? CurrencyData.DEFAULT_CURRENCY_CODE) - .object - ); - } - - if (name === "lang_code") { - setQuoteLanguage( - Language.createFromCode(value.lang_code ?? Language.DEFAULT_LANGUAGE_CODE).object - ); - } - - if (name === "items") { - console.log(">> Recalculo todas las líneas"); - const { items } = value; - - let quoteSubtotal = MoneyValue.create({ - amount: 0, - scale: 4, - }).object; - - // Recálculo líneas - items && - items.map((item, index) => { - const itemTotals = calculateQuoteItemTotals(item); - quoteSubtotal = quoteSubtotal.add(itemTotals.totalPrice); - setValue(`items.${index}.subtotal_price`, itemTotals.subtotalPrice.toObject()); - setValue(`items.${index}.total_price`, itemTotals.totalPrice.toObject()); - }); - - // Recálculo completo - setValue("subtotal_price", quoteSubtotal.convertScale(2).toObject()); - } - - if (name.endsWith("quantity") || name.endsWith("unit_price") || name.endsWith("discount")) { - console.group(">>>>>>>>>>>>>"); - - const { items } = value; - - const [, indexString, fieldName] = String(name).split("."); - const index = parseInt(indexString); - - console.group(">> Voy a recalcular la línea ", index, items[index]); - - const itemTotals_1 = calculateQuoteItemTotals(items[index]); - setValue(`items.${index}.subtotal_price`, itemTotals_1.subtotalPrice.toObject()); - setValue(`items.${index}.total_price`, itemTotals_1.totalPrice.toObject()); - - console.log(">> Total de la línea -> ", index, itemTotals_1.subtotalPrice.toObject()); - - console.groupEnd(); - - // Recálculo completo - let quoteSubtotal = MoneyValue.create({ - amount: 0, - scale: 4, - }).object; - - console.group(">> Recalculo todas las líneas"); - - items && - items.map((item, itemIndex) => { - const itemTotals_2 = calculateQuoteItemTotals(item); - - console.log( - ">> Recalculo la linea ", - itemIndex, - itemTotals_2.subtotalPrice.toObject() - ); - - quoteSubtotal = quoteSubtotal.add(itemTotals_2.totalPrice); - setValue(`items.${itemIndex}.subtotal_price`, itemTotals_2.subtotalPrice.toObject()); - setValue(`items.${itemIndex}.total_price`, itemTotals_2.totalPrice.toObject()); - }); - - console.log( - ">> Gruardo el total en la cabecera ", - quoteSubtotal.convertScale(2).toObject() - ); - - // Recálculo completo - setValue("subtotal_price", quoteSubtotal.convertScale(2).toObject()); - console.groupEnd(); - - console.groupEnd(); - } - } - }); - return () => unsubscribe(); - }, [watch, getValues, setValue]);*/ - useEffect(() => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { unsubscribe } = watch((_, { name, type }) => { diff --git a/client/src/locales/en.json b/client/src/locales/en.json index 65cb259..d4f1c08 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -95,8 +95,9 @@ "subtitle": "", "tabs": { "all": "All", + "emitted": "Emitted", "draft": "Draft", - "archived": "Archive" + "archived": "Archived" }, "columns": { "date": "Date", diff --git a/client/src/locales/es.json b/client/src/locales/es.json index ea80853..4722395 100644 --- a/client/src/locales/es.json +++ b/client/src/locales/es.json @@ -95,8 +95,8 @@ "subtitle": "", "tabs": { "all": "Todas", - "draft": "Borradores", "emitted": "Emitidas", + "draft": "Borradores", "archived": "Archivadas" }, "columns": {