@@ -112,13 +135,15 @@ export const QuotesDataTable = ({
id: "customer_reference" as const,
accessorKey: "customer_reference",
header: () => <>{t("quotes.list.columns.customer_reference")}>,
- cell: ({ renderValue }) =>
{renderValue()}
,
+ cell: ({ renderValue }: { renderValue: () => any }) => (
+
{renderValue()}
+ ),
},
{
id: "customer_information" as const,
accessorKey: "customer_information",
header: () => <>{t("quotes.list.columns.customer_information")}>,
- cell: ({ row: { original } }) => (
+ cell: ({ row: { original } }: { row: { original: IListQuotes_Response_DTO } }) => (
{original.customer_information.split("\n").map((item, index) => {
return (
@@ -164,7 +189,7 @@ export const QuotesDataTable = ({
className='h-8 gap-1'
onClick={(e) => {
e.preventDefault();
- navigate(`/quotes/edit/${row.original.id}`, { relative: "path" });
+ handleEditQuote(row.original);
}}
>
@@ -205,33 +230,18 @@ export const QuotesDataTable = ({
return preview ? columns : [...columns, ...actionColumn];
}, [preview]);
- const handleOnPaginationChange = () => {
- //setActiveRow(undefined);
- };
-
const { table } = useDataTable({
data: data?.items ?? [],
columns: columns,
pageCount: data?.total_pages ?? -1,
- onPaginationChange: handleOnPaginationChange,
});
- const handleOnRowClick = (row: Row
) => {
- setActiveRow(row);
- };
-
useEffect(() => {
if (table && data && data?.total_pages > 0) {
setActiveRow(table.getRowModel().rows[0]);
}
}, [data, table]);
- const handleFinishDownload = useCallback(() => {
- toast({
- description: t("quotes.downloading_dialog.toast_success"),
- });
- }, [toast]);
-
if (isError) {
return ;
}
@@ -287,7 +297,6 @@ export const QuotesDataTable = ({
{preview && (
- {/**/}
)}
diff --git a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor copy.tsx b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor copy.tsx
deleted file mode 100644
index 5eb65a8..0000000
--- a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor copy.tsx
+++ /dev/null
@@ -1,278 +0,0 @@
-import {
- FormCurrencyField,
- FormPercentageField,
- FormQuantityField,
- FormTextAreaField,
-} from "@/components";
-
-import { DataTableProvider } from "@/lib/hooks";
-import { cn } from "@/lib/utils";
-import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/ui";
-import { useToast } from "@/ui/use-toast";
-import { CurrencyData, Language, Quantity } from "@shared/contexts";
-import { ColumnDef } from "@tanstack/react-table";
-import { t } from "i18next";
-import { ChevronDownIcon, ChevronUpIcon, CopyIcon, Trash2Icon } from "lucide-react";
-import { useCallback, useState } from "react";
-import { useFieldArray, useFormContext } from "react-hook-form";
-import { useDetailColumns } from "../../hooks";
-import { CatalogPickerDataTable } from "../CatalogPickerDataTable";
-import { QuoteItemsSortableDataTable } from "../QuoteItemsSortableDataTable";
-import { CatalogPickerDialog } from "./CatalogPickerDialog";
-
-export const QuoteDetailsCardEditor = ({
- currency,
- language,
- defaultValues,
-}: {
- currency: CurrencyData;
- language: Language;
- defaultValues: Readonly<{ [x: string]: any }> | undefined;
-}) => {
- const { toast } = useToast();
- const { control, register } = useFormContext();
-
- const [pickerMode] = useState<"dialog" | "panel">("dialog");
-
- const [pickerDialogOpen, setPickerDialogOpen] = useState
(false);
-
- const { fields, ...fieldActions } = useFieldArray({
- control,
- name: "items",
- });
-
- const columns: ColumnDef[] = useDetailColumns(
- [
- /*{
- id: "row_id" as const,
- header: () => (
-
- ),
- accessorFn: (_: unknown, index: number) => index + 1,
- size: 5,
- enableHiding: false,
- enableSorting: false,
- enableResizing: false,
- },*/
- {
- id: "description" as const,
- accessorKey: "description",
- header: t("quotes.form_fields.items.description.label"),
- cell: ({ row: { index } }) => {
- return ;
- },
- size: 500,
- },
- {
- id: "quantity" as const,
- accessorKey: "quantity",
- header: () => (
- {t("quotes.form_fields.items.quantity.label")}
- ),
- cell: ({ row: { index } }) => {
- return (
-
- );
- },
- },
- {
- id: "unit_price" as const,
- accessorKey: "unit_price",
- header: () => (
- {t("quotes.form_fields.items.unit_price.label")}
- ),
- cell: ({ row: { index } }) => {
- return (
-
- );
- },
- },
- {
- id: "subtotal_price" as const,
- accessorKey: "subtotal_price",
- header: () => (
- {t("quotes.form_fields.items.subtotal_price.label")}
- ),
- cell: ({ row: { index } }) => {
- return (
-
- );
- },
- },
- {
- id: "discount" as const,
- accessorKey: "discount",
- header: () => (
- {t("quotes.form_fields.items.discount.label")}
- ),
- cell: ({ row: { index } }) => {
- return (
-
- );
- },
- },
- {
- id: "total_price" as const,
- accessorKey: "total_price",
- header: () => (
- {t("quotes.form_fields.items.total_price.label")}
- ),
- cell: ({ row: { index } }) => {
- return (
-
- );
- },
- },
- ],
- {
- enableDragHandleColumn: false, // <--- Desactivado temporalmente
- enableSelectionColumn: true,
- enableActionsColumn: true,
- rowActionFn: (props) => {
- const { table, row } = props;
- return [
- {
- label: t("common.duplicate_row"),
- icon: ,
- onClick: () => table.options.meta?.duplicateItems(row.index),
- },
- {
- label: t("common.insert_row_above"),
- icon: ,
- onClick: () => table.options.meta?.insertItem(row.index),
- },
- {
- label: t("common.insert_row_below"),
- icon: ,
- onClick: () => table.options.meta?.insertItem(row.index + 1),
- },
-
- {
- label: "-",
- },
- {
- label: t("common.remove_row"),
- //shortcut: "⌘⌫",
- icon: ,
- onClick: () => {
- table.options.meta?.deleteItems(row.index);
- },
- },
- ];
- },
- }
- );
-
- const handleAppendCatalogArticle = useCallback(
- (article: any) => {
- fieldActions.append({
- ...article,
- quantity: {
- amount: 100,
- scale: Quantity.DEFAULT_SCALE,
- },
- unit_price: article.retail_price,
- discount: {
- amount: null,
- scale: 2,
- },
- });
- toast({
- title: t("quotes.catalog_picker_dialog.toast_article_added"),
- description: article.description,
- });
- },
- [fieldActions]
- );
-
- const [isCollapsed, setIsCollapsed] = useState(false);
-
- const defaultLayout = [265, 440, 655];
- const navCollapsedSize = 4;
-
- if (pickerMode === "dialog") {
- return (
-
- setPickerDialogOpen(true),
- }}
- columns={columns}
- data={fields}
- defaultValues={defaultValues}
- />
-
-
- );
- }
-
- return (
-
- {
- setIsCollapsed(true);
- }}
- onExpand={() => {
- setIsCollapsed(false);
- }}
- className={cn(isCollapsed && "min-w-[50px] transition-all duration-300 ease-in-out")}
- >
-
-
-
-
-
-
-
-
-
- );
-};
diff --git a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx
index 5eb65a8..fa9f11a 100644
--- a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx
+++ b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx
@@ -17,7 +17,7 @@ import { useCallback, useState } from "react";
import { useFieldArray, useFormContext } from "react-hook-form";
import { useDetailColumns } from "../../hooks";
import { CatalogPickerDataTable } from "../CatalogPickerDataTable";
-import { QuoteItemsSortableDataTable } from "../QuoteItemsSortableDataTable";
+import { QuoteItemsSortableDataTable, RowIdData } from "../QuoteItemsSortableDataTable";
import { CatalogPickerDialog } from "./CatalogPickerDialog";
export const QuoteDetailsCardEditor = ({
@@ -41,7 +41,7 @@ export const QuoteDetailsCardEditor = ({
name: "items",
});
- const columns: ColumnDef[] = useDetailColumns(
+ const columns: ColumnDef[] = useDetailColumns(
[
/*{
id: "row_id" as const,
diff --git a/client/src/app/quotes/components/editors/QuoteDocumentsCardEditor.tsx b/client/src/app/quotes/components/editors/QuoteDocumentsCardEditor.tsx
index e448319..4861e78 100644
--- a/client/src/app/quotes/components/editors/QuoteDocumentsCardEditor.tsx
+++ b/client/src/app/quotes/components/editors/QuoteDocumentsCardEditor.tsx
@@ -9,7 +9,7 @@ export const QuoteDocumentsCardEditor = () => {
defaultUploadedFiles: [],
});*/
- const { control, register, formState } = useFormContext();
+ const { control, formState } = useFormContext();
return (
@@ -21,7 +21,7 @@ export const QuoteDocumentsCardEditor = () => {
(
+ render={() => (
Images
diff --git a/client/src/app/quotes/components/useQuoteDataTableColumns.tsx b/client/src/app/quotes/components/useQuoteDataTableColumns.tsx
index f6786e7..521eac4 100644
--- a/client/src/app/quotes/components/useQuoteDataTableColumns.tsx
+++ b/client/src/app/quotes/components/useQuoteDataTableColumns.tsx
@@ -6,7 +6,7 @@ import { Badge } from "@/ui";
import { useMemo } from "react";
export const useQuoteDataTableColumns = (
- actions: DataTablaRowActionFunction
+ actions: DataTablaRowActionFunction
): ColumnDef[] => {
const customerColumns: ColumnDef[] = useMemo(
() => [
@@ -59,8 +59,8 @@ export const useQuoteDataTableColumns = (
{
id: "actions",
header: "Acciones",
- cell: ({ row }) => {
- return ;
+ cell: (context) => {
+ return ;
},
},
],
diff --git a/client/src/app/quotes/edit.tsx b/client/src/app/quotes/edit.tsx
index 7d07603..9d7cf65 100644
--- a/client/src/app/quotes/edit.tsx
+++ b/client/src/app/quotes/edit.tsx
@@ -159,8 +159,7 @@ export const QuoteEdit = () => {
};
useEffect(() => {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { unsubscribe } = watch((_, { name, type }) => {
+ const { unsubscribe } = watch((_, { name }) => {
const quote = getValues();
if (name) {
diff --git a/client/src/app/quotes/hooks/useDetailColumns.tsx b/client/src/app/quotes/hooks/useDetailColumns.tsx
index cdf7d28..a3e68d2 100644
--- a/client/src/app/quotes/hooks/useDetailColumns.tsx
+++ b/client/src/app/quotes/hooks/useDetailColumns.tsx
@@ -4,7 +4,7 @@ import {
DataTableRowDragHandleCell,
} from "@/components";
import { Checkbox } from "@/ui";
-import { ColumnDef, Row, Table } from "@tanstack/react-table";
+import { ColumnDef, Row } from "@tanstack/react-table";
import { useMemo } from "react";
@@ -58,8 +58,7 @@ export function useDetailColumns(
/>
),
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- cell: ({ row, table }: { row: Row; table: Table }) => (
+ cell: ({ row }: { row: Row }) => (
{
+ const location = useLocation();
+
+ const isEditing = location.pathname.includes("/edit");
+
+ return (
+
+
+
+
+
+ {" "}
+
+
+
+
+ {isEditing && (
+
+
+
+ )}
+
+
+
+
+
+ );
+
return (
diff --git a/client/src/components/DataTable/DataTableRowActions.tsx b/client/src/components/DataTable/DataTableRowActions.tsx
index 9f92679..9c87aab 100644
--- a/client/src/components/DataTable/DataTableRowActions.tsx
+++ b/client/src/components/DataTable/DataTableRowActions.tsx
@@ -26,8 +26,7 @@ export type DataTableRowActionDefinition = {
onClick?: (props: CellContext, e: React.BaseSyntheticEvent) => void;
};
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export type DataTableRowActionsProps = {
+export type DataTableRowActionsProps = {
className?: string;
actions?: DataTablaRowActionFunction;
rowContext: CellContext;
@@ -36,7 +35,6 @@ export type DataTableRowActionsProps = {
export function DataTableRowActions({
actions,
rowContext,
- className,
}: DataTableRowActionsProps) {
return (
diff --git a/client/src/components/DataTable/DataTableSelectionColumn.tsx b/client/src/components/DataTable/DataTableSelectionColumn.tsx
index a50e93e..b728565 100644
--- a/client/src/components/DataTable/DataTableSelectionColumn.tsx
+++ b/client/src/components/DataTable/DataTableSelectionColumn.tsx
@@ -16,7 +16,7 @@ export function getDataTableSelectionColumn(): DataTableColumnPro
/>
),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
- cell: ({ row, table }) => (
+ cell: ({ row }) => (
{
+ output: (
+ _value: string | undefined,
+ _name?: string,
+ values?: CurrencyInputOnChangeValues
+ ) => {
const { value: amount } = values ?? { value: null };
setInputValue(amount ?? "");
@@ -103,7 +107,7 @@ export const FormCurrencyField = React.forwardRef {
+ render={({ field }) => {
return (
{label && (
diff --git a/client/src/components/Forms/FormDatePickerField.tsx b/client/src/components/Forms/FormDatePickerField.tsx
index e603bd5..aafd2a7 100644
--- a/client/src/components/Forms/FormDatePickerField.tsx
+++ b/client/src/components/Forms/FormDatePickerField.tsx
@@ -57,8 +57,7 @@ export const FormDatePickerField = React.forwardRef<
control={control}
name={name}
rules={{ required }}
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- render={({ field, fieldState, formState }) => (
+ render={({ field }) => (
{label && }
diff --git a/client/src/components/Forms/FormPercentageField.tsx b/client/src/components/Forms/FormPercentageField.tsx
index 5d11d2e..f77042a 100644
--- a/client/src/components/Forms/FormPercentageField.tsx
+++ b/client/src/components/Forms/FormPercentageField.tsx
@@ -79,7 +79,7 @@ export const FormPercentageField = React.forwardRef<
const result = percentageOrError.object.toString();
return inputValue.endsWith(",") ? result.replace(/.0$/, ",") : result;
},
- output: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => {
+ output: (_value: string | undefined, _name?: string, values?: CurrencyInputOnChangeValues) => {
const { value: amount } = values ?? { value: null };
setInputValue(amount ?? "");
diff --git a/client/src/components/Forms/FormQuantityField.tsx b/client/src/components/Forms/FormQuantityField.tsx
index 613e99e..002d266 100644
--- a/client/src/components/Forms/FormQuantityField.tsx
+++ b/client/src/components/Forms/FormQuantityField.tsx
@@ -76,7 +76,11 @@ export const FormQuantityField = React.forwardRef {
+ output: (
+ _value: string | undefined,
+ _name?: string,
+ values?: CurrencyInputOnChangeValues
+ ) => {
const { value: amount } = values ?? { value: null };
setInputValue(amount ?? "");
diff --git a/client/src/components/Forms/FormTextAreaField.tsx b/client/src/components/Forms/FormTextAreaField.tsx
index 795c2ea..ff0234c 100644
--- a/client/src/components/Forms/FormTextAreaField.tsx
+++ b/client/src/components/Forms/FormTextAreaField.tsx
@@ -75,7 +75,7 @@ export const FormTextAreaField = React.forwardRef<
name={name}
rules={{ required }}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
- render={({ field, fieldState, formState }) => (
+ render={({ field, fieldState }) => (
{label && }
diff --git a/client/src/components/PDFViewer/PDFViewer.tsx b/client/src/components/PDFViewer/PDFViewer.tsx
index 5d0efcf..1bf3bde 100644
--- a/client/src/components/PDFViewer/PDFViewer.tsx
+++ b/client/src/components/PDFViewer/PDFViewer.tsx
@@ -67,10 +67,8 @@ export const PDFViewer = ({ file, onThumbnailClick, className }: PDFViewerProps)
const goToNextPage = useCallback(() => changePage(1), [changePage]);
const goToPrevPage = useCallback(() => changePage(-1), [changePage]);
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const goToFirstPage = useCallback(() => setPageNumber(1), [setPageNumber]);
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const goToLastPage = useCallback(() => setPageNumber(numPages), [setPageNumber, numPages]);
+ //const goToFirstPage = useCallback(() => setPageNumber(1), [setPageNumber]);
+ //const goToLastPage = useCallback(() => setPageNumber(numPages), [setPageNumber, numPages]);
const isLoading = useMemo(
() => renderedPageNumber !== pageNumber,
diff --git a/client/src/components/SorteableDataTable/SortableDataTable.tsx b/client/src/components/SorteableDataTable/SortableDataTable.tsx
index 676ff9b..a9a30fe 100644
--- a/client/src/components/SorteableDataTable/SortableDataTable.tsx
+++ b/client/src/components/SorteableDataTable/SortableDataTable.tsx
@@ -1,3 +1,4 @@
+import { RowIdData } from "@/app/quotes/components/QuoteItemsSortableDataTable";
import { DataTableColumnHeader } from "@/components";
import { Badge } from "@/ui";
import {
@@ -47,11 +48,16 @@ import { SortableTableRow } from "./SortableTableRow";
declare module "@tanstack/react-table" {
interface TableMeta {
- insertItem: (rowIndex: number, data: TData) => void;
- appendItem: (data?: TData) => void;
+ insertItem: (rowIndex: number, data?: unknown) => void;
+ appendItem: (data?: unknown) => void;
duplicateItems: (rowIndex?: number) => void;
deleteItems: (rowIndex?: number | number[]) => void;
- updateItem: (rowIndex: number, rowData: TData, fieldName: string, value: unknown) => void;
+ updateItem: (
+ rowIndex: number,
+ rowData: TData & RowIdData,
+ fieldName: string,
+ value: unknown
+ ) => void;
}
}
@@ -125,8 +131,7 @@ export function SortableDataTable({ columns, data, actions }: SortableDataTableP
const [rowSelection, setRowSelection] = useState({});
const [activeId, setActiveId] = useState();
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const [columnVisibility, setColumnVisibility] = useState({});
+ const [columnVisibility, _setColumnVisibility] = useState({});
const sorteableRowIds = useMemo(() => data.map((item) => item.id), [data]);
const table = useReactTable({
@@ -149,14 +154,14 @@ export function SortableDataTable({ columns, data, actions }: SortableDataTableP
enableHiding: true,
onRowSelectionChange: setRowSelection,
getCoreRowModel: getCoreRowModel(),
- getRowId: (originalRow: unknown) => originalRow?.id,
+ getRowId: (originalRow: any) => originalRow?.id,
debugHeaders: true,
debugColumns: true,
meta: {
- insertItem: (rowIndex: number, data: object = {}) => {
+ insertItem: (rowIndex: number, data: unknown = {}) => {
actions.insert(rowIndex, data, { shouldFocus: true });
},
- appendItem: (data: object = {}) => {
+ appendItem: (data: unknown = {}) => {
actions.append(data, { shouldFocus: true });
},
duplicateItems: (rowIndex?: number) => {
@@ -168,7 +173,7 @@ export function SortableDataTable({ columns, data, actions }: SortableDataTableP
table.getSelectedRowModel().rows[table.getSelectedRowModel().rows.length - 1].index;
const data = table
.getSelectedRowModel()
- .rows.map((row) => ({ ...row.original, id: undefined }));
+ .rows.map((row: any) => ({ ...row.original, id: undefined }));
if (table.getRowModel().rows.length < lastIndex + 1) {
actions.append(data);
@@ -198,7 +203,7 @@ export function SortableDataTable({ columns, data, actions }: SortableDataTableP
actions.remove();
}
},
- updateItem: (rowIndex: number, rowData: unknown, fieldName: string, value: unknown) => {
+ updateItem: (rowIndex: number, rowData: any, fieldName: string, value: unknown) => {
// Skip page index reset until after next rerender
// skipAutoResetPageIndex();
console.log({
@@ -324,9 +329,9 @@ export function SortableDataTable({ columns, data, actions }: SortableDataTableP
items={filterItems(sorteableRowIds)}
strategy={verticalListSortingStrategy}
>
- {filterItems(table.getRowModel().rows).map((row) => (
+ {filterItems(table.getRowModel().rows).map((row: any) => (
- {row.getVisibleCells().map((cell) => (
+ {row.getVisibleCells().map((cell: any) => (
({
ref() {},
});
-function animateLayoutChanges(args) {
+function animateLayoutChanges(args: any) {
if (args.isSorting || args.wasDragging) {
return defaultAnimateLayoutChanges(args);
}
@@ -30,10 +25,7 @@ function animateLayoutChanges(args) {
return true;
}
-export function SortableTableRow({
- id,
- children,
-}: PropsWithChildren) {
+export function SortableTableRow({ id, children }: PropsWithChildren) {
const {
attributes,
isDragging,
@@ -58,7 +50,7 @@ export function SortableTableRow({
listeners,
ref: setActivatorNodeRef,
}),
- [attributes, listeners, setActivatorNodeRef],
+ [attributes, listeners, setActivatorNodeRef]
);
return (
@@ -66,10 +58,7 @@ export function SortableTableRow({
diff --git a/client/src/lib/hooks/useDataSource/useList.tsx b/client/src/lib/hooks/useDataSource/useList.tsx
index 59c1525..a53cda0 100644
--- a/client/src/lib/hooks/useDataSource/useList.tsx
+++ b/client/src/lib/hooks/useDataSource/useList.tsx
@@ -19,7 +19,7 @@ const DEFAULT_REFETCH_INTERVAL = 2 * 60 * 1000; // 2 minutes
const DEFAULT_STALE_TIME = 60 * 1000; // 1 minute
// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export type UseListQueryOptions = {
+export type UseListQueryOptions = {
queryKey: QueryKey;
queryFn: (context: QueryFunctionContext) => Promise;
enabled?: boolean;
@@ -51,8 +51,8 @@ export const useList = ({
queryKey,
queryFn,
placeholderData: keepPreviousData,
- //staleTime: DEFAULT_STALE_TIME,
- //refetchInterval: DEFAULT_REFETCH_INTERVAL,
+ staleTime: DEFAULT_STALE_TIME,
+ refetchInterval: DEFAULT_REFETCH_INTERVAL,
refetchOnWindowFocus: true,
enabled: enabled && !!queryFn,
select,
diff --git a/client/src/lib/hooks/useDataSource/useMany.tsx b/client/src/lib/hooks/useDataSource/useMany.tsx
index 51abf6d..eb49d37 100644
--- a/client/src/lib/hooks/useDataSource/useMany.tsx
+++ b/client/src/lib/hooks/useDataSource/useMany.tsx
@@ -1,10 +1,6 @@
import { QueryFunction, QueryKey, UseQueryResult, useQuery } from "@tanstack/react-query";
-export interface IUseManyQueryOptions<
- TUseManyQueryData = unknown,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- TUseManyQueryError = unknown
-> {
+export interface IUseManyQueryOptions {
queryKey: QueryKey;
queryFn: QueryFunction;
enabled?: boolean;
diff --git a/client/src/lib/hooks/useDataSource/useRemove.tsx b/client/src/lib/hooks/useDataSource/useRemove.tsx
index 4ad4f36..747c64f 100644
--- a/client/src/lib/hooks/useDataSource/useRemove.tsx
+++ b/client/src/lib/hooks/useDataSource/useRemove.tsx
@@ -2,8 +2,7 @@ import { useMutation } from "@tanstack/react-query";
export interface IUseRemoveMutationOptions<
TUseRemoveMutationData,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- TUseRemoveMutationError,
+ _TUseRemoveMutationError,
TUseRemoveMutationVariables
> {
mutationFn: (variables: TUseRemoveMutationVariables) => Promise;
diff --git a/client/src/lib/hooks/useLocalization/usePreferredLanguage.tsx b/client/src/lib/hooks/useLocalization/usePreferredLanguage.tsx
index f30d62c..6f97c46 100644
--- a/client/src/lib/hooks/useLocalization/usePreferredLanguage.tsx
+++ b/client/src/lib/hooks/useLocalization/usePreferredLanguage.tsx
@@ -3,11 +3,11 @@ import { useGetProfile } from "../useAuth";
export const usePreferredLanguage = () => {
const { data } = useGetProfile();
- if (!data || !data.language) {
+ if (!data || !data.lang_code) {
return navigator.languages && navigator.languages.length
? navigator.languages[0]
: navigator.language;
}
- return data.language;
+ return data.lang_code;
};
diff --git a/client/src/lib/hooks/useQueryKey/KeyBuilder.ts b/client/src/lib/hooks/useQueryKey/KeyBuilder.ts
index b8c81d3..88645c4 100644
--- a/client/src/lib/hooks/useQueryKey/KeyBuilder.ts
+++ b/client/src/lib/hooks/useQueryKey/KeyBuilder.ts
@@ -35,7 +35,7 @@ type KeySegment = string | IdType | IdsType | ParamsType;
export function arrayFindIndex(array: T[], slice: T[]): number {
return array.findIndex(
- (item, index) =>
+ (_, index) =>
index <= array.length - slice.length &&
slice.every((sliceItem, sliceIndex) => array[index + sliceIndex] === sliceItem)
);
diff --git a/client/src/lib/hooks/useTheme/useTheme.tsx b/client/src/lib/hooks/useTheme/useTheme.tsx
index f846bf1..c58b647 100644
--- a/client/src/lib/hooks/useTheme/useTheme.tsx
+++ b/client/src/lib/hooks/useTheme/useTheme.tsx
@@ -1,4 +1,5 @@
import { createContext, useContext, useEffect, useState } from "react";
+import secureLocalStorage from "react-secure-storage";
type Theme = "dark" | "light" | "system";
@@ -27,7 +28,7 @@ export function ThemeProvider({
...props
}: ThemeProviderProps) {
const [theme, setTheme] = useState(
- () => (localStorage.getItem(storageKey) as Theme) || defaultTheme
+ () => (secureLocalStorage.getItem(storageKey) as Theme) || defaultTheme
);
useEffect(() => {
@@ -35,8 +36,7 @@ export function ThemeProvider({
root.classList.remove("light", "dark");
if (theme === "system") {
- const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
- .matches
+ const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
@@ -50,7 +50,7 @@ export function ThemeProvider({
const value = {
theme,
setTheme: (theme: Theme) => {
- localStorage.setItem(storageKey, theme);
+ secureLocalStorage.setItem(storageKey, theme);
setTheme(theme);
},
};
@@ -65,8 +65,7 @@ export function ThemeProvider({
export const useTheme = () => {
const context = useContext(ThemeProviderContext);
- if (context === undefined)
- throw new Error("useTheme must be used within a ThemeProvider");
+ if (context === undefined) throw new Error("useTheme must be used within a ThemeProvider");
return context;
};
diff --git a/client/src/lib/hooks/useUploadFile/index.ts b/client/src/lib/hooks/useUploadFile/index.ts
deleted file mode 100644
index 7679cf1..0000000
--- a/client/src/lib/hooks/useUploadFile/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./useUploadFile";
diff --git a/client/src/lib/hooks/useUploadFile/useUploadFile.ts b/client/src/lib/hooks/useUploadFile/useUploadFile.ts
deleted file mode 100644
index db6e2ab..0000000
--- a/client/src/lib/hooks/useUploadFile/useUploadFile.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import * as React from "react";
-import { toast } from "react-toastify";
-
-import { type OurFileRouter } from "@/app/api/uploadthing/core";
-import { getErrorMessage } from "@/lib/handle-error";
-import { uploadFiles } from "@/lib/uploadthing";
-
-export interface UploadedFile {}
-
-interface UseUploadFileProps
- extends Pick<
- UploadFilesOptions,
- "headers" | "onUploadBegin" | "onUploadProgress" | "skipPolling"
- > {
- defaultUploadedFiles?: UploadedFile[];
-}
-
-export function useUploadFile(
- endpoint: keyof OurFileRouter,
- { defaultUploadedFiles = [], ...props }: UseUploadFileProps = {}
-) {
- const [uploadedFiles, setUploadedFiles] = React.useState(defaultUploadedFiles);
- const [progresses, setProgresses] = React.useState>({});
- const [isUploading, setIsUploading] = React.useState(false);
-
- async function uploadThings(files: File[]) {
- setIsUploading(true);
- try {
- const res = await uploadFiles(endpoint, {
- ...props,
- files,
- onUploadProgress: ({ file, progress }) => {
- setProgresses((prev) => {
- return {
- ...prev,
- [file]: progress,
- };
- });
- },
- });
-
- setUploadedFiles((prev) => (prev ? [...prev, ...res] : res));
- } catch (err) {
- toast.error(getErrorMessage(err));
- } finally {
- setProgresses({});
- setIsUploading(false);
- }
- }
-
- return {
- uploadedFiles,
- progresses,
- uploadFiles: uploadThings,
- isUploading,
- };
-}
diff --git a/client/src/ui/input-otp.tsx b/client/src/ui/input-otp.tsx
deleted file mode 100644
index ebf5c28..0000000
--- a/client/src/ui/input-otp.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import * as React from "react"
-import { OTPInput, OTPInputContext } from "input-otp"
-import { Dot } from "lucide-react"
-
-import { cn } from "@/lib/utils"
-
-const InputOTP = React.forwardRef<
- React.ElementRef,
- React.ComponentPropsWithoutRef
->(({ className, containerClassName, ...props }, ref) => (
-
-))
-InputOTP.displayName = "InputOTP"
-
-const InputOTPGroup = React.forwardRef<
- React.ElementRef<"div">,
- React.ComponentPropsWithoutRef<"div">
->(({ className, ...props }, ref) => (
-
-))
-InputOTPGroup.displayName = "InputOTPGroup"
-
-const InputOTPSlot = React.forwardRef<
- React.ElementRef<"div">,
- React.ComponentPropsWithoutRef<"div"> & { index: number }
->(({ index, className, ...props }, ref) => {
- const inputOTPContext = React.useContext(OTPInputContext)
- const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
-
- return (
-
- {char}
- {hasFakeCaret && (
-
- )}
-
- )
-})
-InputOTPSlot.displayName = "InputOTPSlot"
-
-const InputOTPSeparator = React.forwardRef<
- React.ElementRef<"div">,
- React.ComponentPropsWithoutRef<"div">
->(({ ...props }, ref) => (
-
-
-
-))
-InputOTPSeparator.displayName = "InputOTPSeparator"
-
-export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
diff --git a/shared/lib/contexts/common/domain/RuleValidator.ts b/shared/lib/contexts/common/domain/RuleValidator.ts
index 35f1426..7a9644e 100644
--- a/shared/lib/contexts/common/domain/RuleValidator.ts
+++ b/shared/lib/contexts/common/domain/RuleValidator.ts
@@ -51,7 +51,7 @@ export class RuleValidator {
}
public static validateFnc(ruleFnc: (value: any) => any) {
- return (value: any, helpers) => {
+ return (value: any, helpers: any) => {
const result = ruleFnc(value);
return result.isSuccess
? value
diff --git a/shared/lib/contexts/common/domain/entities/Address/PostalCode.ts b/shared/lib/contexts/common/domain/entities/Address/PostalCode.ts
index 2e64353..4ca89df 100644
--- a/shared/lib/contexts/common/domain/entities/Address/PostalCode.ts
+++ b/shared/lib/contexts/common/domain/entities/Address/PostalCode.ts
@@ -4,18 +4,10 @@ import { UndefinedOr } from "../../../../../utilities";
import { RuleValidator } from "../../RuleValidator";
import { DomainError, handleDomainError } from "../../errors";
import { Result } from "../Result";
-import {
- IStringValueObjectOptions,
- StringValueObject,
-} from "../StringValueObject";
+import { IStringValueObjectOptions, StringValueObject } from "../StringValueObject";
export class PostalCode extends StringValueObject {
- private static readonly LENGTH = 5;
-
- protected static validate(
- value: UndefinedOr,
- options: IStringValueObjectOptions
- ) {
+ protected static validate(value: UndefinedOr, options: IStringValueObjectOptions) {
const rule = Joi.string()
.allow(null)
.allow("")
@@ -26,10 +18,7 @@ export class PostalCode extends StringValueObject {
return RuleValidator.validate(rule, value);
}
- public static create(
- value: UndefinedOr,
- options: IStringValueObjectOptions = {}
- ) {
+ public static create(value: UndefinedOr, options: IStringValueObjectOptions = {}) {
const _options = {
label: "postal_code",
...options,
@@ -39,11 +28,7 @@ export class PostalCode extends StringValueObject {
if (validationResult.isFailure) {
return Result.fail(
- handleDomainError(
- DomainError.INVALID_INPUT_DATA,
- validationResult.error.message,
- _options
- )
+ handleDomainError(DomainError.INVALID_INPUT_DATA, validationResult.error.message, _options)
);
}
return Result.ok(new PostalCode(validationResult.object));
diff --git a/shared/lib/contexts/common/domain/entities/Entity.ts b/shared/lib/contexts/common/domain/entities/Entity.ts
index 7045744..ffc019d 100644
--- a/shared/lib/contexts/common/domain/entities/Entity.ts
+++ b/shared/lib/contexts/common/domain/entities/Entity.ts
@@ -56,7 +56,7 @@ export abstract class Entity {
}
protected _flattenProps(props: T): { [s: string]: any } {
- return Object.entries(props).reduce((result, [key, valueObject]) => {
+ return Object.entries(props).reduce((result: any, [key, valueObject]) => {
console.log(key, valueObject.value);
result[key] = valueObject.value;
diff --git a/shared/lib/contexts/common/domain/entities/MoneyValue.ts b/shared/lib/contexts/common/domain/entities/MoneyValue.ts
index 7c48334..3229d2d 100644
--- a/shared/lib/contexts/common/domain/entities/MoneyValue.ts
+++ b/shared/lib/contexts/common/domain/entities/MoneyValue.ts
@@ -1,6 +1,4 @@
-/* eslint-disable no-use-before-define */
import DineroFactory, { Currency, Dinero } from "dinero.js";
-
import Joi from "joi";
import { isNull } from "lodash";
import { NullOr } from "../../../../utilities";
@@ -25,7 +23,7 @@ export interface MoneyValueObject {
currency_code: string;
}
-type RoundingMode =
+export type RoundingMode =
| "HALF_ODD"
| "HALF_EVEN"
| "HALF_UP"
@@ -34,8 +32,6 @@ type RoundingMode =
| "HALF_AWAY_FROM_ZERO"
| "DOWN";
-export { RoundingMode };
-
export interface IMoneyValueProps {
amount: NullOr;
currencyCode?: string;
@@ -92,6 +88,7 @@ export class MoneyValue extends ValueObject implements IMoneyValue {
public static readonly DEFAULT_CURRENCY_CODE = defaultMoneyValueProps.currencyCode;
private readonly _isNull: boolean;
+
private readonly _options: IMoneyValueOptions;
protected static validate(amount: NullOr, options: IMoneyValueOptions) {
@@ -250,12 +247,16 @@ export class MoneyValue extends ValueObject implements IMoneyValue {
.object;
}
- private static _toString(value: NullOr, scale: number): string {
+ private static _toString(
+ value: NullOr,
+ scale: number,
+ locales?: Intl.LocalesArgument
+ ): string {
if (value === null) {
return "";
}
- new Intl.NumberFormat("es", {
+ new Intl.NumberFormat(locales, {
/*minimumSignificantDigits: scale,
maximumSignificantDigits: scale,
minimumFractionDigits: scale,*/
@@ -278,7 +279,11 @@ export class MoneyValue extends ValueObject implements IMoneyValue {
};
public toString(): string {
- return MoneyValue._toString(this.isNull() ? null : this.getAmount(), this.getScale());
+ return MoneyValue._toString(
+ this.isNull() ? null : this.getAmount(),
+ this.getScale(),
+ this._options.locale
+ );
}
public toJSON() {
diff --git a/shared/lib/contexts/common/domain/entities/Phone.ts b/shared/lib/contexts/common/domain/entities/Phone.ts
index 1e53256..3497bcb 100644
--- a/shared/lib/contexts/common/domain/entities/Phone.ts
+++ b/shared/lib/contexts/common/domain/entities/Phone.ts
@@ -5,16 +5,10 @@ import { UndefinedOr } from "../../../../utilities";
import { RuleValidator } from "../RuleValidator";
import { DomainError, handleDomainError } from "../errors";
import { Result } from "./Result";
-import {
- IStringValueObjectOptions,
- StringValueObject,
-} from "./StringValueObject";
+import { IStringValueObjectOptions, StringValueObject } from "./StringValueObject";
export class Phone extends StringValueObject {
- protected static validate(
- value: UndefinedOr,
- options: IStringValueObjectOptions
- ) {
+ protected static validate(value: UndefinedOr, options: IStringValueObjectOptions) {
const rule = Joi.string() //.extend(JoiPhoneNumber)
.allow(null)
.allow("")
@@ -25,10 +19,7 @@ export class Phone extends StringValueObject {
return RuleValidator.validate(rule, value);
}
- public static create(
- value: UndefinedOr,
- options: IStringValueObjectOptions = {}
- ) {
+ public static create(value: UndefinedOr, options: IStringValueObjectOptions = {}) {
const _options = {
label: "phone",
...options,
@@ -38,26 +29,21 @@ export class Phone extends StringValueObject {
if (validationResult.isFailure) {
return Result.fail(
- handleDomainError(
- DomainError.INVALID_INPUT_DATA,
- validationResult.error.message,
- _options
- )
+ handleDomainError(DomainError.INVALID_INPUT_DATA, validationResult.error.message, _options)
);
}
return Result.ok(new Phone(validationResult.object));
}
- public format(countryCode: string) {
+ public format(/*countryCode: string*/) {
const rule = Joi /*.extend(JoiPhoneNumber)*/.string();
/*.phoneNumber({
defaultCountry: countryCode,
format: "international",
- })*/ const validationResult = RuleValidator.validate(rule, this.value);
+ })*/
+ const validationResult = RuleValidator.validate(rule, this.value);
- return validationResult.isSuccess
- ? validationResult.object
- : validationResult.error.message;
+ return validationResult.isSuccess ? validationResult.object : validationResult.error.message;
}
}
diff --git a/shared/lib/utilities/currencies.ts b/shared/lib/utilities/currencies.ts
index 01fd2c3..9778be3 100644
--- a/shared/lib/utilities/currencies.ts
+++ b/shared/lib/utilities/currencies.ts
@@ -1,4 +1,4 @@
-export const Currencies = {
+export const Currencies: any = {
USD: {
symbol: "$",
name: "US Dollar",
diff --git a/shared/lib/utilities/languages_data.ts b/shared/lib/utilities/languages_data.ts
index 2e296d0..9326032 100644
--- a/shared/lib/utilities/languages_data.ts
+++ b/shared/lib/utilities/languages_data.ts
@@ -1,6 +1,6 @@
// https://github.com/meikidd/iso-639-1/
-const LANGUAGES_LIST = {
+const LANGUAGES_LIST: any = {
aa: {
name: "Afar",
nativeName: "Afaraf",
diff --git a/shared/package.json b/shared/package.json
index ea5da32..bf42f44 100644
--- a/shared/package.json
+++ b/shared/package.json
@@ -11,8 +11,9 @@
},
"dependencies": {
"dinero.js": "^1.9.1",
- "joi": "^17.12.3",
+ "joi": "^17.13.3",
"joi-phone-number": "^5.1.1",
+ "lodash": "^4.17.21",
"shallow-equal-object": "^1.1.1",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2",