From 250ab860049500ee37a2892ddbe00c32b99bfe71 Mon Sep 17 00:00:00 2001 From: RezaAshrafi77 Date: Tue, 3 Aug 2021 13:24:05 +0430 Subject: [PATCH] reza fixed qr --- src/AppRouter.js | 14 +- src/Redux/reducers/qr.js | 2 +- src/components/Loader/index.js | 22 + src/views/Auth/Profile/Input/index.js | 3 +- src/views/Auth/Profile/index.js | 633 ++++++++++++++------------ src/views/Home/index.js | 4 +- src/views/QR/index.js | 55 ++- src/views/QR/index.scss | 11 + 8 files changed, 413 insertions(+), 331 deletions(-) create mode 100644 src/components/Loader/index.js diff --git a/src/AppRouter.js b/src/AppRouter.js index 452d52d..c7c3816 100644 --- a/src/AppRouter.js +++ b/src/AppRouter.js @@ -31,13 +31,13 @@ class AppRouter extends Component { let home = ( {proxy.status() ? ( - // this.props.profile.username ? ( - // - // ) : ( - // - // ) - + this.props.profile.username ? ( + + ) : ( + + ) ) : ( + // )} @@ -102,7 +102,7 @@ class AppRouter extends Component { export default connect( (state) => ({ - profile: state.user.status.profile || {}, + profile: state.user.status || state.user.status.profile || {}, // status: state.user.status, }), {} diff --git a/src/Redux/reducers/qr.js b/src/Redux/reducers/qr.js index 02310c3..f567966 100644 --- a/src/Redux/reducers/qr.js +++ b/src/Redux/reducers/qr.js @@ -18,7 +18,7 @@ export default function qr(state = initialState, action) { return { ...state, loading: false, - list: data.content, + list: data, error: null, }; ///////////// diff --git a/src/components/Loader/index.js b/src/components/Loader/index.js new file mode 100644 index 0000000..f85d04c --- /dev/null +++ b/src/components/Loader/index.js @@ -0,0 +1,22 @@ +import React from "react"; +import { makeStyles } from "@material-ui/core/styles"; +import CircularProgress from "@material-ui/core/CircularProgress"; + +const useStyles = makeStyles((theme) => ({ + root: { + display: "flex", + "& > * + *": { + marginLeft: theme.spacing(2), + }, + }, +})); + +export default function CircularIndeterminate() { + const classes = useStyles(); + + return ( +
+ +
+ ); +} diff --git a/src/views/Auth/Profile/Input/index.js b/src/views/Auth/Profile/Input/index.js index 232e663..a0974c3 100644 --- a/src/views/Auth/Profile/Input/index.js +++ b/src/views/Auth/Profile/Input/index.js @@ -19,6 +19,7 @@ export default function FormPropsTextFields(props) { const classes = useStyles(); const { parent, defaultValue } = props; + console.log(defaultValue[props.name]); return (
@@ -28,7 +29,7 @@ export default function FormPropsTextFields(props) { label={props.label} variant="outlined" onChange={(e) => parent.onChange(e.target.name, e.target.value)} - defaultValue={defaultValue} + defaultValue={defaultValue[props.name]} />
diff --git a/src/views/Auth/Profile/index.js b/src/views/Auth/Profile/index.js index f54c1ea..82f1f93 100644 --- a/src/views/Auth/Profile/index.js +++ b/src/views/Auth/Profile/index.js @@ -9,6 +9,7 @@ import Upload from "./Upload/index"; import Gender from "./GenderSwitch/index"; import Birthdate from "./Birthdate/index"; import MultipleSelector from "./MultipleSelector/index"; +import Loader from "~/components/Loader/index"; import logo from "../../../assets/icons/logo.png"; import pic from "../../../assets/images/pic.png"; @@ -30,6 +31,7 @@ const fontSize = { }; class Profile extends Component { state = { + render: false, file: null, firstName: "", lastName: "", @@ -66,9 +68,17 @@ class Profile extends Component { } }; - componentDidMount() { + async componentDidMount() { const { getProfile, profile } = this.props; - // getProfile(); + getProfile(); + } + + componentDidUpdate(prevProps) { + if (prevProps.profile !== this.props.profile) { + this.setState({ + render: true, + }); + } } onSubmit = async (e) => { @@ -103,340 +113,366 @@ class Profile extends Component { return ( <> {window.innerWidth > 1000 ? ( -
-
-

حساب کاربری

-

- لطفا مشخصات خود را به صورت کامل نمایید. -

-
this.onSubmit(e)} - > -
-
- -
-
- -
-
- -
-
- -
+ !this.props.loading ? ( +
+
+

حساب کاربری

+

+ لطفا مشخصات خود را به صورت کامل نمایید. +

+ this.onSubmit(e)} + > +
+
+ +
+
+ +
+
+ +
+
+ +
-
- -
-
- -
-
- -
- {/*
+
+ +
+
+ +
+
+ +
+ {/*
*/} -
-
-
-
- {this.state.userRoleId === "دانش آموز" ? ( -
+
+
+ +
+ {this.state.userRoleId === "دانش آموز" ? ( +
+ +
+ ) : null} + +
- ) : null} - -
- -
-
- +
+ ) : null} + {this.state.userRoleId === "معلم" ? ( +
+ +
+ ) : null}
- ) : null} - {this.state.userRoleId === "معلم" ? (
-
- ) : null} -
- -
-
-