From eae2f124b369186bd5a4b11cde4f65335447418f Mon Sep 17 00:00:00 2001 From: RezaAshrafi77 Date: Tue, 27 Jul 2021 17:05:21 +0430 Subject: [PATCH] reza added some option to profile --- src/views/Auth/Profile/Birthdate/index.js | 46 +++ src/views/Auth/Profile/Birthdate/index.scss | 64 ++++ src/views/Auth/Profile/GenderSwitch/index.js | 61 +++- .../Auth/Profile/GenderSwitch/index.scss | 26 ++ .../Auth/Profile/MultipleSelector/index.js | 96 ++++++ .../Auth/Profile/MultipleSelector/index.scss | 10 + src/views/Auth/Profile/Select/index.js | 93 ++++-- src/views/Auth/Profile/index.js | 285 ++++++++++++++++-- src/views/Auth/Profile/index.scss | 30 +- src/views/Auth/index.scss | 6 +- 10 files changed, 652 insertions(+), 65 deletions(-) create mode 100644 src/views/Auth/Profile/Birthdate/index.js create mode 100644 src/views/Auth/Profile/Birthdate/index.scss create mode 100644 src/views/Auth/Profile/MultipleSelector/index.js create mode 100644 src/views/Auth/Profile/MultipleSelector/index.scss diff --git a/src/views/Auth/Profile/Birthdate/index.js b/src/views/Auth/Profile/Birthdate/index.js new file mode 100644 index 0000000..f734e33 --- /dev/null +++ b/src/views/Auth/Profile/Birthdate/index.js @@ -0,0 +1,46 @@ +import React from "react"; + +import "./index.scss"; +export default function Birthdate(props) { + return ( + <> + {window.innerWidth < 1000 ? ( +
+ +
+ + / + + / + +
+
+ ) : null} + {window.innerWidth > 1000 ? ( +
+ +
+ + / + + / + +
+
+ ) : null} + + ); +} + +const Input = (props) => { + const { name, placeholder, maxLength } = props; + return ( + + ); +}; diff --git a/src/views/Auth/Profile/Birthdate/index.scss b/src/views/Auth/Profile/Birthdate/index.scss new file mode 100644 index 0000000..cf1753b --- /dev/null +++ b/src/views/Auth/Profile/Birthdate/index.scss @@ -0,0 +1,64 @@ +.mobile-birthdate { + width: 100%; + height: 45px; + border-radius: 10px; + padding: 10px 10px; + border: 1px solid #ccc; + margin: 10px 0px; + label { + width: fit-content; + font-family: numeralLight; + } + span { + font-size: calc(100vw / 30); + color: #bfbfbf; + } + input { + border: 0px; + background-color: white; + font-family: numeralLight; + color: #4d4d4d; + width: 42px; + text-align: center; + direction: ltr; + font-size: calc(100vw / 26); + &:focus { + outline: 0px; + } + &::placeholder { + font-size: calc(100vw / 30); + color: #bfbfbf; + } + } +} + +.birthdate { + width: 100%; + height: 55px; + border-radius: 10px; + padding: 10px 10px; + border: 1px solid #ccc; + margin: 10px 0px; + label { + width: fit-content; + font-family: numeralLight; + } + span { + color: #bfbfbf; + } + input { + border: 0px; + background-color: white; + font-family: numeralLight; + color: #4d4d4d; + width: 42px; + text-align: center; + direction: ltr; + &:focus { + outline: 0px; + } + &::placeholder { + color: #bfbfbf; + } + } +} diff --git a/src/views/Auth/Profile/GenderSwitch/index.js b/src/views/Auth/Profile/GenderSwitch/index.js index 31d7f2c..183573a 100644 --- a/src/views/Auth/Profile/GenderSwitch/index.js +++ b/src/views/Auth/Profile/GenderSwitch/index.js @@ -1,18 +1,67 @@ import React from "react"; +import "./index.scss"; + +const maxDesktopSize = 1250; +const maxMobileSize = 550; + +const fontSize = { + desktop: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 65, + mobile: window.innerWidth > maxMobileSize ? 16 : window.innerWidth / 26, +}; export default function GenderSwitch(props) { + const { parent, name, options, selectedOption } = props; + const styles = { + girl: { + fontSize: window.innerWidth > 1000 ? fontSize.desktop : fontSize.mobile, + color: selectedOption === options[1] ? "white" : "grey", + backgroundColor: selectedOption === options[1] ? "green" : "white", + border: selectedOption === options[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] ? "green" : "white", + border: selectedOption === options[0] ? "0px" : "1px solid #ccc", + borderTopRightRadius: 10, + borderBottomRightRadius: 10, + borderLeft: window.innerWidth > 1000 ? "1px solid #ccc" : "0px", + }, + }; return ( <> {window.innerWidth > 1000 ? ( -
- - +
+
parent.onChange(name, options[0])} + > + {options[0]} +
+
parent.onChange(name, options[1])} + > + {options[1]} +
) : null} {window.innerWidth < 1000 ? ( -
- - +
+
parent.onChange(name, options[0])} + > + {options[0]} +
+
parent.onChange(name, options[1])} + > + {options[1]} +
) : null} diff --git a/src/views/Auth/Profile/GenderSwitch/index.scss b/src/views/Auth/Profile/GenderSwitch/index.scss index e69de29..efc3838 100644 --- a/src/views/Auth/Profile/GenderSwitch/index.scss +++ b/src/views/Auth/Profile/GenderSwitch/index.scss @@ -0,0 +1,26 @@ +.gender { + width: 100%; + margin-bottom: 10px; + div { + border-radius: 10px; + font-family: numeralLight; + padding: 13px 0px; + width: 45%; + height: 55px; + text-align: center; + cursor: pointer; + } +} + +.mobile-gender { + width: 100%; + margin: 10px 0px; + div { + font-family: numeralLight; + padding: 11px 0px; + width: 50%; + height: 45px; + text-align: center; + cursor: pointer; + } +} diff --git a/src/views/Auth/Profile/MultipleSelector/index.js b/src/views/Auth/Profile/MultipleSelector/index.js new file mode 100644 index 0000000..2ba9a9f --- /dev/null +++ b/src/views/Auth/Profile/MultipleSelector/index.js @@ -0,0 +1,96 @@ +import React from "react"; +import Select from "@material-ui/core/Select"; +import { makeStyles } from "@material-ui/core/styles"; +import Input from "@material-ui/core/Input"; +import InputLabel from "@material-ui/core/InputLabel"; +import MenuItem from "@material-ui/core/MenuItem"; +import FormControl from "@material-ui/core/FormControl"; +import KeyboardArrowDownIcon from "@material-ui/icons/KeyboardArrowDown"; + +import "./index.scss"; +export default function MultipleSelector(props) { + const useStyles = makeStyles((theme) => ({ + root: { + "& .MuiTextField-root": { + width: "100%", + position: "relative", + marginRight: 10, + "& input": { + textAlign: props.align, + direction: props.align === "right" ? "rtl" : "ltr", + }, + }, + }, + })); + + const classes = useStyles(); + const { parent, defaultValue, name, label, options, selectedOptions } = props; + return ( + <> + {window.innerWidth < 1000 ? ( + + {label} + } + variant="outlined" + > + {options.map((name) => ( + + {name} + + ))} + + + + ) : null} + {window.innerWidth > 1000 ? ( + + {label} + } + variant="outlined" + > + {options.map((name) => ( + + {name} + + ))} + + + + ) : null} + + ); +} diff --git a/src/views/Auth/Profile/MultipleSelector/index.scss b/src/views/Auth/Profile/MultipleSelector/index.scss new file mode 100644 index 0000000..270f6bc --- /dev/null +++ b/src/views/Auth/Profile/MultipleSelector/index.scss @@ -0,0 +1,10 @@ +.mobile-multiple-selector { + width: 100%; + border-radius: 10px; + padding: 10px 10px; + border: 1px solid #ccc !important; + margin: 0px !important; + .MuiInput-formControl { + margin: 9px 0px 7px !important; + } +} diff --git a/src/views/Auth/Profile/Select/index.js b/src/views/Auth/Profile/Select/index.js index 594a7fe..89a17f1 100644 --- a/src/views/Auth/Profile/Select/index.js +++ b/src/views/Auth/Profile/Select/index.js @@ -41,34 +41,69 @@ export default function CustomizedSelects(props) { const classes = useStyles(); const { parent } = props; return ( -
- - - {props.label} - - - - -
+ <> + {window.innerWidth < 1000 ? ( +
+ + + {props.label} + + + + +
+ ) : null} + {window.innerWidth > 1000 ? ( +
+ + + {props.label} + + + + +
+ ) : null} + ); } diff --git a/src/views/Auth/Profile/index.js b/src/views/Auth/Profile/index.js index 9093188..9db6312 100644 --- a/src/views/Auth/Profile/index.js +++ b/src/views/Auth/Profile/index.js @@ -6,6 +6,9 @@ import Select from "./Select/index"; import Input from "./Input/index"; import TextArea from "./TextArea/index"; import Upload from "./Upload/index"; +import Gender from "./GenderSwitch/index"; +import Birthdate from "./Birthdate/index"; +import MultipleSelector from "./MultipleSelector/index"; import logo from "../../../assets/icons/logo.png"; import pic from "../../../assets/images/pic.png"; @@ -13,12 +16,17 @@ import pic from "../../../assets/images/pic.png"; import "./index.scss"; const maxDesktopSize = 1250; +const maxMobileSize = 550; const fontSize = { desktop: { h1: window.innerWidth > maxDesktopSize ? 25 : window.innerWidth / 55, p: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 90, }, + mobile: { + h1: window.innerWidth > maxMobileSize ? 20 : window.innerWidth / 18, + p: window.innerWidth > maxMobileSize ? 14 : window.innerWidth / 28, + }, }; class Profile extends Component { state = { @@ -30,6 +38,13 @@ class Profile extends Component { address: "", gender: "", userRoleId: "", + nationalId: "", + provinceId: "", + cityId: "", + zoneId: "", + schoolId: "", + postalCode: "", + gradeId: [], validation: { firstName: { name: "نام", status: "" }, lastName: { name: "نام خانوادگی", status: "" }, @@ -38,9 +53,15 @@ class Profile extends Component { }; onChange = (name, value) => { - this.setState({ - [name]: value, - }); + if (name === "gardeId" && this.state.userRoleId === "معلم") { + this.setState((prevState) => ({ + gradeId: [...prevState.gradeId, value], + })); + } else { + this.setState({ + [name]: value, + }); + } }; componentDidMount() { @@ -68,7 +89,7 @@ class Profile extends Component { return ( <> {window.innerWidth > 1000 ? ( -
+

حساب کاربری

@@ -93,7 +114,7 @@ class Profile extends Component {

@@ -107,27 +128,95 @@ class Profile extends Component { align="left" />
+ +
+ +
+
+ +
+
+ +
{/*
*/}
- +
+ +
+ ) : null} +
+
+ {this.state.userRoleId === "دانش آموز" ? ( +
+ +
+ ) : null} + {this.state.userRoleId === "معلم" ? ( +
+ +
+ ) : null} +
+ +
+
+