|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import React, { Component } from "react"; |
|
|
|
|
import onInput from "~/util/onInput"; |
|
|
|
|
import { user, file } from "~/Redux/actions"; |
|
|
|
|
import { user, file, publicApi } from "~/Redux/actions"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
|
|
import Select from "./Select/index"; |
|
|
|
@ -14,8 +14,8 @@ import Loader from "~/components/Loader/index"; |
|
|
|
|
import Document from "./Document/index"; |
|
|
|
|
import logo from "../../../assets/icons/logo.png"; |
|
|
|
|
import pic from "../../../assets/images/pic.png"; |
|
|
|
|
import { useHistory } from "react-router-dom"; |
|
|
|
|
import "./index.scss"; |
|
|
|
|
import { useHistory } from "react-router-dom"; |
|
|
|
|
function Navigate({ path }) { |
|
|
|
|
let history = useHistory(); |
|
|
|
|
return <>{history.push(path)}</>; |
|
|
|
@ -47,7 +47,8 @@ class Profile extends Component { |
|
|
|
|
file: this.props.uploads["file"] || this.props.profile.picFileId || null, |
|
|
|
|
picFileId: |
|
|
|
|
this.props.uploads["file"] || this.props.profile.picFileId || null, |
|
|
|
|
docFileIds: "", |
|
|
|
|
docFileIds: |
|
|
|
|
this.props.uploads["docFileIds"] || this.props.profile.docFileIds || "", |
|
|
|
|
firstName: "", |
|
|
|
|
lastName: "", |
|
|
|
|
password: "", |
|
|
|
@ -58,13 +59,15 @@ class Profile extends Component { |
|
|
|
|
gender: this.props.profile.gender || 1, |
|
|
|
|
status: this.props.profile.status || 1, |
|
|
|
|
nationalId: "", |
|
|
|
|
provinceId: "", |
|
|
|
|
|
|
|
|
|
phone: "", |
|
|
|
|
cityId: "", |
|
|
|
|
|
|
|
|
|
zoneId: "", |
|
|
|
|
schoolId: "", |
|
|
|
|
postalCode: "", |
|
|
|
|
gradeIds: this.props.profile.gradeIds, |
|
|
|
|
provinceId: this.props.profile.provinceId, |
|
|
|
|
cityId: this.props.profile.cityId, |
|
|
|
|
|
|
|
|
|
validation: { |
|
|
|
|
firstName: "", |
|
|
|
@ -78,20 +81,28 @@ class Profile extends Component { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
this.props.getProvince(); |
|
|
|
|
this.props.getCity({ provinceId: this.props.profile.provinceId }); |
|
|
|
|
// this.props.getProfile();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onChange = (name, value) => { |
|
|
|
|
// if (name === "gradeIds" && this.state.status == 2) {
|
|
|
|
|
// this.setState((prevState) => ({
|
|
|
|
|
// gradeIds: [...prevState.gradeIds.split(","), value],
|
|
|
|
|
// }));
|
|
|
|
|
// } else
|
|
|
|
|
if (name === "status") { |
|
|
|
|
if (name === "provinceId") { |
|
|
|
|
this.props.getCity({ provinceId: value }); |
|
|
|
|
this.setState({ |
|
|
|
|
cityId: null, |
|
|
|
|
[name]: value, |
|
|
|
|
}); |
|
|
|
|
} else if (name === "status") { |
|
|
|
|
this.setState((prevState) => ({ |
|
|
|
|
gradeIds: prevState.gradeIds.slice(0, 1) || [], |
|
|
|
|
[name]: value, |
|
|
|
|
})); |
|
|
|
|
} else if (name === "docFileIds") { |
|
|
|
|
this.props.upload({ file: value, target: name }); |
|
|
|
|
this.setState({ |
|
|
|
|
[name]: value, |
|
|
|
|
}); |
|
|
|
|
} else if (name === "file") { |
|
|
|
|
this.props.upload({ file: value, target: name }); |
|
|
|
|
this.setState({ |
|
|
|
@ -122,6 +133,9 @@ class Profile extends Component { |
|
|
|
|
schools, |
|
|
|
|
gradeIds, |
|
|
|
|
status, |
|
|
|
|
provinceId, |
|
|
|
|
cityId, |
|
|
|
|
docFileIds, |
|
|
|
|
} = this.state; |
|
|
|
|
const { profile, setProfile } = this.props; |
|
|
|
|
const data = { |
|
|
|
@ -143,6 +157,11 @@ class Profile extends Component { |
|
|
|
|
schools: schools || profile.schools, |
|
|
|
|
gradeIds: String(gradeIds || profile.gradeIds), |
|
|
|
|
status: status || profile.status, |
|
|
|
|
provinceId: provinceId || profile.provinceId, |
|
|
|
|
cityId: cityId || profile.cityId, |
|
|
|
|
docFileIds: String( |
|
|
|
|
this.props.uploads["docFileIds"] || docFileIds || profile.docFileIds |
|
|
|
|
), |
|
|
|
|
}; |
|
|
|
|
await setProfile(data); |
|
|
|
|
}; |
|
|
|
@ -294,21 +313,23 @@ class Profile extends Component { |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
{console.log(this.props.province)} |
|
|
|
|
<div className="mb-2" style={{ minWidth: "100%" }}> |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={["karaj", "tehran"]} |
|
|
|
|
name="province" |
|
|
|
|
options={this.props.provinceList} |
|
|
|
|
name="provinceId" |
|
|
|
|
label={"استان"} |
|
|
|
|
selectedOptions={this.state.provinceId} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={["karaj", "tehran"]} |
|
|
|
|
name="city" |
|
|
|
|
options={this.props.cityList} |
|
|
|
|
name="cityId" |
|
|
|
|
label={"شهرستان"} |
|
|
|
|
selectedOptions={this.state.cityId} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
{/* <div className="mb-2"> |
|
|
|
@ -319,7 +340,7 @@ class Profile extends Component { |
|
|
|
|
label={"شهر/روستا"} |
|
|
|
|
/> |
|
|
|
|
</div> */} |
|
|
|
|
{this.state.status === "دانش آموز" ? ( |
|
|
|
|
{this.state.status == 1 ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
@ -330,7 +351,7 @@ class Profile extends Component { |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.status === "معلم" ? ( |
|
|
|
|
{this.state.status == 2 ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
@ -341,6 +362,9 @@ class Profile extends Component { |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.status == 2 ? ( |
|
|
|
|
<Document parent={this} name="docFileIds" /> |
|
|
|
|
) : null} |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
@ -458,8 +482,7 @@ class Profile extends Component { |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.status === "دانش آموز" && |
|
|
|
|
Number(this.state.gradeIds) > 9 ? ( |
|
|
|
|
{this.state.status == 1 && Number(this.state.gradeIds) > 9 ? ( |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={[ |
|
|
|
@ -478,15 +501,17 @@ class Profile extends Component { |
|
|
|
|
|
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={["karaj", "tehran"]} |
|
|
|
|
options={this.props.provinceList} |
|
|
|
|
name="provinceId" |
|
|
|
|
label={"استان"} |
|
|
|
|
selectedOptions={this.state.provinceId} |
|
|
|
|
/> |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={["karaj", "tehran"]} |
|
|
|
|
options={this.props.cityList} |
|
|
|
|
name="cityId" |
|
|
|
|
label={"شهرستان"} |
|
|
|
|
selectedOptions={this.state.cityId} |
|
|
|
|
/> |
|
|
|
|
{/* <Select |
|
|
|
|
parent={this} |
|
|
|
@ -494,7 +519,7 @@ class Profile extends Component { |
|
|
|
|
name="zoneId" |
|
|
|
|
label={"شهر/روستا"} |
|
|
|
|
/> */} |
|
|
|
|
{this.state.status === "دانش آموز" ? ( |
|
|
|
|
{this.state.status == 1 ? ( |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
|
name="schools" |
|
|
|
@ -503,7 +528,7 @@ class Profile extends Component { |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.status === "معلم" ? ( |
|
|
|
|
{this.state.status == 2 ? ( |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
|
name="schools" |
|
|
|
@ -512,7 +537,7 @@ class Profile extends Component { |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.status === "معلم" ? ( |
|
|
|
|
{this.state.status == 2 ? ( |
|
|
|
|
<Document parent={this} name="docFileIds" /> |
|
|
|
|
) : null} |
|
|
|
|
<Input |
|
|
|
@ -530,7 +555,6 @@ class Profile extends Component { |
|
|
|
|
label={"آدرس محل سکونت"} |
|
|
|
|
name="address" |
|
|
|
|
defaultValue={profile} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
/> |
|
|
|
|
<div className="mobile-auth-profile__footer d-flex justify-content-center"> |
|
|
|
|
<button onClick={() => this.onSubmit()}>ذخیره</button>{" "} |
|
|
|
@ -557,11 +581,15 @@ export default connect( |
|
|
|
|
loading: state.user.loading, |
|
|
|
|
uploading: state.file.loading, |
|
|
|
|
uploads: state.file.uploads, |
|
|
|
|
provinceList: state.publicApi.province, |
|
|
|
|
cityList: state.publicApi.city, |
|
|
|
|
}), |
|
|
|
|
{ |
|
|
|
|
getProfile: user.getProfile, |
|
|
|
|
setProfile: user.setProfile, |
|
|
|
|
upload: file.upload, |
|
|
|
|
getProvince: publicApi.getProvince, |
|
|
|
|
getCity: publicApi.getCity, |
|
|
|
|
} |
|
|
|
|
)(Profile); |
|
|
|
|
|
|
|
|
|