From c3afbd1469e43af2a58c7b99dac57b659971bec0 Mon Sep 17 00:00:00 2001 From: AKILIMAILI CIZUNGU Innocent <51681130+Innocent-Akim@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:13:29 +0200 Subject: [PATCH] [Feat]: Create RejectSelectedModal Component (#3233) * feat: Create RejectSelectedModal component for rejecting selected entries with a reason * fix:Cspell * refact: coderabbitai --- .../components/RejectSelectedModal.tsx | 82 +++++++++++++++++++ .../[memberId]/components/TimesheetAction.tsx | 23 +++--- .../components/TimesheetFilterDate.tsx | 26 ++++-- .../timesheet/[memberId]/components/index.tsx | 3 +- .../[locale]/timesheet/[memberId]/page.tsx | 7 +- .../calendar/table-time-sheet.tsx | 43 ++++++++-- .../manual-time/add-manual-time-modal.tsx | 2 +- 7 files changed, 157 insertions(+), 29 deletions(-) create mode 100644 apps/web/app/[locale]/timesheet/[memberId]/components/RejectSelectedModal.tsx diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/RejectSelectedModal.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/RejectSelectedModal.tsx new file mode 100644 index 000000000..954cb59b4 --- /dev/null +++ b/apps/web/app/[locale]/timesheet/[memberId]/components/RejectSelectedModal.tsx @@ -0,0 +1,82 @@ +import { clsxm } from "@/app/utils"; +import { Modal } from "@/lib/components"; +import { useState } from "react"; +export interface IRejectSelectedModalProps { + isOpen: boolean; + closeModal: () => void; + onReject: (reason: string) => void; + minReasonLength?: number; + maxReasonLength?: number; +} +export function RejectSelectedModal({ isOpen, closeModal, maxReasonLength, onReject, minReasonLength }: IRejectSelectedModalProps) { + const [isSubmitting, setIsSubmitting] = useState(false); + const [reason, setReason] = useState(''); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setIsSubmitting(true); + try { + await onReject(reason); + closeModal(); + } finally { + setIsSubmitting(false); + } + }; + return ( + +
+
+ + You are about to reject the selected entry, would you like to proceed? + +