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

Create Table and Select All Checkbox #38

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

carolynzhang18
Copy link
Contributor

@carolynzhang18 carolynzhang18 commented Mar 8, 2024

Notion Ticket Link

Create Table and Select All Checkbox

Implementation Description

  • Created a table with checkboxes to select individual or all roles.
  • Currently populated with dummy data - replace with actual data once the backend routes are ready.
  • We don't have types for documents yet - once we do, we'll have to touch up the typing of the variables in this PR to match
  • 0 styling rn lol I just plopped in chakra components

Steps to Test

  1. Log in with an admin account!
  2. Go to the documents directory page (localhost:3000/documents).
  3. Open up your developer console window (right click -> Inspect -> Console) - that's where the ids will be logged!
  4. Play around with the checkboxes and logging the ids (button under the table)! Select one, click the button, use the header checkbox to select all of them, click the button, deselect one of the checkboxes, click the button, use the header checkbox to deselect all of them, click the button, etc.

Check that the ids logged in the console correspond to the ids you are selecting!

Screenshots (optional)

Screenshot 2024-03-08 at 6 37 26 PM

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

Linting & Formatting

Mac

docker exec -it CWC-backend /bin/bash -c "yarn fix"
docker exec -it CWC-frontend /bin/bash -c "yarn fix"

Windows

docker exec -it CWC-backend bash -c "yarn fix"
docker exec -it CWC-frontend bash -c "yarn fix"

} else {
selectedDocumentIds.delete(selectedId);
}
setSelectedDocumentIds((prev) => new Set(prev));
Copy link
Contributor Author

@carolynzhang18 carolynzhang18 Mar 8, 2024

Choose a reason for hiding this comment

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

Doing Set.add and Set.delete won't trigger a React state update because the object itself has not changed (even though its contents did).
To force a state update, I'm creating a new Set copied off the mutated previous Set.

<Tr>
<Th>
<Checkbox
isChecked={selectedDocumentIds.size === documents.length}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This covers the case where someone selects all checkboxes, and then deselects one of them - we want the select all checkbox to be deselected in this case.

@shencynthia shencynthia self-assigned this Mar 11, 2024
Copy link
Contributor

@shencynthia shencynthia left a comment

Choose a reason for hiding this comment

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

LGTM!! 🔥🔥

@owen-sellner owen-sellner self-requested a review March 11, 2024 00:53
@carolynzhang18 carolynzhang18 merged commit 1ee5608 into main Mar 19, 2024
1 check passed
@carolynzhang18 carolynzhang18 deleted the carolyn/table-with-select-row-checkboxes branch March 19, 2024 03:09
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.

3 participants