admin dashoard & submission table empty column data added

This commit is contained in:
Senthamilselvi 2025-11-03 10:46:20 +05:30
parent 9d473ecaa8
commit aca131ae33
2 changed files with 44 additions and 35 deletions

View File

@ -74,7 +74,7 @@ const SubmissionTable = ({ selectedQuarter, selectedYear }) => {
'Submission Date & Time', 'Submission Date & Time',
'Status', 'Status',
'Reviewer', 'Reviewer',
'Reviewer On', 'Reviewed On',
'Actions', 'Actions',
]; ];
@ -107,45 +107,51 @@ const SubmissionTable = ({ selectedQuarter, selectedYear }) => {
} }
}; };
const userProfile = JSON.parse(sessionStorage.getItem("user_profile"));
const tableRows = filtered.map((item) => [ const tableRows = filtered.map((item) => [
item?.establishment?.factory_name || '-', item?.establishment?.factory_name || '-',
item?.establishment?.establishment_emirate?.name || '-', item?.establishment?.establishment_emirate?.name || '-',
item?.year || '-', item?.year || '-',
item?.quarter || '-', item?.quarter || '-',
item?.product_count || '-', item?.product_count || '-',
item?.created_by || '-', // item?.created_by || '-',
userProfile?.name || '-',
<span className="whitespace-nowrap">{formatDate(item?.created_at)}</span>, <span className="whitespace-nowrap">{formatDate(item?.created_at)}</span>,
renderStatusBadge(item?.status), renderStatusBadge(item?.status),
item?.updated_by || '-', // item?.updated_by || '-',
<span className="whitespace-nowrap">{formatDate(item?.updated_at)}</span>, userProfile?.name || '-',
<div className="flex items-center justify-center gap-[10px]"> // <span className="whitespace-nowrap">{formatDate(item?.updated_at)}</span>,
<div className="relative group"> <span className="whitespace-nowrap">{formatDate(item?.created_at)}</span>,
<CheckCircle2 size={22} className="text-green-600 cursor-pointer hover:scale-110 transition-transform" /> <div className="flex items-center justify-center gap-[10px]">
<span className="absolute bottom-full mb-1 left-1/2 -translate-x-1/2 bg-black text-white text-xs px-2 py-[2px] rounded opacity-0 group-hover:opacity-100 transition"> <div className="relative group">
Approve <CheckCircle2 size={22} className="text-green-600 cursor-pointer hover:scale-110 transition-transform" />
</span> <span className="absolute bottom-full mb-1 left-1/2 -translate-x-1/2 bg-black text-white text-xs px-2 py-[2px] rounded opacity-0 group-hover:opacity-100 transition">
</div> Approve
<div className="relative group"> </span>
<XCircle size={22} className="text-red-600 cursor-pointer hover:scale-110 transition-transform" /> </div>
<span className="absolute bottom-full mb-1 left-1/2 -translate-x-1/2 bg-black text-white text-xs px-2 py-[2px] rounded opacity-0 group-hover:opacity-100 transition"> <div className="relative group">
Reject <XCircle size={22} className="text-red-600 cursor-pointer hover:scale-110 transition-transform" />
</span> <span className="absolute bottom-full mb-1 left-1/2 -translate-x-1/2 bg-black text-white text-xs px-2 py-[2px] rounded opacity-0 group-hover:opacity-100 transition">
</div> Reject
<div className="relative group"> </span>
<Eye </div>
size={22} <div className="relative group">
className={`cursor-pointer hover:scale-110 transition-transform ${ <Eye
item.status?.toLowerCase() === 'pending' ? 'text-[#9E792B]' : 'text-gray-500' size={22}
}`} className={`cursor-pointer hover:scale-110 transition-transform ${
onClick={() => navigate(`/admin/validations/${item.id}`)} item.status?.toLowerCase() === 'pending' ? 'text-[#9E792B]' : 'text-gray-500'
/> }`}
<span className="absolute bottom-full mb-1 left-1/2 -translate-x-1/2 bg-black text-white text-xs px-2 py-[2px] rounded opacity-0 group-hover:opacity-100 transition"> onClick={() => navigate(`/admin/validations/${item.id}`)}
View />
</span> <span className="absolute bottom-full mb-1 left-1/2 -translate-x-1/2 bg-black text-white text-xs px-2 py-[2px] rounded opacity-0 group-hover:opacity-100 transition">
</div> View
</div>, </span>
</div>
</div>,
]); ]);
const columnWidths = [240, 120, 100, 100, 130, 150, 180, 150, 150, 180, 120]; const columnWidths = [240, 120, 100, 100, 130, 150, 180, 150, 150, 180, 120];
return ( return (

View File

@ -107,7 +107,7 @@ const ManageSubmissions = () => {
try { try {
const result = await getSubmissions(); const result = await getSubmissions();
const data = result?.status === 'success' ? result.data : result; const data = result?.status === 'success' ? result.data : result;
const userProfile = JSON.parse(sessionStorage.getItem("user_profile"));
const mapped = (data || []).map((item) => ({ const mapped = (data || []).map((item) => ({
id: item.id, id: item.id,
establishment: item?.establishment?.factory_name || '-', establishment: item?.establishment?.factory_name || '-',
@ -115,11 +115,14 @@ const ManageSubmissions = () => {
year: String(item.year ?? '-'), year: String(item.year ?? '-'),
quarter: item.quarter ?? '-', quarter: item.quarter ?? '-',
products: item?.product_count || '-', products: item?.product_count || '-',
submittedBy: item.created_by ?? '-', // submittedBy: item.created_by ?? '-',
submittedBy: userProfile?.name || '-',
submittedAt: formatDateTime(item.created_at), submittedAt: formatDateTime(item.created_at),
status: item.status ?? '-', status: item.status ?? '-',
reviewer: item?.updated_by || '-', // reviewer: item?.updated_by || '-',
reviewerOn: formatDateTime(item?.updated_at), reviewer: userProfile?.name || '-',
// reviewerOn: formatDateTime(item?.updated_at),
reviewerOn: formatDateTime(item.created_at),
})); }));
setSubmissions(mapped); setSubmissions(mapped);
@ -190,7 +193,7 @@ const ManageSubmissions = () => {
item, item,
]); ]);
const columnWidths = [302, 105, 83, 91, 100, 152, 208, 120, 104, 140, 130]; const columnWidths = [302, 105, 83, 91, 100, 152, 208, 120, 120, 208, 130];
const toolbar = ( const toolbar = (
<div className="px-6 pt-6 pb-5 space-y-4"> <div className="px-6 pt-6 pb-5 space-y-4">