Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single page #86

Open
wants to merge 11 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_CLERK_PUBLISHABLE_KEY=pk_test_ZW5kbGVzcy1kb2dmaXNoLTE4LmNsZXJrLmFjY291bnRzLmRldiQ
2 changes: 2 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
.env


node_modules
dist
Expand Down
104 changes: 103 additions & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
"format": "prettier --write \"src/**/*.{ts,tsx}\""
},
"dependencies": {
"axios": "^1.5.1",
"@clerk/clerk-react": "^4.26.1",
"@types/uuid": "^9.0.4",
"axios": "^1.5.1",
"dotenv": "^16.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.16.0",
"vite-plugin-svgr": "^3.2.0",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"vite-plugin-svgr": "^3.2.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
Expand Down
76 changes: 63 additions & 13 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,77 @@
import HomePage from "./pages/home/HomePage";

import { BrowserRouter, Route, Routes } from "react-router-dom";
import { BrowserRouter, Route, Routes, useNavigate } from "react-router-dom";
import Layout from "./components/Layout";
import HallOfFame from "./pages/hallOfFame/HallOfFame";
import ErrorPage from "./pages/error/Error";
import FlavorPage from "./pages/flavor_page/FlavorPage";
import HomePage from "./pages/home/HomePage";
import useSetLocalStorage from "./hooks/UseLocalStorage";
import { LocalStorageContext } from "./context/DataContext";

//todo: replace temp with homepage
export default function App() {
const [storage, setStorage] = useSetLocalStorage(null, "Test");

import {
ClerkProvider,
SignedIn,
SignedOut,
RedirectToSignIn,
SignIn,
SignUp,
} from "@clerk/clerk-react";

if (!import.meta.env.VITE_CLERK_PUBLISHABLE_KEY) {
throw new Error("Missing Publishable Key");
}
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;

function ClerkProviderWithRoutes() {
const navigate = useNavigate();
return (
<LocalStorageContext.Provider value={storage}>
<BrowserRouter>
<ClerkProvider publishableKey={clerkPubKey} navigate={(to) => navigate(to)}>
<Layout>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="hall-of-fame" element={<HallOfFame/>}/>
<Route
path="/"
element={
<>
<HomePage />
</>
}
/>
<Route
path="/sign-in/*"
element={<SignIn routing="path" path="/sign-in" />}
/>
<Route
path="/sign-up/*"
element={<SignUp routing="path" path="/sign-up" />}
/>
<Route path="/hall-of-fame" element={<HallOfFame />} />
<Route path="flavor/:flavor" element={<FlavorPage />} />
<Route
path="/create"
element={
<>
<SignedIn>
<div>Create a Flavor Page </div>
</SignedIn>
<SignedOut>
<RedirectToSignIn />
</SignedOut>
</>
}
/>
<Route path="*" element={<ErrorPage />} />
</Routes>
</Layout>
</BrowserRouter>
</ClerkProvider>
);
}
export default function App() {
const [storage, setStorage] = useSetLocalStorage(null, "Test");

return (
<LocalStorageContext.Provider value={storage}>
<BrowserRouter>
<ClerkProviderWithRoutes />
</BrowserRouter>
</LocalStorageContext.Provider>
)
);
}
23 changes: 16 additions & 7 deletions client/src/Components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ import { Link } from "react-router-dom";
import IceCreamLogo from "./IceCreamLogo";
import CartPage from "../pages/cart/CartPage";
import styles from "./header.module.css";

import LogIn from "./LogIn";

export default function IceCreamHeader() {
const [currentPagePath, setCurrentPagePath] = useState<string>("/");

function handleSetStarPage(path: string) {
setCurrentPagePath(path)
setCurrentPagePath(path);
}

return (
<header className={styles["header-container"]}>
<Link to="/" onClick={() => handleSetStarPage("/")}><IceCreamLogo />Randomice</Link>
<Link to="/" onClick={() => handleSetStarPage("/")}>
<IceCreamLogo />
Randomice
</Link>
<nav>
<ul className={styles["nav-container"]}>
<NavOption
Expand All @@ -32,7 +35,8 @@ export default function IceCreamHeader() {
</ul>
</nav>
<div className={styles["header-end"]}>
<button className={styles["login-button"]}>login/logout</button>
<LogIn />
<></>
<CartPage />
</div>
</header>
Expand All @@ -49,8 +53,13 @@ interface NavOptionProps {
function NavOption(props: NavOptionProps) {
return (
<li className={styles["nav-item"]}>
<Link to={props.destinationUrl} onClick={() => props.setCurrentPagePath(props.destinationUrl)}>{props.currentPagePath === props.destinationUrl ? "*" : ""}
{props.destinationPage}</Link>
<Link
to={props.destinationUrl}
onClick={() => props.setCurrentPagePath(props.destinationUrl)}
>
{props.currentPagePath === props.destinationUrl ? "*" : ""}
{props.destinationPage}
</Link>
</li>
);
}
Empty file added client/src/Components/LogIn.css
Empty file.
Loading