fixes seri 1

master
amir hosein gorji 3 years ago
parent 856d027bce
commit 4e66f2d8c9
  1. 22
      src/Redux/actions/file.js
  2. 1
      src/Redux/actions/index.js
  3. 4
      src/Redux/actions/public.js
  4. 38
      src/Redux/proxy.js
  5. 26
      src/Redux/reducers/file.js
  6. 1
      src/Redux/reducers/index.js
  7. 6
      src/Redux/reducers/public.js
  8. 15
      src/Redux/reducers/user.js
  9. 12
      src/constants/defaultValues.js
  10. 83
      src/views/Auth/Profile/Birthdate/index.js
  11. 5
      src/views/Auth/Profile/Birthdate/index.scss
  12. 32
      src/views/Auth/Profile/GenderSwitch/index.js
  13. 13
      src/views/Auth/Profile/Input/index.js
  14. 16
      src/views/Auth/Profile/MultipleSelector/index.js
  15. 10
      src/views/Auth/Profile/Select/index.js
  16. 4
      src/views/Auth/Profile/TextArea/index.js
  17. 84
      src/views/Auth/Profile/Upload/index.js
  18. 176
      src/views/Auth/Profile/index.js
  19. 7
      src/views/Auth/Profile/index.scss

@ -0,0 +1,22 @@
import proxy from "../proxy";
const file = {
upload:
(data = {}) =>
async (dispatch) => {
var formData = new FormData();
for (let key in data) formData.append(key, data[key]);
return await proxy.post(
"file/upload",
formData,
{
dispatch,
headers: {
"Content-Type": "multipart/form-data",
},
},
data
);
},
};
export default file;

@ -11,3 +11,4 @@ export { default as userFactor } from "./userFactor.js";
export { default as transport } from "./transport.js";
export { default as comment } from "./comment.js";
export { default as activation } from "./activation.js";
export { default as file } from "./file.js";

@ -20,6 +20,10 @@ const publicApi = {
await proxy.get("public/blogInfo", data, { history, dispatch }),
filterNewProducts: (data, history) => async (dispatch) =>
await dispatch({ type: "public/filter", data: data }),
getProvince: (data, history) => async (dispatch) =>
await proxy.get("public/province", data, { history, dispatch }),
getCity: (data, history) => async (dispatch) =>
await proxy.get("public/city", data, { history, dispatch }),
};
export default publicApi;

@ -3,7 +3,9 @@ import axios from "axios";
let { baseUrl } = ApiConfig;
let access = window.localStorage.getItem("access");
window.baseURL = baseUrl;
baseUrl = baseUrl + "/";
const Axios = axios.create({
withCredentials: true,
validateStatus: null,
@ -11,41 +13,53 @@ const Axios = axios.create({
//headers: access ? { Authorization: `Bearer ${access}` } : {},
});
class Proxy {
get = async (url, params, opt = {}) =>
get = async (url, params, opt = {}, data) =>
await this.check(
url,
opt,
async () => await Axios.get(url, { params, ...opt }),
data || params
);
post = async (url, params, opt = {}, data) =>
await this.check(
url,
opt,
async () => await Axios.post(url, params, opt),
data || params
);
put = async (url, params, opt = {}, data) =>
await this.check(
url,
opt,
async () => await Axios.get(url, { params, ...opt })
async () => await Axios.put(url, params, opt),
data || params
);
post = async (url, params, opt = {}) =>
await this.check(url, opt, async () => await Axios.post(url, params, opt));
put = async (url, params, opt = {}) =>
await this.check(url, opt, async () => await Axios.put(url, params, opt));
delete = async (url, params, opt = {}) => {
delete = async (url, params, opt = {}, data) => {
await this.check(
url,
opt,
async () => await Axios.delete(url, { ...opt, data: params })
async () => await Axios.delete(url, { ...opt, data: params }),
data || params
);
};
check = async (url, { dispatch }, fetch) => {
check = async (url, { dispatch }, fetch, params) => {
dispatch = dispatch || (() => {});
dispatch({ type: "loading" });
let response = await fetch();
switch (response.status) {
case 200:
dispatch({ type: url, data: response.data.data });
dispatch({ type: url, data: response.data.data, params });
return response.data.data;
case 401:
if (await this.refresh()) {
let response = await fetch();
dispatch({ type: url, data: response.data.data });
dispatch({ type: url, data: response.data.data, params });
return response.data.data;
}
break;
default:
dispatch({ type: "error", data: response.data });
dispatch({ type: "error", data: response.data, params });
}
return false;
};

@ -0,0 +1,26 @@
const initialState = {
loading: false,
error: null,
uploads: {},
lastUpload: null,
};
export default function file(state = initialState, action) {
let { type, data, params } = action;
switch (type) {
case "file/upload":
return {
...state,
loading: false,
error: null,
uploads: { ...state.uploads, [params?.target || "last"]: data.id },
lastUpload: data.id,
};
case "loading":
return { ...state, loading: true };
case "error":
return { ...state, loading: false, error: data.message };
default:
return state;
}
}

@ -11,3 +11,4 @@ export { default as userFactor } from "./userFactor.js";
export { default as transport } from "./transport.js";
export { default as comment } from "./comment.js";
export { default as activation } from "./activation.js";
export { default as file } from "./file.js";

@ -10,6 +10,8 @@ const initialState = {
arList: [],
blogList: [],
blog: null,
province: [],
city: [],
};
const grades = [
@ -130,6 +132,10 @@ export default function publicApi(state = initialState, action) {
};
case "faq/list":
return { ...state, loading: false, error: null, faqList: data };
case "public/province":
return { ...state, loading: false, error: null, province: data };
case "public/city":
return { ...state, loading: false, error: null, city: data };
case "public/faq/activate":
return {
...state,

@ -8,6 +8,7 @@ const initialState = {
domains: [],
mothers: [],
profileStatus: false,
setDone: false,
};
export default function user(state = initialState, action) {
let { type, data } = action;
@ -28,7 +29,13 @@ export default function user(state = initialState, action) {
};
case "user/getProfile":
localStorage.setItem("userData", JSON.stringify(data));
return { ...state, loading: false, status: data, error: null };
return {
...state,
loading: false,
status: data,
error: null,
setDone: false,
};
case "user/logout":
return { ...state, loading: false, status: proxy.status(), error: null };
case "user/getUserRole":
@ -40,11 +47,7 @@ export default function user(state = initialState, action) {
case "mothers/list":
return { ...state, loading: false, mothers: data, error: null };
case "user/setProfile":
toast.success("تغییرات اعمال شد.");
setTimeout(() => {
window.location = "/";
}, 500);
return { ...state, loading: false, error: null };
return { ...state, loading: false, error: null, setDone: true };
case "loading":
return { ...state, loading: true };
case "error":

@ -1,9 +1,9 @@
export const ApiConfig = {
apiKey: 'AIzaSyBBksq-Asxq2M4Ot-75X19IyrEYJqNBPcg',
authDomain: 'dnvn.ir',
baseUrl: 'https://dnvn.ir/api/v1',
apiKey: "AIzaSyBBksq-Asxq2M4Ot-75X19IyrEYJqNBPcg",
authDomain: "dnvn.ir",
baseUrl: "https://dnvn.ir/api/v1/",
//baseUrl: 'http://localhost:3030/api/v1',
loginURL: 'user/login',
otploginURL: 'user/otp/login',
logoutURL: 'user/logout',
loginURL: "user/login",
otploginURL: "user/otp/login",
logoutURL: "user/logout",
};

@ -1,16 +1,26 @@
import React from "react";
import React, { useState } from "react";
import onInput from "~/util/onInput";
import Input from "../Input/index";
import "./index.scss";
const maxMobileSize = 550;
const maxDesktopSize = 1250;
const fontSize = {
// desktop :
};
import moment from "jalali-moment";
export default function Birthdate(props) {
const { defaultValue, parent, name } = props;
const momentDate = moment(defaultValue[name]);
const day = momentDate.format("jDD"),
month = momentDate.format("jMM"),
year = momentDate.format("jYYYY");
const [state, setState] = useState({ day, month, year });
const onChange = (_name, value) => {
let _state = { ...state, [_name]: value };
setState(_state);
parent.onChange(
name,
moment
.from(`${_state.year}/${_state.month}/${_state.day}`, "fa", "YYYY/M/D")
.locale("en")
);
};
return (
<>
{window.innerWidth < 1000 ? (
@ -18,24 +28,33 @@ export default function Birthdate(props) {
<label>تاریخ تولد</label>
<div className="mobile-birthdate__date d-flex align-items-center">
<Input
variant="standard"
name="day"
placeholder="روز"
maxLength={2}
onInput={onInput.dayHandler}
parent={{ onChange }}
defaultValue={state}
/>
<span>/</span>
<Input
variant="standard"
name="month"
placeholder="ماه"
maxLength={2}
onInput={onInput.monthHandler}
parent={{ onChange }}
defaultValue={state}
/>
<span>/</span>
<Input
variant="standard"
name="year"
placeholder="سال"
maxLength={4}
onInput={onInput.yearHandler}
parent={{ onChange }}
defaultValue={state}
/>
</div>
</div>
@ -44,28 +63,38 @@ export default function Birthdate(props) {
<div className="birthdate d-flex justify-content-between align-items-center">
<label>تاریخ تولد</label>
<div className="birthdate__date d-flex align-items-center">
<Input name="day" placeholder="روز" maxLength={2} />
<Input
variant="standard"
name="day"
placeholder="روز"
maxLength={2}
onInput={onInput.dayHandler}
parent={{ onChange }}
defaultValue={state}
/>
<span>/</span>
<Input name="month" placeholder="ماه" maxLength={2} />
<Input
variant="standard"
name="month"
placeholder="ماه"
maxLength={2}
onInput={onInput.monthHandler}
parent={{ onChange }}
defaultValue={state}
/>
<span>/</span>
<Input name="year" placeholder="سال" maxLength={4} />
<Input
variant="standard"
name="year"
placeholder="سال"
maxLength={4}
onInput={onInput.yearHandler}
parent={{ onChange }}
defaultValue={state}
/>
</div>
</div>
) : null}
</>
);
}
const Input = (props) => {
const { name, placeholder, maxLength, onInput } = props;
return (
<input
type="text"
inputMode="numeric"
name={name}
placeholder={placeholder}
maxLength={maxLength}
onInput={(e) => (e.target.value = onInput(e.target.value))}
/>
);
};

@ -12,13 +12,14 @@
span {
color: #bfbfbf;
}
input {
border: 0px;
background-color: white;
font-family: numeralLight;
color: #4d4d4d;
width: 42px;
text-align: center;
text-align: center !important;
direction: ltr;
&:focus {
outline: 0px;
@ -73,7 +74,7 @@
font-family: numeralLight;
color: #4d4d4d;
width: 42px;
text-align: center;
text-align: center !important;
direction: ltr;
&:focus {
outline: 0px;

@ -14,17 +14,17 @@ export default function GenderSwitch(props) {
const styles = {
girl: {
fontSize: window.innerWidth > 1000 ? fontSize.desktop : fontSize.mobile,
color: selectedOption === options[1] ? "white" : "grey",
backgroundColor: selectedOption === options[1] ? "#128c7e" : "white",
border: selectedOption === options[1] ? "0px" : "1px solid #ccc",
color: selectedOption === 1 ? "white" : "grey",
backgroundColor: selectedOption === 1 ? "#128c7e" : "white",
border: selectedOption === 1 ? "0px" : "1px solid #ccc",
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
},
boy: {
fontSize: window.innerWidth > 1000 ? fontSize.desktop : fontSize.mobile,
color: selectedOption === options[0] ? "white" : "grey",
backgroundColor: selectedOption === options[0] ? "#128c7e" : "white",
border: selectedOption === options[0] ? "0px" : "1px solid #ccc",
color: selectedOption === 2 ? "white" : "grey",
backgroundColor: selectedOption === 2 ? "#128c7e" : "white",
border: selectedOption === 2 ? "0px" : "1px solid #ccc",
borderTopRightRadius: 10,
borderBottomRightRadius: 10,
borderLeft: window.innerWidth > 1000 ? "1px solid #ccc" : "0px",
@ -34,32 +34,20 @@ export default function GenderSwitch(props) {
<>
{window.innerWidth > 1000 ? (
<div className="gender d-flex justify-content-between align-items-center">
<div
style={styles.boy}
onClick={() => parent.onChange(name, options[0])}
>
<div style={styles.boy} onClick={() => parent.onChange(name, 2)}>
{options[0]}
</div>
<div
style={styles.girl}
onClick={() => parent.onChange(name, options[1])}
>
<div style={styles.girl} onClick={() => parent.onChange(name, 1)}>
{options[1]}
</div>
</div>
) : null}
{window.innerWidth < 1000 ? (
<div className="mobile-gender d-flex justify-content-between align-items-center">
<div
style={styles.boy}
onClick={() => parent.onChange(name, options[0])}
>
<div style={styles.boy} onClick={() => parent.onChange(name, 2)}>
{options[0]}
</div>
<div
style={styles.girl}
onClick={() => parent.onChange(name, options[1])}
>
<div style={styles.girl} onClick={() => parent.onChange(name, 1)}>
{options[1]}
</div>
</div>

@ -19,7 +19,8 @@ export default function FormPropsTextFields(props) {
}));
const classes = useStyles();
const { parent, defaultValue, maxLength, inputMode, onInput } = props;
const { parent, defaultValue, maxLength, inputMode, onInput, variant } =
props;
return (
<form className={classes.root} noValidate autoComplete="off">
<div>
@ -27,11 +28,15 @@ export default function FormPropsTextFields(props) {
id="outlined-basic"
name={props.name}
label={props.label}
variant="outlined"
variant={variant || "outlined"}
onChange={(e) => parent.onChange(e.target.name, e.target.value)}
defaultValue={defaultValue[props.name] || ""}
maxLength={maxLength}
onInput={(e) => (e.target.value = onInput(e.target.value))}
inputProps={{ maxLength }}
onInput={
onInput
? (e) => (e.target.value = onInput(e.target.value))
: () => {}
}
/>
</div>
</form>

@ -37,13 +37,13 @@ export default function MultipleSelector(props) {
labelId="demo-mutiple-name-label"
id="demo-mutiple-name"
multiple
value={selectedOptions}
onChange={(e) => parent.onChange(name, e.target.value)}
value={selectedOptions.split(",")}
onChange={(e) => parent.onChange(name, e.target.value.join(","))}
input={<Input />}
variant="outlined"
>
{options.map((name) => (
<MenuItem key={name} value={name}>
{options.map((name, i) => (
<MenuItem key={name} value={i}>
{name}
</MenuItem>
))}
@ -69,13 +69,13 @@ export default function MultipleSelector(props) {
labelId="demo-mutiple-name-label"
id="demo-mutiple-name"
multiple
value={selectedOptions}
onChange={(e) => parent.onChange(name, e.target.value)}
value={selectedOptions.split(",")}
onChange={(e) => parent.onChange(name, e.target.value.join(","))}
input={<Input />}
variant="outlined"
>
{options.map((name) => (
<MenuItem key={name} value={name}>
{options.map((name, i) => (
<MenuItem key={name} value={i}>
{name}
</MenuItem>
))}

@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
export default function CustomizedSelects(props) {
const classes = useStyles();
const { parent } = props;
const { parent, selectedOptions } = props;
return (
<>
{window.innerWidth < 1000 ? (
@ -29,12 +29,12 @@ export default function CustomizedSelects(props) {
<Select
labelId="demo-simple-select-outlined-label"
id="demo-simple-select-outlined"
// value={props.parent.state[props.name]}
value={selectedOptions}
onChange={(e) => parent.onChange(props.name, e.target.value)}
>
{/* 09366858119 */}
{props.options.map((item, i) => (
<option key={i} value={item}>
<option key={i} value={i}>
{item}
</option>
))}
@ -60,12 +60,12 @@ export default function CustomizedSelects(props) {
<Select
labelId="demo-simple-select-outlined-label"
id="demo-simple-select-outlined"
// value={props.parent.state[props.name]}
value={selectedOptions}
onChange={(e) => parent.onChange(props.name, e.target.value)}
>
{/* 09366858119 */}
{props.options.map((item, i) => (
<option key={i} value={item}>
<option key={i} value={i}>
{item}
</option>
))}

@ -14,7 +14,7 @@ const useStyles = makeStyles((theme) => ({
export default function MultilineTextFields(props) {
const classes = useStyles();
const [value, setValue] = React.useState("Controlled");
const { parent } = props;
const { parent, defaultValue } = props;
return (
<form className={classes.root} noValidate autoComplete="off">
<TextField
@ -23,8 +23,8 @@ export default function MultilineTextFields(props) {
multiline
rows={4}
onChange={(e) => parent.onChange(e.target.name, e.target.value)}
defaultValue={defaultValue[props.name] || ""}
name={props.name}
defaultValue=""
variant="outlined"
/>
</form>

@ -11,49 +11,40 @@ const fontSize = {
};
export default function Upload(props) {
const { parent } = props;
let { parent, name } = props;
return (
<>
{window.innerWidth < 1000 ? (
<div className="mobile-auth-profile__upload d-flex justify-content-center align-items-center mb-3">
{parent.state.file === null ? (
<>
<input
type="file"
name="file"
onChange={(e) =>
parent.onChange(e.target.name, e.target.files[0])
}
/>
<>
{parent.state.file === null ? (
<AddAPhotoIcon
style={{ width: 40, height: 40, color: "white" }}
/>
</>
) : (
<>
<input
type="file"
name="file"
onChange={(e) =>
parent.onChange(e.target.name, e.target.files[0])
) : (
<img
src={
parent.state.file.name
? URL.createObjectURL(parent.state.file)
: window.baseURL + "file/" + parent.state.file
}
alt={"کاربر"}
/>
{/* <img src={parent.state.file} alt={"کاربر"} /> */}
</>
)}
)}
<input
type="file"
name="file"
onChange={(e) =>
parent.onChange(e.target.name, e.target.files[0])
}
/>
</>
</div>
) : null}
{window.innerWidth > 1000 ? (
<div className="auth-profile__upload d-flex justify-content-center-align-items-center">
{parent.state.file === "" ? (
<>
<input
label={props.label}
onChange={(e) => parent.onChange(e.target.name, e.target.value)}
name={props.name}
defaultValue=""
type="file"
/>
<>
{parent.state.file === null ? (
<AddAPhotoIcon
style={{
width: 40,
@ -64,21 +55,26 @@ export default function Upload(props) {
top: "calc(50% - 20px)",
}}
/>
</>
) : (
<>
<input
label={props.label}
onChange={(e) => parent.onChange(e.target.name, e.target.value)}
name={props.name}
defaultValue=""
type="file"
) : (
<img
src={
parent.state.file.name
? URL.createObjectURL(parent.state.file)
: window.baseURL + "file/" + parent.state.file
}
alt={"کاربر"}
/>
<span style={{ color: "rgb(18,140,126)" }}>
{parent.state.file.name}
</span>
</>
)}
)}
<input
label={props.label}
onChange={(e) =>
parent.onChange(e.target.name, e.target.files[0])
}
name={props.name}
defaultValue=""
type="file"
/>
</>
</div>
) : null}
</>

@ -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 = {

@ -1,3 +1,6 @@
.MuiOutlinedInput-input {
font-family: numeralLight !important;
}
.mobile-auth-profile {
width: 100%;
height: 100%;
@ -43,6 +46,10 @@
img {
width: 100%;
height: 100%;
position: absolute;
left: -15px;
top: 0px;
object-fit: cover;
border-radius: 50%;
}

Loading…
Cancel
Save