From 8585be08498b542168a6ae56a428b6402af3b364 Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 27 Feb 2023 19:27:05 -0600 Subject: [PATCH] Add load example button, remove defaultConfig passed in api/cron route --- src/pages/api/cron.ts | 27 +-------------------------- src/pages/index.tsx | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/pages/api/cron.ts b/src/pages/api/cron.ts index e7f87fc..bca4677 100644 --- a/src/pages/api/cron.ts +++ b/src/pages/api/cron.ts @@ -40,32 +40,7 @@ export default async function handler( async function innerFunction(): Promise { const now = new Date(); - const config = await fetchConfiguration({ - times: [ - { - time: '03:13', - maxLate: '00:10', - message: 'The bus is leaving soon.', - days: [ - 'monday', - 'tuesday', - 'wednesday', - 'thursday', - 'friday', - 'saturday', - 'sunday' - ], - name: 'B' - }, - { - name: 'A', - message: 'The bus is leaving soon.', - time: '23:26', - maxLate: '00:10', - days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'] - } - ] - }); + const config = await fetchConfiguration(); const matching = await getMatchingTime(config, now); // No matching time - no notification to send. diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 201b8c6..f7dd18a 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -43,6 +43,33 @@ export async function getServerSideProps({ }; } +const exampleConfiguration = { + times: [ + { + time: '03:13', + maxLate: '00:10', + message: 'The bus is leaving soon.', + days: [ + 'monday', + 'tuesday', + 'wednesday', + 'thursday', + 'friday', + 'saturday', + 'sunday' + ], + name: 'B' + }, + { + name: 'A', + message: 'The bus is leaving soon.', + time: '23:26', + maxLate: '00:10', + days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'] + } + ] +}; + const IndexPage: NextPage = ({ config }) => { const [code, setCode] = useState(config); const router = useRouter(); @@ -103,7 +130,16 @@ const IndexPage: NextPage = ({ config }) => {
{validationElement}
-
+
+