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

add warning msg
This commit is contained in:
Đỗ Xuân Tân 2024-07-05 10:55:19 +07:00 committed by GitHub Enterprise
commit aa8a16a520

View File

@ -26,7 +26,7 @@ import {
Tag,
} from 'antd';
import { isEmpty } from 'lodash-es';
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import Lightbox from 'react-awesome-lightbox';
import 'react-awesome-lightbox/build/style.css';
import { useHotkeys } from 'react-hotkeys-hook';
@ -225,7 +225,7 @@ const ReviewPage = () => {
.then((data) => {
setTotalPages(data?.page?.total_requests);
setHasNextRequest(requestIndex < data?.page?.total_requests);
fetchRequest(data?.subscription_requests[0].RequestID)
.then(async (data) => {
if (data) setCurrentRequest(data);
@ -303,7 +303,6 @@ const ReviewPage = () => {
throw new Error(await res.text());
}
} catch (error) {
console.log('🚀 ~ handleConfirmRequest ~ error:', error);
addRecentRequest(currentRequest?.RequestID, error, false);
notification.error({
message: getErrorMessage(error),
@ -385,6 +384,16 @@ const ReviewPage = () => {
});
};
const isSafeToConfirm = useMemo(() => {
let isSafe = true;
isSafe = !currentRequest?.Files.some((file) => {
const isRequired = file['Is Required'];
const isReviewed = file['Is Reviewed'];
return isRequired && !isReviewed;
});
return isSafe;
}, [currentRequest]);
return (
<div
style={
@ -1030,6 +1039,11 @@ const ReviewPage = () => {
setIsOpenConfirmRequest(false);
}}
>
{!isSafeToConfirm && (
<p style={{ fontWeight: 'bold', color: 'red' }}>
There is still at least 1 photo need to be reviewed!{' '}
</p>
)}
<p>Are you sure you want to confirm this request is reviewed?</p>
</Modal>
</div>