|
|
@ -1,11 +1,15 @@ |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
import './index.scss' |
|
|
|
import './index.scss' |
|
|
|
import { apiCaller } from '../../../../_helpers'; |
|
|
|
import { apiCaller, history } from '../../../../_helpers'; |
|
|
|
import InputSelectSearch from '../../../../_components/Auth/InputSelectSearch'; |
|
|
|
import InputSelectSearch from '../../../../_components/Auth/InputSelectSearch'; |
|
|
|
import { renderLocationIcon, renderSchoolIcon } from './renderIcon'; |
|
|
|
import { renderLocationIcon, renderSchoolIcon } from './renderIcon'; |
|
|
|
import { stepAuthConstants } from '../../../../_constants/auth'; |
|
|
|
import { stepAuthConstants } from '../../../../_constants/auth'; |
|
|
|
|
|
|
|
import { useParams } from 'react-router-dom'; |
|
|
|
|
|
|
|
import { registerValue } from '../../../../_constants/register'; |
|
|
|
|
|
|
|
|
|
|
|
export default function AddressStudying(props) { |
|
|
|
export default function AddressStudying(props) { |
|
|
|
|
|
|
|
const params = useParams() |
|
|
|
|
|
|
|
const orgLevel = params?.orgLevel |
|
|
|
const [school, setSchool] = useState({ |
|
|
|
const [school, setSchool] = useState({ |
|
|
|
title: '', |
|
|
|
title: '', |
|
|
|
value: '', |
|
|
|
value: '', |
|
|
@ -14,13 +18,13 @@ export default function AddressStudying(props) { |
|
|
|
// address |
|
|
|
// address |
|
|
|
const [provinceList, setProvinceList] = useState([]); |
|
|
|
const [provinceList, setProvinceList] = useState([]); |
|
|
|
const [province, setProvince] = useState({ |
|
|
|
const [province, setProvince] = useState({ |
|
|
|
title: "Nam Định", |
|
|
|
title: "", |
|
|
|
value: "nam_Dinh_", |
|
|
|
value: props?.registerInfo?.province_alias || "nam_dinh_", |
|
|
|
}); |
|
|
|
}); |
|
|
|
const [districtList, setDistrictList] = useState([]); |
|
|
|
const [districtList, setDistrictList] = useState([]); |
|
|
|
const [district, setDistrict] = useState({ |
|
|
|
const [district, setDistrict] = useState({ |
|
|
|
title: "", |
|
|
|
title: "", |
|
|
|
value: "", |
|
|
|
value: props?.registerInfo?.district_alias || "", |
|
|
|
}); |
|
|
|
}); |
|
|
|
const [schoolList, setSchoolList] = useState([]); |
|
|
|
const [schoolList, setSchoolList] = useState([]); |
|
|
|
const [errProvince, setErrProvince] = useState(""); |
|
|
|
const [errProvince, setErrProvince] = useState(""); |
|
|
@ -60,7 +64,7 @@ export default function AddressStudying(props) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getOrganizationList = (districtAlias) => { |
|
|
|
const getOrganizationList = (districtAlias) => { |
|
|
|
apiCaller(`/api_organization/get_represent_code?district_alias=${districtAlias}&represent_code=nd1`).then( |
|
|
|
apiCaller(`/api_organization/get_represent_code?district_alias=${districtAlias}&represent_code=${props?.registerInfo?.represent_code}`).then( |
|
|
|
(res) => { |
|
|
|
(res) => { |
|
|
|
if(res?.status) { |
|
|
|
if(res?.status) { |
|
|
|
setOrganizationList(res.data) |
|
|
|
setOrganizationList(res.data) |
|
|
@ -129,9 +133,38 @@ export default function AddressStudying(props) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
getDistrictList(province.value); |
|
|
|
if(!props?.registerInfo) { |
|
|
|
|
|
|
|
history.push('/namdinh') |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(province.value) { |
|
|
|
|
|
|
|
getDistrictList(province.value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (district.value) { |
|
|
|
|
|
|
|
getOrganizationList(district.value); |
|
|
|
|
|
|
|
} |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if(!!registerValue?.[orgLevel]?.represent_code) { |
|
|
|
|
|
|
|
if(!!registerValue[orgLevel]?.province_alias) { |
|
|
|
|
|
|
|
setProvince({ |
|
|
|
|
|
|
|
title: '', |
|
|
|
|
|
|
|
value: registerValue[orgLevel].province_alias |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
getDistrictList(registerValue[orgLevel]?.province_alias); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!!registerValue[orgLevel]?.district_alias) { |
|
|
|
|
|
|
|
setDistrict({ |
|
|
|
|
|
|
|
title: '', |
|
|
|
|
|
|
|
value: registerValue[orgLevel].district_alias |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
getOrganizationList(registerValue[orgLevel]?.district_alias); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
props.setRegisterInfo(registerValue[orgLevel]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [orgLevel]) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="sunE-form-container login-form-container register_create_account register_step"> |
|
|
|
<div className="sunE-form-container login-form-container register_create_account register_step"> |
|
|
|
<div className="sunE-custom-form login-form-container_content responsive_small_screen_margin_login"> |
|
|
|
<div className="sunE-custom-form login-form-container_content responsive_small_screen_margin_login"> |
|
|
@ -162,7 +195,7 @@ export default function AddressStudying(props) { |
|
|
|
errorAbsolute={true} |
|
|
|
errorAbsolute={true} |
|
|
|
bottomErr={true} |
|
|
|
bottomErr={true} |
|
|
|
/> */} |
|
|
|
/> */} |
|
|
|
<InputSelectSearch |
|
|
|
{!!props?.registerInfo?.province_alias && !props?.registerInfo?.district_alias && <InputSelectSearch |
|
|
|
className="field_item field_district" |
|
|
|
className="field_item field_district" |
|
|
|
value={district} |
|
|
|
value={district} |
|
|
|
setValue={changeDistrict} |
|
|
|
setValue={changeDistrict} |
|
|
@ -183,7 +216,7 @@ export default function AddressStudying(props) { |
|
|
|
setErrorText={setErrDistrict} |
|
|
|
setErrorText={setErrDistrict} |
|
|
|
errorAbsolute={true} |
|
|
|
errorAbsolute={true} |
|
|
|
bottomErr={true} |
|
|
|
bottomErr={true} |
|
|
|
/> |
|
|
|
/>} |
|
|
|
<InputSelectSearch |
|
|
|
<InputSelectSearch |
|
|
|
className="field_item field_school" |
|
|
|
className="field_item field_school" |
|
|
|
value={organization} |
|
|
|
value={organization} |
|
|
@ -194,8 +227,8 @@ export default function AddressStudying(props) { |
|
|
|
title: item.name, |
|
|
|
title: item.name, |
|
|
|
}; |
|
|
|
}; |
|
|
|
})} |
|
|
|
})} |
|
|
|
placeholder="Tổ chức" |
|
|
|
placeholder="Trường" |
|
|
|
titleHeader="Chọn Tổ chức" |
|
|
|
titleHeader="Chọn Trường" |
|
|
|
renderLabelIcon={renderSchoolIcon} |
|
|
|
renderLabelIcon={renderSchoolIcon} |
|
|
|
disabledClick={!district.value} |
|
|
|
disabledClick={!district.value} |
|
|
|
onClickDisable={() => { |
|
|
|
onClickDisable={() => { |
|
|
|