Gorji 4 years ago
parent 76af91c37c
commit ab8c506dd5
  1. 10
      package.json
  2. 50
      src/Redux/proxy.js
  3. 5
      src/Router.js
  4. 2
      src/views/Auth/Auth.js
  5. 2
      src/views/Auth/Auth.scss
  6. 2
      src/views/Auth/Bio/Bio.scss
  7. 7
      src/views/Auth/Login/Code/Code.js
  8. 23
      src/views/Auth/Login/Login.js
  9. 2
      src/views/Auth/Login/Login.scss
  10. 8
      src/views/Auth/Login/Mobile/Mobile.js
  11. 2
      src/views/Auth/Logo/Logo.scss
  12. 1
      src/views/ChatRoom/Body/Body.js
  13. 3
      src/views/ChatRoom/Body/Body.scss
  14. 2
      src/views/ChatRoom/Body/ChatInputs/ChatInputs.scss
  15. 2
      src/views/ChatRoom/Body/ChatSuggest/ChatSuggest.scss
  16. 2
      src/views/ChatRoom/Body/Message/Message2D/Message2D.scss
  17. 2
      src/views/ChatRoom/Body/Message/NormalMessage/NormalMessage.scss
  18. 3
      src/views/ChatRoom/ChatInfo/ChatInfo.scss
  19. 2
      src/views/ChatRoom/ChatInfo/FileTabs/FileTabs.scss
  20. 2
      src/views/ChatRoom/ChatInfo/Gallery/Gallery.scss
  21. 3
      src/views/ChatRoom/ChatRoom.scss
  22. 2
      src/views/ChatRoom/Header/Header.scss
  23. 6
      src/views/Home/Body/Body.js
  24. 3
      src/views/Home/Body/Body.scss
  25. 2
      src/views/Home/Body/ChatList/Chat/Chat.scss
  26. 11
      src/views/Home/Body/ChatList/ChatList.js
  27. 2
      src/views/Home/Body/ChatList/ChatList.scss
  28. 2
      src/views/Home/Body/Location/Location.scss
  29. 2
      src/views/Home/Header/Header.scss
  30. 6
      src/views/Home/Header/NavbarDrawer/NavbarDrawer.js
  31. 3
      src/views/Home/Home.scss
  32. 2
      src/views/Home/TabBar/TabBar.scss

@ -2,6 +2,7 @@
"name": "chat-pwa", "name": "chat-pwa",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"proxy": "http://localhost:4040/",
"dependencies": { "dependencies": {
"@material-ui/core": "^4.11.4", "@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2", "@material-ui/icons": "^4.11.2",
@ -44,16 +45,9 @@
"react-app/jest" "react-app/jest"
] ]
}, },
"browserslist": { "browserslist": [
"production": [
">0.2%", ">0.2%",
"not dead", "not dead",
"not op_mini all" "not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
] ]
}
} }

@ -0,0 +1,50 @@
import axios from 'axios'
const Axios = axios.create({
withCredentials: true,
validateStatus:null,
baseURL: "https://chatstory.ir/api/v1"
// baseURL: "http://localhost:4040/api/v1"
})
class Proxy{
constructor({alert,loginUrl}={}){
this.alert = alert || window.alert;
this.loginUrl = loginUrl || "user/otp/login";
}
get = (url,params,opt={})=> this.check(()=>Axios.get(url,{params,...opt}));
post = (url,params,opt={})=> this.check(()=>Axios.post(url,params,opt));
put = (url,params,opt={})=> this.check(()=> Axios.put(url,params,opt));
delete = (url,params,opt={})=> this.check(()=> Axios.delete(url,params,opt));
check = async (fetch)=>{
let response = await fetch()
switch(response.status){
case 200: return response.data.data;
case 401:
console.log("refreshing")
if(await this.refresh()) return (await fetch()).data.data;
break;
default: window.alert(response.data.message);
}
return false;
}
refresh = async()=>{
let refresh = localStorage.getItem('refresh')
if(!refresh) window.location.href = "/"
let login = await this.login({},{headers: { "Authorization": `Bearer ${refresh}`}})
return login ? true : false
}
login = async(data,opt={})=>{
const login = await this.post(this.loginUrl,data,opt)
if(!login) return false;
localStorage.setItem("refresh",login.refreshToken)
delete login.refreshToken
return login
}
logout = async()=>{
localStorage.removeItem("refresh");
window.location.href = "/"
}
status = ()=>localStorage.getItem("refresh")?true:false;
}
const _proxy = new Proxy()
export default _proxy;

@ -6,12 +6,11 @@ import { Provider } from "react-redux";
import Home from "./views/Home/Home"; import Home from "./views/Home/Home";
import ChatRoom from "./views/ChatRoom/ChatRoom"; import ChatRoom from "./views/ChatRoom/ChatRoom";
import Auth from "./views/Auth/Auth"; import Auth from "./views/Auth/Auth";
import proxy from "./Redux/proxy";
export default class AppRouter extends Component { export default class AppRouter extends Component {
render() { render() {
let home; let home;
if(!localStorage.getItem("access_token")){ if(proxy.status()){
home = <Route exact path={'/'}> home = <Route exact path={'/'}>
<Home /> <Home />
</Route> </Route>

@ -28,7 +28,7 @@ export default class Auth extends Component {
this.state.page === 'bio' ? <Bio setPage={this.setPage} /> : null this.state.page === 'bio' ? <Bio setPage={this.setPage} /> : null
} }
{ {
this.state.page === 'login' ? <Login /> : null this.state.page === 'login' ? <Login/> : null
} }
</div> </div>
); );

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.auth{ .auth{
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.bio{ .bio{
width: 100%; width: 100%;
height: 100%; height: 100%;

@ -24,13 +24,18 @@ export default class Code extends Component {
[e.target.name]: e.target.value, [e.target.name]: e.target.value,
}) })
if(e.target.name === 'auth_code1'){ if(e.target.name === 'auth_code1'){
this.setState({o1:e.target.value})
this.inputRef2.focus(); this.inputRef2.focus();
}else if(e.target.name === 'auth_code2'){ }else if(e.target.name === 'auth_code2'){
this.setState({o2:e.target.value})
this.inputRef3.focus(); this.inputRef3.focus();
}else if(e.target.name === 'auth_code3'){ }else if(e.target.name === 'auth_code3'){
this.setState({o3:e.target.value})
this.inputRef4.focus(); this.inputRef4.focus();
}else if(e.target.name === 'auth_code4'){ }else if(e.target.name === 'auth_code4'){
window.location.href="/" const o4 = e.target.value;
const {o1,o2,o3} = this.state
this.props.parent.setState({otp:`${o1}${o2}${o3}${o4}`})
return; return;
} }

@ -2,8 +2,9 @@ import React, { Component } from 'react';
import Mobile from './Mobile/Mobile'; import Mobile from './Mobile/Mobile';
import Code from './Code/Code'; import Code from './Code/Code';
import proxy from '../../../Redux/proxy'
import './Login.scss'; import './Login.scss';
export default class Login extends Component { export default class Login extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -11,26 +12,20 @@ export default class Login extends Component {
section : 0, section : 0,
} }
} }
setSection = (val) => { async componentDidUpdate(){
this.setState({ const {cellphone,otp,section} = this.state
section : val, if(cellphone && !otp) proxy.get("public/otp",{cellphone})
}) if(section && cellphone && otp) if(await proxy.login({cellphone,otp})) window.location.href="/"
}
componentDidMount() {
} }
render() { render() {
const {section} = this.state;
return( return(
<div className="login d-flex flex-column"> <div className="login d-flex flex-column">
{ {
this.state.section === 0 ? section ? <Code parent={this}/> :<Mobile parent={this} />
<Mobile setSection={this.setSection} /> : null
}
{
this.state.section === 1 ?
<Code setSection={this.setSection}/> : null
} }
<div className="logo__footer d-flex align-self-center"> <div className="logo__footer d-flex align-self-center">
<h2 style={{fontFamily : 'IRANSansNumeralBold',marginRight : 10, color : "rgb(108, 72, 191)"}}>Eema</h2> <h2 style={{fontFamily : 'IRANSansNumeralBold',marginRight : 10, color : "rgb(108, 72, 191)"}}>Eema</h2>
<h2 style={{fontSize :17, color : "rgb(108, 72, 191)"}}>Entertainments</h2> <h2 style={{fontSize :17, color : "rgb(108, 72, 191)"}}>Entertainments</h2>

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.login{ .login{
width: 100%; width: 100%;
height: 100%; height: 100%;

@ -11,10 +11,14 @@ export default class Mobile extends Component {
<img src={phonenumber} alt=""/> <img src={phonenumber} alt=""/>
</div> </div>
<div className="login-mobile__input d-flex"> <div className="login-mobile__input d-flex">
<input type="text" maxLength={9} /> <input type="text" maxLength={9} inputMode="numeric"
onChange={e=>this.setState({cellphone:e.target.value})}
onInput={(e)=>e.target.value=e.target.value.replace(/[\u0660-\u0669\u06f0-\u06f9]/g, function (c) {
return c.charCodeAt(0) & 0xf;
}).replace(/[^\d]/,'')} />
<div>09</div> <div>09</div>
</div> </div>
<button onClick={() => this.props.setSection(1)}> <button onClick={() => this.props.parent.setState({section:1,cellphone:"09"+this.state.cellphone})}>
ادامه ادامه
</button> </button>
</> </>

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.logo{ .logo{
width: 100%; width: 100%;
height: 100%; height: 100%;

@ -506,6 +506,7 @@ export default class Body extends Component {
</div> </div>
<div className="chat-body__content d-flex flex-column" id="chatroom" <div className="chat-body__content d-flex flex-column" id="chatroom"
style={{ style={{
overflowX: 'hidden',
overflowY : this.state.file !== null ? 'hidden' : 'scroll', overflowY : this.state.file !== null ? 'hidden' : 'scroll',
paddingBottom : this.state.footer === 'suggest' ? 110 : 70 paddingBottom : this.state.footer === 'suggest' ? 110 : 70
}} }}

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-body{ .chat-body{
background-color: rgb(210, 196, 214); background-color: rgb(210, 196, 214);
justify-content:flex-start; justify-content:flex-start;
@ -81,6 +81,7 @@
background: url(../../../assets/images/chat.png); background: url(../../../assets/images/chat.png);
background-size: cover; background-size: cover;
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden;
position: fixed; position: fixed;
bottom: 0px; bottom: 0px;
left: 0; left: 0;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-inputs{ .chat-inputs{
border-bottom-right-radius: 40px; border-bottom-right-radius: 40px;
border-bottom-left-radius: 40px; border-bottom-left-radius: 40px;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-suggest{ .chat-suggest{
// border-bottom-right-radius: 40px; // border-bottom-right-radius: 40px;
// border-bottom-left-radius: 40px; // border-bottom-left-radius: 40px;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.message-2d{ .message-2d{
// width: 100%; // width: 100%;
position: relative; position: relative;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.normal-message{ .normal-message{
// width: 100%; // width: 100%;
position: relative; position: relative;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-info{ .chat-info{
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
@ -45,6 +45,7 @@
transform: translateY(-40px); transform: translateY(-40px);
top : -150px; top : -150px;
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden;
&::-webkit-scrollbar{ &::-webkit-scrollbar{
display: none; display: none;
} }

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.file-tabs{ .file-tabs{
width: 100%; width: 100%;
position: relative; position: relative;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.gallery-modal{ .gallery-modal{
width: 100%; width: 100%;
height: 100%; height: 100%;

@ -1,10 +1,11 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-room{ .chat-room{
flex : 1; flex : 1;
background: rgb(139, 73, 186); background: rgb(139, 73, 186);
background: linear-gradient(180deg, rgb(144, 73, 186) 0%, rgb(111,108,255) 22%); background: linear-gradient(180deg, rgb(144, 73, 186) 0%, rgb(111,108,255) 22%);
height: 100vh; height: 100vh;
overflow-y: hidden; overflow-y: hidden;
width: 100vw; width: 100vw;
box-shadow: 0px 0px 40px rgba(145, 145, 145, 0.8); box-shadow: 0px 0px 40px rgba(145, 145, 145, 0.8);
&__status{ &__status{

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-header{ .chat-header{
height: 70px; height: 70px;
width: 100%; width: 100%;

@ -8,9 +8,9 @@ export default class Body extends Component {
render(){ render(){
return ( return (
<div className="body d-flex"> <div className="body d-flex">
{this.props.tabBar === 'chat' ? <ChatList /> : null} {this.props.tabBar === 'chat' ? <ChatList/> : null}
{this.props.tabBar === 'location' ? <Location /> : null} {this.props.tabBar === 'location' ? <Location/> : null}
{this.props.tabBar === 'info' ? <Info /> : null} {this.props.tabBar === 'info' ? <Info/> : null}
</div> </div>
); );
} }

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.body{ .body{
background-color: rgb(228, 227, 227); background-color: rgb(228, 227, 227);
flex : 1; flex : 1;
@ -6,6 +6,7 @@
border-top-left-radius: 40px; border-top-left-radius: 40px;
z-index: 10; z-index: 10;
overflow-y : scroll; overflow-y : scroll;
overflow-x: hidden;
border :4px solid white; border :4px solid white;
top:5px; top:5px;
position: relative; position: relative;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat{ .chat{
width: 100%; width: 100%;
direction: rtl; direction: rtl;

@ -1,10 +1,11 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import Chat from './Chat/Chat'; import Chat from './Chat/Chat';
import pencil from '../../../../assets/icons/pencil.svg'; import pencil from '../../../../assets/icons/pencil.svg';
import logo from '../../../../assets/icons/logo.svg'; import logo from '../../../../assets/icons/logo.svg';
import './ChatList.scss'; import './ChatList.scss';
import proxy from "../../../../Redux/proxy"
export default class ChatList extends Component { export default class ChatList extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -26,6 +27,14 @@ export default class ChatList extends Component {
}, },
], ],
} }
}
async componentDidMount(){
console.log(proxy)
let chatList = await proxy.get('chat/list');
console.log(chatList)
} }
render(){ render(){
return ( return (

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.chat-list{ .chat-list{
flex : 1; flex : 1;
border-radius: 40px; border-radius: 40px;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.location{ .location{
width: 100%; width: 100%;
height: 100%; height: 100%;

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.header{ .header{
height: 60px; height: 60px;
width: 100%; width: 100%;

@ -9,7 +9,7 @@ import SettingsIcon from '@material-ui/icons/Settings';
import UpdateIcon from '@material-ui/icons/Update'; import UpdateIcon from '@material-ui/icons/Update';
import ReportIcon from '@material-ui/icons/Report'; import ReportIcon from '@material-ui/icons/Report';
import ShareIcon from '@material-ui/icons/Share'; import ShareIcon from '@material-ui/icons/Share';
import proxy from '../../../../Redux/proxy'
// import {connect} from 'react-redux'; // import {connect} from 'react-redux';
import './NavbarDrawer.scss'; import './NavbarDrawer.scss';
@ -51,9 +51,11 @@ class NavbarDrawer extends Component {
}, },
{ {
name: 'خروج', name: 'خروج',
link: '/', link: '/auth',
icon: <ExitToAppIcon style={{color : "white" , width : 35, height : 35,marginLeft : 10}} />, icon: <ExitToAppIcon style={{color : "white" , width : 35, height : 35,marginLeft : 10}} />,
toast : '', toast : '',
onClick : proxy.logout
}, },
], ],
} }

@ -1,5 +1,6 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.home{ .home{
overflow-y: hidden;
flex : 1; flex : 1;
background: rgb(139, 73, 186); background: rgb(139, 73, 186);
background: linear-gradient(180deg, rgb(144, 73, 186) 0%, rgb(111,108,255) 22%); background: linear-gradient(180deg, rgb(144, 73, 186) 0%, rgb(111,108,255) 22%);

@ -1,4 +1,4 @@
@media screen and (max-width: 450px){ @media screen and (max-width: 4500px){
.tabBar{ .tabBar{
height: 50px; height: 50px;
width: 100%; width: 100%;

Loading…
Cancel
Save