Skip to content

Commit

Permalink
chore: merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Pond authored and Pond committed Aug 19, 2024
2 parents fa33179 + ea7b8da commit df8694a
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
pnpm-lock.yaml

# testing
/coverage
Expand Down
102 changes: 102 additions & 0 deletions docs/v1.2/document.md
Original file line number Diff line number Diff line change
@@ -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:** <https://pussadusmocu.vercel.app/>
> **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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
21 changes: 21 additions & 0 deletions src/app/_components/popCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface PopupCardProps {
onAccept: (description: string) => void;
onReject: (description: string) => void;
onReturn: (quantity: number) => void;
onRejectBorrowing: (quantity: number) => void;
parcelProject: ParcelProjectWithDetails;
}

Expand Down Expand Up @@ -38,6 +39,7 @@ const PopupCard: React.FC<PopupCardProps> = ({
onAccept,
onReject,
onReturn,
onRejectBorrowing,
parcelProject,
}) => {
const [returnQuantity, setReturnQuantity] = useState<number>(0);
Expand Down Expand Up @@ -79,6 +81,12 @@ const PopupCard: React.FC<PopupCardProps> = ({
setIsLoading(false);
};

const handleRejectBorrowing = async () => {
setIsLoading(true);
onRejectBorrowing(parcelProject.amount);
setIsLoading(false);
};

const renderButton = () => {
switch (parcelProject.status) {
case "PENDING":
Expand Down Expand Up @@ -124,6 +132,19 @@ const PopupCard: React.FC<PopupCardProps> = ({
</Button>
</>
);
case "BORROWING":
return (
<>
<Button
type="button"
className="bg-red01 text-white hover:bg-red-100"
onClick={handleRejectBorrowing}
disabled={isLoading}
>
{isLoading ? "กำลังดำเนินการ..." : "Reject"}
</Button>
</>
);
}
};

Expand Down
20 changes: 20 additions & 0 deletions src/app/admin/status/bokking_status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -185,6 +202,9 @@ function Sta({
onReturn={(quantity: number) =>
updateTostock(parcelsProject.id, quantity)
}
onRejectBorrowing={(quantity: number) =>
rejectBorrowing(parcelsProject.id, quantity)
}
parcelProject={currentParcelProject}
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="grid h-screen w-screen md:grid-cols-5">
Expand Down
39 changes: 39 additions & 0 deletions src/server/api/routers/parcel_Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
});
}),
});

0 comments on commit df8694a

Please sign in to comment.