diff --git a/components/appointment/detail/Form.js b/components/appointment/detail/Form.js index 239206a..d1fe8b9 100644 --- a/components/appointment/detail/Form.js +++ b/components/appointment/detail/Form.js @@ -2,8 +2,8 @@ import Content from "./Content"; import EditField from "../../../app/component/fields/EditField"; import DefaultSelect from "@/app/component/selectors/DefaultSelect"; -function Form({ changeData, insurance, data, isForAnother }) { - const findVal = () => { +function Form({ changeData, insurance, supplementaryInsurance, data, isForAnother }) { + const findBasicInsuranceVal = () => { return insurance?.find( (g) => g.id === @@ -11,6 +11,14 @@ function Form({ changeData, insurance, data, isForAnother }) { ); }; + const findSupplementaryInsuranceVal = () => { + return supplementaryInsurance?.find( + (g) => + g.id === + (data?.supplementary_insurance?.value ? data?.supplementary_insurance.value.id : false) + ); + }; + return (
- + + + + changeData(val, "value", name)} label="نوع بیمه" name="basic_insurance" list={insurance} - value={findVal()} + value={findBasicInsuranceVal()} + /> + + + changeData(val, "value", name)} + label="بیمه تکمیلی" + name="supplementary_insurance" + list={supplementaryInsurance} + value={findSupplementaryInsuranceVal()} />
diff --git a/components/appointment/detail/index.js b/components/appointment/detail/index.js index 8b61501..9751fad 100644 --- a/components/appointment/detail/index.js +++ b/components/appointment/detail/index.js @@ -17,6 +17,7 @@ function Detail({ setIsPay, }) { const [insurance, setInsurance] = useState(); + const [supplementaryInsurance, setSupplementaryInsurance] = useState(); const changeData = (value, type, name) => setData({ ...data, @@ -27,11 +28,19 @@ function Detail({ }); useEffect(() => { + // دریافت لیست بیمه پایه request.getInsuranceType().then((res) => { if (res && res.data) { setInsurance(res.data); } }); + + // دریافت لیست بیمه تکمیلی + request.getSupplementaryInsurance().then((res) => { + if (res && res.data) { + setSupplementaryInsurance(res.data); + } + }); }, []); return ( @@ -56,6 +65,7 @@ function Detail({
diff --git a/services/response.js b/services/response.js index ef6631f..efee94c 100644 --- a/services/response.js +++ b/services/response.js @@ -42,6 +42,8 @@ export const request = { getUserInfo: (headers) => api.get("oauth/userinfo", { ...headers, requireAuth: true }), getInsuranceType: (page = 1, limit = 10) => api.get(`api/v1/categorys/insurance_type?page=${page}&limit=${limit}`, removeTokenHead), + getSupplementaryInsurance: (page = 1, limit = 100) => + api.get(`api/v1/categorys/supplementary_insurance?page=${page}&limit=${limit}`, removeTokenHead), getDoctors: (params) => api.get("api/v1/doctors", { params,