diff --git a/src/App.jsx b/src/App.jsx index 1b51d87..d725c56 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,9 +1,26 @@ -import "./App.css"; +import { useState } from 'react'; +import './App.css'; +import { Routes, Route } from 'react-router-dom'; +import companiesData from './companies.json'; +import technologiesData from './technologies.json'; +import Navbar from './components/Navbar'; +import HomePage from './pages/HomePage'; +import CompanyPage from './pages/CompanyPage'; +import TechnologyPage from './pages/TechnologyPage'; function App() { + const [companies] = useState(companiesData); + const [technologies] = useState(technologiesData); + return (
-

LAB | React Stack Tracker

+ + + + } /> + } /> + } /> +
); } diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 09e2806..568b3f0 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -1,5 +1,13 @@ +import { Link } from 'react-router-dom'; + function Navbar() { - return ; + return ( + + ); } export default Navbar; diff --git a/src/main.jsx b/src/main.jsx index 54b39dd..27067bf 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -1,10 +1,13 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App.jsx' -import './index.css' +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import App from './App.jsx'; +import './index.css'; +import { BrowserRouter as Router } from 'react-router-dom'; ReactDOM.createRoot(document.getElementById('root')).render( - + + + , ) diff --git a/src/pages/CompanyPage.jsx b/src/pages/CompanyPage.jsx index cc5903c..f234a22 100644 --- a/src/pages/CompanyPage.jsx +++ b/src/pages/CompanyPage.jsx @@ -1,7 +1,44 @@ -function CompanyPage() { +import { useParams, Link } from 'react-router-dom'; + +function CompanyPage({ companies }) { + const { companySlug } = useParams(); + + const company = companies && companies.find((c) => c.slug === companySlug); + + if (!company) { + return ( +
+

Company Profile

+

Company not found.

+ Back to Home +
+ ); + } + return ( -
-

CompanyPage

+
+

Company Profile

+ +
+ {company.companyName} +

{company.companyName}

+

Website: {company.website}

+ {company.description &&

{company.description}

} + +

Tech Stack

+
+ {company.techStack && company.techStack.map((tech) => ( + +
+ {tech.name} + {tech.name} +
+ + ))} +
+ + +
); } diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx index e97e7de..a2d9781 100644 --- a/src/pages/HomePage.jsx +++ b/src/pages/HomePage.jsx @@ -1,7 +1,20 @@ -function HomePage() { +import { Link } from 'react-router-dom'; + +function HomePage({ companies }) { return ( -
-

HomePage

+
+

StackTracker: Discover Tech Stacks Used by Top Companies

+ +
+ {companies && companies.map((company) => ( + +
+ {company.companyName} + {company.companyName} +
+ + ))} +
); } diff --git a/src/pages/TechnologyPage.jsx b/src/pages/TechnologyPage.jsx index 30f9414..a67dd2c 100644 --- a/src/pages/TechnologyPage.jsx +++ b/src/pages/TechnologyPage.jsx @@ -1,7 +1,41 @@ -function TechnologyPage() { +import { useParams, useSearchParams, Link } from 'react-router-dom'; + +function TechnologyPage({ technologies }) { + const { slug } = useParams(); + const [searchParams] = useSearchParams(); + const companySlug = searchParams.get('company'); + + const technology = technologies && technologies.find((t) => t.slug === slug); + + if (!technology) { + return ( +
+

Technology Details

+

Technology not found.

+ Back to Home +
+ ); + } + return ( -
-

TechnologyPage

+
+

Technology Details

+ +
+ {technology.name} +

{technology.name}

+

{technology.description}

+ + {companySlug ? ( + + + + ) : ( + + + + )} +
); }