|
1 | | -import React, { useEffect, useState } from 'react'; |
| 1 | +import React from 'react'; |
2 | 2 |
|
3 | 3 | import { Checkbox } from '@leafygreen-ui/checkbox'; |
4 | 4 | import { css } from '@leafygreen-ui/emotion'; |
5 | 5 | import { spacing } from '@leafygreen-ui/tokens'; |
6 | 6 | import { Body, Description, H3, Link } from '@leafygreen-ui/typography'; |
7 | 7 |
|
8 | | -import { useWizardStepContext } from '../'; |
9 | | - |
| 8 | +import { useRequiredActionAcknowledgements } from './hooks/useRequiredActionAcknowledgements'; |
10 | 9 | import { |
11 | 10 | ApplicationsCard, |
12 | 11 | ClustersCard, |
@@ -40,17 +39,8 @@ const sectionDividerStyles = css` |
40 | 39 | `; |
41 | 40 |
|
42 | 41 | export const RequiredActions = () => { |
43 | | - const { setAcknowledged } = useWizardStepContext(); |
44 | | - |
45 | | - const [checkbox1, setCheckbox1] = useState(false); |
46 | | - const [checkbox2, setCheckbox2] = useState(false); |
47 | | - const [checkbox3, setCheckbox3] = useState(false); |
48 | | - |
49 | | - // TODO: reducer. Update the wizard step's acknowledged state when all checkboxes are checked |
50 | | - useEffect(() => { |
51 | | - const allChecked = checkbox1 && checkbox2 && checkbox3; |
52 | | - setAcknowledged(allChecked); |
53 | | - }, [checkbox1, checkbox2, checkbox3, setAcknowledged]); |
| 42 | + const { acknowledgementsState, setAcknowledgementState } = |
| 43 | + useRequiredActionAcknowledgements(); |
54 | 44 |
|
55 | 45 | return ( |
56 | 46 | <> |
@@ -81,24 +71,24 @@ export const RequiredActions = () => { |
81 | 71 | label="Permanently deletes all project data, including clusters, configurations, services, app services and triggers, and data across Atlas, which cannot be recovered." |
82 | 72 | description="All project data including clusters, configurations, services, backup snapshots, app data, search indexes, federated database access, and Stream Processors will be permanently deleted. Deleted data cannot be recovered." |
83 | 73 | bold |
84 | | - checked={checkbox1} |
85 | | - onChange={e => setCheckbox1(e.target.checked)} |
| 74 | + checked={acknowledgementsState[0]} |
| 75 | + onChange={e => setAcknowledgementState(0, e.target.checked)} |
86 | 76 | /> |
87 | 77 |
|
88 | 78 | <Checkbox |
89 | 79 | label="Overrides Termination Protection, deletes archives, backup snapshots, Stream Processors, and Connections, stops all data processing." |
90 | 80 | description="Termination Protection will be disabled for all clusters. While archive data in object storage will remain recoverable for up to 5 days, online archives and backup snapshots will be deleted immediately. Stream Processors and Connections will be permanently deleted. Data processing will stop immediately." |
91 | 81 | bold |
92 | | - checked={checkbox2} |
93 | | - onChange={e => setCheckbox2(e.target.checked)} |
| 82 | + checked={acknowledgementsState[1]} |
| 83 | + onChange={e => setAcknowledgementState(1, e.target.checked)} |
94 | 84 | /> |
95 | 85 |
|
96 | 86 | <Checkbox |
97 | 87 | label="Revokes access to federated databases, disables communication with Atlas clusters, and may disrupt application functionality." |
98 | 88 | description="Access to federated database instances for dependent applications or services will be revoked, and communication between my application and the Atlas cluster or services will be disabled, which may cause functionality disruptions. I confirm that I have taken necessary measures to ensure uninterrupted access and mitigate impact." |
99 | 89 | bold |
100 | | - checked={checkbox3} |
101 | | - onChange={e => setCheckbox3(e.target.checked)} |
| 90 | + checked={acknowledgementsState[2]} |
| 91 | + onChange={e => setAcknowledgementState(2, e.target.checked)} |
102 | 92 | /> |
103 | 93 | </div> |
104 | 94 | </> |
|
0 commit comments