-
Notifications
You must be signed in to change notification settings - Fork 1
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 #421 from trilitech/update-batch-page
Update batch page
- Loading branch information
Showing
31 changed files
with
934 additions
and
484 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { fireEvent, render, screen } from "../mocks/testUtils"; | ||
import { ConfirmationModal } from "./ConfirmationModal"; | ||
|
||
describe("<ConfirmationModal />", () => { | ||
it("shows title", () => { | ||
render(<ConfirmationModal title="Some title" buttonLabel="test" onSubmit={jest.fn()} />); | ||
expect(screen.getByRole("heading")).toHaveTextContent("Some title"); | ||
}); | ||
|
||
it("shows description", () => { | ||
render( | ||
<ConfirmationModal | ||
title="Some title" | ||
description="Some description" | ||
buttonLabel="test" | ||
onSubmit={jest.fn()} | ||
/> | ||
); | ||
expect(screen.getByTestId("description")).toHaveTextContent("Some description"); | ||
}); | ||
|
||
it("doesn't render body if no description is provided", () => { | ||
render(<ConfirmationModal title="Some title" buttonLabel="test" onSubmit={jest.fn()} />); | ||
expect(screen.queryByTestId("description")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("executes the passed in onSubmit callback", () => { | ||
const onSubmit = jest.fn(); | ||
render( | ||
<ConfirmationModal title="Some title" buttonLabel="Do dangerous things" onSubmit={onSubmit} /> | ||
); | ||
const submitButton = screen.getByRole("button", { name: "Do dangerous things" }); | ||
expect(submitButton).toBeInTheDocument(); | ||
|
||
fireEvent.click(submitButton); | ||
expect(onSubmit).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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 { | ||
Box, | ||
Button, | ||
Heading, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import { useContext } from "react"; | ||
import { DynamicModalContext } from "./DynamicModal"; | ||
import WarningIcon from "../assets/icons/Warning"; | ||
import colors from "../style/colors"; | ||
|
||
export const ConfirmationModal: React.FC<{ | ||
title: string; | ||
buttonLabel: string; | ||
description?: string; | ||
onSubmit: () => void; | ||
}> = ({ title, description, buttonLabel, onSubmit }) => { | ||
const { onClose } = useContext(DynamicModalContext); | ||
const onClick = () => { | ||
onSubmit(); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<ModalContent> | ||
<ModalHeader textAlign="center"> | ||
<Box> | ||
<WarningIcon w="40px" h="40px" mb="16px" /> | ||
</Box> | ||
<Heading>{title}</Heading> | ||
<ModalCloseButton /> | ||
</ModalHeader> | ||
{description && ( | ||
<ModalBody> | ||
<Text align="center" color={colors.gray[400]} data-testid="description"> | ||
{description} | ||
</Text> | ||
</ModalBody> | ||
)} | ||
<ModalFooter> | ||
<Button w="100%" onClick={onClick} variant="warning"> | ||
{buttonLabel} | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
); | ||
}; |
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
Oops, something went wrong.