Skip to content

Commit d555d60

Browse files
committed
fix: mailerLite update utilities checkbox issue
1 parent 6cb14e9 commit d555d60

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

frontend-dev/src/components/AllIntegrations/MailerLite/MailerLiteActions.jsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,30 @@ import ConfirmModal from '../../Utilities/ConfirmModal'
99
import TableCheckBox from '../../Utilities/TableCheckBox'
1010
import 'react-multiple-select-dropdown-lite/dist/index.css'
1111
import { getAllGroups } from './MailerLiteCommonFunc'
12+
import { create } from 'mutative'
1213

1314
export default function MailerLiteActions({ mailerLiteConf, setMailerLiteConf, loading, setLoading }) {
1415
const [actionMdl, setActionMdl] = useState({ show: false, action: () => {} })
1516

1617
const actionHandler = (e, type) => {
17-
const newConf = { ...mailerLiteConf }
18-
1918
if (type === 'group') {
2019
getAllGroups(mailerLiteConf, setMailerLiteConf, loading, setLoading)
2120
}
2221

23-
if (e.target.checked) {
24-
newConf.actions[type] = true
25-
} else {
26-
delete newConf.actions[type]
27-
}
28-
2922
setActionMdl({ show: type })
30-
setMailerLiteConf({ ...newConf })
23+
setMailerLiteConf(prevConf =>
24+
create(prevConf, draftConf => {
25+
draftConf.actions = { ...(draftConf.actions || {}) }
26+
27+
if (e.target.checked) {
28+
draftConf.actions[type] = true
29+
} else {
30+
delete draftConf.actions[type]
31+
}
32+
})
33+
)
3134
}
35+
3236
const clsActionMdl = () => {
3337
setActionMdl({ show: false })
3438
}

0 commit comments

Comments
 (0)