@controleonline/ui-common 1.2.133 → 1.2.135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release/rc-manifest.json +12 -6
- package/package.json +1 -1
- package/src/react/components/CategoryForm.js +539 -539
- package/src/react/components/DefaultProvider.native.js +2 -2
- package/src/react/components/DefaultProvider.web.js +2 -2
- package/src/react/components/integrations/IntegrationHero/index.js +1 -1
- package/src/react/components/integrations/IntegrationHero/styles.js +2 -2
- package/src/react/components/integrations/IntegrationTabs/index.js +1 -1
- package/src/react/components/integrations/IntegrationTabs/styles.js +1 -1
- package/src/react/pages/Connections.styles.js +72 -72
- package/src/react/pages/Devices/detail/DeviceDetailHeader.js +1 -1
- package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +1 -1
- package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +2 -2
- package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +2 -2
- package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +1 -1
- package/src/react/pages/Devices/deviceTypes/shared.js +2 -2
- package/src/react/pages/Devices.js +2 -2
- package/src/react/pages/Devices.styles.js +353 -353
- package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -219
- package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -134
- package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -173
- package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +1 -1
- package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -306
- package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -417
- package/src/react/pages/Food99IntegrationPage/index.js +1530 -1530
- package/src/react/pages/Food99IntegrationPage/styles.js +792 -792
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +267 -267
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -118
- package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +101 -101
- package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -150
- package/src/react/pages/IFoodIntegrationPage/index.js +1298 -1298
- package/src/react/pages/Imports.js +1 -1
- package/src/react/pages/Imports.styles.js +223 -223
- package/src/react/pages/IntegrationConfigPage.js +2 -2
- package/src/react/pages/Integrations.js +2 -15
- package/src/react/pages/Integrations.styles.js +130 -130
- package/src/react/pages/LinkedInIntegrationPage.js +2 -2
- package/src/react/pages/ManagerOrderNotificationsPage.js +642 -642
- package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -205
- package/src/react/pages/MercadoLivreIntegrationPage.js +2 -2
- package/src/react/pages/PrinterDeviceDetailPage.js +1915 -1915
- package/src/react/pages/PrinterDeviceFormPage.js +2 -2
- package/src/react/pages/WhatsAppConnectionPage.js +51 -0
- package/src/react/pages/WhatsAppConnectionPage.styles.js +315 -279
- package/src/react/pages/WhatsAppProviderForm.js +39 -1
- package/src/react/pages/whatsAppConnectionHelpers.js +38 -10
- package/src/react/pages/whatsAppEmbeddedSignup.js +133 -0
- package/src/react/router/__tests__/publicRoutes.test.js +12 -0
- package/src/react/router/publicRoutes.js +3 -0
- package/src/react/utils/fileUrl.js +1 -1
- package/src/store/connections/customActions.js +51 -14
- package/src/store/connections/index.js +109 -105
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ActivityIndicator, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import Icon from 'react-native-vector-icons/Feather';
|
|
4
|
-
import { withOpacity } from '@controleonline
|
|
4
|
+
import { withOpacity } from '@controleonline/ui-layout/src/styles/branding';
|
|
5
5
|
import { PROVIDER_OFFICIAL, PROVIDER_UNOFFICIAL } from './whatsAppConnectionHelpers';
|
|
6
6
|
|
|
7
7
|
export default function WhatsAppProviderForm({
|
|
@@ -17,6 +17,8 @@ export default function WhatsAppProviderForm({
|
|
|
17
17
|
setApiVersion,
|
|
18
18
|
submitting,
|
|
19
19
|
onPrimaryAction,
|
|
20
|
+
embeddedSignupAvailable,
|
|
21
|
+
onEmbeddedSignup,
|
|
20
22
|
}) {
|
|
21
23
|
return (
|
|
22
24
|
<>
|
|
@@ -50,6 +52,42 @@ export default function WhatsAppProviderForm({
|
|
|
50
52
|
</TouchableOpacity>
|
|
51
53
|
</View>
|
|
52
54
|
|
|
55
|
+
{providerMode === PROVIDER_OFFICIAL && embeddedSignupAvailable ? (
|
|
56
|
+
<View style={{ marginBottom: 12 }}>
|
|
57
|
+
<Text style={styles.inputLabel}>Conectar pelo Facebook</Text>
|
|
58
|
+
{[
|
|
59
|
+
[true, 'Numero do app WhatsApp Business', 'smartphone', 'Continua no celular; autorize pelo QR Code no app.'],
|
|
60
|
+
[false, 'Numero novo', 'plus-circle', 'O Meta verifica o numero por SMS ou ligacao.'],
|
|
61
|
+
].map(([coexistence, label, icon, hint]) => (
|
|
62
|
+
<TouchableOpacity
|
|
63
|
+
key={label}
|
|
64
|
+
activeOpacity={0.9}
|
|
65
|
+
disabled={submitting}
|
|
66
|
+
onPress={() => onEmbeddedSignup(coexistence)}
|
|
67
|
+
style={{
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
gap: 10,
|
|
71
|
+
borderWidth: 1,
|
|
72
|
+
borderColor: withOpacity('#1877F2', 0.35),
|
|
73
|
+
backgroundColor: withOpacity('#1877F2', 0.06),
|
|
74
|
+
borderRadius: 12,
|
|
75
|
+
padding: 12,
|
|
76
|
+
marginTop: 8,
|
|
77
|
+
opacity: submitting ? 0.6 : 1,
|
|
78
|
+
}}>
|
|
79
|
+
<Icon name={icon} size={18} color="#1877F2" />
|
|
80
|
+
<View style={{ flex: 1 }}>
|
|
81
|
+
<Text style={{ color: '#0F172A', fontWeight: '600' }}>{label}</Text>
|
|
82
|
+
<Text style={{ color: '#64748B', fontSize: 12 }}>{hint}</Text>
|
|
83
|
+
</View>
|
|
84
|
+
<Icon name="chevron-right" size={18} color="#1877F2" />
|
|
85
|
+
</TouchableOpacity>
|
|
86
|
+
))}
|
|
87
|
+
<Text style={[styles.inputLabel, { marginTop: 16 }]}>Ou informe manualmente</Text>
|
|
88
|
+
</View>
|
|
89
|
+
) : null}
|
|
90
|
+
|
|
53
91
|
{providerMode === PROVIDER_OFFICIAL ? (
|
|
54
92
|
<View style={{ marginBottom: 12 }}>
|
|
55
93
|
<Text style={styles.inputLabel}>Access token (Meta)</Text>
|
|
@@ -19,6 +19,29 @@ export const formatPhoneLabel = phone => {
|
|
|
19
19
|
return ddd ? `(${ddd}) ${firstPart}-${lastFour}` : `${firstPart}-${lastFour}`;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const resolveStatusIri = status => {
|
|
23
|
+
if (!status) return null;
|
|
24
|
+
if (typeof status === 'string') {
|
|
25
|
+
if (status.startsWith('/') || status.startsWith('http')) return status;
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (typeof status === 'object') {
|
|
29
|
+
const iri = status['@id'] || status.id;
|
|
30
|
+
if (iri == null) return null;
|
|
31
|
+
const asString = String(iri);
|
|
32
|
+
if (asString.startsWith('/') || asString.startsWith('http')) return asString;
|
|
33
|
+
return `/statuses/${asString}`;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const resolveNumericId = item => {
|
|
39
|
+
const raw = item?.id ?? item?.['@id'];
|
|
40
|
+
if (raw == null) return null;
|
|
41
|
+
const digits = String(raw).replace(/\D/g, '');
|
|
42
|
+
return digits ? Number(digits) : null;
|
|
43
|
+
};
|
|
44
|
+
|
|
22
45
|
export const normalizeConnection = item => {
|
|
23
46
|
const channel =
|
|
24
47
|
item?.channel === CHANNEL_WHATSAPP_OFFICIAL
|
|
@@ -26,15 +49,18 @@ export const normalizeConnection = item => {
|
|
|
26
49
|
: CHANNEL_WHATSAPP;
|
|
27
50
|
return {
|
|
28
51
|
id: item?.id || item?.['@id'] || `connection-${Math.random()}`,
|
|
52
|
+
numericId: resolveNumericId(item),
|
|
29
53
|
name: item?.name || 'Sem nome',
|
|
30
|
-
status:
|
|
54
|
+
status:
|
|
55
|
+
(typeof item?.status === 'object'
|
|
56
|
+
? item?.status?.status || item?.status?.name
|
|
57
|
+
: item?.status) || 'Pendente',
|
|
58
|
+
statusIri: resolveStatusIri(item?.status),
|
|
31
59
|
type: item?.type || 'Nenhum',
|
|
32
60
|
channel,
|
|
33
|
-
|
|
34
|
-
provider: channel === CHANNEL_WHATSAPP_OFFICIAL ? CHANNEL_WHATSAPP_OFFICIAL : CHANNEL_WHATSAPP,
|
|
61
|
+
provider: channel,
|
|
35
62
|
phone: item?.phone || {},
|
|
36
63
|
phoneLabel: formatPhoneLabel(item?.phone),
|
|
37
|
-
channelConfig: item?.channelConfig || item?.channel_config || null,
|
|
38
64
|
};
|
|
39
65
|
};
|
|
40
66
|
|
|
@@ -48,10 +74,18 @@ export const toArray = response => {
|
|
|
48
74
|
export const formatApiError = error => {
|
|
49
75
|
if (!error) return 'Nao foi possivel concluir a operacao.';
|
|
50
76
|
if (typeof error === 'string') return error;
|
|
77
|
+
const violations = error?.violations || error?.data?.violations;
|
|
78
|
+
if (Array.isArray(violations) && violations.length) {
|
|
79
|
+
return violations
|
|
80
|
+
.map(v => v?.message || v?.propertyPath)
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
.join(' · ');
|
|
83
|
+
}
|
|
51
84
|
return (
|
|
52
85
|
error?.message ||
|
|
53
86
|
error?.description ||
|
|
54
87
|
error?.errmsg ||
|
|
88
|
+
error?.hydra?.description ||
|
|
55
89
|
'Nao foi possivel concluir a operacao.'
|
|
56
90
|
);
|
|
57
91
|
};
|
|
@@ -69,9 +103,3 @@ export const buildOfficialChannelConfig = ({
|
|
|
69
103
|
if (version) config.api_version = version;
|
|
70
104
|
return config;
|
|
71
105
|
};
|
|
72
|
-
|
|
73
|
-
export const maskToken = token => {
|
|
74
|
-
const value = String(token || '');
|
|
75
|
-
if (value.length <= 8) return value ? '••••••••' : '';
|
|
76
|
-
return `${value.slice(0, 4)}…${value.slice(-4)}`;
|
|
77
|
-
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Meta WhatsApp Embedded Signup (web only): opens the Facebook login popup with the
|
|
2
|
+
// Embedded Signup configuration and resolves with the code + WABA / phone number ids.
|
|
3
|
+
// The code is exchanged for the token by the API (POST /whatsapp/embedded-signup).
|
|
4
|
+
|
|
5
|
+
const SDK_ID = 'facebook-jssdk';
|
|
6
|
+
const SIGNUP_EVENT = 'WA_EMBEDDED_SIGNUP';
|
|
7
|
+
|
|
8
|
+
let sdkPromise = null;
|
|
9
|
+
|
|
10
|
+
// Only messages posted by the Facebook popup itself (exact host or a facebook.com subdomain).
|
|
11
|
+
const isFacebookOrigin = origin => {
|
|
12
|
+
try {
|
|
13
|
+
const { protocol, hostname } = new URL(origin);
|
|
14
|
+
return protocol === 'https:' && (hostname === 'facebook.com' || hostname.endsWith('.facebook.com'));
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const isEmbeddedSignupSupported = () =>
|
|
21
|
+
typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
22
|
+
|
|
23
|
+
const loadFacebookSdk = ({ appId, graphVersion }) => {
|
|
24
|
+
if (window.FB) {
|
|
25
|
+
window.FB.init({ appId, autoLogAppEvents: true, xfbml: false, version: graphVersion });
|
|
26
|
+
return Promise.resolve(window.FB);
|
|
27
|
+
}
|
|
28
|
+
if (sdkPromise) return sdkPromise;
|
|
29
|
+
|
|
30
|
+
sdkPromise = new Promise((resolve, reject) => {
|
|
31
|
+
window.fbAsyncInit = () => {
|
|
32
|
+
window.FB.init({ appId, autoLogAppEvents: true, xfbml: false, version: graphVersion });
|
|
33
|
+
resolve(window.FB);
|
|
34
|
+
};
|
|
35
|
+
const script = document.createElement('script');
|
|
36
|
+
script.id = SDK_ID;
|
|
37
|
+
script.async = true;
|
|
38
|
+
script.defer = true;
|
|
39
|
+
script.crossOrigin = 'anonymous';
|
|
40
|
+
script.src = 'https://connect.facebook.net/pt_BR/sdk.js';
|
|
41
|
+
script.onerror = () => {
|
|
42
|
+
sdkPromise = null;
|
|
43
|
+
reject(new Error('Nao foi possivel carregar o SDK do Facebook.'));
|
|
44
|
+
};
|
|
45
|
+
document.body.appendChild(script);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return sdkPromise;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {{appId: string, configId: string, graphVersion: string, coexistence: boolean}} options
|
|
53
|
+
* @returns {Promise<{code: string, wabaId: string, phoneNumberId: string}>}
|
|
54
|
+
*/
|
|
55
|
+
export const launchEmbeddedSignup = async ({ appId, configId, graphVersion, coexistence }) => {
|
|
56
|
+
if (!appId || !configId) {
|
|
57
|
+
throw new Error('Cadastro incorporado do Meta nao configurado na API.');
|
|
58
|
+
}
|
|
59
|
+
const FB = await loadFacebookSdk({ appId, graphVersion });
|
|
60
|
+
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
const session = {};
|
|
63
|
+
let code = '';
|
|
64
|
+
let settled = false;
|
|
65
|
+
|
|
66
|
+
const finish = (error, value) => {
|
|
67
|
+
if (settled) return;
|
|
68
|
+
settled = true;
|
|
69
|
+
window.removeEventListener('message', onMessage);
|
|
70
|
+
if (error) reject(error);
|
|
71
|
+
else resolve(value);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const tryResolve = () => {
|
|
75
|
+
if (code && session.wabaId && session.phoneNumberId) {
|
|
76
|
+
finish(null, { code, ...session });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Meta posts the selected WABA / number from the popup; the login callback brings the code.
|
|
81
|
+
const onMessage = event => {
|
|
82
|
+
if (!isFacebookOrigin(event.origin)) return;
|
|
83
|
+
let data = event.data;
|
|
84
|
+
try {
|
|
85
|
+
data = typeof data === 'string' ? JSON.parse(data) : data;
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (data?.type !== SIGNUP_EVENT) return;
|
|
90
|
+
|
|
91
|
+
if (String(data.event || '').startsWith('FINISH')) {
|
|
92
|
+
session.wabaId = String(data.data?.waba_id || '');
|
|
93
|
+
session.phoneNumberId = String(data.data?.phone_number_id || '');
|
|
94
|
+
tryResolve();
|
|
95
|
+
} else if (data.event === 'CANCEL') {
|
|
96
|
+
const step = data.data?.current_step ? ` (etapa ${data.data.current_step})` : '';
|
|
97
|
+
finish(new Error(data.data?.error_message || `Conexao cancelada no Facebook${step}.`));
|
|
98
|
+
} else if (data.event === 'ERROR') {
|
|
99
|
+
finish(new Error(data.data?.error_message || 'O Facebook retornou um erro.'));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
window.addEventListener('message', onMessage);
|
|
103
|
+
|
|
104
|
+
const extras = { setup: {}, sessionInfoVersion: '3' };
|
|
105
|
+
if (coexistence) {
|
|
106
|
+
extras.featureType = 'whatsapp_business_app_onboarding';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// FB.login requires a plain (non-async) callback.
|
|
110
|
+
FB.login(
|
|
111
|
+
response => {
|
|
112
|
+
code = response?.authResponse?.code || '';
|
|
113
|
+
if (!code) {
|
|
114
|
+
finish(new Error('Login no Facebook nao concluido.'));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
tryResolve();
|
|
118
|
+
// The session message may arrive a little after the callback.
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
if (!settled) {
|
|
121
|
+
finish(new Error('O Facebook nao informou a conta e o numero do WhatsApp. Tente novamente.'));
|
|
122
|
+
}
|
|
123
|
+
}, 15000);
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
config_id: configId,
|
|
127
|
+
response_type: 'code',
|
|
128
|
+
override_default_response_type: true,
|
|
129
|
+
extras,
|
|
130
|
+
},
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {isPublicRoute, PUBLIC_ROUTES} from '../publicRoutes'
|
|
2
|
+
|
|
3
|
+
describe('publicRoutes', () => {
|
|
4
|
+
it('treats MCP OAuth consent as public (ManagerLayout gate)', () => {
|
|
5
|
+
expect(PUBLIC_ROUTES.has('McpOAuthConsentPage')).toBe(true)
|
|
6
|
+
expect(isPublicRoute('McpOAuthConsentPage')).toBe(true)
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('keeps SignIn public', () => {
|
|
10
|
+
expect(isPublicRoute('SignInPage')).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {env as APP_ENV} from '@env';
|
|
2
2
|
import {filterApiHeaders, isTrustedApiUrl} from '../../utils/trustedApiUrl';
|
|
3
|
-
import {buildAssetUrl} from '@controleonline
|
|
3
|
+
import {buildAssetUrl} from '@controleonline/ui-layout/src/styles/branding';
|
|
4
4
|
import {
|
|
5
5
|
resolveAppDomain,
|
|
6
6
|
resolveCompanyDomain,
|
|
@@ -4,19 +4,18 @@ import * as types from "@controleonline/ui-default/src/store/default/mutation_ty
|
|
|
4
4
|
export const createWhatsappConnection = ({ commit, getters }, params = {}) => {
|
|
5
5
|
commit(types.SET_ISLOADING, true);
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const options = {
|
|
8
8
|
method: "POST",
|
|
9
9
|
body: params,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
return api
|
|
13
|
-
.fetch("/whatsapp/create-session"
|
|
14
|
-
.then(
|
|
13
|
+
.fetch("/whatsapp/create-session", options)
|
|
14
|
+
.then(data => {
|
|
15
15
|
commit(types.SET_ITEM, data);
|
|
16
|
-
|
|
17
16
|
return data;
|
|
18
17
|
})
|
|
19
|
-
.catch(
|
|
18
|
+
.catch(e => {
|
|
20
19
|
commit(types.SET_ERROR, e.message);
|
|
21
20
|
throw e;
|
|
22
21
|
})
|
|
@@ -26,34 +25,37 @@ export const createWhatsappConnection = ({ commit, getters }, params = {}) => {
|
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
|
-
* Persist
|
|
30
|
-
*
|
|
28
|
+
* Persist official Meta Cloud API WhatsApp connection.
|
|
29
|
+
* channel=whatsapp_official + channelConfig JSON (write-only on API).
|
|
31
30
|
*/
|
|
32
|
-
export const saveOfficialWhatsappConnection = ({ commit
|
|
31
|
+
export const saveOfficialWhatsappConnection = ({ commit }, params = {}) => {
|
|
33
32
|
commit(types.SET_ISLOADING, true);
|
|
34
33
|
|
|
35
34
|
const body = {
|
|
36
|
-
name: params.name || `
|
|
37
|
-
channel:
|
|
38
|
-
type: params.type ||
|
|
35
|
+
name: params.name || `WA Oficial ${params.phoneNumberId || ""}`.trim().slice(0, 50),
|
|
36
|
+
channel: "whatsapp_official",
|
|
37
|
+
type: params.type || "relationship",
|
|
39
38
|
people: params.people,
|
|
40
39
|
channelConfig: JSON.stringify({
|
|
41
40
|
access_token: params.accessToken,
|
|
42
41
|
phone_number_id: params.phoneNumberId,
|
|
43
|
-
api_version: params.apiVersion ||
|
|
42
|
+
api_version: params.apiVersion || "v22.0",
|
|
44
43
|
}),
|
|
45
44
|
};
|
|
46
45
|
|
|
46
|
+
if (params.status) {
|
|
47
|
+
body.status = params.status;
|
|
48
|
+
}
|
|
47
49
|
if (params.phone) {
|
|
48
50
|
body.phone = params.phone;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
const options = {
|
|
52
|
-
method: params.id ?
|
|
54
|
+
method: params.id ? "PUT" : "POST",
|
|
53
55
|
body,
|
|
54
56
|
};
|
|
55
57
|
|
|
56
|
-
const endpoint = params.id ? `/connections/${params.id}` :
|
|
58
|
+
const endpoint = params.id ? `/connections/${params.id}` : "/connections";
|
|
57
59
|
|
|
58
60
|
return api
|
|
59
61
|
.fetch(endpoint, options)
|
|
@@ -109,3 +111,38 @@ export const saveEmailConnection = ({ commit }, params = {}) => {
|
|
|
109
111
|
commit(types.SET_ISLOADING, false);
|
|
110
112
|
});
|
|
111
113
|
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Meta Embedded Signup: public data to open the Facebook popup (app id + configuration id).
|
|
117
|
+
*/
|
|
118
|
+
export const getWhatsappEmbeddedSignupConfig = () =>
|
|
119
|
+
api.fetch('/whatsapp/embedded-signup/config', { method: 'GET' });
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Meta Embedded Signup: the API exchanges the code for the token, subscribes the webhook
|
|
123
|
+
* and creates/updates the whatsapp_official connection of the company.
|
|
124
|
+
*/
|
|
125
|
+
export const completeWhatsappEmbeddedSignup = ({ commit }, params = {}) => {
|
|
126
|
+
commit(types.SET_ISLOADING, true);
|
|
127
|
+
|
|
128
|
+
return api
|
|
129
|
+
.fetch('/whatsapp/embedded-signup', {
|
|
130
|
+
method: 'POST',
|
|
131
|
+
body: {
|
|
132
|
+
people: params.people,
|
|
133
|
+
code: params.code,
|
|
134
|
+
waba_id: params.wabaId,
|
|
135
|
+
phone_number_id: params.phoneNumberId,
|
|
136
|
+
coexistence: !!params.coexistence,
|
|
137
|
+
type: params.type || null,
|
|
138
|
+
connection: params.connection || null,
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
.catch(e => {
|
|
142
|
+
commit(types.SET_ERROR, e.message);
|
|
143
|
+
throw e;
|
|
144
|
+
})
|
|
145
|
+
.finally(() => {
|
|
146
|
+
commit(types.SET_ISLOADING, false);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
@@ -1,101 +1,105 @@
|
|
|
1
|
-
import * as actions from "@controleonline/ui-default/src/store/default/actions";
|
|
2
|
-
import * as getters from "@controleonline/ui-default/src/store/default/getters";
|
|
3
|
-
import mutations from "@controleonline/ui-default/src/store/default/mutations";
|
|
4
|
-
import * as customActions from "./customActions";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
namespaced: true,
|
|
8
|
-
state: {
|
|
9
|
-
item: {},
|
|
10
|
-
items: [],
|
|
11
|
-
resourceEndpoint: "connections",
|
|
12
|
-
isLoading: false,
|
|
13
|
-
reload: false,
|
|
14
|
-
error: "",
|
|
15
|
-
totalItems: 0,
|
|
16
|
-
summary: {},
|
|
17
|
-
messages: [],
|
|
18
|
-
message: {},
|
|
19
|
-
filters: {},
|
|
20
|
-
columns: [
|
|
21
|
-
{
|
|
22
|
-
editable: false,
|
|
23
|
-
isIdentity: true,
|
|
24
|
-
sortable: true,
|
|
25
|
-
name: "id",
|
|
26
|
-
align: "left",
|
|
27
|
-
label: "id",
|
|
28
|
-
sum: false,
|
|
29
|
-
format: function (value) {
|
|
30
|
-
return "#" + value;
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
externalFilter: false,
|
|
35
|
-
sortable: true,
|
|
36
|
-
name: "name",
|
|
37
|
-
align: "left",
|
|
38
|
-
label: "name",
|
|
39
|
-
format: function (value) {
|
|
40
|
-
return value;
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
externalFilter: false,
|
|
45
|
-
sortable: true,
|
|
46
|
-
editable: false,
|
|
47
|
-
name: "phone",
|
|
48
|
-
align: "left",
|
|
49
|
-
label: "phone",
|
|
50
|
-
format: function (value, row, column) {
|
|
51
|
-
const phone = String(value.phone);
|
|
52
|
-
const lastFour = phone.slice(-4);
|
|
53
|
-
const firstPart = phone.slice(0, -4);
|
|
54
|
-
return `(${value?.ddd}) ${firstPart}-${lastFour}`;
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
|
|
1
|
+
import * as actions from "@controleonline/ui-default/src/store/default/actions";
|
|
2
|
+
import * as getters from "@controleonline/ui-default/src/store/default/getters";
|
|
3
|
+
import mutations from "@controleonline/ui-default/src/store/default/mutations";
|
|
4
|
+
import * as customActions from "./customActions";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
namespaced: true,
|
|
8
|
+
state: {
|
|
9
|
+
item: {},
|
|
10
|
+
items: [],
|
|
11
|
+
resourceEndpoint: "connections",
|
|
12
|
+
isLoading: false,
|
|
13
|
+
reload: false,
|
|
14
|
+
error: "",
|
|
15
|
+
totalItems: 0,
|
|
16
|
+
summary: {},
|
|
17
|
+
messages: [],
|
|
18
|
+
message: {},
|
|
19
|
+
filters: {},
|
|
20
|
+
columns: [
|
|
21
|
+
{
|
|
22
|
+
editable: false,
|
|
23
|
+
isIdentity: true,
|
|
24
|
+
sortable: true,
|
|
25
|
+
name: "id",
|
|
26
|
+
align: "left",
|
|
27
|
+
label: "id",
|
|
28
|
+
sum: false,
|
|
29
|
+
format: function (value) {
|
|
30
|
+
return "#" + value;
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
externalFilter: false,
|
|
35
|
+
sortable: true,
|
|
36
|
+
name: "name",
|
|
37
|
+
align: "left",
|
|
38
|
+
label: "name",
|
|
39
|
+
format: function (value) {
|
|
40
|
+
return value;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
externalFilter: false,
|
|
45
|
+
sortable: true,
|
|
46
|
+
editable: false,
|
|
47
|
+
name: "phone",
|
|
48
|
+
align: "left",
|
|
49
|
+
label: "phone",
|
|
50
|
+
format: function (value, row, column) {
|
|
51
|
+
const phone = String(value.phone);
|
|
52
|
+
const lastFour = phone.slice(-4);
|
|
53
|
+
const firstPart = phone.slice(0, -4);
|
|
54
|
+
return `(${value?.ddd}) ${firstPart}-${lastFour}`;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
58
|
{
|
|
59
59
|
externalFilter: false,
|
|
60
60
|
sortable: true,
|
|
61
61
|
name: "type",
|
|
62
62
|
align: "left",
|
|
63
63
|
label: "type",
|
|
64
|
-
list: [
|
|
65
|
-
{
|
|
66
|
-
value: "crm",
|
|
67
|
-
label: "CRM",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
value: "support",
|
|
71
|
-
label: "Suporte",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
value: null,
|
|
75
|
-
label: "Nenhum",
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
format: function (value) {
|
|
79
|
-
return value;
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
|
|
64
|
+
list: [
|
|
65
|
+
{
|
|
66
|
+
value: "crm",
|
|
67
|
+
label: "CRM",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: "support",
|
|
71
|
+
label: "Suporte",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: null,
|
|
75
|
+
label: "Nenhum",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
format: function (value) {
|
|
79
|
+
return value;
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
|
|
83
83
|
{
|
|
84
84
|
sortable: true,
|
|
85
85
|
editable: false,
|
|
86
86
|
name: "channel",
|
|
87
87
|
align: "left",
|
|
88
88
|
label: "channel",
|
|
89
|
-
list: [
|
|
90
|
-
{
|
|
91
|
-
value: "whatsapp",
|
|
92
|
-
label: "
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
89
|
+
list: [
|
|
90
|
+
{
|
|
91
|
+
value: "whatsapp",
|
|
92
|
+
label: "WhatsApp",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
value: "whatsapp_official",
|
|
96
|
+
label: "WhatsApp Oficial",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
format: function (value) {
|
|
100
|
+
return value;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
99
103
|
{
|
|
100
104
|
editable: false,
|
|
101
105
|
externalFilter: false,
|
|
@@ -103,22 +107,22 @@ export default {
|
|
|
103
107
|
name: "status",
|
|
104
108
|
align: "left",
|
|
105
109
|
label: "status",
|
|
106
|
-
list: "status/getItems",
|
|
107
|
-
searchParam: "status",
|
|
108
|
-
format: function (value) {
|
|
109
|
-
return value?.status;
|
|
110
|
-
},
|
|
111
|
-
saveFormat: function (value) {
|
|
112
|
-
return value ? "/statuses/" + (value.value || value) : null;
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: "connection",
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
print: [],
|
|
120
|
-
},
|
|
121
|
-
actions: { ...actions, ...customActions },
|
|
122
|
-
getters,
|
|
123
|
-
mutations,
|
|
124
|
-
};
|
|
110
|
+
list: "status/getItems",
|
|
111
|
+
searchParam: "status",
|
|
112
|
+
format: function (value) {
|
|
113
|
+
return value?.status;
|
|
114
|
+
},
|
|
115
|
+
saveFormat: function (value) {
|
|
116
|
+
return value ? "/statuses/" + (value.value || value) : null;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "connection",
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
print: [],
|
|
124
|
+
},
|
|
125
|
+
actions: { ...actions, ...customActions },
|
|
126
|
+
getters,
|
|
127
|
+
mutations,
|
|
128
|
+
};
|