-
Notifications
You must be signed in to change notification settings - Fork 12k
refactor: booking-list-state-management #24047
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
base: main
Are you sure you want to change the base?
Changes from all commits
972ac63
6a2e352
877b546
a1f109b
12f8d04
c88c3db
840bcc5
122f0d4
ae68a4a
e973f95
a845aee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| export type DialogState = { | ||
| reschedule: boolean; | ||
| reassign: boolean; | ||
| editLocation: boolean; | ||
| addGuests: boolean; | ||
| chargeCard: boolean; | ||
| viewRecordings: boolean; | ||
| meetingSessionDetails: boolean; | ||
| noShowAttendees: boolean; | ||
| rejection: boolean; | ||
| reroute: boolean; | ||
| }; | ||
|
|
||
| export function useBookingItemState() { | ||
| const [rejectionReason, setRejectionReason] = useState<string>(""); | ||
| const [dialogState, setDialogState] = useState<DialogState>({ | ||
| reschedule: false, | ||
| reassign: false, | ||
| editLocation: false, | ||
| addGuests: false, | ||
| chargeCard: false, | ||
| viewRecordings: false, | ||
| meetingSessionDetails: false, | ||
| noShowAttendees: false, | ||
| rejection: false, | ||
| reroute: false, | ||
| }); | ||
|
|
||
| const openDialog = (dialog: keyof DialogState) => { | ||
| setDialogState((prevState) => ({ | ||
| ...prevState, | ||
| [dialog]: true, | ||
| })); | ||
| }; | ||
|
|
||
| const closeDialog = (dialog: keyof DialogState) => { | ||
| setDialogState((prevState) => ({ | ||
| ...prevState, | ||
| [dialog]: false, | ||
| })); | ||
| }; | ||
|
|
||
| const toggleDialog = (dialog: keyof DialogState) => { | ||
| setDialogState((prevState) => ({ | ||
| ...prevState, | ||
| [dialog]: !prevState[dialog], | ||
| })); | ||
| }; | ||
|
|
||
| // Helper function to reset all dialogs (useful when one action should close others) | ||
| const resetDialogs = () => { | ||
| setDialogState({ | ||
| reschedule: false, | ||
| reassign: false, | ||
| editLocation: false, | ||
| addGuests: false, | ||
| chargeCard: false, | ||
| viewRecordings: false, | ||
| meetingSessionDetails: false, | ||
| noShowAttendees: false, | ||
| rejection: false, | ||
| reroute: false, | ||
| }); | ||
| }; | ||
|
|
||
| return { | ||
| dialogState, | ||
| openDialog, | ||
| closeDialog, | ||
| toggleDialog, | ||
| resetDialogs, | ||
| rejectionReason, | ||
| setRejectionReason, | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ DialogOverlay.displayName = DialogPrimitives.Overlay.displayName; | |
|
|
||
| const DialogContent = React.forwardRef< | ||
| React.ElementRef<typeof DialogPrimitives.Content>, | ||
| React.ComponentPropsWithoutRef<typeof DialogPrimitives.Content> | ||
| React.ComponentPropsWithoutRef<typeof DialogPrimitives.Content> & { enableOverflow?: boolean } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding enableOverflow to the public props but leaving the signature as ({ className, children, ...props }) forwards the flag straight to DialogPrimitives.Content without any handling, so consumers get neither overflow behavior nor a safe DOM attribute. Please implement the overflow behavior (or strip the prop) before exposing it. Prompt for AI agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the enableOverflow prop without consuming it breaks parity with the existing DialogContent—dialogs that previously scrolled now overflow because the prop is forwarded instead of toggling overflow classes. Please handle enableOverflow in the atoms implementation the same way as before (e.g., toggle overflow-y-auto) or drop the prop entirely. Prompt for AI agents |
||
| >(({ className, children, ...props }, ref) => ( | ||
| <> | ||
| <DialogPortal> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RerouteDialogsetter ignores the boolean param.Align with other dialogs to handle both open and close paths.
📝 Committable suggestion
🤖 Prompt for AI Agents