This commit is contained in:
David Arranz 2024-07-10 12:41:00 +02:00
parent b2a8073007
commit 95882ee10d
4 changed files with 46 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import { Badge, Card, CardContent } from "@/ui"; import { Badge, Button, Card, CardContent } from "@/ui";
import { DataTableSkeleton, ErrorOverlay, SimpleEmptyState } from "@/components"; import { DataTableSkeleton, ErrorOverlay, SimpleEmptyState } from "@/components";
@ -9,6 +9,7 @@ import { IListQuotes_Response_DTO, MoneyValue, UTCDateValue } from "@shared/cont
import { ColumnDef } from "@tanstack/react-table"; import { ColumnDef } from "@tanstack/react-table";
import { t } from "i18next"; import { t } from "i18next";
import { useMemo } from "react"; import { useMemo } from "react";
import { Trans } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useQuotesList } from "../hooks"; import { useQuotesList } from "../hooks";
@ -31,7 +32,6 @@ export const QuotesDataTable = () => {
accessor: "date", accessor: "date",
header: () => <>{t("quotes.list.columns.date")}</>, header: () => <>{t("quotes.list.columns.date")}</>,
cell: ({ table, row: { index, original }, column, getValue }) => { cell: ({ table, row: { index, original }, column, getValue }) => {
console.log(original.date);
const quoteDate = UTCDateValue.create(original.date); const quoteDate = UTCDateValue.create(original.date);
return quoteDate.isSuccess ? quoteDate.object.toLocaleDateString("es-ES") : "-"; return quoteDate.isSuccess ? quoteDate.object.toLocaleDateString("es-ES") : "-";
}, },
@ -42,8 +42,17 @@ export const QuotesDataTable = () => {
id: "customer_information" as const, id: "customer_information" as const,
accessorKey: "customer_information", accessorKey: "customer_information",
header: () => <>{t("quotes.list.columns.customer_information")}</>, header: () => <>{t("quotes.list.columns.customer_information")}</>,
cell: ({ renderValue }: { renderValue: () => any }) => ( cell: ({ row: { original } }) => (
<div className='font-semibold'>{renderValue()}</div> <div className='text-ellipsis'>
{original.customer_information.split("\n").map((item, index) => {
return (
<span className={index === 0 ? "font-semibold" : "font-medium"}>
{item}
<br />
</span>
);
})}
</div>
), ),
enableResizing: false, enableResizing: false,
size: 10, size: 10,
@ -76,6 +85,24 @@ export const QuotesDataTable = () => {
enableResizing: false, enableResizing: false,
size: 20, size: 20,
}, },
{
id: "edit-acion",
header: () => null,
cell: ({ row, table }: { row: Row<TData>; table: Table<TData> }) => (
<Button
variant='secondary'
onClick={(e) => {
e.preventDefault();
navigate(`/quotes/edit/${row.original.id}`, { relative: "path", replace: true });
}}
>
<Trans i18nKey={"common.edit"} />
<span className='sr-only'>, {row.original.id}</span>
</Button>
),
enableResizing: false,
size: 20,
},
], ],
[] []
); );

View File

@ -31,7 +31,8 @@
"duplicate_rows_tooltip": "Duplica las fila(s) seleccionadas(s)", "duplicate_rows_tooltip": "Duplica las fila(s) seleccionadas(s)",
"pick_date": "Elige una fecha", "pick_date": "Elige una fecha",
"required_field": "Este campo es obligatorio", "required_field": "Este campo es obligatorio",
"unsaved_changes_prompt": "Los últimos cambios no se han guardado. Si continúas, se perderán" "unsaved_changes_prompt": "Los últimos cambios no se han guardado. Si continúas, se perderán",
"edit": "Editar"
}, },
"main_menu": { "main_menu": {
"home": "Inicio", "home": "Inicio",
@ -134,9 +135,9 @@
"placeholder": "" "placeholder": ""
}, },
"customer_information": { "customer_information": {
"label": "Cliente", "label": "Datos del cliente",
"desc": "Datos del cliente de esta cotización", "desc": "Escriba el nombre del cliente en la primera línea, la direccion en la segunda y el código postal y ciudad en la tercera.",
"placeholder": "Nombre\nDirección\n..." "placeholder": "Nombre y apellidos\nCalle y número\nCódigo postal y ciudad..."
}, },
"payment_method": { "payment_method": {
"label": "Forma de pago", "label": "Forma de pago",

View File

@ -1,24 +1,23 @@
import * as React from "react" import * as React from "react";
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils";
export interface TextareaProps export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>( const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
({ className, ...props }, ref) => { ({ className, ...props }, ref) => {
return ( return (
<textarea <textarea
className={cn( className={cn(
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className className
)} )}
ref={ref} ref={ref}
{...props} {...props}
/> />
) );
} }
) );
Textarea.displayName = "Textarea" Textarea.displayName = "Textarea";
export { Textarea } export { Textarea };

View File

@ -14,6 +14,8 @@
"joi": "^17.12.3", "joi": "^17.12.3",
"joi-phone-number": "^5.1.1", "joi-phone-number": "^5.1.1",
"shallow-equal-object": "^1.1.1", "shallow-equal-object": "^1.1.1",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2",
"uuid": "^9.0.1" "uuid": "^9.0.1"
}, },
"devDependencies": { "devDependencies": {