goodu
This commit is contained in:
parent
436d915f9f
commit
6ed0bda5f6
22
src/App.js
22
src/App.js
@ -1,8 +1,11 @@
|
||||
import React, { Component } from 'react'
|
||||
import axios from 'axios';
|
||||
import { BrowserRouter, Route, Switch } from 'react-router-dom'
|
||||
import { useState, useEffect } from 'react';
|
||||
import './scss/style.scss'
|
||||
import ForgotPassword from './views/pages/register/ForgotPassword'
|
||||
import NewRegister from './views/pages/register/NewRegister'
|
||||
import ProtectedRoute from './components/ProtectedRoute';
|
||||
|
||||
const loading = (
|
||||
<div className="pt-3 text-center">
|
||||
@ -26,22 +29,21 @@ class App extends Component {
|
||||
<React.Suspense fallback={loading}>
|
||||
<Switch>
|
||||
< Route exact path="/" name="Login Page" render={(props) => <Login {...props} />} />
|
||||
|
||||
<Route exact path="/forgot" name="Forgot Page" render={(props) => <ForgotPassword {...props} />} />
|
||||
<Route exact path="/newRegister" name="Register Page" render={(props) => <NewRegister {...props} />} />
|
||||
|
||||
|
||||
|
||||
|
||||
{/* <Route exact path="/comproducts/edit/:_id" name="commerce-product-edit" render={(props) => <EditProducts {...props} />} /> */}
|
||||
{/* <Route
|
||||
exact
|
||||
path="/register"
|
||||
name="Register Page"
|
||||
render={(props) => <Register {...props} />}
|
||||
/> */}
|
||||
<Route exact path="/404" name="Page 404" render={(props) => <Page404 {...props} />} />
|
||||
<Route exact path="/500" name="Page 500" render={(props) => <Page500 {...props} />} />
|
||||
|
||||
|
||||
{/* localStorage.getItem('authToken') ? */}
|
||||
<Route path="/" name="Home" render={(props) => <DefaultLayout {...props} />} />
|
||||
{/* < ProtectedRoute path="/" name="Home" render={(props) => <DefaultLayout {...props} />} /> */}
|
||||
|
||||
|
||||
|
||||
|
||||
</Switch>
|
||||
</React.Suspense>
|
||||
</BrowserRouter>
|
||||
|
18
src/components/ProtectedRoute.js
Normal file
18
src/components/ProtectedRoute.js
Normal file
@ -0,0 +1,18 @@
|
||||
import React, { useEffect, useState, } from "react";
|
||||
import { useHistory } from "react-router-dom";
|
||||
const ProtectedRoute = (props) => {
|
||||
let Cmp = props;
|
||||
const history = useHistory();
|
||||
useEffect(() => {
|
||||
if (!localStorage.getItem('authToken'))
|
||||
history.push('/')
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
<Cmp />
|
||||
{/* {...props} */}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProtectedRoute
|
@ -102,7 +102,7 @@ const EditBisuness = () => {
|
||||
let res = await axios.put(
|
||||
`/api/directory/update/${id}`,
|
||||
{
|
||||
state,
|
||||
...state,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
|
@ -31,8 +31,8 @@ const Login = () => {
|
||||
};
|
||||
|
||||
const Login = async () => {
|
||||
const res = await axios.post("/owner/signin", auth);
|
||||
if (res.data.status == "ok") {
|
||||
const res = await axios.post("/api/user/login/", auth);
|
||||
if (res.data.success == true) {
|
||||
localStorage.setItem("authToken", res.data.token)
|
||||
console.log(res.data)
|
||||
localStorage.setItem("auth", JSON.stringify({
|
||||
@ -61,7 +61,7 @@ const Login = () => {
|
||||
<CCardBody>
|
||||
<CForm>
|
||||
<h1>Login</h1>
|
||||
<p className="text-medium-emphasis">Sign In to your account</p>
|
||||
<p className="text-medium-emphasis">Sign In to Your CMP Dashboard Account.</p>
|
||||
<CInputGroup className="mb-3">
|
||||
<CInputGroupText>
|
||||
<CIcon icon={cilUser} />
|
||||
@ -93,20 +93,20 @@ const Login = () => {
|
||||
</Link>
|
||||
<br />
|
||||
|
||||
<CButton color="link" className="px-0">
|
||||
{/* <CButton color="link" className="px-0">
|
||||
<Link to="/forgot">
|
||||
Forgot password?
|
||||
</Link>
|
||||
</CButton>
|
||||
</CButton> */}
|
||||
|
||||
|
||||
</CForm>
|
||||
</CCardBody>
|
||||
<CButton color="" className="px-0">
|
||||
{/* <CButton color="" className="px-0">
|
||||
<Link to="/newRegister">
|
||||
dont have an account? Sign Up
|
||||
</Link>
|
||||
</CButton>
|
||||
</CButton> */}
|
||||
</CCard>
|
||||
|
||||
</CCardGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user