-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from UgnisSoftware/UGN-252
Feature UGN-252 show alert when submitting with errors
- Loading branch information
Showing
9 changed files
with
99 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { | ||
AlertDialog, | ||
AlertDialogBody, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogContent, | ||
AlertDialogOverlay, | ||
Button, | ||
} from "@chakra-ui/react" | ||
import { useRef } from "react" | ||
import { useRsi } from "../../hooks/useRsi" | ||
|
||
interface Props { | ||
isOpen: boolean | ||
onClose: () => void | ||
onConfirm: () => void | ||
} | ||
|
||
const SUBMIT_HEADER_TITLE = "Errors detected" | ||
const SUBMIT_BODY_TEXT = | ||
"There are still some rows that contain errors. Rows with errors will be ignored when submitting." | ||
const SUBMIT_FORBIDDEN_BODY_TEXT = "There are still some rows containing errors." | ||
const CANCEL_BUTTON = "Cancel" | ||
const FINISH_BUTTON = "Submit" | ||
|
||
export const SubmitDataAlert = ({ isOpen, onClose, onConfirm }: Props) => { | ||
const { allowInvalidSubmit } = useRsi() | ||
const cancelRef = useRef<HTMLButtonElement | null>(null) | ||
|
||
return ( | ||
<AlertDialog isOpen={isOpen} onClose={onClose} leastDestructiveRef={cancelRef} isCentered id="rsi"> | ||
<AlertDialogOverlay> | ||
<AlertDialogContent> | ||
<AlertDialogHeader fontSize="lg" fontWeight="bold"> | ||
{SUBMIT_HEADER_TITLE} | ||
</AlertDialogHeader> | ||
<AlertDialogBody>{allowInvalidSubmit ? SUBMIT_BODY_TEXT : SUBMIT_FORBIDDEN_BODY_TEXT}</AlertDialogBody> | ||
<AlertDialogFooter> | ||
<Button ref={cancelRef} onClick={onClose} variant="secondary"> | ||
{CANCEL_BUTTON} | ||
</Button> | ||
{allowInvalidSubmit && ( | ||
<Button onClick={onConfirm} ml={3}> | ||
{FINISH_BUTTON} | ||
</Button> | ||
)} | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialogOverlay> | ||
</AlertDialog> | ||
) | ||
} |
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
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