-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAddOn.jsx
36 lines (31 loc) · 903 Bytes
/
AddOn.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { useDispatch, useSelector } from "react-redux";
import { addRemoveAddon } from "./formSlice";
import ExtentionWrapper from "../ui/ExtentionWrapper";
function AddOn({ id, name, description, costs }) {
const dispatch = useDispatch();
const { isYearly, addOns } = useSelector((state) => state.form);
const cost = isYearly ? `${costs.yearly}/yr` : `${costs.monthly}/mo`;
const isAdded = addOns.includes(id);
function handleToggleAddon() {
dispatch(addRemoveAddon(id));
}
return (
<ExtentionWrapper>
<input
type="checkbox"
name="onlineService"
id={name}
checked={isAdded}
onChange={() => handleToggleAddon()}
/>
<label htmlFor={name}>
<span>
<h3>{name}</h3>
<p>{description}</p>
</span>
<p>+${cost}</p>
</label>
</ExtentionWrapper>
);
}
export default AddOn;