diff --git a/src/AppRouter.js b/src/AppRouter.js index a10e61e..90a2560 100644 --- a/src/AppRouter.js +++ b/src/AppRouter.js @@ -1,21 +1,24 @@ -import React, { Component } from 'react'; -import './App.css'; -import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; -// import proxy from './Redux/proxy'; -import Home from './views/Home/index'; -import Faq from './views/Faq/index'; -import Contact from './views/Contact/index'; -import About from './views/About/index'; -import Products from './views/Products/index'; -import Product from './views/Product/index'; -import QR from './views/QR/index'; -import Auth from './views/Auth/index'; -import QRScan from './views/QRScan/index'; -import Activation from './views/Activation/index'; -import ChatList from './views/ChatList/index'; -import Chatroom from './views/ChatRoom/index'; -import Cart from './views/Cart/index'; -import MyBooks from './views/MyBooks/index'; +import React, { Component } from "react"; +import "./App.css"; +import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; + +import { connect } from "react-redux"; + +import proxy from "./Redux/proxy"; +import Home from "./views/Home/index"; +import Faq from "./views/Faq/index"; +import Contact from "./views/Contact/index"; +import About from "./views/About/index"; +import Products from "./views/Products/index"; +import Product from "./views/Product/index"; +import QR from "./views/QR/index"; +import Auth from "./views/Auth/index"; +import QRScan from "./views/QRScan/index"; +import Activation from "./views/Activation/index"; +import ChatList from "./views/ChatList/index"; +import Chatroom from "./views/ChatRoom/index"; +import Cart from "./views/Cart/index"; +import MyBooks from "./views/MyBooks/index"; class AppRouter extends Component { constructor(props) { @@ -25,9 +28,16 @@ class AppRouter extends Component { state = {}; render() { let home = ( - - - {/* {proxy.status() ? : } */} + + {proxy.status() ? ( + this.props.profile.username ? ( + + ) : ( + + ) + ) : ( + + )} ); @@ -35,58 +45,59 @@ class AppRouter extends Component { {home} - {/* - - */} - + - + - + - + - + - + - + - - + + - + - + - + - + - + - { - window.innerWidth < 1000 ? - + {window.innerWidth < 1000 ? ( + - : null - } + + ) : null} ); } } -export default AppRouter; +export default connect( + (state) => ({ + profile: state.user.status.profile || {}, + }), + {} +)(AppRouter); diff --git a/src/Redux/actions/user.js b/src/Redux/actions/user.js index 1dc496e..db2572b 100644 --- a/src/Redux/actions/user.js +++ b/src/Redux/actions/user.js @@ -1,37 +1,53 @@ -import proxy from '../proxy'; -const user = { +import proxy from "../proxy"; +const user = { otp: (data, history) => async (dispatch) => - await proxy.login('public/sendOTP', data, { history, dispatch }), + await proxy.login("public/sendOTP", data, { history, dispatch }), otp_login: (data, history) => async (dispatch) => - await proxy.login('user/otp/login', data, { history, dispatch }), + await proxy.login("user/otp/login", data, { history, dispatch }), register: (data, history) => async (dispatch) => - await proxy.login('user/register', data, { history, dispatch }), + await proxy.login("user/register", data, { history, dispatch }), switchRole: (data, history) => async (dispatch) => - await proxy.login('user/switchRole', data, { history, dispatch }), + await proxy.login("user/switchRole", data, { history, dispatch }), logout: (data, history) => async (dispatch) => - await proxy.logout('user/logout', data, { history, dispatch }), + await proxy.logout("user/logout", data, { history, dispatch }), getUserRole: (data) => async (dispatch) => - await proxy.get('user/getUserRole', data, { dispatch }), - list: (data = {}) => async (dispatch) => - await proxy.get('user/list', data, { dispatch }), - domains: (data = {}) => async (dispatch) => - await proxy.get('user/domains', data, { dispatch }), - getmothers: (data = {}) => async (dispatch) => - await proxy.get2('mothers/list', data, { - dispatch, - }), - update: (data = {}, data2 = {}) => async (dispatch) => { - await proxy.put('user/update', data); - await proxy.get('user/list', data2, { dispatch }); - }, - add: (data = {}, data2 = {}) => async (dispatch) => { - await proxy.post('user/add', data); - await proxy.get('user/list', data2, { dispatch }); - }, - del: (data = {}, data2 = {}) => async (dispatch) => { - await proxy.delete('user/delete', data); - await proxy.get('user/list', data2, { dispatch }); - }, + await proxy.get("user/getUserRole", data, { dispatch }), + list: + (data = {}) => + async (dispatch) => + await proxy.get("user/list", data, { dispatch }), + domains: + (data = {}) => + async (dispatch) => + await proxy.get("user/domains", data, { dispatch }), + getmothers: + (data = {}) => + async (dispatch) => + await proxy.get2("mothers/list", data, { + dispatch, + }), + getProfile: + (data = {}) => + async (dispatch) => + await proxy.get("user/getProfile", data, { dispatch }), + setProfile: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.put("user/setProfile", data, { dispatch }); + await proxy.get("user/getProfile", data2, { dispatch }); + }, + add: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.post("user/add", data); + await proxy.get("user/list", data2, { dispatch }); + }, + del: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.delete("user/delete", data); + await proxy.get("user/list", data2, { dispatch }); + }, }; -export default user; \ No newline at end of file +export default user; diff --git a/src/Redux/proxy.js b/src/Redux/proxy.js index 7abfce2..631493e 100644 --- a/src/Redux/proxy.js +++ b/src/Redux/proxy.js @@ -1,18 +1,15 @@ -import { ApiConfig } from './../constants/defaultValues'; -import axios from 'axios'; +import { ApiConfig } from "./../constants/defaultValues"; +import axios from "axios"; let { baseUrl, apiKey } = ApiConfig; -baseUrl = baseUrl + '/'; -const baseUrl2 = 'https://dnvn.ir/api/v1'; +let access = window.localStorage.getItem("access"); +baseUrl = baseUrl + "/"; +const baseUrl2 = "https://dnvn.ir/api/v1"; const Axios = axios.create({ withCredentials: true, validateStatus: null, baseURL: baseUrl, -}); -const Axios2 = axios.create({ - withCredentials: true, - validateStatus: null, - baseURL: baseUrl2, + headers: access ? { Authorization: `Bearer ${access}` } : {}, }); class Proxy { get = async (url, params, opt = {}) => @@ -21,12 +18,6 @@ class Proxy { opt, async () => await Axios.get(url, { params, ...opt }) ); - get2 = async (url, params, opt = {}) => - await this.check2( - url, - opt, - async () => await Axios2.get(url, { params, ...opt }) - ); post = async (url, params, opt = {}) => await this.check(url, opt, async () => await Axios.post(url, params, opt)); put = async (url, params, opt = {}) => @@ -41,7 +32,7 @@ class Proxy { check = async (url, { dispatch }, fetch) => { dispatch = dispatch || (() => {}); - dispatch({ type: 'loading' }); + dispatch({ type: "loading" }); let response = await fetch(); switch (response.status) { case 200: @@ -55,32 +46,14 @@ class Proxy { } break; default: - dispatch({ type: 'error', data: response.data }); - } - return false; - }; - check2 = async (url, { dispatch }, fetch) => { - dispatch({ type: 'loading' }); - let response = await fetch(); - switch (response.status) { - case 200: - dispatch({ type: url, data: response.data }); - return response.data; - case 401: - if (await this.refresh()) { - let response = await fetch(); - dispatch({ type: url, data: response.data }); - return response.data; - } - break; - default: - dispatch({ type: 'error', data: response.data }); + dispatch({ type: "error", data: response.data }); } return false; }; + refresh = async () => { - let refresh = localStorage.getItem('refresh'); - if (!refresh) window.location.href = '/'; + let refresh = localStorage.getItem("refresh"); + if (!refresh) window.location.href = "/"; let login = await this.login( {}, { headers: { Authorization: `Bearer ${refresh}` } } @@ -92,10 +65,11 @@ class Proxy { dispatch: (obj) => { let login = obj.data; if (!login || !login.refreshToken) return false; - localStorage.setItem('refresh', login.refreshToken); + localStorage.setItem("refresh", login.refreshToken); + localStorage.setItem("access", login.accessToken); delete login.refreshToken; delete login.accessToken; - localStorage.setItem('userData', JSON.stringify(login)); + localStorage.setItem("userData", JSON.stringify(login)); dispatch(obj); }, }); @@ -103,19 +77,21 @@ class Proxy { logout = async (url, params, { dispatch }) => { this.post(url, params, { dispatch: (obj) => { - localStorage.removeItem('refresh'); - localStorage.removeItem('userData'); + localStorage.removeItem("refresh"); + localStorage.removeItem("access"); + localStorage.removeItem("userData"); dispatch(obj); }, }); }; status = () => { - let refresh = localStorage.getItem('refresh'); - let userData = localStorage.getItem('userData'); + let refresh = localStorage.getItem("refresh"); + let userData = localStorage.getItem("userData"); if (!refresh) return false; - if (refresh == 'undefined') { - localStorage.removeItem('refresh'); - localStorage.removeItem('userData'); + if (refresh == "undefined") { + localStorage.removeItem("refresh"); + localStorage.removeItem("access"); + localStorage.removeItem("userData"); return false; } return JSON.parse(userData); @@ -123,4 +99,4 @@ class Proxy { } const _proxy = new Proxy(); -export default _proxy; \ No newline at end of file +export default _proxy; diff --git a/src/assets/icons/danger_lg.png b/src/assets/icons/danger_lg.png new file mode 100644 index 0000000..b277f6f Binary files /dev/null and b/src/assets/icons/danger_lg.png differ diff --git a/src/assets/icons/home_ar(2).png b/src/assets/icons/home_ar(2).png new file mode 100644 index 0000000..d5ee865 Binary files /dev/null and b/src/assets/icons/home_ar(2).png differ diff --git a/src/assets/icons/home_ar.png b/src/assets/icons/home_ar.png new file mode 100644 index 0000000..ab500a1 Binary files /dev/null and b/src/assets/icons/home_ar.png differ diff --git a/src/assets/icons/home_chat.png b/src/assets/icons/home_chat.png new file mode 100644 index 0000000..8b5d0a6 Binary files /dev/null and b/src/assets/icons/home_chat.png differ diff --git a/src/assets/icons/ppt.png b/src/assets/icons/ppt.png new file mode 100644 index 0000000..07a64f7 Binary files /dev/null and b/src/assets/icons/ppt.png differ diff --git a/src/views/Auth/Login/Cellphone/index.js b/src/views/Auth/Login/Cellphone/index.js index 3ab92ba..4b0a1d1 100644 --- a/src/views/Auth/Login/Cellphone/index.js +++ b/src/views/Auth/Login/Cellphone/index.js @@ -11,8 +11,8 @@ const maxMobileSize = 550; const fontSize = { desktop: { - span: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 85, - input: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 85, + span: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 80, + input: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 80, button: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 85, div: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 100, }, diff --git a/src/views/Auth/Login/Cellphone/index.scss b/src/views/Auth/Login/Cellphone/index.scss index 90e2fbe..5eee6d2 100644 --- a/src/views/Auth/Login/Cellphone/index.scss +++ b/src/views/Auth/Login/Cellphone/index.scss @@ -19,27 +19,29 @@ } form { width: 100%; - max-width: 400px; position: relative; + padding: 10px 40px; img { position: absolute; - left: 10px; - top: 6px; + left: 50px; + top: 17px; width: 45px; } span { text-align: right; position: absolute; - left: 65px; - top: 8px; + left: 108px; + top: 18px; direction: ltr; color: #a5a5a5; + font-family: numeralLight; } input { + font-family: numeralLight; width: 100%; - max-width: 400px; background-color: inherit; color: #a5a5a5; + height: 43px; direction: ltr; text-align: left; background-color: #f2f2f2; @@ -53,7 +55,6 @@ button { margin-top: 20px; width: 100%; - max-width: 400px; border: 0px; font-family: numeralLight; background-color: #6cbe44; @@ -63,7 +64,6 @@ } } &--footer { - max-width: 400px; div { font-family: numeralLight; color: #a5a5a5; diff --git a/src/views/Auth/Login/Code/index.js b/src/views/Auth/Login/Code/index.js index c6e80e0..ebe87ea 100644 --- a/src/views/Auth/Login/Code/index.js +++ b/src/views/Auth/Login/Code/index.js @@ -10,9 +10,9 @@ const maxDesktopSize = 1250; const fontSize = { desktop: { - input: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 85, - button: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 85, - div: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 95, + input: window.innerWidth > maxDesktopSize ? 20 : window.innerWidth / 85, + button: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 85, + div: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95, }, }; export default class Code extends Component { @@ -164,7 +164,9 @@ export default class Code extends Component { /> - + {!this.state.resendStatus ? ( ) : ( @@ -210,7 +212,8 @@ export default class Code extends Component {

دانوین

- یک کد تائیدیه به شماره {this.props.parent.state.cellphone} ارسال شد
+ یک کد تائیدیه به شماره{" "} + {this.props.parent.state.cellphone} ارسال شد
آن را در قسمت زیر وارد کنید.

diff --git a/src/views/Auth/Login/Code/index.scss b/src/views/Auth/Login/Code/index.scss index 1e4f16b..4acc5e7 100644 --- a/src/views/Auth/Login/Code/index.scss +++ b/src/views/Auth/Login/Code/index.scss @@ -1,4 +1,4 @@ -.auth-code{ +.auth-code { width: 100vw; height: 100vh; &__box { @@ -11,46 +11,48 @@ img { margin-bottom: 30px; } - button{ + button { margin-top: 20px; width: 100%; max-width: 300px; border: 0px; - font-family: numeralMedium; - background-color: #6CBE44; + font-family: numeralLight; + background-color: #6cbe44; color: white; border-radius: 7px; padding: 8px; } - &--codes{ + &--codes { direction: ltr; input { max-width: 60px; max-height: 60px; background-color: #f2f2f2; - border : 0px; - margin : 0px 10px; - color: #6F7074; + border: 0px; + margin: 0px 10px; + color: #6f7074; text-align: center; - direction : ltr; + direction: ltr; border-radius: 5px; padding: 10px 15px; - &:focus{ + font-family: numeralLight; + &:focus { outline: 0px; } } - div{ - letter-spacing:-1px; + div { + letter-spacing: -1px; + font-family: numeralLight; } } } } -.mobile-auth-code{ +.mobile-auth-code { width: 100%; height: 100%; - justify-content:center; - align-items:center; + justify-content: center; + align-items: center; direction: ltr; position: relative; max-width: 360px; @@ -75,35 +77,35 @@ position: relative; bottom: 40px; } - button{ + button { margin-top: 20px; width: 100%; max-width: 300px; border: 0px; font-family: numeralMedium; - background-color: #6CBE44; + background-color: #6cbe44; color: white; border-radius: 7px; padding: 8px; font-size: calc(100vw / 20); } - &__codes{ + &__codes { direction: ltr; input { max-width: 60px; max-height: 60px; background-color: #f2f2f2; - border : 0px; - margin : 0px 10px; - color: #6F7074; + border: 0px; + margin: 0px 10px; + color: #6f7074; text-align: center; - direction : ltr; + direction: ltr; font-size: calc(100vw / 15); border-radius: 5px; padding: 10px 15px; - &:focus{ + &:focus { outline: 0px; } } } -} \ No newline at end of file +} diff --git a/src/views/Auth/Login/Timer/index.css b/src/views/Auth/Login/Timer/index.css index f45c2fc..44ee40b 100644 --- a/src/views/Auth/Login/Timer/index.css +++ b/src/views/Auth/Login/Timer/index.css @@ -1,6 +1,7 @@ -.timer{ +.timer { flex-direction: row; direction: rtl !important; margin-right: 10px; - color: #6CBE44; -} \ No newline at end of file + color: #6cbe44; + font-family: numeralLight; +} diff --git a/src/views/Auth/Login/Timer/index.js b/src/views/Auth/Login/Timer/index.js index b3befab..c13167f 100644 --- a/src/views/Auth/Login/Timer/index.js +++ b/src/views/Auth/Login/Timer/index.js @@ -5,7 +5,7 @@ const maxDesktopSize = 1250; const fontSize = { desktop: { - div: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 95, + div: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95, }, }; export default class Timer extends Component { @@ -66,17 +66,29 @@ export default class Timer extends Component { <> {window.innerWidth > 1000 ? (
-
+
زمان باقیمانده تا انقضای کد:
-
{this.state.time.s}
: -
{this.state.time.m + this.state.time.h * 60}
+
+ {this.state.time.s} +
+ : +
+ {this.state.time.m + this.state.time.h * 60} +
) : null} {window.innerWidth < 1000 ? (
- زمان باقیمانده تا انقضای کد: + زمان باقیمانده تا انقضای کد
{this.state.time.s}
:
{this.state.time.m + this.state.time.h * 60}
diff --git a/src/views/Auth/Login/index.js b/src/views/Auth/Login/index.js index 8e9897f..a0c7b8b 100644 --- a/src/views/Auth/Login/index.js +++ b/src/views/Auth/Login/index.js @@ -19,7 +19,13 @@ class Login extends Component { async componentDidUpdate() { const { cellphone, otp, page } = this.state; if (cellphone && !otp) this.props.otp({ cellphone }); - if (page && cellphone && otp) this.props.otp_login({ cellphone, otp }); + if (page && cellphone && otp) + this.props.otp_login({ + cellphone, + otp, + userToken: "1", + applicationToken: "11", + }); } resend = () => { diff --git a/src/views/Auth/Profile/GenderSwitch/index.js b/src/views/Auth/Profile/GenderSwitch/index.js new file mode 100644 index 0000000..31d7f2c --- /dev/null +++ b/src/views/Auth/Profile/GenderSwitch/index.js @@ -0,0 +1,20 @@ +import React from "react"; + +export default function GenderSwitch(props) { + return ( + <> + {window.innerWidth > 1000 ? ( +
+ + +
+ ) : null} + {window.innerWidth < 1000 ? ( +
+ + +
+ ) : null} + + ); +} diff --git a/src/views/Auth/Profile/GenderSwitch/index.scss b/src/views/Auth/Profile/GenderSwitch/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/views/Auth/Profile/Input/index.js b/src/views/Auth/Profile/Input/index.js index 6dbcd5d..232e663 100644 --- a/src/views/Auth/Profile/Input/index.js +++ b/src/views/Auth/Profile/Input/index.js @@ -1,27 +1,40 @@ -import React from 'react'; -import TextField from '@material-ui/core/TextField'; -import { makeStyles } from '@material-ui/core/styles'; +import React from "react"; +import TextField from "@material-ui/core/TextField"; +import { makeStyles } from "@material-ui/core/styles"; -const useStyles = makeStyles((theme) => ({ - root: { - '& .MuiTextField-root': { - - width: '100%', - position : 'relative', - marginRight : 10, - +export default function FormPropsTextFields(props) { + const useStyles = makeStyles((theme) => ({ + root: { + "& .MuiTextField-root": { + width: "100%", + position: "relative", + marginRight: 10, + "& input": { + textAlign: props.align, + direction: props.align === "right" ? "rtl" : "ltr", + }, + }, }, - }, -})); + })); -export default function FormPropsTextFields(props) { const classes = useStyles(); - + const { parent, defaultValue } = props; return (
- + parent.onChange(e.target.name, e.target.value)} + defaultValue={defaultValue} + />
); } + +FormPropsTextFields.defaultProps = { + align: "right", +}; diff --git a/src/views/Auth/Profile/Select/index.js b/src/views/Auth/Profile/Select/index.js index 376b94d..594a7fe 100644 --- a/src/views/Auth/Profile/Select/index.js +++ b/src/views/Auth/Profile/Select/index.js @@ -1,32 +1,31 @@ import React from "react"; import { makeStyles, withStyles } from "@material-ui/core/styles"; import FormControl from "@material-ui/core/FormControl"; -import Select from '@material-ui/core/Select'; +import Select from "@material-ui/core/Select"; import InputBase from "@material-ui/core/InputBase"; import KeyboardArrowDownIcon from "@material-ui/icons/KeyboardArrowDown"; -import InputLabel from '@material-ui/core/InputLabel'; +import InputLabel from "@material-ui/core/InputLabel"; const BootstrapInput = withStyles((theme) => ({ root: { "label + &": { marginTop: theme.spacing(3), }, - }, - input: { - borderRadius: 4, - position: "relative", - // backgroundColor: theme.palette.background.paper, - border: "1px solid #a5a5a5", - fontSize: window.innerWidth > 1000 ? 16 : "calc(100vw / 30)", - color: "#a5a5a5", - // maxWidth : 70, - minWidth: '100%', - padding: "0px", - transition: theme.transitions.create(["border-color", "box-shadow"]), - // Use the system font instead of the default Roboto font. - fontFamily: "numeralLight", - "&:focus": { + input: { borderRadius: 4, + position: "relative", + // backgroundColor: theme.palette.background.paper, + border: "1px solid #a5a5a5", + fontSize: window.innerWidth > 1000 ? 16 : "calc(100vw / 30)", + color: "#a5a5a5", + // maxWidth : 70, + minWidth: "100%", + padding: "0px", + // Use the system font instead of the default Roboto font. + fontFamily: "numeralLight", + "&:focus": { + borderRadius: 4, + }, }, }, }))(InputBase); @@ -40,21 +39,21 @@ const useStyles = makeStyles((theme) => ({ export default function CustomizedSelects(props) { const classes = useStyles(); - - console.log(props); + const { parent } = props; return ( -
+
- {props.label} + + {props.label} + parent.onChange(e.target.name, e.target.value)} + /> + + + ) : ( + <> + parent.onChange(e.target.name, e.target.value)} + /> + {"کاربر"} + + )} +
+ ) : null} + {window.innerWidth > 1000 ? ( +
+ {parent.state.file === null ? ( + <> + parent.onChange(e.target.name, e.target.value)} + name={props.name} + defaultValue="" + type="file" + /> + + + ) : ( + <> + parent.onChange(e.target.name, e.target.value)} + name={props.name} + defaultValue="" + type="file" + /> + + )} +
+ ) : null} + + ); +} diff --git a/src/views/Auth/Profile/index.js b/src/views/Auth/Profile/index.js index c4fdaf6..9093188 100644 --- a/src/views/Auth/Profile/index.js +++ b/src/views/Auth/Profile/index.js @@ -1,11 +1,14 @@ import React, { Component } from "react"; +import { user } from "~/Redux/actions"; +import { connect } from "react-redux"; + import Select from "./Select/index"; import Input from "./Input/index"; import TextArea from "./TextArea/index"; +import Upload from "./Upload/index"; import logo from "../../../assets/icons/logo.png"; import pic from "../../../assets/images/pic.png"; -import AddAPhotoIcon from "@material-ui/icons/AddAPhoto"; import "./index.scss"; @@ -14,20 +17,54 @@ const maxDesktopSize = 1250; const fontSize = { desktop: { h1: window.innerWidth > maxDesktopSize ? 25 : window.innerWidth / 55, - p: window.innerWidth > maxDesktopSize ? 18 : window.innerWidth / 85, + p: window.innerWidth > maxDesktopSize ? 14 : window.innerWidth / 90, }, }; -export default class Profile extends Component { +class Profile extends Component { state = { file: null, + firstName: "", + lastName: "", + password: "", + username: "", + address: "", + gender: "", + userRoleId: "", + validation: { + firstName: { name: "نام", status: "" }, + lastName: { name: "نام خانوادگی", status: "" }, + username: { name: "نام کاربری", status: "" }, + }, }; - onChange = (e) => { + + onChange = (name, value) => { this.setState({ - [e.target.name]: e.target.value, + [name]: value, }); }; + + componentDidMount() { + const { getProfile, profile } = this.props; + // if (!profile) { + // getProfile(); + // } + } + + onSubmit = (e) => { + e.preventDefault(); + const { firstName, lastName, username, cellphone } = this.state; + const { profile, setProfile } = this.props; + const data = { + firstName: firstName || profile.firstName, + lastName: lastName || profile.lastName, + username: username || profile.username, + cellphone: profile.cellphone, + }; + setProfile(data); + }; + render() { - const { user } = this.props; + const { user, profile } = this.props; return ( <> {window.innerWidth > 1000 ? ( @@ -37,19 +74,60 @@ export default class Profile extends Component {

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

-
+ this.onSubmit(e)} + >
+
+ +
- +
- +
- +
+ {/*
+ +
*/}
+
+ + ) : null}