Skip to content

Commit 36ecb64

Browse files
authored
validation fix (#404) (#405)
2 parents 4ba1c68 + 18dee33 commit 36ecb64

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/components/JAF/JobDetails.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,37 @@ const JobDetails = ({
301301
const [courses, setCourses] = useState<string[]>([]);
302302
const [branches, setBranches] = useState<string[]>([]);
303303

304+
// Prevent placement-only required fields from blocking INTERN submissions
305+
useEffect(() => {
306+
if (seasonType !== "INTERN") return;
307+
308+
const currentSalaries = form.getFieldValue("salaries") || [];
309+
if (!Array.isArray(currentSalaries) || currentSalaries.length === 0) return;
310+
311+
let didChange = false;
312+
const updated = currentSalaries.map((s: any) => {
313+
const next = { ...s };
314+
if (next.baseSalary === undefined || next.baseSalary === null) {
315+
next.baseSalary = 1; // minimal placeholder to satisfy required validation elsewhere
316+
didChange = true;
317+
}
318+
if (next.totalCTC === undefined || next.totalCTC === null) {
319+
next.totalCTC = 1;
320+
didChange = true;
321+
}
322+
if (next.firstYearCTC === undefined || next.firstYearCTC === null) {
323+
next.firstYearCTC = 1;
324+
didChange = true;
325+
}
326+
return next;
327+
});
328+
329+
if (didChange) {
330+
form.setFieldValue("salaries", updated);
331+
setFieldValue("salaries", updated);
332+
}
333+
}, [seasonType]);
334+
304335
const [selectedYears, setSelectedYears] = useState<string[]>([]);
305336
const [selectedCourses, setSelectedCourses] = useState<string[]>([]);
306337
const [selectedBranches, setSelectedBranches] = useState<string[]>([]);

0 commit comments

Comments
 (0)