diff --git a/.gitignore b/.gitignore index 9b986df..a3ce491 100755 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /node_modules /.pnp .pnp.js +pnpm-lock.yaml # testing /coverage diff --git a/docs/v1.2/document.md b/docs/v1.2/document.md new file mode 100755 index 0000000..922bb6a --- /dev/null +++ b/docs/v1.2/document.md @@ -0,0 +1,102 @@ +title: Pussadusmocu +created at: Thu Aug 15 2024 17:26:10 GMT+0000 (Coordinated Universal Time) +updated at: Thu Aug 15 2024 17:26:41 GMT+0000 (Coordinated Universal Time) + +--- + +# Pussadusmocu + +!! **Pussadusmocu** is a parcel borrowing project for the Faculty of Science at Chulalongkorn University. This documentation will help developers understand how to set up, run, and contribute to the project. + +> **Software Name:** +> **Version:** 1.x +> **Date: ** + +## **Software summary **👀 + +### Features + +- **User Authentication**: Secure login and registration using **ChulaSSO**. +- **Parcel Management**: Intuitive interface for managing parcel borrowing and returns. +- **Notifications**: Automated email and SMS reminders for upcoming due dates. +- **Admin Dashboard**: Comprehensive dashboard for administrators to monitor and manage the system. +- **Search Functionality**: Powerful search feature to quickly locate parcels and user records. +- **Reporting**: Generate detailed reports on borrowing activities and system usage. + +## Recent Updates + +- **New Functionality**: + - Added a bulk upload feature for parcel records. + - Enhanced notification system with customizable reminders. +- **Bug Fixes**: + - Fixed an issue with the login process that affected some users. + - Resolved a bug causing delays in the notification system. +- **Performance Improvements**: + - Optimized database queries for faster search results. + - Improved the overall responsiveness of the admin dashboard. + +## **Requirements \*\***☝️\*\* + +Outline additional details that might be required by users to proceeding with the software use. + +## How-to guide 🐣 + +Provide step-by-step instructions to help users use your software for the first time. + +### Step 1 + +Description + +![Explainer 8.jpg](media_Pussadusmocu/hAdFQ3o5Xq6bly-Explainer%208.jpg) + +### Step 2 + +Description + +``` +Add your code snippets + +``` + +### Step 3 + +Description + +![Explainer 23.jpg](media_Pussadusmocu/Gj9qYWedIqDeMO-Explainer%2023.jpg) + +## **Tutorials \*\***🎬\*\* + +Have any videos or knowledge bases to link if new users need additional guidance? Include them here. + +![Explainer 32.jpg](media_Pussadusmocu/aHCuasp6tDbzG8-Explainer%2032.jpg) + +## FAQs 🙋🏽‍♂️ + +Answer and document frequently asked questions below. + +### Question + +Answer + +### Question + +Answer + +### Question + +Answer + +## Additional Resources 🧩 + +Include any additional information, forum or documentation that might be relevant to users here for easy access when questions arise. + +![Explainer 6.jpg](media_Pussadusmocu/s-adVcTnmmqv5G-Explainer%206.jpg) + +## Customer support 💬 + +If users need extra assistance or have any troubleshooting issues, provide contact information to your customer support or link them to online assistance or chat portals here. + +--- + +!! **Make it your own** +!! Once edited to your liking, [save this template to your team’s templates list](http://help.slite.com/en/articles/2622390-document-templates) by clicking on the three dots on the right of the screen. diff --git a/docs/v1.2/media_Pussadusmocu/Gj9qYWedIqDeMO-Explainer 23.jpg b/docs/v1.2/media_Pussadusmocu/Gj9qYWedIqDeMO-Explainer 23.jpg new file mode 100755 index 0000000..ae5b42b Binary files /dev/null and b/docs/v1.2/media_Pussadusmocu/Gj9qYWedIqDeMO-Explainer 23.jpg differ diff --git a/docs/v1.2/media_Pussadusmocu/aHCuasp6tDbzG8-Explainer 32.jpg b/docs/v1.2/media_Pussadusmocu/aHCuasp6tDbzG8-Explainer 32.jpg new file mode 100755 index 0000000..55172ba Binary files /dev/null and b/docs/v1.2/media_Pussadusmocu/aHCuasp6tDbzG8-Explainer 32.jpg differ diff --git a/docs/v1.2/media_Pussadusmocu/hAdFQ3o5Xq6bly-Explainer 8.jpg b/docs/v1.2/media_Pussadusmocu/hAdFQ3o5Xq6bly-Explainer 8.jpg new file mode 100755 index 0000000..832ecae Binary files /dev/null and b/docs/v1.2/media_Pussadusmocu/hAdFQ3o5Xq6bly-Explainer 8.jpg differ diff --git a/docs/v1.2/media_Pussadusmocu/s-adVcTnmmqv5G-Explainer 6.jpg b/docs/v1.2/media_Pussadusmocu/s-adVcTnmmqv5G-Explainer 6.jpg new file mode 100755 index 0000000..efa815e Binary files /dev/null and b/docs/v1.2/media_Pussadusmocu/s-adVcTnmmqv5G-Explainer 6.jpg differ diff --git a/package.json b/package.json index 1fbb7e7..3ff2bae 100755 --- a/package.json +++ b/package.json @@ -18,16 +18,16 @@ }, "dependencies": { "@hookform/resolvers": "^3.9.0", - "@prisma/client": "^5.17.0", + "@prisma/client": "^5.18.0", "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-popover": "^1.1.1", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-toast": "^1.2.1", - "@reduxjs/toolkit": "^2.2.6", + "@reduxjs/toolkit": "^2.2.7", "@t3-oss/env-nextjs": "^0.10.1", - "@tanstack/react-query": "^5.51.9", + "@tanstack/react-query": "^5.51.23", "@trpc/client": "11.0.0-rc.370", "@trpc/react-query": "11.0.0-rc.370", "@trpc/server": "11.0.0-rc.370", @@ -46,38 +46,38 @@ "react": "18.3.1", "react-day-picker": "^8.10.1", "react-dom": "18.3.1", - "react-hook-form": "^7.52.1", + "react-hook-form": "^7.52.2", "react-redux": "^9.1.2", "server-only": "^0.0.1", "superjson": "^2.2.1", - "tailwind-merge": "^2.4.0", + "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", "zod": "^3.23.8" }, "devDependencies": { "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "^9.7.0", + "@eslint/js": "^9.9.0", "@testing-library/react": "^16.0.0", - "@types/eslint": "^8.56.10", - "@types/eslint__eslintrc": "^2.1.1", + "@types/eslint": "^8.56.11", + "@types/eslint__eslintrc": "^2.1.2", "@types/eslint__js": "^8.42.3", "@types/jsonwebtoken": "^9.0.6", - "@types/node": "^20.14.11", + "@types/node": "^20.14.15", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "@typescript-eslint/eslint-plugin": "^7.16.1", - "@typescript-eslint/parser": "^7.16.1", + "@typescript-eslint/eslint-plugin": "^7.18.0", + "@typescript-eslint/parser": "^7.18.0", "@vitejs/plugin-react": "^4.3.1", "eslint": "^8.57.0", "eslint-config-next": "^14.2.5", - "husky": "^9.1.1", - "jsdom": "^24.1.0", - "postcss": "^8.4.39", + "husky": "^9.1.4", + "jsdom": "^24.1.1", + "postcss": "^8.4.41", "prettier": "^3.3.3", "prettier-plugin-tailwindcss": "^0.5.14", - "prisma": "^5.17.0", - "tailwindcss": "^3.4.6", - "typescript": "^5.5.3", + "prisma": "^5.18.0", + "tailwindcss": "^3.4.10", + "typescript": "^5.5.4", "vitest": "^1.6.0" }, "ct3aMetadata": { diff --git a/src/app/_components/popCard.tsx b/src/app/_components/popCard.tsx index 3967f2f..5c2c706 100755 --- a/src/app/_components/popCard.tsx +++ b/src/app/_components/popCard.tsx @@ -10,6 +10,7 @@ interface PopupCardProps { onAccept: (description: string) => void; onReject: (description: string) => void; onReturn: (quantity: number) => void; + onRejectBorrowing: (quantity: number) => void; parcelProject: ParcelProjectWithDetails; } @@ -38,6 +39,7 @@ const PopupCard: React.FC = ({ onAccept, onReject, onReturn, + onRejectBorrowing, parcelProject, }) => { const [returnQuantity, setReturnQuantity] = useState(0); @@ -79,6 +81,12 @@ const PopupCard: React.FC = ({ setIsLoading(false); }; + const handleRejectBorrowing = async () => { + setIsLoading(true); + onRejectBorrowing(parcelProject.amount); + setIsLoading(false); + }; + const renderButton = () => { switch (parcelProject.status) { case "PENDING": @@ -124,6 +132,19 @@ const PopupCard: React.FC = ({ ); + case "BORROWING": + return ( + <> + + + ); } }; diff --git a/src/app/admin/status/bokking_status.tsx b/src/app/admin/status/bokking_status.tsx index 22e6b46..00a003e 100755 --- a/src/app/admin/status/bokking_status.tsx +++ b/src/app/admin/status/bokking_status.tsx @@ -64,6 +64,15 @@ function Sta({ }, }); + const reject = api.parcel_Project.rejectBorrowing.useMutation({ + onSuccess: () => { + router.refresh(); + }, + onError: (error) => { + console.error("Return error", error); + }, + }); + const closePopup = () => { setIsOpen(false); setCurrentParcelProject(null); @@ -93,6 +102,14 @@ function Sta({ setIsOpen(false); }; + const rejectBorrowing = async (id: string, quantity: number) => { + reject.mutate({ + parcel_project_id: id, + parcel_return: quantity, + }); + setIsOpen(false); + }; + const formatDate = (dateString: string) => { const options: Intl.DateTimeFormatOptions = { year: "numeric", @@ -185,6 +202,9 @@ function Sta({ onReturn={(quantity: number) => updateTostock(parcelsProject.id, quantity) } + onRejectBorrowing={(quantity: number) => + rejectBorrowing(parcelsProject.id, quantity) + } parcelProject={currentParcelProject} /> )} diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 0406975..1b72eb6 100755 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -11,8 +11,8 @@ const LoginPage = () => { }; // Version and deployment date - const version = "1.2.0"; - const deploymentDate = "Aug 14, 2024"; + const version = "1.2.1"; + const deploymentDate = "Aug 19, 2024"; return (
diff --git a/src/server/api/routers/parcel_Project.ts b/src/server/api/routers/parcel_Project.ts index 5ee689b..7c5ec58 100755 --- a/src/server/api/routers/parcel_Project.ts +++ b/src/server/api/routers/parcel_Project.ts @@ -197,4 +197,43 @@ export const Parcel_projectRouter = createTRPCRouter({ }); }); }), + + rejectBorrowing: publicProcedure + .input( + z.object({ + parcel_project_id: z.string(), + parcel_return: z.number(), + }), + ) + .mutation(async ({ ctx, input }) => { + return await ctx.db.$transaction(async (tx) => { + const parcel = await tx.parcel_Project.findFirst({ + where: { + id: input.parcel_project_id, + }, + include: { + parcel: true, + }, + }); + await tx.parcel_Project.updateMany({ + where: { + id: input.parcel_project_id, + }, + data: { + status: BORROWING_STATUS.REJECT, + }, + }); + const currentAmount = parcel?.parcel.amount ?? 0; + const returnAmount = input.parcel_return; + const toStock = currentAmount + returnAmount; + await tx.parcel.update({ + where: { + parcel_id: parcel?.parcel_id, + }, + data: { + amount: toStock, + }, + }); + }); + }), });