/* Imports */ import React from 'react'; import { displayForecast } from '../web/display/displayForecasts'; import { platformsWithLabels } from '../web/platforms'; import searchAccordingToQueryData from '../web/worker/searchAccordingToQueryData'; /* Helper functions */ export async function getServerSideProps(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: platformsWithLabels, // weird key value format, ...urlQuery, }; let results; switch (initialQueryParameters.query != "") { case true: results = await searchAccordingToQueryData(initialQueryParameters); break; default: results = []; break; } return { props: { results: results, }, }; } /* Body */ export default function Home({ results }) { /* Final return */ let result = results ? results[0] : null; return ( <>
{result ? displayForecast({ ...result.item, score: result.score, showTimeStamp: true, expandFooterToFullWidth: true, }) : null}


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