= ({
>
);
+ 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,
+ },
+ });
+ });
+ }),
});