Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Drop buggy "solved times" at the end of each advent #5501

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,12 @@ export function buildAdventOfTheDay(options: Options) {
placeholder={`Example of answer:\n${placeholderForm}`}
></textarea>
<br />
<div>
<button type="submit">Submit</button>
<SolvedTimes />
</div>
<button type="submit">Submit</button>
</form>
</>
);
}

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 (
<span style={{ marginLeft: '1rem' }}>
{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' : ''}!`}
</span>
);
}

return { AdventPlaygroundOfTheDay, FormOfTheDay };
}

Expand Down
Loading