Skip to content

Commit fbcafd9

Browse files
chore: update changes
1 parent 3fd5dc0 commit fbcafd9

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

frontend-dev/src/components/AllIntegrations/Line/Line.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function Line({ formFields, setFlow, flow, allIntegURL }) {
6464
}
6565
}, 300)
6666

67-
if (val === 3 && !isNextButtonEnabled()) {
67+
if (val === 3 && (lineConf?.name || isNextButtonEnabled())) {
6868
const messages = getLineValidationMessages(lineConf)
6969
setSnackbar({
7070
show: true,
@@ -76,13 +76,7 @@ function Line({ formFields, setFlow, flow, allIntegURL }) {
7676
return
7777
}
7878

79-
if (lineConf?.name && isNextButtonEnabled()) {
80-
setstep(val)
81-
}
82-
83-
if (val !== 3) {
84-
return
85-
}
79+
setstep(val)
8680
}
8781

8882
const isNextButtonEnabled = () => {

frontend-dev/src/components/AllIntegrations/Line/LineCommonFunc.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const handleAuthorize = async (
2323
setError({})
2424
setIsLoading(true)
2525

26+
setIsLoading(true)
27+
2628
try {
2729
const result = await bitsFetch({ accessToken: confTmp.accessToken }, 'line_authorization')
2830

@@ -31,21 +33,31 @@ export const handleAuthorize = async (
3133
setisAuthorized(true)
3234
setSnackbar({ show: true, msg: __('Authorized Successfully', 'bit-integrations') })
3335
} else {
34-
const msg =
35-
result?.data?.data || (!result.success && typeof result.data === 'string')
36-
? `${__('Authorization failed Cause:', 'bit-integrations')}${result.data?.data || result.data}. ${__('please try again', 'bit-integrations')}`
37-
: __('Authorization failed. please try again', 'bit-integrations')
36+
const msg = result?.data?.data
37+
? `${__('Authorization failed Cause:', 'bit-integrations')} ${result.data.data}. ${__('Please try again', 'bit-integrations')}`
38+
: typeof result?.data === 'string'
39+
? `${__('Authorization failed Cause:', 'bit-integrations')} ${result.data}. ${__('Please try again', 'bit-integrations')}`
40+
: __('Authorization failed. Please try again', 'bit-integrations')
3841

3942
setSnackbar({ show: true, msg })
4043
}
41-
} finally {
44+
45+
setIsLoading(false)
46+
} catch (error) {
47+
setSnackbar({
48+
show: true,
49+
msg: `${__('An error occurred during authorization:', 'bit-integrations')} ${error?.message || error}`
50+
})
51+
4252
setIsLoading(false)
4353
}
4454
}
4555

4656
const updateFieldMap = (prevConf, type, index, updater) => {
4757
const newConf = { ...prevConf }
58+
4859
if (!Array.isArray(newConf[type])) newConf[type] = []
60+
4961
if (!newConf[type][index]) newConf[type][index] = {}
5062
newConf[type][index] = { ...newConf[type][index], ...updater(newConf[type][index]) }
5163
return newConf
@@ -68,6 +80,7 @@ export const handleCustomValue = (event, index, _, setConf, type) => {
6880
export const delFieldMap = (index, _, setConf, type) => {
6981
setConf(prev => {
7082
const fieldMap = prev[type] || []
83+
7184
if (fieldMap.length <= 1) return prev
7285

7386
const updatedFieldMap = fieldMap[index]?.groupId
@@ -88,6 +101,7 @@ export const addFieldMap = (i, confTmp, setConf, FieldMappings, mapKey) => {
88101

89102
setConf(prev => {
90103
const newConf = { ...prev }
104+
91105
if (!Array.isArray(newConf[mapKey])) newConf[mapKey] = []
92106
newConf[mapKey].splice(i, 0, ...newFieldMap)
93107
return newConf
@@ -148,11 +162,13 @@ export const getLineValidationMessages = lineConf => {
148162
case 'sendPushMessage':
149163
if (!lineConf.recipientId?.trim())
150164
messages.push(__('Recipient ID is required', 'bit-integrations'))
165+
151166
if (!isMessageFieldConfigured(lineConf))
152167
messages.push(__('Message field mapping is required', 'bit-integrations'))
153168
break
154169
case 'sendReplyMessage':
155170
if (!lineConf.replyToken?.trim()) messages.push(__('Reply Token is required', 'bit-integrations'))
171+
156172
if (!isMessageFieldConfigured(lineConf))
157173
messages.push(__('Message field mapping is required', 'bit-integrations'))
158174
break

0 commit comments

Comments
 (0)