Skip to content

Instantly share code, notes, and snippets.

@SatyaAchanta
Created December 25, 2022 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SatyaAchanta/30068482a1ca91fdd872574ab900acf5 to your computer and use it in GitHub Desktop.
Save SatyaAchanta/30068482a1ca91fdd872574ab900acf5 to your computer and use it in GitHub Desktop.
SummaryForm component
import React, { useState } from "react";
import Form from "react-bootstrap/Form";
import Button from "react-bootstrap/Button";
import OverlayTrigger from "react-bootstrap/OverlayTrigger";
import Popover from "react-bootstrap/Popover";
export default function SummaryForm() {
const [tcChecked, setTcChecked] = useState(false);
const popover = (
<Popover id="popover-basic">
<Popover.Body>No ice cream will actually be delivered</Popover.Body>
</Popover>
);
const checkboxLabel = (
<span>
I agree to{" "}
<OverlayTrigger trigger="click" placement="right" overlay={popover}>
<span style={{ color: "blue" }}>Terms and Conditions</span>
</OverlayTrigger>
</span>
);
return (
<Form>
<Form.Group controlId="terms-and-conditions">
<Form.Check
type="checkbox"
checked={tcChecked}
onChange={(e) => setTcChecked(e.target.checked)}
label={checkboxLabel}
/>
</Form.Group>
<Button variant="primary" type="submit" disabled={!tcChecked}>
Confirm order
</Button>
</Form>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment