bug fixed

This commit is contained in:
Malini 2026-01-05 11:03:28 +05:30
parent e2da3f439d
commit e451e179ad
2 changed files with 21 additions and 10 deletions

View File

@ -15,7 +15,7 @@ const STATUS_VARIANTS = {
Approved: { background: '#F3FAF4', text: '#2F663C', border: '#F3FAF4' }, Approved: { background: '#F3FAF4', text: '#2F663C', border: '#F3FAF4' },
Pending: { background: '#E7F5FF', text: '#286CFF', border: '#E7F5FF' }, Pending: { background: '#E7F5FF', text: '#286CFF', border: '#E7F5FF' },
Rejected: { background: '#FEF2F2', text: '#B52520', border: '#FEF2F2' }, Rejected: { background: '#FEF2F2', text: '#B52520', border: '#FEF2F2' },
Resubmitted: { background: '#F9F7ED', text: '#7C5E24', border: '#FEF2F2' }, Resubmitted: { background: '#F9F7ED', text: '#7C5E24', border: '#7C5E24' },
Submitted: { background: '#E7F5FF', text: '#003CFF', border: '#E7F5FF' }, Submitted: { background: '#E7F5FF', text: '#003CFF', border: '#E7F5FF' },
}; };
@ -25,7 +25,7 @@ const SUMMARY_VARIANTS = {
// pending: { background: '#E7F5FF', label: '#003CFF', value: '#232528' }, // pending: { background: '#E7F5FF', label: '#003CFF', value: '#232528' },
submitted: { background: '#E7F5FF', text: '#003CFF', value: '#232528',border: '#FEF2F2' }, submitted: { background: '#E7F5FF', text: '#003CFF', value: '#232528',border: '#FEF2F2' },
rejected: { background: '#FEF2F2', label: '#B52520', value: '#232528' }, rejected: { background: '#FEF2F2', label: '#B52520', value: '#232528' },
resubmitted: { background: '#F9F7ED', text: '#7C5E24', border: '#FEF2F2' }, resubmitted: { background: '#F9F7ED', label: '#7C5E24', value: '#7C5E24' },
}; };
@ -83,7 +83,13 @@ const ManageSubmissions = () => {
const [showRejectError, setShowRejectError] = React.useState(false); const [showRejectError, setShowRejectError] = React.useState(false);
const pageSize = 10; const pageSize = 10;
const [isInitialLoad, setIsInitialLoad] = React.useState(true); const [isInitialLoad, setIsInitialLoad] = React.useState(true);
const [filters, setFilters] = React.useState({
search: '',
year: '',
quarter: 'All',
emirate: 'All',
status: 'All'
});
const toastTimeoutRef = React.useRef(null); const toastTimeoutRef = React.useRef(null);
@ -293,6 +299,11 @@ React.useEffect(() => {
limit limit
}; };
// Ensure year is included in the API call if provided
if (year && year !== 'All') {
params.year = year;
}
const result = await getSubmissions(params); const result = await getSubmissions(params);
// Check if result has a data property or is the data array itself // Check if result has a data property or is the data array itself
const data = Array.isArray(result) ? result : (result?.data || []); const data = Array.isArray(result) ? result : (result?.data || []);
@ -357,8 +368,8 @@ React.useEffect(() => {
const yearOptions = React.useMemo(() => { const yearOptions = React.useMemo(() => {
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const years = []; const years = [];
// Generate years from 2022 to current year + 1 (to include current year) // Generate years from 2022 to current year
for (let y = 2022; y <= currentYear + 1; y++) { for (let y = 2022; y <= currentYear; y++) {
years.push(y.toString()); years.push(y.toString());
} }
return ['All', ...years].sort((a, b) => { return ['All', ...years].sort((a, b) => {
@ -366,14 +377,14 @@ React.useEffect(() => {
if (b === 'All') return 1; if (b === 'All') return 1;
return b.localeCompare(a); return b.localeCompare(a);
}); });
}, [submissions]); }, []);
const quarterOptions = React.useMemo(() => ['All', 'Q1', 'Q2', 'Q3', 'Q4'], []); const quarterOptions = React.useMemo(() => ['All', 'Q1', 'Q2', 'Q3', 'Q4'], []);
const emirateOptions = React.useMemo(() => ['All', ...new Set(submissions.map((i) => i.emirate))], [submissions]); const emirateOptions = React.useMemo(() => ['All', ...new Set(submissions.map((i) => i.emirate))], [submissions]);
const statusOptions = React.useMemo(() => { const statusOptions = React.useMemo(() => {
const statuses = [...new Set(submissions.map((i) => i.status))]; // Always return all possible statuses
return ['All', ...statuses]; return ['All', 'Approved', 'Submitted', 'Rejected', 'Resubmitted'];
}, [submissions]); }, []);
const filtered = React.useMemo(() => { const filtered = React.useMemo(() => {
const term = search.trim().toLowerCase(); const term = search.trim().toLowerCase();

View File

@ -924,7 +924,7 @@ const handleSave = async () => {
} }
value={form.year} value={form.year}
onChange={(e) => handleFormChange('year')(e.target.value)} onChange={(e) => handleFormChange('year')(e.target.value)}
options={Array.from({ length: 7 }).map((_, idx) => { options={Array.from({ length: new Date().getFullYear() - 2021 }, (_, idx) => {
const yr = 2022 + idx; const yr = 2022 + idx;
return { label: String(yr), value: String(yr) }; return { label: String(yr), value: String(yr) };
})} })}