building out admin portal

This commit is contained in:
Mikayla Dobson
2022-09-21 16:59:05 -05:00
parent fbaca9b97d
commit 905b3266a3
5 changed files with 42 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ import ProductPage from './components/Products/ProductPage';
import Cart from './components/Cart/Cart';
import './App.scss'
import AdminHome from './components/AdminPortal/AdminHome';
function App() {
const [state, dispatch] = useReducer(reducer, initialState);
@@ -29,6 +30,8 @@ function App() {
<Route path="/products/" element={<Products />} />
<Route path="/cart/" element={<Cart />} />
<Route path="/products/:productID" element={<ProductPage />} />
<Route path="/admin" element={<AdminHome />} />
</Routes>
</AppContext.Provider>
</BrowserRouter>

View File

@@ -0,0 +1,33 @@
import { useContext } from "react";
import { AppContext } from "../../store/store";
import Page from "../../util/Page";
export default function AdminHome() {
const [state, dispatch] = useContext(AppContext);
// to do: provide protected access based on a list of approved admin users
if (state.user.name) return (
<Page>
<h1>Admin Management Portal</h1>
<h2>Welcome, {state.user.name || ''}</h2>
<section>
<h3>This is where administrative tasks will be supported for the store.</h3>
<p>Choose from the options below:</p>
<div className="admin-options">
<button>Access product listings and inventory</button>
<button>Manage registered users</button>
<button>Database options</button>
</div>
</section>
</Page>
)
return (
<Page>
<h1>Administrative access required to view this page.</h1>
<p>Please click <a href="/">here</a> to return home.</p>
</Page>
)
}

View File

@@ -1,10 +1,5 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.scss'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>
)
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);

View File

@@ -37,7 +37,8 @@ require('dotenv').config({ path: "../.env" });
CREATE TABLE IF NOT EXISTS category (
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY NOT NULL,
name VARCHAR NOT NULL,
description VARCHAR NOT NULL
description VARCHAR NOT NULL,
is_product_subset BOOLEAN NOT NULL
);
`;
@@ -63,6 +64,8 @@ require('dotenv').config({ path: "../.env" });
let status;
try {
await client.query("DROP SCHEMA public CASCADE; CREATE SCHEMA public;");
for (let q of allQueries) {
await client.query(q);
}

View File

@@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js",
"seed": "cd db && node Seed.js"
"seed": "cd db && node seed.js"
},
"engines": {
"node": "v16.13.1"