Skip to content
Snippets Groups Projects
Commit f1903108 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Use a single entrypoint instead of one for report and one for survey

parent 295b4dc6
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
"cartesian-product-multiple-arrays": "~1.0.9", "cartesian-product-multiple-arrays": "~1.0.9",
"chart.js": "~4.4.7", "chart.js": "~4.4.7",
"chartjs-plugin-datalabels": "~2.2.0", "chartjs-plugin-datalabels": "~2.2.0",
"eslint-plugin-react-compiler": "^19.0.0-beta-27714ef-20250124",
"html-to-image": "~1.11.11", "html-to-image": "~1.11.11",
"lodash": "~4.17.21", "lodash": "~4.17.21",
"react": "~19.0.0", "react": "~19.0.0",
...@@ -34,8 +33,9 @@ ...@@ -34,8 +33,9 @@
"@typescript-eslint/parser": "~8.21.0", "@typescript-eslint/parser": "~8.21.0",
"@vitejs/plugin-react": "~4.3.4", "@vitejs/plugin-react": "~4.3.4",
"babel-plugin-react-compiler": "~19.0.0-beta-27714ef-20250124", "babel-plugin-react-compiler": "~19.0.0-beta-27714ef-20250124",
"eslint": "~9.18.0", "eslint": "^9.19.0",
"eslint-plugin-react": "~7.37.4", "eslint-plugin-react": "~7.37.4",
"eslint-plugin-react-compiler": "^19.0.0-beta-27714ef-20250124",
"eslint-plugin-react-hooks": "~5.1.0", "eslint-plugin-react-hooks": "~5.1.0",
"rollup-plugin-license": "~3.5.3", "rollup-plugin-license": "~3.5.3",
"sass": "~1.83.4", "sass": "~1.83.4",
...@@ -463,7 +463,7 @@ ...@@ -463,7 +463,7 @@
"escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="], "escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="],
"eslint": ["eslint@9.18.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.10.0", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "9.18.0", "@eslint/plugin-kit": "^0.2.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": "bin/eslint.js" }, "sha512-+waTfRWQlSbpt3KWE+CjrPPYnbq9kfZIYUqapc0uBXyjTp8aYXZDsUH16m39Ryq3NjAVP4tjuF7KaukeqoCoaA=="], "eslint": ["eslint@9.19.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.10.0", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "9.19.0", "@eslint/plugin-kit": "^0.2.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-ug92j0LepKlbbEv6hD911THhoRHmbdXt2gX+VDABAW/Ir7D3nqKdv5Pf5vtlyY6HQMTEP2skXY43ueqTCWssEA=="],
"eslint-plugin-react": ["eslint-plugin-react@7.37.4", "", { "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.3", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", "es-iterator-helpers": "^1.2.1", "estraverse": "^5.3.0", "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", "minimatch": "^3.1.2", "object.entries": "^1.1.8", "object.fromentries": "^2.0.8", "object.values": "^1.2.1", "prop-types": "^15.8.1", "resolve": "^2.0.0-next.5", "semver": "^6.3.1", "string.prototype.matchall": "^4.0.12", "string.prototype.repeat": "^1.0.0" }, "peerDependencies": { "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" } }, "sha512-BGP0jRmfYyvOyvMoRX/uoUeW+GqNj9y16bPQzqAHf3AYII/tDs+jMN0dBVkl88/OZwNGwrVFxE7riHsXVfy/LQ=="], "eslint-plugin-react": ["eslint-plugin-react@7.37.4", "", { "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.3", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", "es-iterator-helpers": "^1.2.1", "estraverse": "^5.3.0", "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", "minimatch": "^3.1.2", "object.entries": "^1.1.8", "object.fromentries": "^2.0.8", "object.values": "^1.2.1", "prop-types": "^15.8.1", "resolve": "^2.0.0-next.5", "semver": "^6.3.1", "string.prototype.matchall": "^4.0.12", "string.prototype.repeat": "^1.0.0" }, "peerDependencies": { "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" } }, "sha512-BGP0jRmfYyvOyvMoRX/uoUeW+GqNj9y16bPQzqAHf3AYII/tDs+jMN0dBVkl88/OZwNGwrVFxE7riHsXVfy/LQ=="],
...@@ -925,6 +925,8 @@ ...@@ -925,6 +925,8 @@
"@typescript-eslint/typescript-estree/semver": ["semver@7.6.3", "", { "bin": "bin/semver.js" }, "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A=="], "@typescript-eslint/typescript-estree/semver": ["semver@7.6.3", "", { "bin": "bin/semver.js" }, "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A=="],
"eslint/@eslint/js": ["@eslint/js@9.19.0", "", {}, "sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ=="],
"fast-glob/glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="], "fast-glob/glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="],
"@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="], "@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
"name": "compendium-v2", "name": "compendium-v2",
"version": "1.0.0", "version": "1.0.0",
"devDependencies": { "devDependencies": {
"babel-plugin-react-compiler": "~19.0.0-beta-27714ef-20250124",
"eslint-plugin-react-compiler": "^19.0.0-beta-27714ef-20250124",
"@eslint/compat": "~1.2.5", "@eslint/compat": "~1.2.5",
"@eslint/eslintrc": "~3.2.0", "@eslint/eslintrc": "~3.2.0",
"@eslint/js": "~9.18.0", "@eslint/js": "~9.18.0",
...@@ -13,8 +11,10 @@ ...@@ -13,8 +11,10 @@
"@typescript-eslint/eslint-plugin": "~8.21.0", "@typescript-eslint/eslint-plugin": "~8.21.0",
"@typescript-eslint/parser": "~8.21.0", "@typescript-eslint/parser": "~8.21.0",
"@vitejs/plugin-react": "~4.3.4", "@vitejs/plugin-react": "~4.3.4",
"eslint": "~9.18.0", "babel-plugin-react-compiler": "~19.0.0-beta-27714ef-20250124",
"eslint": "^9.19.0",
"eslint-plugin-react": "~7.37.4", "eslint-plugin-react": "~7.37.4",
"eslint-plugin-react-compiler": "^19.0.0-beta-27714ef-20250124",
"eslint-plugin-react-hooks": "~5.1.0", "eslint-plugin-react-hooks": "~5.1.0",
"rollup-plugin-license": "~3.5.3", "rollup-plugin-license": "~3.5.3",
"sass": "~1.83.4", "sass": "~1.83.4",
......
import { ReactElement, useEffect, lazy } from "react"; import { ReactElement, lazy } from "react";
import { createBrowserRouter, RouterProvider, Outlet, useLocation } from "react-router-dom"; import { createBrowserRouter, RouterProvider, Outlet, useLocation } from "react-router-dom";
import Providers from "./Providers"; import Providers from "./Providers";
import { ConnectivityPage, ServiceCategory } from "./Schema"; import { ConnectivityPage, ServiceCategory } from "./Schema";
...@@ -65,6 +65,12 @@ const NetworkWeatherMapPage = lazy(() => import("./pages/Network/WeatherMap")); ...@@ -65,6 +65,12 @@ const NetworkWeatherMapPage = lazy(() => import("./pages/Network/WeatherMap"));
// Services Matrix // Services Matrix
const ServicesPage = lazy(() => import("./pages/Services/Services")); const ServicesPage = lazy(() => import("./pages/Services/Services"));
// Survey
const SurveyLanding = lazy(() => import('./survey/Landing'));
const SurveyContainerComponent = lazy(() => import('./survey/SurveyContainerComponent'));
const SurveyManagementComponent = lazy(() => import('./survey/management/SurveyManagementComponent'));
const UserManagementComponent = lazy(() => import('./survey/management/UserManagementComponent'));
const GlobalLayout = () => { const GlobalLayout = () => {
// this component is needed to provide a global layout for the app, including the navbar and footer, // this component is needed to provide a global layout for the app, including the navbar and footer,
// and make them part of the react-router-dom context // and make them part of the react-router-dom context
...@@ -85,21 +91,6 @@ const GlobalLayout = () => { ...@@ -85,21 +91,6 @@ const GlobalLayout = () => {
) )
} }
const RedirectToSurvey = () => {
const { pathname } = useLocation();
useEffect(() => {
// Only redirect if we're not already on a survey path
if (!pathname.startsWith('/survey')) {
window.location.replace(`/survey${pathname}`);
} else {
window.location.replace(pathname);
}
}, [pathname]);
return <Landing />
}
const router = createBrowserRouter([ const router = createBrowserRouter([
{ {
"path": "", "path": "",
...@@ -168,7 +159,14 @@ const router = createBrowserRouter([ ...@@ -168,7 +159,14 @@ const router = createBrowserRouter([
{ path: "/service-management-framework", element: <ServiceManagementFrameworkPage /> }, { path: "/service-management-framework", element: <ServiceManagementFrameworkPage /> },
{ path: "/service-level-targets", element: <ServiceLevelTargetsPage /> }, { path: "/service-level-targets", element: <ServiceLevelTargetsPage /> },
{ path: "/corporate-strategy", element: <CorporateStrategyPage /> }, { path: "/corporate-strategy", element: <CorporateStrategyPage /> },
{ path: "/survey/*", element: <RedirectToSurvey /> },
// survey
{ path: "/survey/admin/surveys", element: <SurveyManagementComponent /> },
{ path: "/survey/admin/users", element: <UserManagementComponent /> },
{ path: "/survey/admin/inspect/:year", element: <SurveyContainerComponent loadFrom={"/api/response/inspect/"} /> },
{ path: "/survey/admin/try/:year", element: <SurveyContainerComponent loadFrom={"/api/response/try/"} /> },
{ path: "/survey/response/:year/:nren", element: <SurveyContainerComponent loadFrom={"/api/response/load/"} /> },
{ path: "/survey/*", element: <SurveyLanding /> },
{ path: "*", element: <Landing /> }, { path: "*", element: <Landing /> },
] ]
} }
......
import { useEffect, lazy } from "react";
import { createBrowserRouter, RouterProvider, Outlet, useLocation } from "react-router-dom";
import Providers from "../Providers";
import ExternalPageNavBar from "../components/global/ExternalPageNavBar";
import GeantFooter from "../components/global/GeantFooter";
import PrivacyModal from "../matomo/PrivacyModal";
import SurveyLanding from "./Landing";
const SurveyContainerComponent = lazy(() => import('./SurveyContainerComponent'));
const SurveyManagementComponent = lazy(() => import('./management/SurveyManagementComponent'));
const UserManagementComponent = lazy(() => import('./management/UserManagementComponent'));
const RedirectToReport = ({ pathname }) => {
useEffect(() => {
console.log(pathname)
// Only redirect if we're not already on a survey path
if (!pathname.startsWith('/survey')) {
window.location.replace(`${pathname}`);
}
}, [pathname]);
return null;
}
const GlobalLayout = () => {
// this component is needed to provide a global layout for the app, including the navbar and footer,
// and make them part of the react-router-dom context
const { pathname } = useLocation();
// hacky workaround for supporting a landing page on the root path, as well as any undefined path
const hasOutlet = pathname !== "/survey"
return (
<>
<Providers>
<RedirectToReport pathname={pathname} />
<ExternalPageNavBar />
<main className="grow">
{hasOutlet ? <Outlet /> : <SurveyLanding />}
</main>
<PrivacyModal />
</Providers>
<GeantFooter />
</>
)
}
const router = createBrowserRouter([
{
"path": "",
"element": <GlobalLayout />,
"children": [
{ path: "/survey/admin/surveys", element: <SurveyManagementComponent /> },
{ path: "/survey/admin/users", element: <UserManagementComponent /> },
{ path: "/survey/admin/inspect/:year", element: <SurveyContainerComponent loadFrom={"/api/response/inspect/"} /> },
{ path: "/survey/admin/try/:year", element: <SurveyContainerComponent loadFrom={"/api/response/try/"} /> },
{ path: "/survey/response/:year/:nren", element: <SurveyContainerComponent loadFrom={"/api/response/load/"} /> },
{ path: "*", element: <SurveyLanding /> },
]
}
])
function App() {
return (
<div className="app">
<RouterProvider router={router} />
</div>
);
}
export default App
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from "./App";
import 'bootstrap/dist/css/bootstrap.min.css';
import '../main.scss';
const container = document.getElementById('root') as HTMLElement;
const root = createRoot(container);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
)
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Compendium Survey</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/survey/index.tsx"></script>
</body>
</html>
\ No newline at end of file
...@@ -53,10 +53,6 @@ export default defineConfig({ ...@@ -53,10 +53,6 @@ export default defineConfig({
outDir: outDir, outDir: outDir,
sourcemap: process.env.NODE_ENV !== 'production', sourcemap: process.env.NODE_ENV !== 'production',
rollupOptions: { rollupOptions: {
input: {
report: path.resolve(__dirname, 'index.html'),
survey: path.resolve(__dirname, 'survey.html'),
},
output: { output: {
entryFileNames: '[name].js', entryFileNames: '[name].js',
assetFileNames: function (assetInfo) { assetFileNames: function (assetInfo) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment