diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..c1e657a --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "rvest.vs-code-prettier-eslint" + ] +} \ No newline at end of file diff --git a/src/Redux/proxy.js b/src/Redux/proxy.js index 25f4400..528780f 100644 --- a/src/Redux/proxy.js +++ b/src/Redux/proxy.js @@ -1,6 +1,6 @@ import axios from 'axios'; import { toast } from 'react-toastify'; -const baseURL = 'http://localhost:4040/api/v1'; //"https://chatstory.ir/api/v1"; +const baseURL = 'https://chatstory.ir/api/v1'; //"https://chatstory.ir/api/v1"; const token = ''; const loginURL = 'user/otp/login'; const logoutURL = 'user/logout'; diff --git a/src/index.js b/src/index.js index 520c490..727521b 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ import ReactDOM from 'react-dom'; import App from './App'; import 'bootstrap/dist/css/bootstrap.min.css'; import './index.scss'; +import 'react-toastify/dist/ReactToastify.css'; ReactDOM.render( diff --git a/src/views/Auth/Auth.js b/src/views/Auth/Auth.js index 36a2993..124d1b9 100644 --- a/src/views/Auth/Auth.js +++ b/src/views/Auth/Auth.js @@ -24,6 +24,17 @@ export default class Auth extends Component { {this.state.page === 'logo' ? : null} {this.state.page === 'bio' ? : null} {this.state.page === 'login' ? : null} + ); } diff --git a/src/views/Auth/Auth.scss b/src/views/Auth/Auth.scss index 37862c8..41457cd 100644 --- a/src/views/Auth/Auth.scss +++ b/src/views/Auth/Auth.scss @@ -5,5 +5,13 @@ direction: rtl; overflow-x: hidden; position: relative; + .Toastify__toast-container { + width: calc(100vw - 20px) !important; + padding: 0 !important; + left: 0 !important; + bottom: 30px !important; + margin: 0px auto !important; + max-height: 50px; + } } } diff --git a/src/views/Auth/Login/Code/Code.js b/src/views/Auth/Login/Code/Code.js index d9c7305..b7796e9 100644 --- a/src/views/Auth/Login/Code/Code.js +++ b/src/views/Auth/Login/Code/Code.js @@ -1,14 +1,17 @@ import React, { Component } from 'react'; +import Timer from '../Timer/Timer'; export default class Code extends Component { constructor(props) { super(props); + this.state = { auth_code1: '', auth_code2: '', auth_code3: '', auth_code4: '', flag: false, + resendStatus: false, }; } @@ -123,6 +126,17 @@ export default class Code extends Component { value={this.state.auth_code4} onKeyDown={(e) => this.keyboardEvent(e)} /> + {!this.state.resendStatus ? ( + + ) : ( + this.props.parent.resend()} + > + دریافت مجدد + + )}

{ + const {cellphone} = this.state; + this.props.otp({cellphone}); + } + render() { const { section } = this.state; return ( diff --git a/src/views/Auth/Login/Timer/Timer.css b/src/views/Auth/Login/Timer/Timer.css new file mode 100644 index 0000000..6fcd6eb --- /dev/null +++ b/src/views/Auth/Login/Timer/Timer.css @@ -0,0 +1,5 @@ +.timer{ + flex-direction: row; + direction: rtl !important; + margin-right: 10px; +} \ No newline at end of file diff --git a/src/views/Auth/Login/Timer/Timer.js b/src/views/Auth/Login/Timer/Timer.js new file mode 100644 index 0000000..a0cb8a5 --- /dev/null +++ b/src/views/Auth/Login/Timer/Timer.js @@ -0,0 +1,66 @@ +import { Component } from 'react'; +import './Timer.css'; + +export default class Timer extends Component { + constructor(props) { + super(props); + this.state = { time: {}, seconds: this.props.seconds, flag: true, }; + this.timer = 0; + this.startTimer = this.startTimer.bind(this); + this.countDown = this.countDown.bind(this); + } + + secondsToTime(secs) { + let hours = Math.floor(secs / (60 * 60)); + + let divisor_for_minutes = secs % (60 * 60); + let minutes = Math.floor(divisor_for_minutes / 60); + + let divisor_for_seconds = divisor_for_minutes % 60; + let seconds = Math.ceil(divisor_for_seconds); + + let obj = { + "h": hours, + "m": minutes, + "s": seconds + }; + return obj; + } + + componentDidMount() { + this.startTimer(); + let timeLeftVar = this.secondsToTime(this.state.seconds); + this.setState({ time: timeLeftVar }); + } + + startTimer() { + if (this.timer === 0 && this.state.seconds > 0) { + this.timer = setInterval(this.countDown, 1000); + } + } + + countDown = async () => { + // Remove one second, set state so a re-render happens. + let seconds = this.state.seconds - 1; + this.setState({ + time: this.secondsToTime(seconds), + seconds: seconds, + }); + if (seconds === 0) { + this.props.parent.setState({ resendStatus : true }); + } + } + + componentWillUnmount() { + clearInterval(this.timer); + } + render() { + return ( +
+
دریافت مجدد کد در
+
{this.state.time.s}
:
{this.state.time.m+this.state.time.h*60}
+
دیگر
+
+ ); + } +} \ No newline at end of file