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

Feat: implement DeleteGroupDialog #248

Merged
merged 7 commits into from
Feb 27, 2024

Conversation

kanta1207
Copy link
Member

@kanta1207 kanta1207 commented Feb 21, 2024

Overview

Implement DeleteGroupConfirmDialog component.

Changes

  • Wrap GroupCardDropdownMenu with DialogRoot, and put DeleteGroupConfirmDialog outside of drop down menu because if DialogRoot goes inside of GroupCardDropdownMenuContent, closing the dropdown will also close the dialog.
  • Add DeleteGroupConfirmDialog component.
  • Add trigger to open the dialog in GroupCardDropdownMenuContent.

Review points

  • The trigger is in GroupCardDropdownMenuContent, content is in GroupCardDropdownMenu. Is this component structure complexity okay? If not, not using DialogTrigger to open the dialog can be an another solution.

Screen Captures

Screen.Recording.2024-02-21.at.12.36.52.mov

Assignee Checklist:

  • The naming convention of the PR title is correct (See the comment at the top of this template)
  • The base branch is correct (See: Types of Branches)
  • The branch name follows the Branch Naming Conventions
  • The correct assignees and reviewers have been designated for this PR
  • The coding style follows the Coding Style Guide
  • All the related issues are associated with this PR
  • All criteria in the associated issues are met (please tick the checkboxes)
  • My changes do not generate new warnings or errors (especially in the console)

Reviewer Checklist:

  • Double-check the "Assignee Checklist"
  • The code follows the generic best practices and our Coding Style Guide
  • The code is well-commented and easy to understand
  • The UI changes accurately reflect the provided design

@kanta1207 kanta1207 changed the title feat: implement deleteGroupConfirmDialog Feat: implement deleteGroupConfirmDialog Feb 21, 2024
@kanta1207 kanta1207 self-assigned this Feb 21, 2024
@kanta1207 kanta1207 linked an issue Feb 21, 2024 that may be closed by this pull request
2 tasks
@kanta1207 kanta1207 marked this pull request as ready for review February 21, 2024 20:50
@kanta1207 kanta1207 changed the title Feat: implement deleteGroupConfirmDialog Feat: implement DeleteGroupConfirmDialog Feb 21, 2024
Copy link
Member

@nick-y-ito nick-y-ito left a comment

Choose a reason for hiding this comment

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

@kanta1207
Thank you for researching the issue of how to prevent the dialog from unintentionally closing together when the dropdown menu is closed. I couldn't even find any solution when I tried.

However, I still doubt this approach, although it works here.

Wrap GroupCardDropdownMenu with DialogRoot, and put DeleteGroupConfirmDialog outside of drop down menu because if DialogRoot goes inside of GroupCardDropdownMenuContent, closing the dropdown will also close the dialog.

The reason is that with this approach, we would not be able to have two or more dialogs within the same dropdown menu. Here are the cases we should face shortly:

image
image image

Review Points

The trigger is in GroupCardDropdownMenuContent, content is in GroupCardDropdownMenu. Is this component structure complexity okay?

I think the complexity is acceptable as long as the comments are appropriately written.

If not, not using DialogTrigger to open the dialog can be an another solution.

I am wondering if not using the DialogTrigger may degrade the accessibility.

We may need to discuss this.

</DropdownMenuTrigger>
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} />
</DropdownMenu>
// Wrapping dialog menu with DialogRoot. Trigger is in GroupCarDropdownMenuContent
Copy link
Member

@nick-y-ito nick-y-ito Feb 22, 2024

Choose a reason for hiding this comment

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

I'm sorry, but could you please clarify this comment? It's a bit difficult to understand what it's trying to say.

I could be like the following if my understanding is correct:

The <DropdownMenu> must be wrapped with the <DialogRoot> to prevent the dialog from closing unintentionally when the dropdown menu is closed. The trigger for the dialog can be found in the <GroupCarDropdownMenuContent>.

Copy link
Member Author

Choose a reason for hiding this comment

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

This issue was addressed by adjusting DeleteGroupDialog to follow how it's implemented in DeleteFoodDialog.

Copy link
Member

@nick-y-ito nick-y-ito Feb 22, 2024

Choose a reason for hiding this comment

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

From my perspective, naming this component DeleteGroupDialogContent (without "confirmation") is understandable enough. The name DeleteGroupConfirmDialogContent sounds to me like a "second" dialog to confirm the deletion. You can decide it. However, since our design has multiple delete dialogs, we should prioritize consistency across the project. You can decide :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed the file name to DeleteGroupDialog!

Copy link
Member Author

@kanta1207 kanta1207 Feb 27, 2024

Choose a reason for hiding this comment

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

This file has changed just because I removed FC type.

I did the change only to this file for now because the file was in this PR's scope. Maybe I'll refactor rest of FC types in other files later in different scope.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed the file name to DeleteGroupDialog!

</DropdownMenuTrigger>
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} />
</DropdownMenu>
// Wrapping dialog menu with DialogRoot. Trigger is in GroupCarDropdownMenuContent
Copy link
Member Author

Choose a reason for hiding this comment

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

This issue was addressed by adjusting DeleteGroupDialog to follow how it's implemented in DeleteFoodDialog.

@@ -122,7 +122,7 @@ export const deleteMember = async (
): Promise<Result<undefined, string>> => {
try {
await request({
url: `${BACKEND_API_DOMAIN}/groups/${groupId}/users/${userId}`,
url: `${API_BASE_URL}/groups/${groupId}/users/${userId}`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Found out thisBACKEND_API_DOMAIN variable (which doesn't exist) is set as base url in here, and caused build error. The functionality shouldn't be also working tho, don't know how it's in develop branch now...

@kanta1207
Copy link
Member Author

@nick-y-ito
Thank you for your review!
I basically followed the way it's implemented in DeleteFoodDialog, and this PR stays focusing on only UI.

Please take a look at the change when you have time 🙏

@kanta1207 kanta1207 changed the title Feat: implement DeleteGroupConfirmDialog Feat: implement DeleteGroupDialog Feb 27, 2024
Copy link
Member

@nick-y-ito nick-y-ito left a comment

Choose a reason for hiding this comment

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

@kanta1207
Thank you for updating! Please kindly take a look at the comments. They are not as crucial as I have to request changes.

However, I suppose the dropdown menu should be closed together when closing the dialog. If you are planning to implement that behavior in the next PR, please never mind :)

If you address this and need my further review, please feel free to ask me again!

* This is necessary because closing dropdown menu also closes the dialog unintentionally.
* @see {@link https://www.radix-ui.com/primitives/docs/components/dropdown-menu#item}
*
* @param e The event object
Copy link
Member

Choose a reason for hiding this comment

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

This is a minor thing, though; here is the official way of formatting the @param tag. It is good to be aware of.

/**
 * @param e - The event object
 */

https://tsdoc.org/pages/tags/param/

<DialogTitle>Delete Group</DialogTitle>
</DialogHeader>
<DialogBody>
<p>Are you sure you want to delete group?</p>
Copy link
Member

Choose a reason for hiding this comment

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

"Are you sure you want to delete 'this' group?" would sound slightly better.

Icon,
} from '@/components/ui';

import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

Maybe unnecessary

DialogTitle,
} from '@/components/ui';

import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

Maybe unnecessary

Copy link
Member

@nick-y-ito nick-y-ito left a comment

Choose a reason for hiding this comment

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

I am sorry, I found an error in the console after I approved. That says:

app-index.js:35 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Could you inspect it, please?

delete-container-dropdown-menu-error.mov

@kanta1207
Copy link
Member Author

@nick-y-ito
Thank you for your review!

the dropdown menu should be closed together when closing the dialog

I just forgot to implement the functionality in this PR, so I included it in commit #9c5e7d2.

I am sorry, I found an error in the console after I approved. That says:
app-index.js:35 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Could you inspect it, please?

Sorry that I didn't notice the warning in the first place. I should've checked that.
I fixed the issue in the commit #00e3444.
It was because of unnecessary asChild in DropdownMenuItem.

Please kindly take a look at them again on your convenience 🙏

<DropdownMenuTrigger asChild>
<Button variant="ghost" className="w-12">
<Icon icon={MenuKebabIcon} size={4.5} />
</Button>
</DropdownMenuTrigger>
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} />
Copy link
Member Author

Choose a reason for hiding this comment

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

Because I separated GroupCardDropdownMenuContent from trigger as a different component,
I ended up having to pass onDropdownMenuClose prop from this file, and it's props drilling among 4 layers.

(GroupCardDropdownMenuTriggerButton => GroupCardDropdownMenuContent => DeleteGroupDialogTriggerButton => DeleteGroupDialogContent)

The directory structure itself is reasonable one tho, let me know if you feel we have to do something for this props drilling. I personally chose to keep this directory structure for now.

Copy link
Member

@nick-y-ito nick-y-ito Feb 27, 2024

Choose a reason for hiding this comment

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

I personally chose to keep this directory structure for now.

I agree. I think it's acceptable for now.

Copy link
Member

@nick-y-ito nick-y-ito left a comment

Choose a reason for hiding this comment

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

@kanta1207
Thank you for updating!

I think the dropdown menu should also be closed when after the [ Delete ] button is clicked.

There is another problem with this behavior, though...
#269

<DropdownMenuTrigger asChild>
<Button variant="ghost" className="w-12">
<Icon icon={MenuKebabIcon} size={4.5} />
</Button>
</DropdownMenuTrigger>
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} />
Copy link
Member

@nick-y-ito nick-y-ito Feb 27, 2024

Choose a reason for hiding this comment

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

I personally chose to keep this directory structure for now.

I agree. I think it's acceptable for now.

@kanta1207
Copy link
Member Author

@kanta1207 Thank you for updating!

I think the dropdown menu should also be closed when after the [ Delete ] button is clicked.

There is another problem with this behavior, though... #269

Thank you for your review!
I fixed to close dropdown on closing dialog with delete button clicked! Please take a look again 🙏

Copy link
Member

@nick-y-ito nick-y-ito left a comment

Choose a reason for hiding this comment

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

@kanta1207
Thank you for fixing them promptly! Looks good to go 😄

@kanta1207 kanta1207 merged commit 8b7608c into develop Feb 27, 2024
3 checks passed
@kanta1207 kanta1207 deleted the feature/244-delete-group-confirm-dialog-component branch February 27, 2024 15:16
nick-y-ito added a commit that referenced this pull request Mar 2, 2024
* Feature: create container feature(UI) in group single page (#256)

* feat: implemenet drawer UI"

* feat: implement UI of creating container drawer

* chore: delete console.log

* fix: change the first letter of file name to lower case

* fix: add a type to the function parameter

* fix: change to self-closing

* fix: avoid using type annotation

* docs: add docs to interface and function

* fix(creategroupdrawercontent.tsx): add param, change to self-closing in whicht it referenced from

* Feature: add delete functionality to the members page (#268)

* fix: adjust menuIcon and 'Members' in MembersPage

* feat: implement popup DropdownMenu when clicked only UI"

* feat: implement member delete dialog

* refactor: create on click function

* feat: disable dialog and dropdown at same time when button clicked

* chore: delete unnecessary code

* test: set up for deleting-member function

* docs: add docs to interfaces and functions

* test: change the way of comparison to primitive

* test: add schema for validation

* docs: add doc to the handling function for delete button

* docs: add doc to interface IMemberPageProps

* fix: typo

* fix: change onClick event to one line

* Feature: Add validation to the DELETE food (#266)

* feat: add validation to the DELETE food

* feat: revise the ID validation for CREATE & UPDATE food

* Feature: Adjust environment variables and deploy on Vercel (#267)

* refactor: rename env LOCALHOST_URL

* refactor: rename env BACKEND_API_DOMAIN

* refactor: unify OAuth Domain and Redirect URL

* chore: clarify the env.example

* fix: gitignore for env

* Feature: Create container feature api in group single page (#272)

* feat: pass groupId to child

* feat: implement fetch function

* test: test for postContainer

* fix: change Domain variable

* test: implement test for action

* test: implement test for API error

* feat: implement call API when submit

* docs: add docs to interface and function

* docs: typo

* fix: modified variable and put a link in docs to improve readability

* docs: add doc for more descriptive

* refactor: move createContainer function to top for readability

* refactor: change the function name from postContainer to postCreateContaier

* fix: typo

* refactor: separate container and food test function

* Feat: implement DeleteGroupDialog (#248)

* feat: implement deleteGroupConfirmDialog

* feat: re-implement delete group dialog with new file structure

* fix: out of scope, env variable name

* fix: restructure to close dropdown menu on dialog close

* fix: remove unnecessary asChild in DropdownMenuItem

* fix: close dropdown on closing dialog

* Docs: Relocate the content of NOTE documents (#276)

* refactor: refactor & add TSDocs in Icon.tsx

* docs: remove note docs

* docs: add Icons sections to the style guide

* refactor: rename icon components to improve accessibility

* Docs: Improve `README.md` & `CONTRIBUTING.md` (#281)

* Feature: Apply a correct link to the back button of each page (#271)

* feat: allow the Link component to accept any attributes

* feat: correct the back link for foods page

* feat: create API client and apply group name to header

* refactor: rename GroupSingle

* style: add line break

* chore: allow leading underscore for variable names

* fix: correct env and solve the compile error

* Feat : implement delete group api client (#282)

* feat: implement delete group api client

* refactor: refactor TsDoc comments for existing action functions

* feat: add remove group action

* refactor: refactor group action file

* feat: apply api client to delete dialog component

* fix: fix following coding style guide

* fix: refactor TsDoc comments to add info

* Feature: Rename container UI in group single page (#287)

* feat: implement UI of DropdownMenu

* feat: implement switching container name to input field

* feat: add 1rem padding to right side of input

* docs: add docs to interface and function

* style: formatting for readability

* docs: add docs to the function which it is missing

* fix: change default font size of input from ld to md

* refactor: change the event props name to onXXX

* fix: change type to alias

* Feature: Apply design changes to Select.tsx (#249)

* style(select.tsx): changed some styles to match the Figma design

* style(select.tsx): added a wrapper to check icon to align with the Figma design

#127

* style(select.tsx): added className that was accidentally deleted in the previous commit

#127

* style(select.tsx): fixed icon name

#127

* style(select.tsx): applied style changes to the icon

#127

* Feature: Rename container api in group single page (#297)

* feat: implement UI of DropdownMenu

* feat: implement switching container name to input field

* feat: add 1rem padding to right side of input

* docs: add docs to interface and function

* style: formatting for readability

* fix: update Icon name

* feat: implement putRenameContainer function

* docs: add docs to the function which it is missing

* fix: change default font size of input from ld to md

* refactor: change the event props name to onXXX

* refactor: delete unnecessary file

* feat: implement API call

* fix: change type to alias

* feat: pass containerId to child components

* feat: implement test without validation

* test: add validation test

* docs: add comment on function

* style: add lines

* docs: add doc to renameContainer functions

* style: add lines for readability

* fix: update the messages

* fix: update the message in test

* refactor: change the structure in action for readability

* fix: create a gap between each card

* fix: modify the position of icon when error appears

* fix: typo

* fix: change the approach to self-start

* Feature: Disable authentication for contributors (#290)

* feat: create auth utils

* feat: disable login flow

* feat: disable toke check when using mock API

* feat: update .env.example

* feat: copy .env.example to .env.local on `postinstall`

* chore: add comments in .env.example

* test: fix test for request function

* refactor: increase the readability

* Feature: Adjust the UI & behavior of the login form (#286)

* feat: added google login icon

* feat: google login with reac-ui amplify

* feat: rm unused code

* refactor: remove unused styles in tailwind.config.ts

* refactor: define color variables in CSS

* feat: add spinner image

* feat: create the WhiteOverlay UI component

* feat: adjust the style and behavior of the login form

* ci: update the node version

* chore: remove unnecessary google image

* ci: update the node version

* feat: set timeout to prevent indefinite loading

---------

Co-authored-by: kotaaaa <kota.k.1132.pda@gmail.com>

* Feature: Delete container UI in group single page (#306)

* feat: implement displaying dialog

* docs: add docs to function and interface

* chore: adjust the documentation

* docs: typo

* docs: update the content

* docs: update doc

* docs: add doc where missing

* docs: add missing symbol for doc

* docs: fix the explanation

* docs: fix the explanation

* Fix: Highlight the bottom icons on sub pages (#302)

* Chore: Add pre-push hook to run test (#301)

* ci: add pre-push hook to run test

* Revert "ci: add pre-push hook to run test"

This reverts commit d01a418.

* ci: add pre-push hook to run test

* Docs: Improve Community Standards (#307)

* docs: create SECURITY.md

* docs: create `CODE_OF_CONDUCT.md`

* Feat : Get users name in profile page (#308)

* feat: implement getCurrentUserId api client

* test: test getCurrentUser api client

* fix: fix api client to resolve with the issue #255

* refactor: refactor the TSDoc comment in authApiClient

* feat: implement getUserById API client

* feat: apply api clients to Profile page

* refactor: remove unnecessary temp solution

* refactor: update the comments in api client

* test: test getUserByUserId function

* refactor: add comments

* refactor: update TSDoc comments

* refactor: add issue reference in Profile page

* fix: return => returns in getUserName TSDoc

* fix: duplicate import line in userApiClient.server

* fix: relative import path to absolute

* refactor: add better comment to getUserName function

* refactor: add TSDoc comment to UserProfile prop interface

* fix: remove return types from TSDoc

* refactor: add line break before `it`

* refactor: use template literal

* refactor: use template literal

* refactor: update TSDoc and add error handling to throw error

* fix: remove relative path

* fix: remove relative path

* test: refactor test to make it better

---------

Co-authored-by: ShoeheyOt <142355969+ShoeheyOt@users.noreply.github.com>
Co-authored-by: kanta1207 <99339182+kanta1207@users.noreply.github.com>
Co-authored-by: Anukrati Mehta <anukratimehta@gmail.com>
Co-authored-by: kotaaaa <kota.k.1132.pda@gmail.com>
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.

Implement Delete Group Confirm Dialog component
2 participants