-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from pages router to app router (#17)
* Add TypeScript improvements * Migrated to app router * Add SEO * Lint and format * Add analytics * Add static prefetching * Reenable iterable fields comparison * Add og image for school * Force sitemap dynamic render * Fix map page layout * Add special pages * Add Sentry reporting in app dir
- Loading branch information
Showing
247 changed files
with
2,461 additions
and
2,170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+3.8 KB
...-env-npm-13.3.1-751ac0a3f6-3bf01e62b7.zip → ...-env-npm-13.4.3-c237e6ca8f-e45f7b7a46.zip
Binary file not shown.
Binary file renamed
BIN
+35.7 MB
...linux-x64-gnu-npm-13.3.1-3ddb7d1c27-8.zip → ...linux-x64-gnu-npm-13.4.3-63fb2c9601-8.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+47 KB
.yarn/cache/@rollup-plugin-commonjs-npm-24.0.0-b18d79acac-e2a1bf295b.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+33.5 KB
...-cli-npm-1.75.0-398a323f0b-d5b130bb45.zip → ...-cli-npm-1.75.2-bc4184e111-a0f29b2766.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.07 MB
.yarn/cache/@sentry-integrations-npm-6.19.7-26e727adb3-6ea22ef8d5.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+251 KB
.yarn/cache/@sentry-internal-tracing-npm-7.52.1-d662abf118-6693f95ced.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-17.5 KB
.yarn/cache/@sentry-webpack-plugin-npm-1.18.8-65d12364bc-e159ee1e4b.zip
Binary file not shown.
Binary file added
BIN
+18 KB
.yarn/cache/@sentry-webpack-plugin-npm-1.20.0-9eeec4f0d8-d582026c36.zip
Binary file not shown.
Binary file added
BIN
+571 KB
.yarn/cache/@shuding-opentype.js-npm-1.4.0-beta.0-498d62cde8-af3478c40c.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.24 KB
.yarn/cache/css-background-parser-npm-0.1.0-d1e94221f7-cf53bef8d5.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+12.4 MB
...next-npm-13.3.1-f9884a3d2e-a685abbcfe.zip → ...next-npm-13.4.3-db62749baa-65f13be060.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+3.61 KB
.yarn/cache/string.prototype.codepointat-npm-0.2.1-82003deaf5-bafa15844d.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { fetchJson } from '../serverFetch'; | ||
import { IInstitutionDetails } from '../../app/[projectID]/school/[rspo]/(sections)/types'; | ||
|
||
export const fetchInstitutionDetails = async (rspo: string) => { | ||
return fetchJson<IInstitutionDetails>(`/school/${rspo}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { fetchJson } from '../serverFetch'; | ||
import type { ProjectConfig } from './types'; | ||
|
||
export const fetchProjectConfig = async (projectID: string) => { | ||
return fetchJson<ProjectConfig>(`/project/${projectID}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client'; | ||
|
||
import { createContext, FC, useContext } from 'react'; | ||
import { ProjectConfig } from './types'; | ||
|
||
export const projectConfigContext = createContext<ProjectConfig>({}); | ||
|
||
export const useProjectConfig = () => useContext(projectConfigContext); | ||
|
||
interface ProjectConfigProviderProps { | ||
projectConfig: ProjectConfig; | ||
} | ||
const ProjectConfigProvider: FC<ProjectConfigProviderProps> = ({ projectConfig, children }) => ( | ||
<projectConfigContext.Provider value={projectConfig}>{children}</projectConfigContext.Provider> | ||
); | ||
|
||
export default ProjectConfigProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
import { publicRuntimeConfig } from '../runtimeConfig'; | ||
import { QueryClientConfig, QueryKey } from '@tanstack/react-query'; | ||
|
||
interface FetcherArgs { | ||
queryKey: QueryKey; | ||
} | ||
|
||
export const fetchData = (path: string) => fetch(`${publicRuntimeConfig.API_URL}${path}`); | ||
|
||
export const fetcher = <T>({ queryKey }: FetcherArgs): Promise<T> => | ||
fetchData(queryKey[0]).then((res) => res.json()); | ||
import { QueryClient, QueryClientConfig, useQuery, UseQueryOptions } from '@tanstack/react-query'; | ||
import { useEnvironment } from '../environment/environmentContext'; | ||
|
||
export const queryClientOptions: QueryClientConfig = { | ||
defaultOptions: { | ||
queries: { | ||
queryFn: fetcher, | ||
refetchIntervalInBackground: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const queryClient = new QueryClient(queryClientOptions); | ||
|
||
export const useAPIQuery = <T = void>( | ||
queryKey: [string], | ||
options: Omit<UseQueryOptions, 'queryKey' | 'queryFn'>, | ||
) => { | ||
const { | ||
publicEnvironment: { API_URL }, | ||
} = useEnvironment(); | ||
const path = queryKey[0]; | ||
const fullUrl = `${API_URL}${path}`; | ||
const modifiedQueryKey: [string] = [fullUrl]; | ||
|
||
return useQuery<T>(modifiedQueryKey, () => fetch(fullUrl).then((res) => res.json()), options); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import environment from '../environment/server'; | ||
|
||
export const fetchData = (path: string) => fetch(`${environment.publicEnvironment.API_URL}${path}`); | ||
|
||
export const fetchJson = <T = unknown>(path: string) => | ||
fetchData(path).then((res) => res.json() as T); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { ISchoolData } from '../types'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { IInstitutionDetails } from '../app/[projectID]/school/[rspo]/(sections)/types'; | ||
|
||
export const createSingleSchoolDataQueryKey = (rspo: string) => [`/school/${rspo}`]; | ||
|
||
const useSingleSchoolData = (rspo: string) => | ||
useQuery<ISchoolData>(createSingleSchoolDataQueryKey(rspo)); | ||
useQuery<IInstitutionDetails>(createSingleSchoolDataQueryKey(rspo)); | ||
|
||
export default useSingleSchoolData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client'; | ||
|
||
import { store } from '../../store/store'; | ||
import { Provider as StoreProvider } from 'react-redux/es/exports'; | ||
import EnvironmentProvider from '../../environment/environmentContext'; | ||
import ProjectConfigProvider from '../../api/projectConfig/projectConfigContext'; | ||
import { IEnvironment } from '../../environment/types'; | ||
import { FC, PropsWithChildren } from 'react'; | ||
import { QueryClientProvider } from '@tanstack/react-query'; | ||
import { queryClient } from '../../api/queryClient'; | ||
import { ProjectConfig } from '../../api/projectConfig/types'; | ||
|
||
interface ProvidersProps { | ||
environment: IEnvironment; | ||
projectConfig: ProjectConfig; | ||
} | ||
|
||
const Providers: FC<PropsWithChildren<ProvidersProps>> = ({ | ||
children, | ||
environment, | ||
projectConfig, | ||
}) => { | ||
return ( | ||
<EnvironmentProvider environment={environment}> | ||
<ProjectConfigProvider projectConfig={projectConfig}> | ||
<QueryClientProvider client={queryClient}> | ||
<StoreProvider store={store}>{children}</StoreProvider> | ||
</QueryClientProvider> | ||
</ProjectConfigProvider> | ||
</EnvironmentProvider> | ||
); | ||
}; | ||
|
||
export default Providers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use client'; | ||
|
||
import usePosthogPageChangeTracker from '../../../hooks/usePosthogPageChangeTracker'; | ||
|
||
const Analytics = () => { | ||
usePosthogPageChangeTracker(); | ||
return null; | ||
}; | ||
|
||
export default Analytics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use client'; | ||
|
||
import type { FC, PropsWithChildren } from 'react'; | ||
import AppNavbar from './AppNavbar'; | ||
import AppFooter from './AppFooter'; | ||
import BetaBanner from './BetaBanner'; | ||
import { usePathname } from 'next/navigation'; | ||
|
||
interface AppLayoutProps { | ||
className?: string; | ||
} | ||
|
||
const AppLayout: FC<PropsWithChildren<AppLayoutProps>> = ({ children, className }) => { | ||
const pathname = usePathname(); | ||
const isMapSite = pathname.includes('map'); | ||
return ( | ||
<div className={['bg-appBg flex flex-col min-h-full', className ?? ''].join(' ')}> | ||
<AppNavbar wide={isMapSite} /> | ||
<main className={`pt-navbarHeight ${isMapSite ? 'h-full' : ''}`} style={{ flex: '1 0 auto' }}> | ||
{children} | ||
</main> | ||
<div className="shrink-0">{!isMapSite && <AppFooter />}</div> | ||
<BetaBanner /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AppLayout; |
Oops, something went wrong.