added resubmit icon
This commit is contained in:
parent
2ab2180c89
commit
95a3578d80
@ -70,6 +70,25 @@ const getStatusBadge = (status) => {
|
||||
}
|
||||
};
|
||||
|
||||
const isResubmitDisabled = (submission) => {
|
||||
// Only apply this logic for rejected records
|
||||
if (submission.originalData?.approve_reject_status !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const rejectedAt = submission.originalData?.rejected_at;
|
||||
if (!rejectedAt) {
|
||||
return false; // If no rejection date, keep enabled
|
||||
}
|
||||
|
||||
const currentDate = new Date();
|
||||
const rejectionDate = new Date(rejectedAt);
|
||||
const blockOnDate = new Date(rejectionDate);
|
||||
blockOnDate.setDate(blockOnDate.getDate() + 14);
|
||||
|
||||
return currentDate >= blockOnDate;
|
||||
};
|
||||
|
||||
const downloadCsv = (data) => {
|
||||
if (!data.length) return;
|
||||
|
||||
@ -362,11 +381,22 @@ const handleDeleteDraft = async (e, submission) => {
|
||||
</button>
|
||||
{item.status.toLowerCase() === 'rejected' && (
|
||||
<button
|
||||
onClick={() => handleResubmit(item)}
|
||||
className="text-[#9E792B] hover:text-[#7b5f22] font-medium"
|
||||
title="Resubmit"
|
||||
onClick={() => !isResubmitDisabled(item) && handleResubmit(item)}
|
||||
disabled={isResubmitDisabled(item)}
|
||||
className={`font-medium ${
|
||||
isResubmitDisabled(item)
|
||||
? 'text-[#A88632] cursor-not-allowed opacity-55'
|
||||
: 'text-[#9E792B] hover:text-[#7b5f22] cursor-pointer'
|
||||
}`}
|
||||
title={isResubmitDisabled(item) ? 'Resubmission deadline passed' : 'Resubmit'}
|
||||
>
|
||||
<HiMiniArrowPathRoundedSquare className="w-5 h-5 text-[#92722A] opacity-60 hover:opacity-100 transition-opacity" />
|
||||
<HiMiniArrowPathRoundedSquare
|
||||
className={`w-5 h-5 transition-opacity ${
|
||||
isResubmitDisabled(item)
|
||||
? 'text-[#A88632] cursor-not-allowed opacity-55'
|
||||
: 'text-[#92722A] opacity-60 hover:opacity-100'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -29,6 +29,25 @@ const formatDate = (dateString) => {
|
||||
return date.toLocaleDateString('en-GB');
|
||||
};
|
||||
|
||||
const isResubmitDisabled = (record) => {
|
||||
// Only apply this logic for rejected records
|
||||
if (record.approve_reject_status !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const rejectedAt = record.rejected_at;
|
||||
if (!rejectedAt) {
|
||||
return false; // If no rejection date, keep enabled
|
||||
}
|
||||
|
||||
const currentDate = new Date();
|
||||
const rejectionDate = new Date(rejectedAt);
|
||||
const blockOnDate = new Date(rejectionDate);
|
||||
blockOnDate.setDate(blockOnDate.getDate() + 14);
|
||||
|
||||
return currentDate >= blockOnDate;
|
||||
};
|
||||
|
||||
const Overview = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
@ -221,16 +240,19 @@ const showToast = (message, type = 'success') => {
|
||||
<img
|
||||
src="/assets/images/Eye.svg"
|
||||
alt="View"
|
||||
className="w-5 h-5 text-[#92722A] opacity-60 hover:opacity-100 transition-opacity"
|
||||
style={{ filter: 'invert(36%) sepia(49%) saturate(680%) hue-rotate(1deg) brightness(89%) contrast(91%)' }}
|
||||
className="w-5 h-5 text-[#A88632] opacity-60 hover:opacity-100 transition-opacity"
|
||||
/>
|
||||
{record.status === 'Rejected' && (
|
||||
<HiMiniArrowPathRoundedSquare
|
||||
className="w-5 h-5 text-[#92722A] opacity-60 hover:opacity-100 transition-opacity cursor-pointer"
|
||||
style={{ filter: 'invert(36%) sepia(49%) saturate(680%) hue-rotate(1deg) brightness(89%) contrast(91%)' }}
|
||||
title="Resubmit"
|
||||
className={`w-5 h-5 transition-opacity ${
|
||||
isResubmitDisabled(record)
|
||||
? 'text-[#A88632] opacity-30 cursor-not-allowed'
|
||||
: 'text-[#92722A] opacity-60 hover:opacity-100'
|
||||
}`}
|
||||
title={isResubmitDisabled(record) ? 'Resubmission deadline passed' : 'Resubmit'}
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
if (!isResubmitDisabled(record)) {
|
||||
try {
|
||||
const response = await fetchSubmissionDetail(record.id);
|
||||
const submissionData = response.data;
|
||||
@ -279,6 +301,7 @@ const showToast = (message, type = 'success') => {
|
||||
console.error('Error preparing resubmission:', error);
|
||||
// Optionally show error to user
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user