table search no submission found solved
This commit is contained in:
parent
6813f23c42
commit
83361a76e0
@ -100,13 +100,11 @@ export const SubmissionHistory = ({ history = [], loading = false, error = '' })
|
|||||||
}, [history]);
|
}, [history]);
|
||||||
|
|
||||||
const filtered = normalizedHistory.filter((entry) => {
|
const filtered = normalizedHistory.filter((entry) => {
|
||||||
const term = searchTerm.trim().toLowerCase();
|
const term = searchTerm.trim().toLowerCase().replace(/\s+/g, '');
|
||||||
return (
|
if (!term) return true;
|
||||||
!term ||
|
|
||||||
entry.survey_name.toLowerCase().includes(term) ||
|
return Object.values(entry).some((val) =>
|
||||||
entry.year.toString().includes(term) ||
|
String(val).toLowerCase().replace(/\s+/g, '').includes(term)
|
||||||
entry.quarter.toLowerCase().includes(term) ||
|
|
||||||
entry.status.toLowerCase().includes(term)
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -209,6 +207,10 @@ export const SubmissionHistory = ({ history = [], loading = false, error = '' })
|
|||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="flex items-center justify-center h-[500px] text-gray-500">
|
<div className="flex items-center justify-center h-[500px] text-gray-500">
|
||||||
Loading submissions...
|
Loading submissions...
|
||||||
|
</div>
|
||||||
|
) : filtered.length === 0 ? (
|
||||||
|
<div className="flex items-center justify-center py-20 text-[#7B5C1F] font-semibold text-[15px]">
|
||||||
|
No Submission Found
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
|
|||||||
@ -142,15 +142,19 @@ const ManageSubmissions = () => {
|
|||||||
const statusOptions = React.useMemo(() => ['All', ...new Set(submissions.map((i) => i.status))], [submissions]);
|
const statusOptions = React.useMemo(() => ['All', ...new Set(submissions.map((i) => i.status))], [submissions]);
|
||||||
|
|
||||||
const filtered = React.useMemo(() => {
|
const filtered = React.useMemo(() => {
|
||||||
|
const term = search.trim().toLowerCase();
|
||||||
|
|
||||||
return submissions.filter((item) => {
|
return submissions.filter((item) => {
|
||||||
const matchSearch =
|
const allValues = Object.values(item)
|
||||||
!search ||
|
.map((v) => String(v ?? '').toLowerCase())
|
||||||
item.establishment?.toLowerCase().includes(search.toLowerCase()) ||
|
.join(' ');
|
||||||
item.submittedBy?.toLowerCase().includes(search.toLowerCase());
|
|
||||||
|
const matchSearch = !term || allValues.includes(term);
|
||||||
const matchYear = !year || year === 'All' || item.year === year;
|
const matchYear = !year || year === 'All' || item.year === year;
|
||||||
const matchQuarter = !quarter || quarter === 'All' || item.quarter === quarter;
|
const matchQuarter = !quarter || quarter === 'All' || item.quarter === quarter;
|
||||||
const matchEmirate = !emirate || emirate === 'All' || item.emirate === emirate;
|
const matchEmirate = !emirate || emirate === 'All' || item.emirate === emirate;
|
||||||
const matchStatus = !status || status === 'All' || item.status === status;
|
const matchStatus = !status || status === 'All' || item.status === status;
|
||||||
|
|
||||||
return matchSearch && matchYear && matchQuarter && matchEmirate && matchStatus;
|
return matchSearch && matchYear && matchQuarter && matchEmirate && matchStatus;
|
||||||
});
|
});
|
||||||
}, [submissions, search, year, quarter, emirate, status]);
|
}, [submissions, search, year, quarter, emirate, status]);
|
||||||
@ -354,10 +358,16 @@ const ManageSubmissions = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-2xl border border-[#E5E7EB] bg-white shadow overflow-hidden">
|
<div className="rounded-2xl border border-[#E5E7EB] bg-white shadow overflow-hidden">
|
||||||
|
{toolbar}
|
||||||
|
|
||||||
|
{filtered.length === 0 ? (
|
||||||
|
<div className="flex items-center justify-center py-16 text-[#7B5C1F] font-semibold text-sm border-t border-[#E5E7EB]">
|
||||||
|
No Submission Found
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Table
|
<Table
|
||||||
headers={headers}
|
headers={headers}
|
||||||
rows={tableRows}
|
rows={tableRows}
|
||||||
beforeHeader={toolbar}
|
|
||||||
separated
|
separated
|
||||||
columnWidths={columnWidths}
|
columnWidths={columnWidths}
|
||||||
pagination={{
|
pagination={{
|
||||||
@ -433,7 +443,9 @@ const ManageSubmissions = () => {
|
|||||||
return value;
|
return value;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user