From 09cbfc12c5c1e7718586edc7bed85532bf3a42c8 Mon Sep 17 00:00:00 2001
From: David Arranz
Date: Mon, 12 Aug 2024 20:22:34 +0200
Subject: [PATCH] .
---
client/src/Routes.tsx | 15 +-
client/src/app/ErrorPage.tsx | 23 +++
.../AppendCatalogArticleRowButton.tsx | 31 ++++
...RowButton.tsx => AppendEmptyRowButton.tsx} | 11 +-
.../components/CatalogPickerDataTable.tsx | 34 ++--
.../QuoteItemsSortableDataTable.tsx | 87 +++-------
.../QuoteItemsSortableDataTableToolbar.tsx | 126 ++++++++-------
.../editors/CatalogPickerDialog.tsx | 28 ++++
.../editors/QuoteDetailsCardEditor.tsx | 62 ++++---
client/src/components/DataTable/DataTable.tsx | 16 +-
.../DataTable/DataTablePagination.tsx | 153 ++++++++++--------
.../hooks/useDataTable/DataTableContext.tsx | 10 +-
.../useDataTable/useSyncedPagination.tsx | 17 +-
.../lib/hooks/usePagination/usePagination.tsx | 2 +-
.../WarnAboutChangeContext.tsx | 48 +-----
.../WarnAboutChangeProvider.tsx | 50 ++++++
.../hooks/useUnsavedChangesNotifier/index.ts | 3 +-
client/src/locales/en.json | 11 +-
client/src/locales/es.json | 11 +-
.../QueryCriteria/Pagination/defaults.ts | 2 +-
20 files changed, 429 insertions(+), 311 deletions(-)
create mode 100644 client/src/app/quotes/components/AppendCatalogArticleRowButton.tsx
rename client/src/app/quotes/components/{AddNewRowButton.tsx => AppendEmptyRowButton.tsx} (65%)
create mode 100644 client/src/app/quotes/components/editors/CatalogPickerDialog.tsx
create mode 100644 client/src/lib/hooks/useUnsavedChangesNotifier/WarnAboutChangeProvider.tsx
diff --git a/client/src/Routes.tsx b/client/src/Routes.tsx
index eac1139..3fee279 100644
--- a/client/src/Routes.tsx
+++ b/client/src/Routes.tsx
@@ -2,6 +2,7 @@ import { Outlet, RouterProvider, createBrowserRouter } from "react-router-dom";
import {
DealerLayout,
DealersList,
+ ErrorPage,
LoginPage,
LogoutPage,
QuoteCreate,
@@ -25,6 +26,13 @@ export const Routes = () => {
},
];
+ const routesForErrors = [
+ {
+ path: "*",
+ Component: ErrorPage,
+ },
+ ];
+
// Define routes accessible only to authenticated users
const routesForAuthenticatedOnly = [
{
@@ -123,7 +131,12 @@ export const Routes = () => {
// Combine and conditionally include routes based on authentication status
const router = createBrowserRouter(
- [...routesForPublic, ...routesForAuthenticatedOnly, ...routesForNotAuthenticatedOnly],
+ [
+ ...routesForPublic,
+ ...routesForAuthenticatedOnly,
+ ...routesForNotAuthenticatedOnly,
+ ...routesForErrors,
+ ],
{
//basename: "/app",
}
diff --git a/client/src/app/ErrorPage.tsx b/client/src/app/ErrorPage.tsx
index f8f38e6..ac753a3 100644
--- a/client/src/app/ErrorPage.tsx
+++ b/client/src/app/ErrorPage.tsx
@@ -25,6 +25,29 @@ export const ErrorPage = (props: ErrorPageProps) => {
try again.
);
+
+ return (
+
+
+
+
+ Oops, page not found!
+
+
+ The page you're looking for doesn't exist or has been moved.
+
+
+
+
+
+
+ );
+
return (
{msg}
diff --git a/client/src/app/quotes/components/AppendCatalogArticleRowButton.tsx b/client/src/app/quotes/components/AppendCatalogArticleRowButton.tsx
new file mode 100644
index 0000000..d675286
--- /dev/null
+++ b/client/src/app/quotes/components/AppendCatalogArticleRowButton.tsx
@@ -0,0 +1,31 @@
+import { cn } from "@/lib/utils";
+import { Button, ButtonProps } from "@/ui";
+import { t } from "i18next";
+import { PackagePlusIcon } from "lucide-react";
+
+export interface AppendCatalogArticleRowButtonProps extends ButtonProps {
+ label?: string;
+ className?: string;
+}
+
+export const AppendCatalogArticleRowButton = ({
+ label = t("common.append_article"),
+ className,
+ ...props
+}: AppendCatalogArticleRowButtonProps): JSX.Element => (
+
+);
+
+AppendCatalogArticleRowButton.displayName = "AddNewRowButton";
diff --git a/client/src/app/quotes/components/AddNewRowButton.tsx b/client/src/app/quotes/components/AppendEmptyRowButton.tsx
similarity index 65%
rename from client/src/app/quotes/components/AddNewRowButton.tsx
rename to client/src/app/quotes/components/AppendEmptyRowButton.tsx
index a314d35..87a2e16 100644
--- a/client/src/app/quotes/components/AddNewRowButton.tsx
+++ b/client/src/app/quotes/components/AppendEmptyRowButton.tsx
@@ -1,17 +1,18 @@
import { cn } from "@/lib/utils";
import { Button, ButtonProps } from "@/ui";
+import { t } from "i18next";
import { PlusCircleIcon } from "lucide-react";
-export interface AddNewRowButtonProps extends ButtonProps {
+export interface AppendEmptyRowButtonProps extends ButtonProps {
label?: string;
className?: string;
}
-export const AddNewRowButton = ({
- label = "Añade nueva fila",
+export const AppendEmptyRowButton = ({
+ label = t("common.append_empty_row"),
className,
...props
-}: AddNewRowButtonProps): JSX.Element => (
+}: AppendEmptyRowButtonProps): JSX.Element => (