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,63 +240,67 @@ 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();
|
||||
try {
|
||||
const response = await fetchSubmissionDetail(record.id);
|
||||
const submissionData = response.data;
|
||||
|
||||
// Structure the data in the format expected by the component
|
||||
const formattedData = {
|
||||
...submissionData,
|
||||
establishment: {
|
||||
...submissionData.establishment,
|
||||
establishment_contact_email: submissionData.establishment.establishment_contact_email,
|
||||
emirate: submissionData.establishment.establishment_emirate_id,
|
||||
establishment_emirate_id: submissionData.establishment.establishment_emirate_id
|
||||
},
|
||||
employeeInfo: {
|
||||
emiratiMale: submissionData.establishment.emirati_male,
|
||||
emiratiFemale: submissionData.establishment.emirati_female,
|
||||
nonEmiratiMale: submissionData.establishment.non_emirati_male,
|
||||
nonEmiratiFemale: submissionData.establishment.non_emirati_female,
|
||||
totalEmirati: submissionData.establishment.total_emirati,
|
||||
totalEmployees: submissionData.establishment.total_employees
|
||||
},
|
||||
products: submissionData.products || [],
|
||||
quarterWindow: submissionData.quarter_window || {}
|
||||
};
|
||||
if (!isResubmitDisabled(record)) {
|
||||
try {
|
||||
const response = await fetchSubmissionDetail(record.id);
|
||||
const submissionData = response.data;
|
||||
|
||||
// Structure the data in the format expected by the component
|
||||
const formattedData = {
|
||||
...submissionData,
|
||||
establishment: {
|
||||
...submissionData.establishment,
|
||||
establishment_contact_email: submissionData.establishment.establishment_contact_email,
|
||||
emirate: submissionData.establishment.establishment_emirate_id,
|
||||
establishment_emirate_id: submissionData.establishment.establishment_emirate_id
|
||||
},
|
||||
employeeInfo: {
|
||||
emiratiMale: submissionData.establishment.emirati_male,
|
||||
emiratiFemale: submissionData.establishment.emirati_female,
|
||||
nonEmiratiMale: submissionData.establishment.non_emirati_male,
|
||||
nonEmiratiFemale: submissionData.establishment.non_emirati_female,
|
||||
totalEmirati: submissionData.establishment.total_emirati,
|
||||
totalEmployees: submissionData.establishment.total_employees
|
||||
},
|
||||
products: submissionData.products || [],
|
||||
quarterWindow: submissionData.quarter_window || {}
|
||||
};
|
||||
|
||||
// Save the complete data to localStorage
|
||||
localStorage.setItem('resubmissionData', JSON.stringify(formattedData));
|
||||
|
||||
// Save products separately
|
||||
if (submissionData.products && submissionData.products.length > 0) {
|
||||
localStorage.setItem('submissionProducts', JSON.stringify(submissionData.products));
|
||||
// Save the complete data to localStorage
|
||||
localStorage.setItem('resubmissionData', JSON.stringify(formattedData));
|
||||
|
||||
// Save products separately
|
||||
if (submissionData.products && submissionData.products.length > 0) {
|
||||
localStorage.setItem('submissionProducts', JSON.stringify(submissionData.products));
|
||||
}
|
||||
|
||||
// Set resubmission flags
|
||||
localStorage.setItem('isResubmission', 'true');
|
||||
|
||||
// Navigate to survey with resubmission state
|
||||
navigate('/survey', {
|
||||
state: {
|
||||
submission: formattedData,
|
||||
isResubmit: true,
|
||||
fromResubmit: true
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error preparing resubmission:', error);
|
||||
// Optionally show error to user
|
||||
}
|
||||
|
||||
// Set resubmission flags
|
||||
localStorage.setItem('isResubmission', 'true');
|
||||
|
||||
// Navigate to survey with resubmission state
|
||||
navigate('/survey', {
|
||||
state: {
|
||||
submission: formattedData,
|
||||
isResubmit: true,
|
||||
fromResubmit: true
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error preparing resubmission:', error);
|
||||
// Optionally show error to user
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user