@controleonline/ui-crm 1.0.42 → 1.0.45

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.
@@ -0,0 +1,68 @@
1
+ name: Integration source gate
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [dev, staging, master]
6
+ types: [opened, synchronize, reopened, edited, ready_for_review]
7
+
8
+ permissions:
9
+ contents: read
10
+ pull-requests: read
11
+
12
+ jobs:
13
+ source-policy:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Enforce task or frozen RC source
17
+ env:
18
+ HEAD_REF: ${{ github.head_ref }}
19
+ BASE_REF: ${{ github.base_ref }}
20
+ run: |
21
+ set -eu
22
+ if [ "$BASE_REF" = "dev" ]; then
23
+ echo "$HEAD_REF" | grep -Eq '^task-[1-9][0-9]*$' || {
24
+ echo "::error::dev only accepts task-<numeric issue>."
25
+ exit 1
26
+ }
27
+ exit 0
28
+ fi
29
+ echo "$HEAD_REF" | grep -Eq '^rc/[0-9]+\.[0-9]+\.[0-9]+-rc\.[1-9][0-9]*$' || {
30
+ echo "::error::$BASE_REF only accepts a frozen rc/X.Y.Z-rc.N source."
31
+ exit 1
32
+ }
33
+
34
+ - uses: actions/checkout@v4
35
+ if: github.base_ref != 'dev'
36
+ with:
37
+ ref: ${{ github.head_ref }}
38
+
39
+ - name: Validate frozen RC manifest
40
+ if: github.base_ref != 'dev'
41
+ env:
42
+ HEAD_REF: ${{ github.head_ref }}
43
+ run: |
44
+ set -eu
45
+ test -f .release/rc-manifest.json || {
46
+ echo "::error::Missing .release/rc-manifest.json"
47
+ exit 1
48
+ }
49
+ node --input-type=module <<'NODE'
50
+ import fs from 'node:fs';
51
+ const m = JSON.parse(fs.readFileSync('.release/rc-manifest.json', 'utf8'));
52
+ const branch = process.env.HEAD_REF;
53
+ const match = /^rc\/(\d+\.\d+\.\d+)-rc\.([1-9][0-9]*)$/.exec(branch);
54
+ if (!match) throw new Error('invalid RC branch');
55
+ if (m.branch !== branch || m.version !== match[1] || Number(m.rc) !== Number(match[2])) throw new Error('manifest identity mismatch');
56
+ if (m.frozen !== true) throw new Error('manifest is not frozen');
57
+ if (!Array.isArray(m.tasks) || m.tasks.length < 1 || m.tasks.length > 5) throw new Error('RC must contain 1..5 tasks');
58
+ const tasks = m.tasks.map(Number);
59
+ if (tasks.some((id) => !Number.isInteger(id) || id < 1)) throw new Error('invalid task id');
60
+ if (new Set(tasks).size !== tasks.length) throw new Error('duplicate RC tasks');
61
+ if (!/^[0-9a-f]{40}$/i.test(String(m.baseMaster || ''))) throw new Error('invalid baseMaster');
62
+ const repos = m.repositories || {};
63
+ if (!Object.keys(repos).length) throw new Error('empty repositories manifest');
64
+ for (const [repo, sha] of Object.entries(repos)) {
65
+ if (!/^ControleOnline\/[A-Za-z0-9_.-]+$/.test(repo) || !/^[0-9a-f]{40}$/i.test(String(sha))) throw new Error('invalid repository manifest entry');
66
+ }
67
+ console.log('Frozen RC manifest valid:', branch, tasks);
68
+ NODE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-crm",
3
- "version": "1.0.42",
3
+ "version": "1.0.45",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline CRM Quasar UI Component",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "https://github.com/controleonline/conline-quasar-ui"
29
+ "url": "https://github.com/ControleOnline/ui-crm.git"
30
30
  },
31
31
  "bugs": "",
32
32
  "homepage": "https://www.controleonline.com/devs/plugins",
@@ -0,0 +1,301 @@
1
+ /*
2
+ * @agents MCP AI chat (Task type=ia). Keep under 500 lines; API via /mcp/chat*.
3
+ */
4
+ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
5
+ import {
6
+ ActivityIndicator,
7
+ FlatList,
8
+ KeyboardAvoidingView,
9
+ Platform,
10
+ ScrollView,
11
+ Text,
12
+ TextInput,
13
+ TouchableOpacity,
14
+ View,
15
+ } from 'react-native';
16
+ import {useStore} from '@store';
17
+ import {api} from '@controleonline/ui-common/src/api';
18
+ import useToastMessage from '../../hooks/useToastMessage';
19
+ import styles from './McpPage.styles';
20
+
21
+ const PROVIDER_LABELS = {
22
+ grok: 'Grok',
23
+ openai: 'Codex / OpenAI',
24
+ gemini: 'Gemini',
25
+ claude: 'Claude',
26
+ };
27
+
28
+ export default function McpPage() {
29
+ const {showError, showSuccess} = useToastMessage();
30
+ const peopleStore = useStore('people');
31
+ const company =
32
+ peopleStore?.getters?.currentCompany ||
33
+ peopleStore?.getters?.defaultCompany ||
34
+ null;
35
+ const companyId = company?.id || company?.['@id']?.split('/').pop() || null;
36
+
37
+ const [providers, setProviders] = useState([]);
38
+ const [provider, setProvider] = useState(null);
39
+ const [tasks, setTasks] = useState([]);
40
+ const [activeTaskId, setActiveTaskId] = useState(null);
41
+ const [messages, setMessages] = useState([]);
42
+ const [draft, setDraft] = useState('');
43
+ const [loadingList, setLoadingList] = useState(true);
44
+ const [loadingChat, setLoadingChat] = useState(false);
45
+ const [sending, setSending] = useState(false);
46
+ const listRef = useRef(null);
47
+
48
+ const companyQuery = useMemo(
49
+ () => (companyId ? {company_id: Number(companyId)} : {}),
50
+ [companyId],
51
+ );
52
+
53
+ const loadProviders = useCallback(async () => {
54
+ try {
55
+ const res = await api.fetch('/mcp/chat/providers', {params: companyQuery});
56
+ const list = res?.providers || res?.member || res || [];
57
+ const arr = Array.isArray(list) ? list : [];
58
+ setProviders(arr);
59
+ const enabled = arr.find(p => p.enabled || p.has_key);
60
+ setProvider(prev => prev || enabled?.provider || enabled?.id || enabled?.name || null);
61
+ } catch (e) {
62
+ showError(e?.message || 'Falha ao carregar providers de IA');
63
+ }
64
+ }, [companyQuery, showError]);
65
+
66
+ const loadTasks = useCallback(async () => {
67
+ setLoadingList(true);
68
+ try {
69
+ const params = {
70
+ type: 'ia',
71
+ order: {alterDate: 'desc'},
72
+ itemsPerPage: 50,
73
+ };
74
+ if (companyId) {
75
+ params.provider = `/people/${companyId}`;
76
+ }
77
+ const res = await api.fetch('/tasks', {params});
78
+ const items = res?.member || res?.['hydra:member'] || res || [];
79
+ setTasks(Array.isArray(items) ? items : []);
80
+ } catch (e) {
81
+ showError(e?.message || 'Falha ao listar chats');
82
+ } finally {
83
+ setLoadingList(false);
84
+ }
85
+ }, [companyId, showError]);
86
+
87
+ const loadMessages = useCallback(
88
+ async taskId => {
89
+ if (!taskId) {
90
+ setMessages([]);
91
+ return;
92
+ }
93
+ setLoadingChat(true);
94
+ try {
95
+ const res = await api.fetch('/task_interations', {
96
+ params: {
97
+ 'task.id': taskId,
98
+ type: 'comment',
99
+ order: {id: 'asc'},
100
+ itemsPerPage: 100,
101
+ },
102
+ });
103
+ const items = res?.member || res?.['hydra:member'] || res || [];
104
+ setMessages(Array.isArray(items) ? items : []);
105
+ } catch (e) {
106
+ showError(e?.message || 'Falha ao carregar mensagens');
107
+ } finally {
108
+ setLoadingChat(false);
109
+ }
110
+ },
111
+ [showError],
112
+ );
113
+
114
+ useEffect(() => {
115
+ loadProviders();
116
+ loadTasks();
117
+ }, [loadProviders, loadTasks]);
118
+
119
+ useEffect(() => {
120
+ loadMessages(activeTaskId);
121
+ }, [activeTaskId, loadMessages]);
122
+
123
+ const selectTask = task => {
124
+ const id = task?.id || task?.['@id']?.split('/').pop();
125
+ setActiveTaskId(id ? Number(id) : null);
126
+ };
127
+
128
+ const startNewChat = () => {
129
+ setActiveTaskId(null);
130
+ setMessages([]);
131
+ setDraft('');
132
+ };
133
+
134
+ const sendMessage = async () => {
135
+ const text = draft.trim();
136
+ if (!text || sending) return;
137
+ if (!provider) {
138
+ showError('Selecione um provider de IA configurado na empresa');
139
+ return;
140
+ }
141
+ setSending(true);
142
+ try {
143
+ const body = {
144
+ message: text,
145
+ provider,
146
+ ...(activeTaskId ? {task_id: activeTaskId} : {}),
147
+ ...(companyId ? {company_id: Number(companyId)} : {}),
148
+ };
149
+ const res = await api.post('/mcp/chat', body);
150
+ const newTaskId = res?.task?.id;
151
+ setDraft('');
152
+ if (newTaskId && newTaskId !== activeTaskId) {
153
+ setActiveTaskId(Number(newTaskId));
154
+ await loadTasks();
155
+ } else {
156
+ await loadMessages(activeTaskId || newTaskId);
157
+ }
158
+ if (res?.reply) {
159
+ // optimistic refresh
160
+ await loadMessages(newTaskId || activeTaskId);
161
+ }
162
+ } catch (e) {
163
+ showError(e?.message || e?.error || 'Falha ao enviar mensagem');
164
+ } finally {
165
+ setSending(false);
166
+ }
167
+ };
168
+
169
+ const activeTask = tasks.find(
170
+ t => String(t.id) === String(activeTaskId) || t['@id']?.endsWith(`/${activeTaskId}`),
171
+ );
172
+
173
+ const renderMessage = ({item}) => {
174
+ const body = item?.body || '';
175
+ const byId =
176
+ item?.registeredBy?.id ||
177
+ item?.registeredBy?.['@id']?.split('/').pop() ||
178
+ item?.registered_by_id;
179
+ const isUser = companyId && String(byId) !== String(companyId);
180
+ return (
181
+ <View style={[styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAi]}>
182
+ <Text style={styles.bubbleText}>{body}</Text>
183
+ </View>
184
+ );
185
+ };
186
+
187
+ return (
188
+ <KeyboardAvoidingView
189
+ style={styles.root}
190
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
191
+ keyboardVerticalOffset={80}>
192
+ <View style={styles.sidebar}>
193
+ <View style={styles.sidebarHeader}>
194
+ <Text style={styles.sidebarTitle}>Chats IA</Text>
195
+ <TouchableOpacity onPress={startNewChat} style={styles.newBtn}>
196
+ <Text style={styles.newBtnText}>Novo</Text>
197
+ </TouchableOpacity>
198
+ </View>
199
+ <ScrollView
200
+ horizontal
201
+ style={styles.providerRow}
202
+ contentContainerStyle={styles.providerRowContent}>
203
+ {(providers.length ? providers : Object.keys(PROVIDER_LABELS).map(k => ({provider: k, enabled: false}))).map(
204
+ p => {
205
+ const key = p.provider || p.id || p.name;
206
+ const selected = key === provider;
207
+ const disabled = p.enabled === false && !p.has_key;
208
+ return (
209
+ <TouchableOpacity
210
+ key={String(key)}
211
+ disabled={disabled}
212
+ onPress={() => setProvider(key)}
213
+ style={[
214
+ styles.providerChip,
215
+ selected && styles.providerChipActive,
216
+ disabled && styles.providerChipDisabled,
217
+ ]}>
218
+ <Text
219
+ style={[
220
+ styles.providerChipText,
221
+ selected && styles.providerChipTextActive,
222
+ ]}>
223
+ {PROVIDER_LABELS[key] || p.label || key}
224
+ </Text>
225
+ </TouchableOpacity>
226
+ );
227
+ },
228
+ )}
229
+ </ScrollView>
230
+ {loadingList ? (
231
+ <ActivityIndicator style={{marginTop: 16}} />
232
+ ) : (
233
+ <FlatList
234
+ data={tasks}
235
+ keyExtractor={item => String(item.id || item['@id'])}
236
+ renderItem={({item}) => {
237
+ const id = item.id || item['@id']?.split('/').pop();
238
+ const selected = String(id) === String(activeTaskId);
239
+ return (
240
+ <TouchableOpacity
241
+ onPress={() => selectTask(item)}
242
+ style={[styles.taskRow, selected && styles.taskRowActive]}>
243
+ <Text numberOfLines={1} style={styles.taskNameText}>
244
+ {item.name || `Chat #${id}`}
245
+ </Text>
246
+ </TouchableOpacity>
247
+ );
248
+ }}
249
+ ListEmptyComponent={
250
+ <Text style={styles.emptyText}>Nenhum chat ainda. Envie uma mensagem.</Text>
251
+ }
252
+ />
253
+ )}
254
+ </View>
255
+
256
+ <View style={styles.chatPane}>
257
+ <View style={styles.chatHeader}>
258
+ <Text style={styles.chatTitle}>
259
+ {activeTask?.name || (activeTaskId ? `Chat #${activeTaskId}` : 'Novo chat')}
260
+ </Text>
261
+ <Text style={styles.chatSubtitle}>
262
+ {PROVIDER_LABELS[provider] || provider || 'Selecione a IA'}
263
+ </Text>
264
+ </View>
265
+ {loadingChat ? (
266
+ <ActivityIndicator style={{marginTop: 24}} />
267
+ ) : (
268
+ <FlatList
269
+ ref={listRef}
270
+ data={messages}
271
+ keyExtractor={item => String(item.id || item['@id'])}
272
+ renderItem={renderMessage}
273
+ contentContainerStyle={styles.messagesContent}
274
+ onContentSizeChange={() => listRef.current?.scrollToEnd?.({animated: true})}
275
+ ListEmptyComponent={
276
+ <Text style={styles.emptyText}>
277
+ Pergunte algo. A conversa vira uma Task type=ia.
278
+ </Text>
279
+ }
280
+ />
281
+ )}
282
+ <View style={styles.composer}>
283
+ <TextInput
284
+ style={styles.input}
285
+ value={draft}
286
+ onChangeText={setDraft}
287
+ placeholder="Mensagem para a IA…"
288
+ multiline
289
+ editable={!sending}
290
+ />
291
+ <TouchableOpacity
292
+ style={[styles.sendBtn, (!draft.trim() || sending) && styles.sendBtnDisabled]}
293
+ disabled={!draft.trim() || sending}
294
+ onPress={sendMessage}>
295
+ <Text style={styles.sendBtnText}>{sending ? '…' : 'Enviar'}</Text>
296
+ </TouchableOpacity>
297
+ </View>
298
+ </View>
299
+ </KeyboardAvoidingView>
300
+ );
301
+ }
@@ -0,0 +1,116 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ export default StyleSheet.create({
4
+ root: {
5
+ flex: 1,
6
+ flexDirection: 'row',
7
+ backgroundColor: '#0f1419',
8
+ minHeight: 0,
9
+ },
10
+ sidebar: {
11
+ width: 280,
12
+ maxWidth: '35%',
13
+ borderRightWidth: 1,
14
+ borderRightColor: '#2a3441',
15
+ backgroundColor: '#15202b',
16
+ },
17
+ sidebarHeader: {
18
+ flexDirection: 'row',
19
+ alignItems: 'center',
20
+ justifyContent: 'space-between',
21
+ paddingHorizontal: 12,
22
+ paddingVertical: 12,
23
+ },
24
+ sidebarTitle: {
25
+ color: '#e7e9ea',
26
+ fontSize: 16,
27
+ fontWeight: '700',
28
+ },
29
+ newBtn: {
30
+ backgroundColor: '#1d9bf0',
31
+ paddingHorizontal: 10,
32
+ paddingVertical: 6,
33
+ borderRadius: 8,
34
+ },
35
+ newBtnText: {color: '#fff', fontWeight: '600', fontSize: 13},
36
+ providerRow: {maxHeight: 44, marginBottom: 4},
37
+ providerRowContent: {paddingHorizontal: 8, gap: 6, alignItems: 'center'},
38
+ providerChip: {
39
+ borderWidth: 1,
40
+ borderColor: '#38444d',
41
+ borderRadius: 16,
42
+ paddingHorizontal: 10,
43
+ paddingVertical: 6,
44
+ marginRight: 6,
45
+ },
46
+ providerChipActive: {
47
+ backgroundColor: '#1d9bf0',
48
+ borderColor: '#1d9bf0',
49
+ },
50
+ providerChipDisabled: {opacity: 0.4},
51
+ providerChipText: {color: '#8b98a5', fontSize: 12},
52
+ providerChipTextActive: {color: '#fff'},
53
+ taskRow: {
54
+ paddingHorizontal: 12,
55
+ paddingVertical: 10,
56
+ borderBottomWidth: StyleSheet.hairlineWidth,
57
+ borderBottomColor: '#2a3441',
58
+ },
59
+ taskRowActive: {backgroundColor: '#1e2732'},
60
+ taskRowText: {color: '#e7e9ea', fontSize: 13},
61
+ emptyText: {color: '#8b98a5', padding: 16, fontSize: 13},
62
+ chatPane: {flex: 1, minWidth: 0},
63
+ chatHeader: {
64
+ paddingHorizontal: 16,
65
+ paddingVertical: 12,
66
+ borderBottomWidth: 1,
67
+ borderBottomColor: '#2a3441',
68
+ },
69
+ chatTitle: {color: '#e7e9ea', fontSize: 16, fontWeight: '600'},
70
+ chatSubtitle: {color: '#8b98a5', fontSize: 12, marginTop: 2},
71
+ messagesContent: {padding: 12, paddingBottom: 24},
72
+ bubble: {
73
+ maxWidth: '85%',
74
+ borderRadius: 12,
75
+ paddingHorizontal: 12,
76
+ paddingVertical: 8,
77
+ marginVertical: 4,
78
+ },
79
+ bubbleUser: {
80
+ alignSelf: 'flex-end',
81
+ backgroundColor: '#1d9bf0',
82
+ },
83
+ bubbleAi: {
84
+ alignSelf: 'flex-start',
85
+ backgroundColor: '#212a33',
86
+ },
87
+ bubbleText: {color: '#e7e9ea', fontSize: 14, lineHeight: 20},
88
+ composer: {
89
+ flexDirection: 'row',
90
+ alignItems: 'flex-end',
91
+ padding: 10,
92
+ borderTopWidth: 1,
93
+ borderTopColor: '#2a3441',
94
+ gap: 8,
95
+ },
96
+ input: {
97
+ flex: 1,
98
+ minHeight: 40,
99
+ maxHeight: 120,
100
+ borderWidth: 1,
101
+ borderColor: '#38444d',
102
+ borderRadius: 12,
103
+ paddingHorizontal: 12,
104
+ paddingVertical: 8,
105
+ color: '#e7e9ea',
106
+ backgroundColor: '#15202b',
107
+ },
108
+ sendBtn: {
109
+ backgroundColor: '#1d9bf0',
110
+ borderRadius: 12,
111
+ paddingHorizontal: 14,
112
+ paddingVertical: 10,
113
+ },
114
+ sendBtnDisabled: {opacity: 0.5},
115
+ sendBtnText: {color: '#fff', fontWeight: '700'},
116
+ });
@@ -29,6 +29,7 @@ import CrmSection from './sections/CrmSection';
29
29
  import LoyaltySection from './sections/LoyaltySection';
30
30
  import MapsSection from './sections/MapsSection';
31
31
  import ShopSettingsSection from './sections/shop/ShopSettingsSection';
32
+ import AiProvidersSection from './sections/AiProvidersSection';
32
33
  import IntegrationsSection from './sections/IntegrationsSection';
33
34
  import LogSection from './sections/LogSection';
34
35
  import MaintenanceSection from './sections/MaintenanceSection';
@@ -51,6 +52,13 @@ const SETTINGS_TABS = [
51
52
  stores: ['configs', 'people'],
52
53
  Component: IntegrationsSection,
53
54
  },
55
+ {
56
+ key: 'ai-providers',
57
+ label: 'IA / MCP',
58
+ icon: 'smart-toy',
59
+ stores: ['configs', 'people'],
60
+ Component: AiProvidersSection,
61
+ },
54
62
  {
55
63
  key: 'logs',
56
64
  label: 'Logs',
@@ -136,8 +144,8 @@ const GeneralSettings = () => {
136
144
  const {
137
145
  companies,
138
146
  currentCompany,
139
- mainCompany,
140
- hasMainCompanyAccess,
147
+ defaultCompany,
148
+ hasDefaultCompanyAccess,
141
149
  isMainCompanySelected,
142
150
  peopleActions,
143
151
  } =
@@ -157,9 +165,9 @@ const GeneralSettings = () => {
157
165
  SETTINGS_TABS.filter(
158
166
  tab =>
159
167
  (!MAIN_COMPANY_ONLY_TABS.has(tab.key) || isMainCompanySelected) &&
160
- (!TECHNICAL_TABS.has(tab.key) || hasMainCompanyAccess),
168
+ (!TECHNICAL_TABS.has(tab.key) || hasDefaultCompanyAccess),
161
169
  ),
162
- [hasMainCompanyAccess, isMainCompanySelected],
170
+ [hasDefaultCompanyAccess, isMainCompanySelected],
163
171
  );
164
172
 
165
173
  useFocusEffect(
@@ -176,10 +184,10 @@ const GeneralSettings = () => {
176
184
  }
177
185
  }
178
186
 
179
- if (!mainCompany?.id) {
180
- const mainCompanyRequest = peopleActions.mainCompany?.();
181
- if (mainCompanyRequest?.then) {
182
- requests.push(mainCompanyRequest.catch(() => {}));
187
+ if (!defaultCompany?.id) {
188
+ const defaultCompanyRequest = peopleActions.defaultCompany?.();
189
+ if (defaultCompanyRequest?.then) {
190
+ requests.push(defaultCompanyRequest.catch(() => {}));
183
191
  }
184
192
  }
185
193
 
@@ -196,7 +204,7 @@ const GeneralSettings = () => {
196
204
  return () => {
197
205
  cancelled = true;
198
206
  };
199
- }, [companies, mainCompany?.id, peopleActions]),
207
+ }, [companies, defaultCompany?.id, peopleActions]),
200
208
  );
201
209
 
202
210
  /*
@@ -204,7 +204,7 @@ const isMethodNotAllowedError = error => {
204
204
 
205
205
  export const useGeneralSettingsConfig = () => {
206
206
  const peopleStore = useStore('people');
207
- const {companies, currentCompany, mainCompany} = peopleStore.getters;
207
+ const {companies, currentCompany, defaultCompany} = peopleStore.getters;
208
208
  const peopleActions = peopleStore.actions;
209
209
 
210
210
  const configsStore = useStore('configs');
@@ -228,26 +228,26 @@ export const useGeneralSettingsConfig = () => {
228
228
  () => normalizeEntityId(currentCompany?.id || currentCompany?.['@id']),
229
229
  [currentCompany?.['@id'], currentCompany?.id],
230
230
  );
231
- const mainCompanyId = useMemo(
232
- () => normalizeEntityId(mainCompany?.id || mainCompany?.['@id']),
233
- [mainCompany?.['@id'], mainCompany?.id],
231
+ const defaultCompanyId = useMemo(
232
+ () => normalizeEntityId(defaultCompany?.id || defaultCompany?.['@id']),
233
+ [defaultCompany?.['@id'], defaultCompany?.id],
234
234
  );
235
- const hasMainCompanyAccess = useMemo(() => {
236
- if (mainCompanyId === '') {
235
+ const hasDefaultCompanyAccess = useMemo(() => {
236
+ if (defaultCompanyId === '') {
237
237
  return false;
238
238
  }
239
239
 
240
240
  return (Array.isArray(companies) ? companies : []).some(
241
241
  company =>
242
- normalizeEntityId(company?.id || company?.['@id']) === mainCompanyId,
242
+ normalizeEntityId(company?.id || company?.['@id']) === defaultCompanyId,
243
243
  );
244
- }, [companies, mainCompanyId]);
244
+ }, [companies, defaultCompanyId]);
245
245
  const isMainCompanySelected =
246
246
  selectedCompanyId !== '' &&
247
- mainCompanyId !== '' &&
248
- selectedCompanyId === mainCompanyId;
249
- const mainCompanyLabel =
250
- mainCompany?.alias || mainCompany?.name || 'empresa principal';
247
+ defaultCompanyId !== '' &&
248
+ selectedCompanyId === defaultCompanyId;
249
+ const defaultCompanyLabel =
250
+ defaultCompany?.alias || defaultCompany?.name || 'empresa principal';
251
251
 
252
252
  const syncConfigCache = useCallback(
253
253
  entries => {
@@ -366,9 +366,9 @@ export const useGeneralSettingsConfig = () => {
366
366
  [configActions, currentCompany?.id, syncConfigCache],
367
367
  );
368
368
 
369
- const saveMainCompanyConfigs = useCallback(
369
+ const saveDefaultCompanyConfigs = useCallback(
370
370
  entries => {
371
- if (!mainCompanyId) {
371
+ if (!defaultCompanyId) {
372
372
  Alert.alert(
373
373
  'Empresa principal nao selecionada',
374
374
  'Selecione uma empresa principal para salvar as configuracoes.',
@@ -412,7 +412,7 @@ export const useGeneralSettingsConfig = () => {
412
412
  try {
413
413
  const data = await configActions.addManyConfigs({
414
414
  configs: requestConfigItems,
415
- people: '/people/' + mainCompanyId,
415
+ people: '/people/' + defaultCompanyId,
416
416
  module: 4,
417
417
  visibility: 'public',
418
418
  });
@@ -429,7 +429,7 @@ export const useGeneralSettingsConfig = () => {
429
429
  configActions.initQueue();
430
430
  });
431
431
  },
432
- [configActions, mainCompanyId, syncConfigCache],
432
+ [configActions, defaultCompanyId, syncConfigCache],
433
433
  );
434
434
 
435
435
  const saveConfig = useCallback(
@@ -476,15 +476,15 @@ export const useGeneralSettingsConfig = () => {
476
476
  companies,
477
477
  configActions,
478
478
  currentCompany,
479
- mainCompany,
480
- mainCompanyLabel,
479
+ defaultCompany,
480
+ defaultCompanyLabel,
481
481
  effectiveCompanyConfigs,
482
- hasMainCompanyAccess,
482
+ hasDefaultCompanyAccess,
483
483
  isMainCompanySelected,
484
484
  isSaving,
485
485
  peopleActions,
486
486
  saveConfig,
487
487
  saveConfigs,
488
- saveMainCompanyConfigs,
488
+ saveDefaultCompanyConfigs,
489
489
  };
490
490
  };