From 2942f76f7c9a342e55ef7c79e917acc64618bd87 Mon Sep 17 00:00:00 2001 From: mai Date: Fri, 2 Oct 2026 14:11:27 -0400 Subject: [PATCH 1/2] convert app entry --- index.html | 2 +- src/App.jsx | 60 ----------------------------- src/App.tsx | 73 ++++++++++++++++++++++++++++++++++++ src/{index.jsx => index.tsx} | 10 ++++- 4 files changed, 83 insertions(+), 62 deletions(-) delete mode 100644 src/App.jsx create mode 100644 src/App.tsx rename src/{index.jsx => index.tsx} (51%) diff --git a/index.html b/index.html index befe7ae9..60bc2856 100644 --- a/index.html +++ b/index.html @@ -23,6 +23,6 @@
- + diff --git a/src/App.jsx b/src/App.jsx deleted file mode 100644 index 98bf3543..00000000 --- a/src/App.jsx +++ /dev/null @@ -1,60 +0,0 @@ -import React, { useState, useEffect } from 'react' -import { BrowserRouter as Router, Navigate, useRoutes } from 'react-router-dom' -import ExternalRedirect from './component/ExternalRedirect' -import ApplyPageV2 from './pages/ApplyPageV2' -import Position from './component/ApplyPage/Position' -import ScrollToTop from './component/ScrollToTop' -import LandingPageV3 from './pages/LandingPageV3' -import CulturePage from './component/CulturePage' -import TeamsPage from './pages/TeamsPage' -import ExpandedTeamsPage from './pages/TeamsPage/ExpandedTeams' -import ProjectsPage from './component/ProjectsPage' -import { useSanity } from './services/useSanity' - -function AppRoutes({ sanityRoutes }) { - const routes = [ - { path: '/', element: }, - { - path: '/apply', - element: , - children: [{ path: ':team', element: }] - }, - { path: '/positions/:id', element: }, - { path: '/positions/:categoryType/:index', element: }, - { path: '/about', element: }, - { path: '/culture', element: }, - { path: '/teams', element: }, - { path: '/projects', element: }, - { path: '/teams-expanded/*', element: }, - ...sanityRoutes, - { path: '*', element: } - ] - - const allRoutes = useRoutes(routes) - return allRoutes -} - -export default function App() { - const query = `*[_type == "generateLink"]` - const links = useSanity(query) - const [sanityRoutes, setSanityRoutes] = useState([]) - - useEffect(() => { - if (links.length > 0) { - const newRoutes = links.map((link) => ({ - path: `/${link.slug.current}`, - element: - })) - setSanityRoutes(newRoutes) - } - }, [links]) - - return ( -
- - - - -
- ) -} diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 00000000..65edc4fe --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,73 @@ +import React, { useState, useEffect } from 'react'; +import { BrowserRouter as Router, Navigate, useRoutes } from 'react-router-dom'; +import type { RouteObject } from 'react-router-dom'; + +import Position from './component/ApplyPage/Position'; +import CulturePage from './component/CulturePage'; +import ExternalRedirect from './component/ExternalRedirect'; +import ProjectsPage from './component/ProjectsPage'; +import ScrollToTop from './component/ScrollToTop'; +import ApplyPageV2 from './pages/ApplyPageV2'; +import LandingPageV3 from './pages/LandingPageV3'; +import TeamsPage from './pages/TeamsPage'; +import ExpandedTeamsPage from './pages/TeamsPage/ExpandedTeams'; +import { useSanity } from './services/useSanity'; + +type GenerateLink = { + slug: { current: string }; + url: string; +}; + +type AppRoutesProps = { + sanityRoutes: RouteObject[]; +}; + +function AppRoutes({ sanityRoutes }: AppRoutesProps) { + const routes: RouteObject[] = [ + { path: '/', element: }, + { + path: '/apply', + element: , + children: [{ path: ':team', element: }], + }, + { path: '/positions/:id', element: }, + { path: '/positions/:categoryType/:index', element: }, + { path: '/about', element: }, + { path: '/culture', element: }, + { path: '/teams', element: }, + { path: '/projects', element: }, + { path: '/teams-expanded/*', element: }, + ...sanityRoutes, + { path: '*', element: }, + ]; + + const allRoutes = useRoutes(routes); + + return allRoutes; +} + +export default function App() { + const query = `*[_type == "generateLink"]`; + const links = useSanity(query); + const [sanityRoutes, setSanityRoutes] = useState([]); + + useEffect(() => { + if (links.length > 0) { + const newRoutes = links.map(link => ({ + path: `/${link.slug.current}`, + element: , + })); + + setSanityRoutes(newRoutes); + } + }, [links]); + + return ( +
+ + + + +
+ ); +} diff --git a/src/index.jsx b/src/index.tsx similarity index 51% rename from src/index.jsx rename to src/index.tsx index fb80a815..13e1e919 100644 --- a/src/index.jsx +++ b/src/index.tsx @@ -1,9 +1,17 @@ // After (React 18) import React from 'react'; import ReactDOM from 'react-dom/client'; + import App from './App'; -const root = ReactDOM.createRoot(document.getElementById('root')); +const rootElement = document.getElementById('root'); + +if (!rootElement) { + throw new Error('Root element #root not found'); +} + +const root = ReactDOM.createRoot(rootElement); + root.render( From e51413c2849cdf7b67564bff83b12d1a227a8f66 Mon Sep 17 00:00:00 2001 From: mai Date: Fri, 2 Oct 2026 14:12:28 -0400 Subject: [PATCH 2/2] small fix --- src/App.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 65edc4fe..c77c7e1e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React from 'react'; import { BrowserRouter as Router, Navigate, useRoutes } from 'react-router-dom'; import type { RouteObject } from 'react-router-dom'; @@ -49,18 +49,11 @@ function AppRoutes({ sanityRoutes }: AppRoutesProps) { export default function App() { const query = `*[_type == "generateLink"]`; const links = useSanity(query); - const [sanityRoutes, setSanityRoutes] = useState([]); - useEffect(() => { - if (links.length > 0) { - const newRoutes = links.map(link => ({ - path: `/${link.slug.current}`, - element: , - })); - - setSanityRoutes(newRoutes); - } - }, [links]); + const sanityRoutes: RouteObject[] = links.map(link => ({ + path: `/${link.slug.current}`, + element: , + })); return (