creates pages and routes; firebase utils

This commit is contained in:
Ruidy Nemausat 2020-04-23 19:16:53 +02:00
parent 79ccc875a6
commit 47fa15e229
14 changed files with 179 additions and 0 deletions

View file

@ -0,0 +1,26 @@
import React from "react";
import { Route, Switch } from "react-router-dom";
import * as ROUTES from "../../constants/routes";
import {
LandingPage,
SignUpPage,
SignInPage,
PasswordForgetPage,
AppPage,
AccountPage,
AdminPage,
} from "../../pages/index";
export default function MainRouter() {
return (
<Switch>
<Route exact path={ROUTES.LANDING} component={LandingPage} />
<Route path={ROUTES.SIGN_UP} component={SignUpPage} />
<Route path={ROUTES.SIGN_IN} component={SignInPage} />
<Route path={ROUTES.PASSWORD_FORGET} component={PasswordForgetPage} />
<Route path={ROUTES.APP} component={AppPage} />
<Route path={ROUTES.ACCOUNT} component={AccountPage} />
<Route path={ROUTES.ADMIN} component={AdminPage} />
</Switch>
);
}

View file

@ -0,0 +1,7 @@
export const LANDING = "/";
export const SIGN_UP = "/signup";
export const SIGN_IN = "/signin";
export const APP = "/app";
export const ACCOUNT = "/account";
export const ADMIN = "/admin";
export const PASSWORD_FORGET = "/pw-forget";

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function AccountPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function AdminPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function AppPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function LandingPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function PasswordForgetPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function SignInPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

View file

@ -0,0 +1,13 @@
import React from "react";
import { Container } from "reactstrap";
import ItemModal from "../ItemModal";
import List from "../List";
export default function SignUpPage() {
return (
<Container>
<ItemModal />
<List />
</Container>
);
}

16
client/src/pages/index.js Normal file
View file

@ -0,0 +1,16 @@
import AppPage from "./App";
import LandingPage from "./Landing"
import SignUpPage from "./SignUp"
import SignInPage from "./SignIn"
import PasswordForgetPage from "./PasswordForget"
import AccountPage from "./Account"
import AdminPage from "./Admin"
export const AppPage
export const LandingPage
export const SignUpPage
export const SignInPage
export const PasswordForgetPage
export const AccountPage
export const AdminPage

View file

@ -0,0 +1,7 @@
import { createContext, useContext } from "react";
// create a Firebase context to make state available anywhere in the App.
const FirebaseContext = createContext(null);
export const useFirebase = () => useContext(FirebaseContext);
export default FirebaseContext;

View file

@ -0,0 +1,24 @@
import app from "firebase/app";
// import "firebase/firestore";
import "firebase/auth";
import config from "./config.json";
const CONFIG = {
apiKey: config.apiKey,
authDomain: config.authDomain,
databaseURL: config.databaseURL,
projectId: config.projectId,
storageBucket: config.storageBucket,
messagingSenderId: config.messagingSenderId,
appId: config.appId,
measurementId: config.measurementId,
};
// Firebase initializes the Application and provides method to interact with
// Firebase services as auth and firestore.
export default class Firebase {
constructor() {
app.initializeApp(CONFIG);
this.auth = app.auth();
}
}

View file

@ -0,0 +1,6 @@
// This file centralize all Firebase related exports
import Firebase from "./firebase";
import FirebaseContext, { useFirebase } from "./context";
export default Firebase;
export { FirebaseContext, useFirebase };

2
constants/routes.js Normal file
View file

@ -0,0 +1,2 @@
export const ITEMS = "/api/items/";
export const USERS = "/api/users/";