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

Add boardgames, lecture proposal form, dark mode #13

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

bartacc
Copy link
Collaborator

@bartacc bartacc commented Sep 30, 2024

This PR contains:

  • Form for adding lecture proposals
  • Pages related to boardgames
  • Dark mode

queryKey: [zosiaApiRoutes.addLectureDurations, lectureType],
queryFn: async ({ queryKey }) => {
const lecture = queryKey[1];
if (lecture === "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should validate outside of the query function; the query function is only for calling an API.

const lecture = queryKey[1];
if (lecture === "") {
return Promise.resolve<LectureDurations>({
durations: ["Please choose lecture type first!"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is especially weird because, in fact, we have an error, and outside of it, we think it is a valid response


const onCheckboxChange = (boardGameId: number, checked: boolean) => {
if (checked) {
setVotes([...votes, boardGameId]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, it would be better to use functional setState in both cases, it may cause less bugs

Suggested change
setVotes([...votes, boardGameId]);
setVotes(oldVotes => ([...oldVotes, boardGameId]));

}
};

const isVoteLimitReached = votes.length >= 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also validated on backend?

* This approach is inspired by this blogpost:
* https://hangindev.com/blog/avoid-flash-of-default-theme-an-implementation-of-dark-mode-in-react-app
*/
export const themeInitScript = `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this approach. Isn't file app/server/templates/base.html the one to which we will inject this code? Can't we add this code there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants