From 82fdc6de13ef0e92617b6cd00c28e3d0be741ad4 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Fri, 14 Jun 2024 14:07:20 +0200 Subject: [PATCH] . --- client/src/Routes.tsx | 20 +++- .../catalog/components/CatalogDataTable.tsx | 21 +++- client/src/app/catalog/layout.tsx | 1 - client/src/app/settings/edit.tsx | 72 ++++++++++++++ client/src/app/settings/index.tsx | 83 +--------------- client/src/app/settings/layout.tsx | 19 ++++ .../DataTable/DataTablePagination.tsx | 3 +- client/src/components/Layout/LayoutHeader.tsx | 2 +- .../src/lib/axios/createAxiosDataProvider.ts | 3 +- .../lib/hooks/useDataTable/useDataTable.tsx | 4 +- .../hooks/usePagination/usePagination.test.ts | 7 +- .../lib/hooks/usePagination/usePagination.tsx | 17 ++-- .../usePagination/usePaginationParams.tsx | 10 +- client/src/locales/es.json | 3 + client/tsconfig.json | 5 +- server/src/config/environments/development.ts | 7 ++ .../auth/infrastructure/express/index.ts | 1 - .../express/passport/authMiddleware.ts | 34 ++++--- .../catalog/domain/entities/Article.ts | 12 --- .../listArticles/ListArticlesController.ts | 14 +-- .../presenter/ListArticles.presenter.ts | 2 - .../catalog/infrastructure/express/index.ts | 1 - .../infrastructure/mappers/article.mapper.ts | 2 - .../infrastructure/sequelize/article.model.ts | 12 --- .../profile/infrastructure/Profile.context.ts | 31 ++++++ .../getProfile/GetProfile.controller.ts | 95 +++++++++++++++++++ .../express/controllers/getProfile/index.ts | 17 ++++ .../getProfile/presenter/GetUser.presenter.ts | 26 +++++ .../controllers/getProfile/presenter/index.ts | 1 + .../express/controllers/index.ts | 2 + .../profile/infrastructure/express/index.ts | 1 + .../contexts/profile/infrastructure/index.ts | 2 + .../contexts/sales/domain/entities/Dealer.ts | 6 ++ .../sales/infrastructure/Dealer.repository.ts | 15 +-- .../express/controllers/index.ts | 1 + .../infrastructure/express/dealers.routes.ts | 26 ----- .../sales/infrastructure/express/index.ts | 2 +- .../contexts/sales/infrastructure/index.ts | 1 + .../infrastructure/mappers/dealer.mapper.ts | 5 +- .../infrastructure/sequelize/dealer.model.ts | 26 +++-- .../users/application/userServices.ts | 49 ++++++++++ .../users/infrastructure/express/index.ts | 2 +- .../infrastructure/sequelize/user.model.ts | 4 +- .../express/api/routes/auth.routes.ts} | 20 ++-- .../express/api/routes/catalog.routes.ts} | 14 +-- .../express/api/routes/dealers.routes.ts | 27 ++++++ .../express/api/routes/index.ts | 7 ++ .../express/api/routes/profile.routes.ts | 24 +++++ .../express/api/routes}/quote.routes.ts | 4 +- .../express/api/routes/sales.routes.ts} | 2 +- .../express/api/routes/users.routes.ts} | 16 ++-- server/src/infrastructure/express/api/v1.ts | 87 +++++++++++++++-- server/src/infrastructure/http/server.ts | 4 +- .../src/infrastructure/sequelize/initData.ts | 28 ++++++ .../sequelize/initializeAdminUser.ts | 10 -- .../QueryCriteria/Pagination/OffsetPaging.ts | 43 ++++----- .../QueryCriteria/Pagination/defaults.ts | 7 ++ .../QueryCriteria/Pagination/index.ts | 3 +- shared/lib/contexts/index.ts | 4 +- .../IGetProfile_Response.dto.ts | 13 +++ .../application/dto/GetProfile.dto/index.ts | 1 + .../contexts/profile/application/dto/index.ts | 1 + .../lib/contexts/profile/application/index.ts | 1 + shared/lib/contexts/profile/index.ts | 1 + 64 files changed, 688 insertions(+), 296 deletions(-) create mode 100644 client/src/app/settings/edit.tsx create mode 100644 client/src/app/settings/layout.tsx create mode 100644 server/src/contexts/profile/infrastructure/Profile.context.ts create mode 100644 server/src/contexts/profile/infrastructure/express/controllers/getProfile/GetProfile.controller.ts create mode 100644 server/src/contexts/profile/infrastructure/express/controllers/getProfile/index.ts create mode 100644 server/src/contexts/profile/infrastructure/express/controllers/getProfile/presenter/GetUser.presenter.ts create mode 100644 server/src/contexts/profile/infrastructure/express/controllers/getProfile/presenter/index.ts create mode 100644 server/src/contexts/profile/infrastructure/express/controllers/index.ts create mode 100644 server/src/contexts/profile/infrastructure/express/index.ts create mode 100644 server/src/contexts/profile/infrastructure/index.ts delete mode 100644 server/src/contexts/sales/infrastructure/express/dealers.routes.ts rename server/src/{contexts/auth/infrastructure/express/routes.ts => infrastructure/express/api/routes/auth.routes.ts} (56%) rename server/src/{contexts/catalog/infrastructure/express/routes.ts => infrastructure/express/api/routes/catalog.routes.ts} (50%) create mode 100644 server/src/infrastructure/express/api/routes/dealers.routes.ts create mode 100644 server/src/infrastructure/express/api/routes/index.ts create mode 100644 server/src/infrastructure/express/api/routes/profile.routes.ts rename server/src/{contexts/sales/infrastructure/express => infrastructure/express/api/routes}/quote.routes.ts (85%) rename server/src/{contexts/sales/infrastructure/express/routes.ts => infrastructure/express/api/routes/sales.routes.ts} (75%) rename server/src/{contexts/users/infrastructure/express/routes.ts => infrastructure/express/api/routes/users.routes.ts} (81%) create mode 100644 server/src/infrastructure/sequelize/initData.ts delete mode 100644 server/src/infrastructure/sequelize/initializeAdminUser.ts create mode 100644 shared/lib/contexts/common/domain/entities/QueryCriteria/Pagination/defaults.ts create mode 100644 shared/lib/contexts/profile/application/dto/GetProfile.dto/IGetProfile_Response.dto.ts create mode 100644 shared/lib/contexts/profile/application/dto/GetProfile.dto/index.ts create mode 100644 shared/lib/contexts/profile/application/dto/index.ts create mode 100644 shared/lib/contexts/profile/application/index.ts create mode 100644 shared/lib/contexts/profile/index.ts diff --git a/client/src/Routes.tsx b/client/src/Routes.tsx index c74b908..4a4d276 100644 --- a/client/src/Routes.tsx +++ b/client/src/Routes.tsx @@ -1,5 +1,13 @@ import { Outlet, RouterProvider, createBrowserRouter } from "react-router-dom"; -import { DealerLayout, DealersList, LoginPage, LogoutPage, SettingsPage, StartPage } from "./app"; +import { + DealerLayout, + DealersList, + LoginPage, + LogoutPage, + SettingsEditor, + SettingsLayout, + StartPage, +} from "./app"; import { CatalogLayout, CatalogList } from "./app/catalog"; import { DashboardPage } from "./app/dashboard"; import { QuotesList } from "./app/quotes/list"; @@ -68,9 +76,17 @@ export const Routes = () => { path: "/settings", element: ( - + + + ), + children: [ + { + index: true, + element: , + }, + ], }, { path: "/logout", diff --git a/client/src/app/catalog/components/CatalogDataTable.tsx b/client/src/app/catalog/components/CatalogDataTable.tsx index 3948d77..5925145 100644 --- a/client/src/app/catalog/components/CatalogDataTable.tsx +++ b/client/src/app/catalog/components/CatalogDataTable.tsx @@ -15,7 +15,6 @@ import { useCatalogList } from "../hooks"; export const CatalogDataTable = () => { const navigate = useNavigate(); const { pagination, globalFilter, isFiltered } = useDataTableContext(); - console.log("pagination PADRE => ", pagination); const { data, isPending, isError, error } = useCatalogList({ pagination: { @@ -27,12 +26,30 @@ export const CatalogDataTable = () => { const columns = useMemo[]>( () => [ + { + id: "id" as const, + accessorKey: "id", + 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: 300, + size: 100, }, { id: "points" as const, diff --git a/client/src/app/catalog/layout.tsx b/client/src/app/catalog/layout.tsx index 8d3982b..e7c9438 100644 --- a/client/src/app/catalog/layout.tsx +++ b/client/src/app/catalog/layout.tsx @@ -16,7 +16,6 @@ export const CatalogLayout = ({ children }: PropsWithChildren) => { {children} - 1 ); diff --git a/client/src/app/settings/edit.tsx b/client/src/app/settings/edit.tsx new file mode 100644 index 0000000..584c419 --- /dev/null +++ b/client/src/app/settings/edit.tsx @@ -0,0 +1,72 @@ +import { + Button, + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, + Input, +} from "@/ui"; + +import { Checkbox } from "@radix-ui/react-checkbox"; + +import { Link } from "react-router-dom"; + +export const SettingsEditor = () => { + return ( +
+ +
+ + + Store Name + Used to identify your store in the marketplace. + + +
+ +
+
+ + + +
+ + + Plugins Directory + + The directory within your project, in which your plugins are located. + + + +
+ +
+ + +
+
+
+ + + +
+
+
+ ); +}; diff --git a/client/src/app/settings/index.tsx b/client/src/app/settings/index.tsx index a6c113d..6e2b7b9 100644 --- a/client/src/app/settings/index.tsx +++ b/client/src/app/settings/index.tsx @@ -1,81 +1,2 @@ -import { Layout, LayoutHeader } from "@/components"; -import { - Button, - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - Input, -} from "@/ui"; - -import { Checkbox } from "@radix-ui/react-checkbox"; - -import { Link } from "react-router-dom"; - -export const SettingsPage = () => { - return ( - - -
-
-

Settings

-
-
- -
- - - Store Name - Used to identify your store in the marketplace. - - -
- -
-
- - - -
- - - Plugins Directory - - The directory within your project, in which your plugins are located. - - - -
- -
- - -
-
-
- - - -
-
-
-
-
- ); -}; +export * from "./edit"; +export * from "./layout"; diff --git a/client/src/app/settings/layout.tsx b/client/src/app/settings/layout.tsx new file mode 100644 index 0000000..b5a968c --- /dev/null +++ b/client/src/app/settings/layout.tsx @@ -0,0 +1,19 @@ +import { Layout, LayoutContent, LayoutHeader } from "@/components"; +import { PropsWithChildren } from "react"; +import { Trans } from "react-i18next"; + +export const SettingsLayout = ({ children }: PropsWithChildren) => { + return ( + + + +
+

+ +

+
+ {children} +
+
+ ); +}; diff --git a/client/src/components/DataTable/DataTablePagination.tsx b/client/src/components/DataTable/DataTablePagination.tsx index 39adbdc..0d2f69f 100644 --- a/client/src/components/DataTable/DataTablePagination.tsx +++ b/client/src/components/DataTable/DataTablePagination.tsx @@ -1,6 +1,7 @@ -import { DEFAULT_PAGE_SIZES, INITIAL_PAGE_INDEX } from "@/lib/hooks"; +import { DEFAULT_PAGE_SIZES } from "@/lib/hooks"; import { cn } from "@/lib/utils"; import { Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/ui"; +import { INITIAL_PAGE_INDEX } from "@shared/contexts"; import { Table } from "@tanstack/react-table"; import { t } from "i18next"; import { diff --git a/client/src/components/Layout/LayoutHeader.tsx b/client/src/components/Layout/LayoutHeader.tsx index e40f07b..5990a20 100644 --- a/client/src/components/Layout/LayoutHeader.tsx +++ b/client/src/components/Layout/LayoutHeader.tsx @@ -9,7 +9,7 @@ import { UserButton } from "./components/UserButton"; export const LayoutHeader = () => { return ( -
+