From e797c40eb4cc5ec000ca8a280c00a8325d1ee309 Mon Sep 17 00:00:00 2001 From: phanphan Date: Thu, 20 Jun 2024 13:27:41 +0700 Subject: [PATCH] update modal confir --- cope2n-fe/src/pages/reviews2/FileCard.tsx | 6 +-- cope2n-fe/src/pages/reviews2/index.tsx | 47 ++++++++++++++--------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/cope2n-fe/src/pages/reviews2/FileCard.tsx b/cope2n-fe/src/pages/reviews2/FileCard.tsx index 3c7d715..9ca7bc5 100644 --- a/cope2n-fe/src/pages/reviews2/FileCard.tsx +++ b/cope2n-fe/src/pages/reviews2/FileCard.tsx @@ -5,7 +5,7 @@ const FileCard = ({ file, isSelected, onClick }) => { const fileName = file['File Name']; const extensionType = fileName.split('.').pop(); const isRequired = file['Is Required']; - const isReviewd = file['Is Reviewed']; + const isReviewed = file['Is Reviewed']; return (
{ > {isRequired ? ( <> - {isReviewd ? ( + {isReviewed ? ( { textTransform: 'capitalize', }} > - Reviewd + Reviewed ) : ( { const [selectedFileData, setSelectedFileData] = useState(null); const [selectedFileDataSource, setSelectedFileDataSource] = useState({}); const [selectedFileName, setSelectedFileName] = useState(null); - + const [isOpenConfirmRequest, setIsOpenConfirmRequest] = useState(false); // Default date range: 1 month ago to today const [filterDateRange, setFilterDateRange] = useState(['', '']); @@ -290,23 +290,18 @@ const ReviewPage = () => { }; const handleConfirmReview = async () => { - const isConfirmed = window.confirm( - 'Are you sure you want to confirm this request is reviewed?', - ); - if (isConfirmed) { - try { - await updateRevisedData(currentRequest?.RequestID); - addRecentRequest(currentRequest?.RequestID); - setCurrentRequest({ - ...currentRequest, - ['Is Reviewed']: true, - }); - notification.success({ message: 'Update file success' }); - } catch (error) { - notification.error({ - message: getErrorMessage(error), - }); - } + try { + await updateRevisedData(currentRequest?.RequestID); + addRecentRequest(currentRequest?.RequestID); + setCurrentRequest({ + ...currentRequest, + ['Is Reviewed']: true, + }); + notification.success({ message: 'Update file success' }); + } catch (error) { + notification.error({ + message: getErrorMessage(error), + }); } }; @@ -699,7 +694,7 @@ const ReviewPage = () => { size='middle' disabled={currentRequest && currentRequest['Is Reviewed']} style={{ minWidth: '120px' }} - onClick={handleConfirmReview} + onClick={() => setIsOpenConfirmRequest(true)} > Confirm request @@ -1012,6 +1007,20 @@ const ReviewPage = () => {
+ { + setIsOpenConfirmRequest(false); + handleConfirmReview(); + }} + onCancel={() => { + setIsOpenConfirmRequest(false); + }} + > +

Are you sure you want to confirm this request is reviewed?

+
); };