diff --git a/src/pages/secretEmbed.tsx b/src/pages/secretEmbed.tsx index fd59204..6ede915 100644 --- a/src/pages/secretEmbed.tsx +++ b/src/pages/secretEmbed.tsx @@ -1,20 +1,27 @@ /* Imports */ +import { GetServerSideProps, NextPage } from "next"; import React from "react"; -import { displayForecast } from "../web/display/displayForecasts"; +import { platforms } from "../backend/platforms"; +import { DisplayForecast } from "../web/display/displayForecasts"; import { FrontendForecast } from "../web/platforms"; import searchAccordingToQueryData from "../web/worker/searchAccordingToQueryData"; -/* Helper functions */ +interface Props { + results: FrontendForecast[]; +} -export async function getServerSideProps(context) { +export const getServerSideProps: GetServerSideProps = async ( + context +) => { let urlQuery = context.query; // this is an object, not a string which I have to parse!! let initialQueryParameters = { query: "", starsThreshold: 2, forecastsThreshold: 0, + forecastingPlatforms: platforms.map((platform) => platform.name), ...urlQuery, }; @@ -28,34 +35,32 @@ export async function getServerSideProps(context) { results: results, }, }; -} +}; -/* Body */ -export default function Home({ results }) { - /* Final return */ - let result = results ? results[0] : null; +const SecretEmbedPage: NextPage = ({ results }) => { + let result = results.length ? results[0] : null; return ( - <> -
-
-
-
- {result - ? displayForecast({ - ...result, - showTimeStamp: true, - expandFooterToFullWidth: true, - }) - : null} -
-

-
- {result ? JSON.stringify(result.item, null, 4) : null} -
+
+
+
+
+ {result ? ( + + ) : null} +
+

+
+ {result ? JSON.stringify(result, null, 4) : null}
- +
); -} +}; + +export default SecretEmbedPage; diff --git a/src/web/display/displayForecasts.tsx b/src/web/display/displayForecasts.tsx index 6d07933..c0760de 100644 --- a/src/web/display/displayForecasts.tsx +++ b/src/web/display/displayForecasts.tsx @@ -581,7 +581,7 @@ interface SingleProps { showIdToggle?: boolean; } -export const displayForecast: React.FC = ({ +export const DisplayForecast: React.FC = ({ forecast: { id, title, @@ -760,20 +760,19 @@ const DisplayForecasts: React.FC = ({ } return ( <> - {results.slice(0, numDisplay).map((result) => { + {results.slice(0, numDisplay).map((result) => ( /*let displayWithMetaculusCapture = fuseSearchResult.item.platform == "Metaculus" ? metaculusEmbed(fuseSearchResult.item) : displayForecast({ ...fuseSearchResult.item }); */ - const display = displayForecast({ - forecast: result, - showTimeStamp: false, - expandFooterToFullWidth: false, - showIdToggle, - }); - return display; - })} + + ))} ); }; diff --git a/src/web/display/displayOneForecastForCapture.tsx b/src/web/display/displayOneForecastForCapture.tsx index 72a97f4..def9b9b 100644 --- a/src/web/display/displayOneForecastForCapture.tsx +++ b/src/web/display/displayOneForecastForCapture.tsx @@ -4,18 +4,18 @@ import { CopyToClipboard } from "react-copy-to-clipboard"; import { FrontendForecast } from "../platforms"; import { uploadToImgur } from "../worker/uploadToImgur"; -import { displayForecast } from "./displayForecasts"; +import { DisplayForecast } from "./displayForecasts"; function displayOneForecastInner(result: FrontendForecast, containerRef) { return (
- {result - ? displayForecast({ - forecast: result, - showTimeStamp: true, - expandFooterToFullWidth: true, - }) - : null} + {result ? ( + + ) : null}
); }