mirror of
https://github.com/rjNemo/MERN_sample_app
synced 2026-06-06 00:36:39 +00:00
creates pages and routes; firebase utils
This commit is contained in:
parent
79ccc875a6
commit
47fa15e229
14 changed files with 179 additions and 0 deletions
26
client/src/components/Router/index.jsx
Normal file
26
client/src/components/Router/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
7
client/src/constants/routes.js
Normal file
7
client/src/constants/routes.js
Normal 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";
|
||||
13
client/src/pages/Account/index.jsx
Normal file
13
client/src/pages/Account/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
13
client/src/pages/Admin/index.jsx
Normal file
13
client/src/pages/Admin/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
13
client/src/pages/App/index.jsx
Normal file
13
client/src/pages/App/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
13
client/src/pages/Landing/index.jsx
Normal file
13
client/src/pages/Landing/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
13
client/src/pages/PasswordForget/index.jsx
Normal file
13
client/src/pages/PasswordForget/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
13
client/src/pages/SignIn/index.jsx
Normal file
13
client/src/pages/SignIn/index.jsx
Normal 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>
|
||||
);
|
||||
}
|
||||
13
client/src/pages/SignUp/index.jsx
Normal file
13
client/src/pages/SignUp/index.jsx
Normal 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
16
client/src/pages/index.js
Normal 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
|
||||
7
client/src/services/auth/context.js
Normal file
7
client/src/services/auth/context.js
Normal 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;
|
||||
24
client/src/services/auth/firebase.js
Normal file
24
client/src/services/auth/firebase.js
Normal 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();
|
||||
}
|
||||
}
|
||||
6
client/src/services/auth/index.js
Normal file
6
client/src/services/auth/index.js
Normal 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
2
constants/routes.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export const ITEMS = "/api/items/";
|
||||
export const USERS = "/api/users/";
|
||||
Loading…
Reference in a new issue