Skip to content
Snippets Groups Projects
Select Git revision
  • 0ef7a55aa08160e9dfa29ee34cded74742f46d7b
  • master default protected
  • react
3 results

configured.route.js

Blame
  • Larbi Gharib's avatar
    Larbi Gharib authored
    Change-Id: I1520a420c7b34a33c7c9829b8702bdfd57c347bf
    0ef7a55a
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    configured.route.js 1.35 KiB
    
    import React from 'react'
    import { Route, Redirect } from 'react-router-dom'
    import auth from './auth'
    import SignUp from "layouts/SignUp";
    import SignIn from "layouts/SignIn";
    import Admin from 'layouts/Admin';
    
    export const ConfiguredRoute = ({ component: Component, ...rest }) => {
        return (
            <Route {...rest} render={
                
                (props) => {
                    if (auth.hasAdmin()) {
                        if(auth.isInstalled()){
                            return <Component {...props} />
                        }else if(!auth.isInstalled() && auth.isAuthenticated()){
                            if(auth.uri == '/api/install/ca' || auth.uri == 'start'){
                                return <SignUp step={1}/>
                            }
                            else if (auth.uri == '/api/install/auth'){
                                return <SignUp step={2}/>
                            } else if (auth.uri == '/api/install/settings'){
                                return <SignUp step={3}/>
                            } else {
                                console.log('Error no matching path for configuration')
                            }
                            
                        }else {
                            return <SignIn />
                        }
                    } else {
                        return <SignUp step={0}/>
                    }
    
                }
            } />
        )
    }