-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Copy ID / Delete functionality to My Queries page (#202)
Co-authored-by: fzhao99 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
32b4596
commit 541172a
Showing
11 changed files
with
392 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
query-connector/src/app/query/designSystem/modal/deleteModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { RefObject } from "react"; | ||
import { Modal, ModalRef } from "@/app/query/designSystem/modal/Modal"; | ||
|
||
interface DeleteModalProps { | ||
modalRef: RefObject<ModalRef>; | ||
heading: string; | ||
description: string; | ||
onDelete: () => void; | ||
onCancel?: () => void; | ||
additionalProps?: Record<string, unknown>; // Additional props for extensibility | ||
} | ||
|
||
/** | ||
* DeleteModal component with default Delete and Cancel buttons. | ||
* @param root0 - The DeleteModal props object. | ||
* @param root0.modalRef - Reference to the modal component. | ||
* @param root0.heading - The heading/title text for the modal. | ||
* @param root0.description - The descriptive text explaining the modal's purpose. | ||
* @param root0.onDelete - Callback function to execute when the Delete button is clicked. | ||
* @param root0.onCancel - Optional callback function to execute when the Cancel button is clicked. | ||
* @param root0.additionalProps - Optional additional props to pass to the Modal component, such as a custom ID. | ||
* @returns The JSX element for the DeleteModal component. | ||
*/ | ||
export const DeleteModal: React.FC<DeleteModalProps> = ({ | ||
modalRef, | ||
heading, | ||
description, | ||
onDelete, | ||
onCancel, | ||
additionalProps = {}, | ||
}) => { | ||
return ( | ||
<Modal | ||
id="delete-confirmation-modal" | ||
modalRef={modalRef} | ||
heading={heading} | ||
description={description} | ||
buttons={[ | ||
{ | ||
text: "Delete", | ||
type: "button", | ||
className: "usa-button--secondary", | ||
onClick: () => { | ||
onDelete(); | ||
modalRef.current?.toggleModal(); | ||
}, | ||
}, | ||
{ | ||
text: "Cancel", | ||
type: "button", | ||
className: "usa-button--outline", | ||
onClick: () => { | ||
if (onCancel) onCancel(); | ||
modalRef.current?.toggleModal(); | ||
}, | ||
}, | ||
]} | ||
{...additionalProps} | ||
/> | ||
); | ||
}; | ||
|
||
export default DeleteModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.