Files
hounam-submit-form-frontend/ui/forms/JobRequestSection.tsx
2026-05-31 14:22:39 +03:30

44 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { useState } from "react";
import { Button, Box } from "@mui/material";
import JobRequestForm from "./JobRequestForm";
import { AddCircleOutlineOutlined } from "@mui/icons-material";
export default function JobRequestSection() {
const [jobs, setJobs] = useState([{ id: Date.now(), jobCategoryId: "", hasPlan: false, planStartDate: null, degree: "" }]);
const addJob = () => {
setJobs([...jobs, { id: Date.now(), jobCategoryId: "", hasPlan: false, planStartDate: null, degree: "" }]);
};
const updateJob = (id, updatedData) => {
setJobs(jobs.map(j => j.id === id ? { ...updatedData, id } : j));
};
const removeJob = (id) => {
if (jobs.length > 1) setJobs(jobs.filter(j => j.id !== id));
};
return (
<div className="space-y-10 ">
{jobs.map((job) => (
<JobRequestForm
key={job.id}
data={job}
onChange={(newData) => updateJob(job.id, newData)}
onRemove={() => removeJob(job.id)}
isDeletable={jobs.length > 1}
/>
))}
<Button
variant="outlined"
startIcon={<AddCircleOutlineOutlined />}
onClick={addJob}
sx={{ mt: 1, borderColor: '#4caf50', color: '#4caf50' }}
>
افزودن شغل درخواستی جدید
</Button>
</div>
);
}