From 1b1c0f4228a3df8824e11f08d99c9fe6ad29da24 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Sat, 26 Mar 2022 04:15:07 +0300 Subject: [PATCH] refactor: move layout.tsx to web/display https://metaforecast.org/layout is not a real page, so it shouldn't be in src/pages. --- src/pages/about.tsx | 2 +- src/pages/capture.tsx | 2 +- src/pages/dashboards.tsx | 2 +- src/pages/index.tsx | 2 +- src/pages/tools.tsx | 2 +- src/{pages => web/display}/layout.tsx | 13 ++++++------- 6 files changed, 11 insertions(+), 12 deletions(-) rename src/{pages => web/display}/layout.tsx (95%) diff --git a/src/pages/about.tsx b/src/pages/about.tsx index fad8acb..29aa16c 100644 --- a/src/pages/about.tsx +++ b/src/pages/about.tsx @@ -2,7 +2,7 @@ import React from 'react'; import ReactMarkdown from 'react-markdown'; import gfm from 'remark-gfm'; -import Layout from './layout'; +import Layout from '../web/display/layout'; let readmeMarkdownText = `# About diff --git a/src/pages/capture.tsx b/src/pages/capture.tsx index 6149926..0a7e4e6 100644 --- a/src/pages/capture.tsx +++ b/src/pages/capture.tsx @@ -2,9 +2,9 @@ import { NextPage } from 'next'; import React from 'react'; import { displayForecastsWrapperForCapture } from '../web/display/displayForecastsWrappers'; +import Layout from '../web/display/layout'; import { Props } from '../web/search/anySearchPage'; import CommonDisplay from '../web/search/CommonDisplay'; -import Layout from './layout'; export { getServerSideProps } from "../web/search/anySearchPage"; diff --git a/src/pages/dashboards.tsx b/src/pages/dashboards.tsx index 09b5afe..4ec9098 100644 --- a/src/pages/dashboards.tsx +++ b/src/pages/dashboards.tsx @@ -6,8 +6,8 @@ import { useState } from 'react'; import { DashboardCreator } from '../web/display/dashboardCreator'; import displayForecasts from '../web/display/displayForecasts'; +import Layout from '../web/display/layout'; import { getDashboardForecastsByDashboardId } from '../web/worker/getDashboardForecasts'; -import Layout from './layout'; /* get Props */ diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0a547f3..0b0bb9d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -2,9 +2,9 @@ import { NextPage } from 'next'; import React from 'react'; import { displayForecastsWrapperForSearch } from '../web/display/displayForecastsWrappers'; +import Layout from '../web/display/layout'; import { Props } from '../web/search/anySearchPage'; import CommonDisplay from '../web/search/CommonDisplay'; -import Layout from './layout'; export { getServerSideProps } from "../web/search/anySearchPage"; diff --git a/src/pages/tools.tsx b/src/pages/tools.tsx index d9b39f4..1c105e6 100644 --- a/src/pages/tools.tsx +++ b/src/pages/tools.tsx @@ -1,7 +1,7 @@ import Link from 'next/link'; import React from 'react'; -import Layout from './layout'; +import Layout from '../web/display/layout'; /* Display one tool */ function displayTool({ diff --git a/src/pages/layout.tsx b/src/web/display/layout.tsx similarity index 95% rename from src/pages/layout.tsx rename to src/web/display/layout.tsx index 474b3a5..7e1a567 100644 --- a/src/pages/layout.tsx +++ b/src/web/display/layout.tsx @@ -1,12 +1,11 @@ import Head from 'next/head'; import Link from 'next/link'; -import React from 'react'; +import React, { ErrorInfo } from 'react'; -// import { GiDiceEightFacesEight } from "react-icons/gi"; -import { Logo2 } from '../web/icons/index'; +import { Logo2 } from '../icons/index'; /* Utilities */ -const classNameSelected = (isSelected) => +const classNameSelected = (isSelected: boolean) => `no-underline py-4 px-2 ml-4 text-md font-medium cursor-pointer border-b-2 border-transparent ${ isSelected ? "text-blue-700 border-blue-700" @@ -27,16 +26,16 @@ let calculateLastUpdate = () => { // Error catcher class ErrorBoundary extends React.Component< - any, + {}, { error: any; errorInfo: any } > { // https://reactjs.org/docs/error-boundaries.html - constructor(props) { + constructor(props: {}) { super(props); this.state = { error: null, errorInfo: null }; } - componentDidCatch(error, errorInfo) { + componentDidCatch(error: Error, errorInfo: ErrorInfo) { // Catch errors in any components below and re-render with error message this.setState({ error: error,