|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import React, { Component } from "react"; |
|
|
|
|
import onInput from "~/util/onInput"; |
|
|
|
|
import { user } from "~/Redux/actions"; |
|
|
|
|
import { user, file } from "~/Redux/actions"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
|
|
import Select from "./Select/index"; |
|
|
|
@ -14,8 +14,12 @@ 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"; |
|
|
|
|
function Navigate({ path }) { |
|
|
|
|
let history = useHistory(); |
|
|
|
|
return <>{history.push(path)}</>; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const maxDesktopSize = 1250; |
|
|
|
|
const maxMobileSize = 550; |
|
|
|
@ -40,7 +44,9 @@ const toastMessages = { |
|
|
|
|
class Profile extends Component { |
|
|
|
|
state = { |
|
|
|
|
render: false, |
|
|
|
|
file: null, |
|
|
|
|
file: this.props.uploads["file"] || this.props.profile.picFileId || null, |
|
|
|
|
picFileId: |
|
|
|
|
this.props.uploads["file"] || this.props.profile.picFileId || null, |
|
|
|
|
docFileIds: "", |
|
|
|
|
firstName: "", |
|
|
|
|
lastName: "", |
|
|
|
@ -48,8 +54,9 @@ class Profile extends Component { |
|
|
|
|
username: "", |
|
|
|
|
address: "", |
|
|
|
|
email: "", |
|
|
|
|
gender: "دختر", |
|
|
|
|
userRoleId: "دانش آموز", |
|
|
|
|
birthDate: "", |
|
|
|
|
gender: this.props.profile.gender || 1, |
|
|
|
|
status: this.props.profile.status || 1, |
|
|
|
|
nationalId: "", |
|
|
|
|
provinceId: "", |
|
|
|
|
phone: "", |
|
|
|
@ -57,7 +64,8 @@ class Profile extends Component { |
|
|
|
|
zoneId: "", |
|
|
|
|
schoolId: "", |
|
|
|
|
postalCode: "", |
|
|
|
|
gradeId: [], |
|
|
|
|
gradeIds: this.props.profile.gradeIds, |
|
|
|
|
|
|
|
|
|
validation: { |
|
|
|
|
firstName: "", |
|
|
|
|
lastName: "", |
|
|
|
@ -74,14 +82,19 @@ class Profile extends Component { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onChange = (name, value) => { |
|
|
|
|
if (name === "gardeId" && this.state.userRoleId === "معلم") { |
|
|
|
|
// if (name === "gradeIds" && this.state.status == 2) {
|
|
|
|
|
// this.setState((prevState) => ({
|
|
|
|
|
// gradeIds: [...prevState.gradeIds.split(","), value],
|
|
|
|
|
// }));
|
|
|
|
|
// } else
|
|
|
|
|
if (name === "status") { |
|
|
|
|
this.setState((prevState) => ({ |
|
|
|
|
gradeId: [...prevState.gradeId, value], |
|
|
|
|
gradeIds: prevState.gradeIds.slice(0, 1) || [], |
|
|
|
|
[name]: value, |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
if (name === "userRoleId") { |
|
|
|
|
} else if (name === "file") { |
|
|
|
|
this.props.upload({ file: value, target: name }); |
|
|
|
|
this.setState({ |
|
|
|
|
gradeId: [], |
|
|
|
|
[name]: value, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
@ -96,12 +109,19 @@ class Profile extends Component { |
|
|
|
|
firstName, |
|
|
|
|
lastName, |
|
|
|
|
username, |
|
|
|
|
cellphone, |
|
|
|
|
//cellphone,
|
|
|
|
|
password, |
|
|
|
|
postalCode, |
|
|
|
|
address, |
|
|
|
|
email, |
|
|
|
|
phone, |
|
|
|
|
picFileId, |
|
|
|
|
gender, |
|
|
|
|
nationalId, |
|
|
|
|
birthDate, |
|
|
|
|
schools, |
|
|
|
|
gradeIds, |
|
|
|
|
status, |
|
|
|
|
} = this.state; |
|
|
|
|
const { profile, setProfile } = this.props; |
|
|
|
|
const data = { |
|
|
|
@ -114,11 +134,21 @@ class Profile extends Component { |
|
|
|
|
address: address || profile.address, |
|
|
|
|
email: email || profile.email, |
|
|
|
|
phone: phone || profile.phone, |
|
|
|
|
nationalId: nationalId || profile.nationalId, |
|
|
|
|
picFileId: String( |
|
|
|
|
this.props.uploads["file"] || picFileId || profile.picFileId |
|
|
|
|
), |
|
|
|
|
gender: gender || profile.gender, |
|
|
|
|
birthDate: birthDate || profile.birthDate, |
|
|
|
|
schools: schools || profile.schools, |
|
|
|
|
gradeIds: String(gradeIds || profile.gradeIds), |
|
|
|
|
status: status || profile.status, |
|
|
|
|
}; |
|
|
|
|
await setProfile(data); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
if (this.props.setDone) return <Navigate path="/" />; |
|
|
|
|
const grades = [ |
|
|
|
|
"پیش دبستان", |
|
|
|
|
"اول", |
|
|
|
@ -134,7 +164,7 @@ class Profile extends Component { |
|
|
|
|
"یازدهم", |
|
|
|
|
"دوازدهم", |
|
|
|
|
]; |
|
|
|
|
const { user, profile } = this.props; |
|
|
|
|
const { profile } = this.props; |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
{window.innerWidth > 1000 ? ( |
|
|
|
@ -145,7 +175,7 @@ class Profile extends Component { |
|
|
|
|
<p style={{ fontSize: fontSize.desktop.p }}> |
|
|
|
|
لطفا مشخصات خود را به صورت کامل نمایید. |
|
|
|
|
</p> |
|
|
|
|
<form |
|
|
|
|
<div |
|
|
|
|
className="auth-profile__box--form d-flex" |
|
|
|
|
onSubmit={(e) => this.onSubmit(e)} |
|
|
|
|
> |
|
|
|
@ -159,6 +189,7 @@ class Profile extends Component { |
|
|
|
|
label="نام" |
|
|
|
|
parent={this} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="mb-2"> |
|
|
|
@ -167,6 +198,7 @@ class Profile extends Component { |
|
|
|
|
label="نام خانوادگی" |
|
|
|
|
parent={this} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="mb-2"> |
|
|
|
@ -176,6 +208,7 @@ class Profile extends Component { |
|
|
|
|
parent={this} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
align="left" |
|
|
|
|
onInput={onInput.englishAndNumberWithoutSpace} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
@ -190,14 +223,20 @@ class Profile extends Component { |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Input |
|
|
|
|
name="nationalId" |
|
|
|
|
label="کد ملی" |
|
|
|
|
label="کد ملی/اتباع" |
|
|
|
|
parent={this} |
|
|
|
|
align="left" |
|
|
|
|
maxLength={13} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.numberOnly} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Birthdate /> |
|
|
|
|
<Birthdate |
|
|
|
|
defaultValue={profile} |
|
|
|
|
parent={this} |
|
|
|
|
name="birthDate" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
{/* <div className="mb-2"> |
|
|
|
|
<Input name="password" label="رمز عبور" parent={this} /> |
|
|
|
@ -208,35 +247,36 @@ class Profile extends Component { |
|
|
|
|
<Gender |
|
|
|
|
parent={this} |
|
|
|
|
options={["معلم", "دانش آموز"]} |
|
|
|
|
name="userRoleId" |
|
|
|
|
name="status" |
|
|
|
|
label={"عنوان"} |
|
|
|
|
selectedOption={this.state.userRoleId} |
|
|
|
|
selectedOption={this.state.status} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
{this.state.userRoleId === "دانش آموز" ? ( |
|
|
|
|
{this.state.status === 1 ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={grades} |
|
|
|
|
name="gradeId" |
|
|
|
|
name="gradeIds" |
|
|
|
|
label={"پایه تحصیلی"} |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.userRoleId === "معلم" ? ( |
|
|
|
|
{this.state.status === 2 ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<MultipleSelector |
|
|
|
|
parent={this} |
|
|
|
|
options={grades} |
|
|
|
|
name="gradeId" |
|
|
|
|
name="gradeIds" |
|
|
|
|
label={"پایه تحصیلی"} |
|
|
|
|
selectedOptions={this.state.gradeId} |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
{this.state.userRoleId === "دانش آموز" && |
|
|
|
|
this.state.gradeId > 9 ? ( |
|
|
|
|
{this.state.status === "دانش آموز" && |
|
|
|
|
this.state.gradeIds > 9 ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
@ -250,7 +290,7 @@ class Profile extends Component { |
|
|
|
|
]} |
|
|
|
|
name="field" |
|
|
|
|
label={"رشته تحصیلی"} |
|
|
|
|
selectedOptions={this.state.gradeId} |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
@ -271,31 +311,33 @@ class Profile extends Component { |
|
|
|
|
label={"شهرستان"} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
{/* <div className="mb-2"> |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={["chaharbagh", "mahalat"]} |
|
|
|
|
name="zoneId" |
|
|
|
|
label={"شهر/روستا"} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
{this.state.userRoleId === "دانش آموز" ? ( |
|
|
|
|
</div> */} |
|
|
|
|
{this.state.status === "دانش آموز" ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
|
name="schoolId" |
|
|
|
|
name="schools" |
|
|
|
|
label={"نام مدرسه"} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.userRoleId === "معلم" ? ( |
|
|
|
|
{this.state.status === "معلم" ? ( |
|
|
|
|
<div className="mb-2"> |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
|
name="schoolId" |
|
|
|
|
name="schools" |
|
|
|
|
label={"محل تدریس"} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
@ -305,7 +347,10 @@ class Profile extends Component { |
|
|
|
|
name="postalCode" |
|
|
|
|
label={"کد پستی"} |
|
|
|
|
align="left" |
|
|
|
|
maxLength={10} |
|
|
|
|
inputMode="numeric" |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.numberOnly} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="mb-2"> |
|
|
|
@ -313,13 +358,14 @@ class Profile extends Component { |
|
|
|
|
parent={this} |
|
|
|
|
label={"آدرس محل سکونت"} |
|
|
|
|
name="address" |
|
|
|
|
defaultValue={profile} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="auth-profile__box--form__footer d-flex justify-content-center"> |
|
|
|
|
<button>ذخیره</button> |
|
|
|
|
<button onClick={() => this.onSubmit()}>ذخیره</button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</form> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
) : ( |
|
|
|
@ -383,32 +429,37 @@ class Profile extends Component { |
|
|
|
|
inputMode="numeric" |
|
|
|
|
onInput={onInput.numberOnly} |
|
|
|
|
/> |
|
|
|
|
<Birthdate /> |
|
|
|
|
<Birthdate |
|
|
|
|
defaultValue={profile} |
|
|
|
|
parent={this} |
|
|
|
|
name="birthDate" |
|
|
|
|
/> |
|
|
|
|
<Gender |
|
|
|
|
parent={this} |
|
|
|
|
options={["معلم", "دانش آموز"]} |
|
|
|
|
name="userRoleId" |
|
|
|
|
selectedOption={this.state.userRoleId} |
|
|
|
|
name="status" |
|
|
|
|
selectedOption={this.state.status} |
|
|
|
|
/> |
|
|
|
|
{this.state.userRoleId === "دانش آموز" ? ( |
|
|
|
|
{this.state.status === 1 ? ( |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={grades} |
|
|
|
|
name="gradeId" |
|
|
|
|
name="gradeIds" |
|
|
|
|
label={"پایه تحصیلی"} |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.userRoleId === "معلم" ? ( |
|
|
|
|
{this.state.status === 2 ? ( |
|
|
|
|
<MultipleSelector |
|
|
|
|
parent={this} |
|
|
|
|
options={grades} |
|
|
|
|
name="gradeId" |
|
|
|
|
name="gradeIds" |
|
|
|
|
label={"پایه تحصیلی"} |
|
|
|
|
selectedOptions={this.state.gradeId} |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.userRoleId === "دانش آموز" && |
|
|
|
|
Number(this.state.gradeId) > 9 ? ( |
|
|
|
|
{this.state.status === "دانش آموز" && |
|
|
|
|
Number(this.state.gradeIds) > 9 ? ( |
|
|
|
|
<Select |
|
|
|
|
parent={this} |
|
|
|
|
options={[ |
|
|
|
@ -421,7 +472,7 @@ class Profile extends Component { |
|
|
|
|
]} |
|
|
|
|
name="field" |
|
|
|
|
label={"رشته تحصیلی"} |
|
|
|
|
selectedOptions={this.state.gradeId} |
|
|
|
|
selectedOptions={this.state.gradeIds} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
@ -437,31 +488,31 @@ class Profile extends Component { |
|
|
|
|
name="cityId" |
|
|
|
|
label={"شهرستان"} |
|
|
|
|
/> |
|
|
|
|
<Select |
|
|
|
|
{/* <Select |
|
|
|
|
parent={this} |
|
|
|
|
options={["chaharbagh", "mahalat"]} |
|
|
|
|
name="zoneId" |
|
|
|
|
label={"شهر/روستا"} |
|
|
|
|
/> |
|
|
|
|
{this.state.userRoleId === "دانش آموز" ? ( |
|
|
|
|
/> */} |
|
|
|
|
{this.state.status === "دانش آموز" ? ( |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
|
name="schoolId" |
|
|
|
|
name="schools" |
|
|
|
|
label={"نام مدرسه"} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.userRoleId === "معلم" ? ( |
|
|
|
|
{this.state.status === "معلم" ? ( |
|
|
|
|
<Input |
|
|
|
|
parent={this} |
|
|
|
|
name="schoolId" |
|
|
|
|
name="schools" |
|
|
|
|
label={"محل تدریس"} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.persianOnly} |
|
|
|
|
/> |
|
|
|
|
) : null} |
|
|
|
|
{this.state.userRoleId === "معلم" ? ( |
|
|
|
|
{this.state.status === "معلم" ? ( |
|
|
|
|
<Document parent={this} name="docFileIds" /> |
|
|
|
|
) : null} |
|
|
|
|
<Input |
|
|
|
@ -469,14 +520,20 @@ class Profile extends Component { |
|
|
|
|
name="postalCode" |
|
|
|
|
label={"کد پستی"} |
|
|
|
|
align="left" |
|
|
|
|
maxLength={13} |
|
|
|
|
maxLength={10} |
|
|
|
|
inputMode="numeric" |
|
|
|
|
defaultValue={profile} |
|
|
|
|
onInput={onInput.numberOnly} |
|
|
|
|
/> |
|
|
|
|
<TextArea parent={this} label={"آدرس محل سکونت"} name="address" /> |
|
|
|
|
<TextArea |
|
|
|
|
parent={this} |
|
|
|
|
label={"آدرس محل سکونت"} |
|
|
|
|
name="address" |
|
|
|
|
defaultValue={profile} |
|
|
|
|
defaultValue={profile} |
|
|
|
|
/> |
|
|
|
|
<div className="mobile-auth-profile__footer d-flex justify-content-center"> |
|
|
|
|
<button onClick={() => this.onSubmit()}>ذخیره</button> |
|
|
|
|
<button onClick={() => this.onSubmit()}>ذخیره</button>{" "} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
) : ( |
|
|
|
@ -496,9 +553,16 @@ class Profile extends Component { |
|
|
|
|
export default connect( |
|
|
|
|
(state) => ({ |
|
|
|
|
profile: state.user.status, |
|
|
|
|
setDone: state.user.setDone, |
|
|
|
|
loading: state.user.loading, |
|
|
|
|
uploading: state.file.loading, |
|
|
|
|
uploads: state.file.uploads, |
|
|
|
|
}), |
|
|
|
|
{ getProfile: user.getProfile, setProfile: user.setProfile } |
|
|
|
|
{ |
|
|
|
|
getProfile: user.getProfile, |
|
|
|
|
setProfile: user.setProfile, |
|
|
|
|
upload: file.upload, |
|
|
|
|
} |
|
|
|
|
)(Profile); |
|
|
|
|
|
|
|
|
|
Profile.defaultProps = { |
|
|
|
|