diff --git a/client/src/app/quotes/components/QuotesDataTable.tsx b/client/src/app/quotes/components/QuotesDataTable.tsx
index 865d095..53ac225 100644
--- a/client/src/app/quotes/components/QuotesDataTable.tsx
+++ b/client/src/app/quotes/components/QuotesDataTable.tsx
@@ -1,12 +1,12 @@
-import { Card, CardContent } from "@/ui";
+import { Badge, Card, CardContent } from "@/ui";
import { DataTableSkeleton, ErrorOverlay, SimpleEmptyState } from "@/components";
import { DataTable } from "@/components";
import { DataTableToolbar } from "@/components/DataTable/DataTableToolbar";
import { useDataTable, useDataTableContext } from "@/lib/hooks";
-import { IListQuotes_Response_DTO, MoneyValue } from "@shared/contexts";
-import { ColumnDef, Row } from "@tanstack/react-table";
+import { IListQuotes_Response_DTO, MoneyValue, UTCDateValue } from "@shared/contexts";
+import { ColumnDef } from "@tanstack/react-table";
import { t } from "i18next";
import { useMemo } from "react";
import { useNavigate } from "react-router-dom";
@@ -27,47 +27,51 @@ export const QuotesDataTable = () => {
const columns = useMemo
[]>(
() => [
{
- id: "id" as const,
- accessorKey: "id",
+ id: "date" as const,
+ accessor: "date",
+ header: () => <>{t("quotes.list.columns.date")}>,
+ cell: ({ table, row: { index, original }, column, getValue }) => {
+ console.log(original.date);
+ const quoteDate = UTCDateValue.create(original.date);
+ return quoteDate.isSuccess ? quoteDate.object.toLocaleDateString("es-ES") : "-";
+ },
enableResizing: false,
size: 10,
},
{
- id: "article_id" as const,
- accessorKey: "id_article",
- enableResizing: false,
- size: 10,
- },
- {
- id: "catalog_name" as const,
- accessorKey: "catalog_name",
- enableResizing: false,
- size: 10,
- },
- {
- id: "description" as const,
- accessorKey: "description",
- header: () => <>{t("catalog.list.columns.description")}>,
- enableResizing: false,
- size: 100,
- },
- {
- id: "points" as const,
- accessorKey: "points",
- header: () => {t("catalog.list.columns.points")}
,
+ id: "customer_information" as const,
+ accessorKey: "customer_information",
+ header: () => <>{t("quotes.list.columns.customer_information")}>,
cell: ({ renderValue }: { renderValue: () => any }) => (
- {renderValue()}
+ {renderValue()}
),
enableResizing: false,
- size: 20,
+ size: 10,
},
{
- id: "retail_price" as const,
- accessorKey: "retail_price",
- header: () => {t("catalog.list.columns.retail_price")}
,
- cell: ({ row }: { row: Row }) => {
- const price = MoneyValue.create(row.original.retail_price).object;
- return {price.toFormat()}
;
+ id: "reference" as const,
+ accessorKey: "reference",
+ header: () => <>{t("quotes.list.columns.reference")}>,
+ enableResizing: false,
+ size: 10,
+ },
+ {
+ id: "status" as const,
+ accessorKey: "status",
+ header: () => <>{t("quotes.list.columns.status")}>,
+ cell: ({ renderValue }: { renderValue: () => any }) => {renderValue()},
+ enableResizing: false,
+ size: 10,
+ },
+ {
+ id: "total_price" as const,
+ accessor: "total_price",
+ header: () => {t("quotes.list.columns.total_price")}
,
+ cell: ({ table, row: { index, original }, column, getValue }) => {
+ const price = MoneyValue.create(original.total_price);
+ return (
+ {price.isSuccess ? price.object.toFormat() : "-"}
+ );
},
enableResizing: false,
size: 20,
diff --git a/client/src/components/Buttons/CustomButton.tsx b/client/src/components/Buttons/CustomButton.tsx
index 7ef594d..54c54ef 100644
--- a/client/src/components/Buttons/CustomButton.tsx
+++ b/client/src/components/Buttons/CustomButton.tsx
@@ -19,17 +19,21 @@ const customButtonVariants = cva("", {
});
export interface CustomButtonProps extends ButtonProps, VariantProps {
- icon: LucideIcon; // Propiedad para proporcionar el icono personalizado
+ icon?: LucideIcon; // Propiedad para proporcionar el icono personalizado
label?: string;
}
const CustomButton = React.forwardRef(
- ({ className, label, size, icon: Icon, children, ...props }, ref) => (
-
- )
+ ({ className, label, size, icon: Icon, children, ...props }, ref) => {
+ const hasIcon = !!Icon;
+
+ return (
+
+ );
+ }
);
CustomButton.displayName = "CustomButton";
diff --git a/client/src/components/Buttons/SubmitButton.tsx b/client/src/components/Buttons/SubmitButton.tsx
index 224a3df..46a3e7f 100644
--- a/client/src/components/Buttons/SubmitButton.tsx
+++ b/client/src/components/Buttons/SubmitButton.tsx
@@ -1,13 +1,12 @@
import { ButtonProps } from "@/ui";
-import { SaveIcon } from "lucide-react";
import { CustomButton } from "./CustomButton";
export interface SubmitButtonProps extends ButtonProps {
label?: string;
}
-export const SubmitButton = ({ label = "Guardar", ...props }: SubmitButtonProps) => (
-
+export const SubmitButton = ({ label = "Enviar", ...props }: SubmitButtonProps) => (
+
);
SubmitButton.displayName = "SubmitButton";
diff --git a/client/src/components/Forms/FormSubmitButton.tsx b/client/src/components/Forms/FormSubmitButton.tsx
new file mode 100644
index 0000000..2bab82b
--- /dev/null
+++ b/client/src/components/Forms/FormSubmitButton.tsx
@@ -0,0 +1,11 @@
+import { useFormState } from "react-hook-form";
+import { SubmitButton, SubmitButtonProps } from "../Buttons";
+
+export interface FromSubmitButtonProps extends SubmitButtonProps {}
+
+export const FormSubmitButton = (props: FromSubmitButtonProps) => {
+ const { isSubmitting, isLoading, isValidating } = useFormState();
+ return ;
+};
+
+FormSubmitButton.displayName = "FormSubmitButton";
diff --git a/client/src/components/ProtectedRoute/ProtectedRoute.tsx b/client/src/components/ProtectedRoute/ProtectedRoute.tsx
index 76062ae..bc4a897 100644
--- a/client/src/components/ProtectedRoute/ProtectedRoute.tsx
+++ b/client/src/components/ProtectedRoute/ProtectedRoute.tsx
@@ -10,13 +10,6 @@ type ProctectRouteProps = {
export const ProtectedRoute = ({ children }: ProctectRouteProps) => {
const { isPending, isSuccess, data: { authenticated, redirectTo } = {} } = useIsLoggedIn();
- console.debug("ProtectedRouter", {
- isPending,
- isSuccess,
- authenticated,
- redirectTo,
- });
-
if (isPending) {
return ;
}
diff --git a/client/src/locales/es.json b/client/src/locales/es.json
index 0eae66f..5702ee7 100644
--- a/client/src/locales/es.json
+++ b/client/src/locales/es.json
@@ -76,7 +76,14 @@
},
"quotes": {
"list": {
- "title": "Cotizaciones"
+ "title": "Cotizaciones",
+ "columns": {
+ "date": "Fecha",
+ "reference": "Referencia",
+ "status": "Estado",
+ "customer_information": "Cliente",
+ "total_price": "Imp. total"
+ }
},
"status": {
"draft": "Borrador"
diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts
index b35524d..17f6803 100644
--- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts
+++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts
@@ -11,12 +11,12 @@ export const CreateQuotePresenter: ICreateQuotePresenter = {
map: (quote: Quote, context: ISalesContext): ICreateQuote_Response_DTO => {
return {
id: quote.id.toString(),
- //reference: quote.refe
+ reference: quote.reference.toString(),
status: quote.status.toString(),
- date: quote.date.toString(),
+ date: quote.date.toISO8601(),
lang_code: quote.language.toString(),
currency_code: quote.currency.toString(),
- customer_information: quote.customer,
+ customer_information: quote.customer.toString(),
subtotal: {
amount: 0,
precision: 2,
diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts
index b6caac0..db72bae 100644
--- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts
+++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts
@@ -16,10 +16,10 @@ export const GetQuotePresenter: IGetQuotePresenter = {
return {
id: quote.id.toString(),
status: quote.status.toString(),
- date: quote.date.toString(),
+ date: quote.date.toISO8601(),
reference: quote.reference.toString(),
customer_information: quote.customer.toString(),
- lang_code: quote.language.code,
+ lang_code: quote.language.toString(),
currency_code: quote.currency.toString(),
payment_method: quote.paymentMethod.toString(),
diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/listQuotes/presenter/ListQuotes.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/listQuotes/presenter/ListQuotes.presenter.ts
index 342d3e4..90f9b02 100644
--- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/listQuotes/presenter/ListQuotes.presenter.ts
+++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/listQuotes/presenter/ListQuotes.presenter.ts
@@ -20,10 +20,10 @@ export const ListQuotesPresenter: IListQuotesPresenter = {
return {
id: quote.id.toString(),
status: quote.status.toString(),
- date: quote.date.toString(),
+ date: quote.date.toISO8601(),
reference: quote.reference.toString(),
customer_information: quote.customer.toString(),
- lang_code: quote.date.toISO8601(),
+ lang_code: quote.language.toString(),
currency_code: quote.currency.toString(),
subtotal: {
diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts
index a413e45..fc1d41d 100644
--- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts
+++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts
@@ -12,20 +12,22 @@ export const UpdateQuotePresenter: IUpdateQuotePresenter = {
return {
id: quote.id.toString(),
status: quote.status.toString(),
- date: quote.date.toString(),
- language_code: quote.date.toString(),
+ date: quote.date.toISO8601(),
+ reference: quote.reference.toString(),
+ customer_information: quote.customer.toString(),
+ lang_code: quote.language.toString(),
currency_code: quote.currency.toString(),
- subtotal: {
- amount: 0,
- precision: 2,
- currency: "EUR",
- },
- total: {
- amount: 0,
- precision: 2,
- currency: "EUR",
- },
+
+ payment_method: quote.paymentMethod.toString(),
+ validity: quote.validity.toString(),
+ notes: quote.notes.toString(),
+
+ subtotal_price: quote.subtotalPrice.toObject(),
+ discount: quote.discount.toObject(),
+ total_price: quote.totalPrice.toObject(),
+
items: quoteItemPresenter(quote.items, context),
+ dealer_id: quote.dealerId.toString(),
};
},
};
@@ -34,23 +36,12 @@ export const UpdateQuotePresenter: IUpdateQuotePresenter = {
const quoteItemPresenter = (items: ICollection, context: ISalesContext) =>
items.totalCount > 0
? items.items.map((item: QuoteItem) => ({
+ article_id: item.articleId,
description: item.description.toString(),
- quantity: item.quantity.toString(),
- unit_measure: "",
- unit_price: {
- amount: 0,
- precision: 2,
- currency: "EUR",
- },
- subtotal: {
- amount: 0,
- precision: 2,
- currency: "EUR",
- },
- total: {
- amount: 0,
- precision: 2,
- currency: "EUR",
- },
+ quantity: item.quantity.toObject(),
+ unit_price: item.unitPrice.toObject(),
+ subtotal_price: item.subtotalPrice.toObject(),
+ discount: item.discount.toObject(),
+ total_price: item.totalPrice.toObject(),
}))
: [];
diff --git a/shared/lib/contexts/common/domain/entities/UTCDateValue.ts b/shared/lib/contexts/common/domain/entities/UTCDateValue.ts
index 9785fbc..cb1051c 100644
--- a/shared/lib/contexts/common/domain/entities/UTCDateValue.ts
+++ b/shared/lib/contexts/common/domain/entities/UTCDateValue.ts
@@ -55,7 +55,25 @@ export class UTCDateValue extends ValueObject {
return this.isValid() ? this.props.toISOString() : "";
};
+ public toDateString = (): string => {
+ // Tue Jul 09 2024
+ return this.isValid() ? this.props.toDateString() : "";
+ };
+
+ public toLocaleDateString = (
+ locales?: Intl.LocalesArgument,
+ options?: Intl.DateTimeFormatOptions
+ ): string => {
+ // DD/MM/YYYY
+ return this.isValid() ? this.props.toLocaleDateString(locales, options) : "";
+ };
+
+ public toLocaleTimeString = (): string => {
+ return this.isValid() ? this.props.toLocaleTimeString() : "";
+ };
+
public toString(): string {
+ // YYYY-MM-DD
if (!this.isEmpty()) {
const year = this.props.getFullYear();
const month = String(this.props.getMonth() + 1).padStart(2, "0");
diff --git a/shared/lib/contexts/sales/application/dto/Quote/ListQuotes.dto/IListQuotes_Response.dto.ts b/shared/lib/contexts/sales/application/dto/Quote/ListQuotes.dto/IListQuotes_Response.dto.ts
index 62b88f1..4944478 100644
--- a/shared/lib/contexts/sales/application/dto/Quote/ListQuotes.dto/IListQuotes_Response.dto.ts
+++ b/shared/lib/contexts/sales/application/dto/Quote/ListQuotes.dto/IListQuotes_Response.dto.ts
@@ -1,4 +1,4 @@
-import { IQuantuty_Response_DTO } from "../../../../../common";
+import { IMoney_Response_DTO } from "../../../../../common";
export interface IListQuotes_Response_DTO {
id: string;
@@ -9,6 +9,6 @@ export interface IListQuotes_Response_DTO {
lang_code: string;
currency_code: string;
- subtotal: IQuantuty_Response_DTO;
- total: IQuantuty_Response_DTO;
+ subtotal_price: IMoney_Response_DTO;
+ total_price: IMoney_Response_DTO;
}