Skip to content

Commit 951cd6a

Browse files
committed
fix: mailMint integrations name edit issue
1 parent 4c5b155 commit 951cd6a

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

frontend-dev/src/components/AllIntegrations/MailMint/EditMailMint.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function EditMailMint({ allIntegURL }) {
2222
const formFields = useRecoilValue($formFields)
2323
const [isLoading, setIsLoading] = useState(false)
2424
const [snack, setSnackbar] = useState({ show: false })
25+
const [name, setName] = useState(mailMintConf?.name || '')
2526

2627
const saveConfig = () => {
2728
if (!checkMappedFields(mailMintConf)) {
@@ -59,9 +60,12 @@ function EditMailMint({ allIntegURL }) {
5960
<b className="wdt-200 d-in-b">{__('Integration Name:', 'bit-integrations')}</b>
6061
<input
6162
className="btcd-paper-inp w-5"
62-
onChange={e => handleInput(e, mailMintConf, setMailMintConf)}
63+
onChange={e => {
64+
setName(e.target.value)
65+
handleInput(e, mailMintConf, setMailMintConf, setIsLoading, setSnackbar)
66+
}}
6367
name="name"
64-
value={mailMintConf.name}
68+
value={name}
6569
type="text"
6670
placeholder={__('Integration Name...', 'bit-integrations')}
6771
/>

frontend-dev/src/components/AllIntegrations/MailMint/MailMintCommonFunc.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@ import bitsFetch from '../../../Utils/bitsFetch'
33
import { deepCopy } from '../../../Utils/Helpers'
44
import { sprintf, __ } from '../../../Utils/i18nwrap'
55

6-
export const handleInput = (
7-
e,
8-
mailMintConf,
9-
setMailMintConf,
10-
setIsLoading,
11-
setSnackbar,
12-
formID
13-
) => {
6+
export const handleInput = (e, mailMintConf, setMailMintConf, setIsLoading, setSnackbar, formID) => {
147
const newConf = { ...mailMintConf }
15-
const { name } = e.target
16-
if (e.target.value !== '') {
17-
newConf[name] = e.target.value
8+
const { name, value } = e.target
9+
10+
newConf[name] = value
11+
12+
if (name === 'mainAction' && value !== '') {
1813
mailMintRefreshFields(newConf, setMailMintConf, setIsLoading, setSnackbar)
19-
} else {
20-
delete newConf[name]
2114
}
22-
newConf[e.target.name] = e.target.value
15+
2316
setMailMintConf({ ...newConf })
2417
}
2518

2619
export const mailMintRefreshFields = (mailMintConf, setMailMintConf, setIsLoading, setSnackbar) => {
2720
setIsLoading(true)
2821
bitsFetch(null, 'fetch_all_mail_mint_custom_fields')
29-
.then((result) => {
22+
.then(result => {
3023
if (result && result.success) {
31-
setMailMintConf((oldConf) => {
24+
setMailMintConf(oldConf => {
3225
const newConf = { ...oldConf }
3326
if (!newConf.default) {
3427
newConf.default = {}
@@ -51,9 +44,9 @@ export const mailMintRefreshFields = (mailMintConf, setMailMintConf, setIsLoadin
5144
export const getAllList = (mailMintConf, setMailMintConf, setIsLoading, setSnackbar) => {
5245
setIsLoading(true)
5346
bitsFetch(null, 'fetch_all_mail_mint_list')
54-
.then((result) => {
47+
.then(result => {
5548
if (result && result.success) {
56-
setMailMintConf((oldConf) => {
49+
setMailMintConf(oldConf => {
5750
const newConf = { ...oldConf }
5851
if (!newConf.default) {
5952
newConf.default = {}
@@ -76,9 +69,9 @@ export const getAllList = (mailMintConf, setMailMintConf, setIsLoading, setSnack
7669
export const getAllTags = (mailMintConf, setMailMintConf, setIsLoading, setSnackbar) => {
7770
setIsLoading(true)
7871
bitsFetch(null, 'fetch_all_mail_mint_tags')
79-
.then((result) => {
72+
.then(result => {
8073
if (result && result.success) {
81-
setMailMintConf((oldConf) => {
74+
setMailMintConf(oldConf => {
8275
const newConf = { ...oldConf }
8376
if (!newConf.default) {
8477
newConf.default = {}
@@ -98,16 +91,16 @@ export const getAllTags = (mailMintConf, setMailMintConf, setIsLoading, setSnack
9891
.catch(() => setIsLoading(false))
9992
}
10093

101-
export const generateMappedField = (mailMintConf) => {
102-
const requiredFlds = mailMintConf?.mailMintContactFields.filter((fld) => fld.required === true)
94+
export const generateMappedField = mailMintConf => {
95+
const requiredFlds = mailMintConf?.mailMintContactFields.filter(fld => fld.required === true)
10396
return requiredFlds.length > 0
104-
? requiredFlds.map((field) => ({ formField: '', mailMintFormField: field.key }))
97+
? requiredFlds.map(field => ({ formField: '', mailMintFormField: field.key }))
10598
: [{ formField: '', mailMintFormField: '' }]
10699
}
107100

108-
export const checkMappedFields = (mailMintConf) => {
101+
export const checkMappedFields = mailMintConf => {
109102
const mappedFleld = mailMintConf.field_map
110-
? mailMintConf.field_map.filter((mapped) => !mapped.formField && !mapped.mailMintFormField)
103+
? mailMintConf.field_map.filter(mapped => !mapped.formField && !mapped.mailMintFormField)
111104
: []
112105
if (mappedFleld.length > 0) {
113106
return false

0 commit comments

Comments
 (0)