diff --git a/src/components/layout/Footer/Footer.tsx b/src/components/layout/Footer/Footer.tsx index 31c166ac9f..34031697bf 100644 --- a/src/components/layout/Footer/Footer.tsx +++ b/src/components/layout/Footer/Footer.tsx @@ -27,7 +27,7 @@ const Footer: React.FC = ({ className, noMargin, comboOfTheDay }) => { Find My Combos Featured Combos Metrics - Combo of the Day + Combo of the Day

Commander Spellbook

diff --git a/src/pages/combo-of-the-day.tsx b/src/pages/combo-of-the-day.tsx new file mode 100644 index 0000000000..b0fcd7d5b5 --- /dev/null +++ b/src/pages/combo-of-the-day.tsx @@ -0,0 +1,54 @@ +import React from 'react'; +import ArtCircle from '../components/layout/ArtCircle/ArtCircle'; +import SpellbookHead from '../components/SpellbookHead/SpellbookHead'; +import Link from 'next/link'; +import { GetServerSideProps } from 'next'; +import { apiConfiguration } from 'services/api.service'; +import { PropertiesApi, ResponseError } from '@space-cow-media/spellbook-client'; + +const MissingComboOfTheDay: React.FC = () => { + return ( + <> + +
+ +

Combo of the Day

+ +
+

Today we are missing a combo of the day. Please check back later or tomorrow.

+ + Go back to the homepage + +
+
+ + ); +}; + +export default MissingComboOfTheDay; + +export const getServerSideProps: GetServerSideProps = async (context) => { + const configuration = apiConfiguration(context); + const propertiesApi = new PropertiesApi(configuration); + try { + const comboOfTheDayData = await propertiesApi.propertiesRetrieve({ key: 'combo_of_the_day' }); + if (comboOfTheDayData.value) { + return { + redirect: { + destination: `/combo/${comboOfTheDayData.value}`, + permanent: false, + }, + }; + } + } catch (err) { + if (!(err instanceof ResponseError && err.response.status === 404)) { + throw err; + } + } + return { + props: {}, + }; +}; diff --git a/src/pages/combo/[id]/index.tsx b/src/pages/combo/[id]/index.tsx index d07f4e7791..f8299ee780 100644 --- a/src/pages/combo/[id]/index.tsx +++ b/src/pages/combo/[id]/index.tsx @@ -14,7 +14,6 @@ import EDHRECService from '../../../services/edhrec.service'; import NoCombosFound from 'components/layout/NoCombosFound/NoCombosFound'; import { FindMyCombosApi, - PropertiesApi, ResponseError, Template, Variant, @@ -375,24 +374,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => { } const configuration = apiConfiguration(context); - if (params.id === 'combo-of-the-day') { - const propertiesApi = new PropertiesApi(configuration); - try { - const comboOfTheDayData = await propertiesApi.propertiesRetrieve({ key: 'combo_of_the_day' }); - if (comboOfTheDayData.value) { - return { - redirect: { - destination: `/combo/${comboOfTheDayData.value}`, - permanent: false, - }, - }; - } - } catch (err) { - if (!(err instanceof ResponseError && err.response.status === 404)) { - throw err; - } - } - } const variantsApi = new VariantsApi(configuration); try {