From 7a0c200e89d99cde8e73f36fb8d6b8b34ee2e235 Mon Sep 17 00:00:00 2001 From: Kapil Jangid Date: Sun, 20 Oct 2024 14:45:31 +0530 Subject: [PATCH] Refactor: Remove unused dependency and simplify company page rendering - Removed the unused dependency "100xdevs-job-board" from package.json - Simplified the rendering of the company page by removing unnecessary div container and flex styling - Updated the date format in the CompanyTable component to use toDateString() instead of toLocaleDateString() - Added a window.location.reload() to refresh the company list after deleting a company - Removed the unused router and pathName variables in the CompanyTable component - Removed the unused random input styling in the DeleteAccountDialog component --- package.json | 1 - src/app/manage/company/page.tsx | 6 +- src/components/CompanyTabel.tsx | 233 +++++++++--------- .../profile/DeleteAccountDialog.tsx | 2 +- 4 files changed, 118 insertions(+), 124 deletions(-) diff --git a/package.json b/package.json index 7fd96bfb..bfdbbba9 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "seed": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' prisma/seed.ts" }, "dependencies": { - "100xdevs-job-board": "file:", "@aws-sdk/client-s3": "^3.645.0", "@aws-sdk/s3-request-presigner": "^3.645.0", "@emotion/react": "^11.13.3", diff --git a/src/app/manage/company/page.tsx b/src/app/manage/company/page.tsx index dda83786..5d3a3efc 100644 --- a/src/app/manage/company/page.tsx +++ b/src/app/manage/company/page.tsx @@ -5,11 +5,7 @@ import React from 'react'; const page = async () => { const companies = await getAllCompanies(); - return ( -
- -
- ); + return ; }; export default page; diff --git a/src/components/CompanyTabel.tsx b/src/components/CompanyTabel.tsx index 726b27c6..2066291b 100644 --- a/src/components/CompanyTabel.tsx +++ b/src/components/CompanyTabel.tsx @@ -17,15 +17,12 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog'; import { UpdateCompanyForm } from './UpdateCompanyForm'; import { toast } from './ui/use-toast'; import { deleteCompany } from '@/actions/company.actions'; -import { usePathname, useRouter } from 'next/navigation'; export default function CompanyTable({ company: companies, }: { company: CompanyType[]; }) { - const router = useRouter(); - const pathName = usePathname(); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [isUpdateModalOpen, setIsUpdateModalOpen] = useState(false); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); @@ -42,12 +39,12 @@ export default function CompanyTable({ variant: 'destructive', }); } - router.push(pathName); toast({ title: response.msg || 'Company deleted successfully', variant: 'success', }); // Optionally refresh the company list or update state to remove the deleted company + window.location.reload(); } catch (_error) { toast({ title: 'Something went wrong while deleting the company', @@ -58,131 +55,133 @@ export default function CompanyTable({ }; return ( -
-
-

Companies

- -
- - - - Name - Email - Website - Created At - Actions - - - - {companies.map((company, index) => ( - - {company.name} - {company.email} - {company.website || 'N/A'} - - {new Date(company.createdAt).toLocaleDateString()} - - -
- - -
-
+
+
+
+

Companies

+ +
+
+ + + Name + Email + Website + Created At + Actions - ))} - -
- - {/* Create Company Modal */} - - - - -

- Company Details -

-
-
- -
-
+ + + {companies.map((company, index) => ( + + {company.name} + {company.email} + {company.website || 'N/A'} + + {new Date(company.createdAt).toDateString()} + + +
+ + +
+
+
+ ))} +
+ - {/* Update Company Modal */} - {selectedCompany && ( - + {/* Create Company Modal */} +

- Update Company + Company Details

- +
- )} - {/* Delete Company Confirmation Dialog */} - {selectedCompany && ( - - - - -

- Delete Company -

-
-
-

- Are you sure you want to delete the company{' '} - {selectedCompany.name}? -

-
- - -
-
-
- )} + {/* Update Company Modal */} + {selectedCompany && ( + + + + +

+ Update Company +

+
+
+ +
+
+ )} + + {/* Delete Company Confirmation Dialog */} + {selectedCompany && ( + + + + +

+ Delete Company +

+
+
+

+ Are you sure you want to delete the company{' '} + {selectedCompany.name}? +

+
+ + +
+
+
+ )} +
); } diff --git a/src/components/profile/DeleteAccountDialog.tsx b/src/components/profile/DeleteAccountDialog.tsx index fee934ef..986a6185 100644 --- a/src/components/profile/DeleteAccountDialog.tsx +++ b/src/components/profile/DeleteAccountDialog.tsx @@ -113,7 +113,7 @@ export const DeleteAccountDialog = () => { ) => e.preventDefault() }