@@ -3,32 +3,25 @@ import bitsFetch from '../../../Utils/bitsFetch'
33import { deepCopy } from '../../../Utils/Helpers'
44import { 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
2619export 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
5144export 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
7669export 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