Merge pull request #143 from SDSRV-IDP/factory/review

update modal confirm
This commit is contained in:
Đỗ Xuân Tân 2024-06-24 17:18:31 +07:00 committed by GitHub Enterprise
commit 1b31765b69
2 changed files with 31 additions and 22 deletions

View File

@ -5,7 +5,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
const fileName = file['File Name']; const fileName = file['File Name'];
const extensionType = fileName.split('.').pop(); const extensionType = fileName.split('.').pop();
const isRequired = file['Is Required']; const isRequired = file['Is Required'];
const isReviewd = file['Is Reviewed']; const isReviewed = file['Is Reviewed'];
return ( return (
<div <div
@ -60,7 +60,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
> >
{isRequired ? ( {isRequired ? (
<> <>
{isReviewd ? ( {isReviewed ? (
<Tag <Tag
color={'success'} color={'success'}
style={{ style={{
@ -69,7 +69,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
textTransform: 'capitalize', textTransform: 'capitalize',
}} }}
> >
Reviewd Reviewed
</Tag> </Tag>
) : ( ) : (
<Tag <Tag

View File

@ -63,7 +63,7 @@ const ReviewPage = () => {
const [selectedFileData, setSelectedFileData] = useState(null); const [selectedFileData, setSelectedFileData] = useState(null);
const [selectedFileDataSource, setSelectedFileDataSource] = useState({}); const [selectedFileDataSource, setSelectedFileDataSource] = useState({});
const [selectedFileName, setSelectedFileName] = useState(null); const [selectedFileName, setSelectedFileName] = useState(null);
const [isOpenConfirmRequest, setIsOpenConfirmRequest] = useState(false);
// Default date range: 1 month ago to today // Default date range: 1 month ago to today
const [filterDateRange, setFilterDateRange] = useState(['', '']); const [filterDateRange, setFilterDateRange] = useState(['', '']);
@ -290,23 +290,18 @@ const ReviewPage = () => {
}; };
const handleConfirmReview = async () => { const handleConfirmReview = async () => {
const isConfirmed = window.confirm( try {
'Are you sure you want to confirm this request is reviewed?', await updateRevisedData(currentRequest?.RequestID);
); addRecentRequest(currentRequest?.RequestID);
if (isConfirmed) { setCurrentRequest({
try { ...currentRequest,
await updateRevisedData(currentRequest?.RequestID); ['Is Reviewed']: true,
addRecentRequest(currentRequest?.RequestID); });
setCurrentRequest({ notification.success({ message: 'Update file success' });
...currentRequest, } catch (error) {
['Is Reviewed']: true, notification.error({
}); message: getErrorMessage(error),
notification.success({ message: 'Update file success' }); });
} catch (error) {
notification.error({
message: getErrorMessage(error),
});
}
} }
}; };
@ -699,7 +694,7 @@ const ReviewPage = () => {
size='middle' size='middle'
disabled={currentRequest && currentRequest['Is Reviewed']} disabled={currentRequest && currentRequest['Is Reviewed']}
style={{ minWidth: '120px' }} style={{ minWidth: '120px' }}
onClick={handleConfirmReview} onClick={() => setIsOpenConfirmRequest(true)}
> >
Confirm request Confirm request
</Button> </Button>
@ -1012,6 +1007,20 @@ const ReviewPage = () => {
</div> </div>
</Form> </Form>
</Modal> </Modal>
<Modal
title='Confirm this request?'
centered
open={isOpenConfirmRequest}
onOk={() => {
setIsOpenConfirmRequest(false);
handleConfirmReview();
}}
onCancel={() => {
setIsOpenConfirmRequest(false);
}}
>
<p>Are you sure you want to confirm this request is reviewed?</p>
</Modal>
</div> </div>
); );
}; };