update modal confir

This commit is contained in:
phanphan 2024-06-20 13:27:41 +07:00
parent 6279fdc30c
commit e797c40eb4
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 extensionType = fileName.split('.').pop();
const isRequired = file['Is Required'];
const isReviewd = file['Is Reviewed'];
const isReviewed = file['Is Reviewed'];
return (
<div
@ -60,7 +60,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
>
{isRequired ? (
<>
{isReviewd ? (
{isReviewed ? (
<Tag
color={'success'}
style={{
@ -69,7 +69,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
textTransform: 'capitalize',
}}
>
Reviewd
Reviewed
</Tag>
) : (
<Tag

View File

@ -63,7 +63,7 @@ const ReviewPage = () => {
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
</Button>
@ -1012,6 +1007,20 @@ const ReviewPage = () => {
</div>
</Form>
</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>
);
};