Skip to content
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
19 changes: 19 additions & 0 deletions app/hooks/useSession.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useState, useEffect } from "react";
import { v4 as uuidv4 } from "uuid";

export const useSession = () => {
const [sessionId, setSessionId] = useState<string | null>(null);

useEffect(() => {
let currentId = sessionStorage.getItem("session_id");

if (!currentId) {
currentId = uuidv4();
sessionStorage.setItem("session_id", currentId);
}

setSessionId(currentId);
}, []);

return sessionId;
};
55 changes: 28 additions & 27 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
import type { Metadata } from 'next';
import localFont from 'next/font/local';
import Image from 'next/image';
import NavBar from '@/components/NavBar';
import type { Metadata } from "next";
import localFont from "next/font/local";
import Image from "next/image";
import NavBar from "@/components/NavBar";
import { AnalyticsProvider } from "@/components/AnalyticsProvider";

import './globals.css';
import "./globals.css";

const geistSans = localFont({
src: './fonts/GeistVF.woff',
variable: '--font-geist-sans',
weight: '100 900',
src: "./fonts/GeistVF.woff",
variable: "--font-geist-sans",
weight: "100 900",
});
const geistMono = localFont({
src: './fonts/GeistMonoVF.woff',
variable: '--font-geist-mono',
weight: '100 900',
src: "./fonts/GeistMonoVF.woff",
variable: "--font-geist-mono",
weight: "100 900",
});

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<NavBar />
{children}
</body>
</html>
);
children,
}: Readonly<{ children: React.ReactNode }>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<AnalyticsProvider>
<NavBar />
{children}
</AnalyticsProvider>
</body>
</html>
);
}
20 changes: 10 additions & 10 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ export default function HomePage() {
<Title />
<section className="flex w-full border-t border-b border-black">
<div className="w-1/2">
<Feature
text="Overview of Consumer Features:"
image="/consumer.png"
link="/consumer"
/>
<Feature
text="Overview of Consumer Features:"
image="/consumer.png"
link="/consumer"
/>
</div>
<div className="w-1/2 border-l border-black">
<Feature
text="Overview of Vendor Offerings:"
image="/vendor.png"
link="/vendor"
/>
<Feature
text="Overview of Vendor Offerings:"
image="/vendor.png"
link="/vendor"
/>
</div>
</section>
<PreviewSection />
Expand Down
22 changes: 22 additions & 0 deletions components/AnalyticsProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";

import React, { createContext, useContext } from "react";
import { useSession } from "@/app/hooks/useSession";

const AnalyticsContext = createContext<string | null>(null);

export const AnalyticsProvider = ({
children,
}: {
children: React.ReactNode;
}) => {
const sessionId = useSession();

return (
<AnalyticsContext.Provider value={sessionId}>
{children}
</AnalyticsContext.Provider>
);
};

export const useAnalytics = () => useContext(AnalyticsContext);
22 changes: 22 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
"react-dom": "19.0.0",
"tailwind-merge": "^2.5.5",
"tailwind-scrollbar-hide": "^4.0.0",
"uuid": "^13.0.0",
"zod": "^4.1.12"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"eslint": "^8",
Expand Down