From 26345cc9a65eaf6b4e7612cd212eca3d93e25407 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Wed, 9 Aug 2023 12:13:58 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20chore(frontend):=20update=20pack?= =?UTF-8?q?age.json=20to=20add=20@radix-ui/react-form=20dependency=20?= =?UTF-8?q?=F0=9F=94=A8=20refactor(PaginatorComponent):=20remove=20unneces?= =?UTF-8?q?sary=20whitespace=20in=20paginate=20prop=20=F0=9F=93=9D=20docs(?= =?UTF-8?q?ConfirmationModal):=20add=20missing=20JSDoc=20comments=20and=20?= =?UTF-8?q?improve=20code=20readability=20=F0=9F=93=9D=20docs(UserManageme?= =?UTF-8?q?ntModal):=20add=20missing=20JSDoc=20comments=20and=20improve=20?= =?UTF-8?q?code=20readability=20=F0=9F=94=A8=20refactor(baseModal):=20impr?= =?UTF-8?q?ove=20code=20readability=20by=20adding=20a=20div=20wrapper=20fo?= =?UTF-8?q?r=20headerChild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ feat(AdminPage/index.tsx): add Pencil icon from lucide-react library to the import statement to use it in the component ✨ feat(AdminPage/index.tsx): add ConfirmationModal and UserManagementModal components to import statements to use them in the component 🐛 fix(AdminPage/index.tsx): remove unused handleSaveClick function ✨ feat(AdminPage/index.tsx): add modalEditOpen and modalDeleteOpen states to handle the opening and closing of the modals ✨ feat(AdminPage/index.tsx): add handleEditUser function to handle the edit user functionality 🐛 fix(AdminPage/index.tsx): remove unused handleSaveClick function ✨ feat(AdminPage/index.tsx): add ConfirmationModal component to handle the delete user functionality ✨ feat(AdminPage/index.tsx): add UserManagementModal component to handle the edit user functionality ✨ feat(components/index.ts): add ConfirmationModalType and UserManagementType types to handle the props of ConfirmationModal and UserManagementModal components 🐛 fix(components/index.ts): add missing newline at the end of the file ✨ feat(utils/styleUtils.ts): add UserMinus2 and UserPlus2 icons from lucide-react library to the import statement --- src/frontend/package-lock.json | 29 +++++ src/frontend/package.json | 1 + .../components/PaginatorComponent/index.tsx | 2 +- .../src/modals/ConfirmationModal/index.tsx | 66 +++++++++++ .../src/modals/UserManagementModal/index.tsx | 94 ++++++++++++++++ src/frontend/src/modals/baseModal/index.tsx | 4 +- src/frontend/src/pages/AdminPage/index.tsx | 105 +++++++++++------- src/frontend/src/types/components/index.ts | 28 ++++- src/frontend/src/utils/styleUtils.ts | 4 + 9 files changed, 290 insertions(+), 43 deletions(-) create mode 100644 src/frontend/src/modals/ConfirmationModal/index.tsx create mode 100644 src/frontend/src/modals/UserManagementModal/index.tsx diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json index c92efd188..d28f74b68 100644 --- a/src/frontend/package-lock.json +++ b/src/frontend/package-lock.json @@ -17,6 +17,7 @@ "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "^1.0.4", "@radix-ui/react-dropdown-menu": "^2.0.5", + "@radix-ui/react-form": "^0.0.3", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-menubar": "^1.0.3", @@ -1777,6 +1778,34 @@ } } }, + "node_modules/@radix-ui/react-form": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-form/-/react-form-0.0.3.tgz", + "integrity": "sha512-kgE+Z/haV6fxE5WqIXj05KkaXa3OkZASoTDy25yX2EIp/x0c54rOH/vFr5nOZTg7n7T1z8bSyXmiVIFP9bbhPQ==", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@radix-ui/primitive": "1.0.1", + "@radix-ui/react-compose-refs": "1.0.1", + "@radix-ui/react-context": "1.0.1", + "@radix-ui/react-id": "1.0.1", + "@radix-ui/react-label": "2.0.2", + "@radix-ui/react-primitive": "1.0.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-icons": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@radix-ui/react-icons/-/react-icons-1.3.0.tgz", diff --git a/src/frontend/package.json b/src/frontend/package.json index dd0cadeeb..b4afc7999 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -12,6 +12,7 @@ "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "^1.0.4", "@radix-ui/react-dropdown-menu": "^2.0.5", + "@radix-ui/react-form": "^0.0.3", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-menubar": "^1.0.3", diff --git a/src/frontend/src/components/PaginatorComponent/index.tsx b/src/frontend/src/components/PaginatorComponent/index.tsx index 96f6dd067..29921c60a 100644 --- a/src/frontend/src/components/PaginatorComponent/index.tsx +++ b/src/frontend/src/components/PaginatorComponent/index.tsx @@ -20,7 +20,7 @@ export default function PaginatorComponent({ pageIndex = 1, rowsCount = [10, 20, 30], totalRowsCount = 0, - paginate, + paginate }: PaginatorComponentType) { const [size, setPageSize] = useState(pageSize); const [index, setPageIndex] = useState(pageIndex); diff --git a/src/frontend/src/modals/ConfirmationModal/index.tsx b/src/frontend/src/modals/ConfirmationModal/index.tsx new file mode 100644 index 000000000..1e615d799 --- /dev/null +++ b/src/frontend/src/modals/ConfirmationModal/index.tsx @@ -0,0 +1,66 @@ +import { useState } from "react"; +import { Button } from "../../components/ui/button"; +import { ConfirmationModalType } from "../../types/components"; +import { nodeIconsLucide } from "../../utils/styleUtils"; +import BaseModal from "../baseModal"; + +export default function ConfirmationModal({ + title, + titleHeader, + modalContent, + modalContentTitle, + cancelText, + confirmationText, + children, + icon, + data, + index, + onConfirm, +}: ConfirmationModalType) { + const Icon: any = nodeIconsLucide[icon]; + + const [open, setOpen] = useState(false); + return ( + + {children} + + {title} + + + {modalContentTitle != "" && ( + <> + {modalContentTitle} +

+ + )} + {modalContent} +
+ + + + + + +
+ ); +} diff --git a/src/frontend/src/modals/UserManagementModal/index.tsx b/src/frontend/src/modals/UserManagementModal/index.tsx new file mode 100644 index 000000000..1ab661223 --- /dev/null +++ b/src/frontend/src/modals/UserManagementModal/index.tsx @@ -0,0 +1,94 @@ +import { useState } from "react"; +import { Button } from "../../components/ui/button"; +import { ConfirmationModalType, UserManagementType } from "../../types/components"; +import { nodeIconsLucide } from "../../utils/styleUtils"; +import BaseModal from "../baseModal"; +import * as Form from '@radix-ui/react-form'; + +export default function UserManagementModal({ + title, + titleHeader, + cancelText, + confirmationText, + children, + icon, + data, + index, + onConfirm, +}: UserManagementType) { + const Icon: any = nodeIconsLucide[icon]; + + const [open, setOpen] = useState(false); + return ( + + {children} + + {title} + + + + + + +
+ Email + + Please enter your email + + + Please provide a valid email + +
+ + + +
+ +
+ Question + + Please enter a question + +
+ +