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) => {
|
const downloadCsv = (data) => {
|
||||||
if (!data.length) return;
|
if (!data.length) return;
|
||||||
|
|
||||||
@ -362,11 +381,22 @@ const handleDeleteDraft = async (e, submission) => {
|
|||||||
</button>
|
</button>
|
||||||
{item.status.toLowerCase() === 'rejected' && (
|
{item.status.toLowerCase() === 'rejected' && (
|
||||||
<button
|
<button
|
||||||
onClick={() => handleResubmit(item)}
|
onClick={() => !isResubmitDisabled(item) && handleResubmit(item)}
|
||||||
className="text-[#9E792B] hover:text-[#7b5f22] font-medium"
|
disabled={isResubmitDisabled(item)}
|
||||||
title="Resubmit"
|
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>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -29,6 +29,25 @@ const formatDate = (dateString) => {
|
|||||||
return date.toLocaleDateString('en-GB');
|
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 Overview = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -221,16 +240,19 @@ const showToast = (message, type = 'success') => {
|
|||||||
<img
|
<img
|
||||||
src="/assets/images/Eye.svg"
|
src="/assets/images/Eye.svg"
|
||||||
alt="View"
|
alt="View"
|
||||||
className="w-5 h-5 text-[#92722A] opacity-60 hover:opacity-100 transition-opacity"
|
className="w-5 h-5 text-[#A88632] opacity-60 hover:opacity-100 transition-opacity"
|
||||||
style={{ filter: 'invert(36%) sepia(49%) saturate(680%) hue-rotate(1deg) brightness(89%) contrast(91%)' }}
|
|
||||||
/>
|
/>
|
||||||
{record.status === 'Rejected' && (
|
{record.status === 'Rejected' && (
|
||||||
<HiMiniArrowPathRoundedSquare
|
<HiMiniArrowPathRoundedSquare
|
||||||
className="w-5 h-5 text-[#92722A] opacity-60 hover:opacity-100 transition-opacity cursor-pointer"
|
className={`w-5 h-5 transition-opacity ${
|
||||||
style={{ filter: 'invert(36%) sepia(49%) saturate(680%) hue-rotate(1deg) brightness(89%) contrast(91%)' }}
|
isResubmitDisabled(record)
|
||||||
title="Resubmit"
|
? 'text-[#A88632] opacity-30 cursor-not-allowed'
|
||||||
|
: 'text-[#92722A] opacity-60 hover:opacity-100'
|
||||||
|
}`}
|
||||||
|
title={isResubmitDisabled(record) ? 'Resubmission deadline passed' : 'Resubmit'}
|
||||||
onClick={async (e) => {
|
onClick={async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
if (!isResubmitDisabled(record)) {
|
||||||
try {
|
try {
|
||||||
const response = await fetchSubmissionDetail(record.id);
|
const response = await fetchSubmissionDetail(record.id);
|
||||||
const submissionData = response.data;
|
const submissionData = response.data;
|
||||||
@ -279,6 +301,7 @@ const showToast = (message, type = 'success') => {
|
|||||||
console.error('Error preparing resubmission:', error);
|
console.error('Error preparing resubmission:', error);
|
||||||
// Optionally show error to user
|
// Optionally show error to user
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user