From 833dc71030edcee119f8f7d4d7fc0dffb1ccbcdb Mon Sep 17 00:00:00 2001 From: Nicolas DUBIEN Date: Mon, 9 Dec 2024 12:33:42 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20back=20buggy=20"solved=20t?= =?UTF-8?q?imes"=20at=20the=20end=20of=20each=20advent=20(#5503)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts dubzzz/fast-check#5501 --- .../AdventOfTheDayBuilder.tsx | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/website/blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx b/website/blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx index 3ba5e56fc2e..ec9861734a9 100644 --- a/website/blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx +++ b/website/blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx @@ -147,12 +147,44 @@ export function buildAdventOfTheDay(options: Options) { placeholder={`Example of answer:\n${placeholderForm}`} >
- +
+ + +
); } + function SolvedTimes() { + const [times, setTimes] = useState(null); + useEffect(() => { + async function update() { + try { + const response = await fetch(`https://api.counterapi.dev/v1/fast-check/AdventOfPBT2024Day${day}Success`); + const data = await response.json(); + const count = data.count || 0; + setTimes(count); + } catch (err) { + setTimes(-1); + } + } + update(); + }, []); + + return ( + + {times === null + ? 'Loading the solve count...' + : times === 0 + ? 'Be the first to solve this challenge!' + : times === -1 + ? 'Unable to retrieve the solve count at the moment.' + : `This puzzle has been solved ${times} time${times > 1 ? 's' : ''}!`} + + ); + } + return { AdventPlaygroundOfTheDay, FormOfTheDay }; }