@controleonline/ui-crm 1.0.42
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/.github/actions/workers/manager/action.yml +147 -0
- package/.github/actions/workers/qa/action.yml +44 -0
- package/.github/actions/workers/security/action.yml +44 -0
- package/.github/actions/workers/technical-documenter/action.yml +51 -0
- package/.github/workflows/manager-worker.yml +167 -0
- package/.github/workflows/publish-npm.yml +40 -0
- package/.github/workflows/pull-request-checks.yml +29 -0
- package/.scrutinizer.yml +24 -0
- package/AGENTS.md +56 -0
- package/FUNDING.yml +1 -0
- package/docs/technical/Cliente-Vendedor-Vinculo-e-Permissoes.md +121 -0
- package/docs/technical/Income-Statements-Demonstrativo.md +38 -0
- package/docs/technical/Oportunidades-Ordenacao-por-Data-de-Retorno.md +134 -0
- package/docs/technical/Propostas-Filtro-de-Status.md +147 -0
- package/docs/technical/Royalties-a-pagar-Franqueado.md +51 -0
- package/docs/technical/Visao-Vendedor-Comissoes.md +58 -0
- package/docs/wiki.md +1 -0
- package/package.json +43 -0
- package/scripts/validate-wiki-pointer.cjs +13 -0
- package/src/react/components/AnimatedModal.js +149 -0
- package/src/react/components/AnimatedModal.styles.js +21 -0
- package/src/react/components/CreateContractModal.js +151 -0
- package/src/react/components/CreateContractModal.styles.js +43 -0
- package/src/react/hooks/useToastMessage.js +59 -0
- package/src/react/index.js +4 -0
- package/src/react/pages/ModelTemplatesPage.js +1461 -0
- package/src/react/pages/ModelTemplatesPage.styles.js +441 -0
- package/src/react/pages/comissions/IncomeStatementDetailsModal.js +102 -0
- package/src/react/pages/comissions/IncomeStatementsFilters.js +120 -0
- package/src/react/pages/comissions/SellerCommissionsPage.js +368 -0
- package/src/react/pages/comissions/SellerCommissionsPage.styles.js +219 -0
- package/src/react/pages/comissions/incomeStatementsHelpers.js +233 -0
- package/src/react/pages/comissions/index.js +309 -0
- package/src/react/pages/comissions/index.styles.js +381 -0
- package/src/react/pages/comissions/sellerCommissionsHelpers.js +222 -0
- package/src/react/pages/crm/components/CrmHeader.js +117 -0
- package/src/react/pages/crm/components/MarketingEventsSection.js +142 -0
- package/src/react/pages/crm/components/MarketingEventsSection.styles.js +105 -0
- package/src/react/pages/crm/components/OpportunityCard.js +138 -0
- package/src/react/pages/crm/components/OpportunityFormModal.js +279 -0
- package/src/react/pages/crm/components/OpportunityList.js +113 -0
- package/src/react/pages/crm/components/OpportunitySkeletons.js +53 -0
- package/src/react/pages/crm/components/ProviderSelectModal.js +166 -0
- package/src/react/pages/crm/components/SelectModal.js +178 -0
- package/src/react/pages/crm/conversation.js +342 -0
- package/src/react/pages/crm/conversation.styles.js +206 -0
- package/src/react/pages/crm/hooks/useCrmData.js +494 -0
- package/src/react/pages/crm/hooks/useOpportunityForms.js +306 -0
- package/src/react/pages/crm/index.js +262 -0
- package/src/react/pages/crm/index.styles.js +13 -0
- package/src/react/pages/crm/marketingEventsHelpers.js +41 -0
- package/src/react/pages/crm/styles/card.styles.js +178 -0
- package/src/react/pages/crm/styles/layout.styles.js +184 -0
- package/src/react/pages/crm/styles/modal.styles.js +347 -0
- package/src/react/pages/home/index.js +559 -0
- package/src/react/pages/home/index.styles.js +268 -0
- package/src/react/pages/proposals/CreateProposalsModal.js +466 -0
- package/src/react/pages/proposals/CreateProposalsModal.styles.js +344 -0
- package/src/react/pages/proposals/CreateProposalsPickers.js +187 -0
- package/src/react/pages/proposals/CreateProposalsProductSection.js +117 -0
- package/src/react/pages/proposals/ProposalCard.js +112 -0
- package/src/react/pages/proposals/ProposalDetails.js +263 -0
- package/src/react/pages/proposals/ProposalDetails.styles.js +195 -0
- package/src/react/pages/proposals/index.js +488 -0
- package/src/react/pages/proposals/index.styles.js +248 -0
- package/src/react/pages/proposals/proposalListHelpers.js +216 -0
- package/src/react/pages/proposals/proposalNavigation.js +26 -0
- package/src/react/pages/royalties/ReceivablePage.js +233 -0
- package/src/react/pages/royalties/RoyaltiesPayablePage.js +260 -0
- package/src/react/pages/royalties/index.js +2 -0
- package/src/react/pages/royalties/royaltiesReceivableHelpers.js +68 -0
- package/src/react/pages/settings/GeneralSettings.js +317 -0
- package/src/react/pages/settings/GeneralSettings.shared.js +490 -0
- package/src/react/pages/settings/GeneralSettings.styles.js +746 -0
- package/src/react/pages/settings/GeneralSettingsSection.js +57 -0
- package/src/react/pages/settings/generalSettingsActiveTab.js +85 -0
- package/src/react/pages/settings/sections/CrmSection.js +281 -0
- package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +128 -0
- package/src/react/pages/settings/sections/DisplayPreparationSection.js +155 -0
- package/src/react/pages/settings/sections/IntegrationsSection.js +392 -0
- package/src/react/pages/settings/sections/LogSection.js +322 -0
- package/src/react/pages/settings/sections/LoginSection.js +137 -0
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +230 -0
- package/src/react/pages/settings/sections/LoyaltySection.js +451 -0
- package/src/react/pages/settings/sections/MaintenanceSection.js +205 -0
- package/src/react/pages/settings/sections/MapsSection.js +629 -0
- package/src/react/pages/settings/sections/MenuCatalogSection.js +405 -0
- package/src/react/pages/settings/sections/OperationsSection.js +303 -0
- package/src/react/pages/settings/sections/OrderPaymentSection.js +379 -0
- package/src/react/pages/settings/sections/OrderPrintSection.js +308 -0
- package/src/react/pages/settings/sections/ShopSection.js +490 -0
- package/src/react/pages/settings/sections/shop/FranchiseMapPreview.js +124 -0
- package/src/react/pages/settings/sections/shop/ShopDomainCreateForm.js +57 -0
- package/src/react/pages/settings/sections/shop/ShopDomainPanel.js +184 -0
- package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.js +237 -0
- package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.styles.js +256 -0
- package/src/react/pages/settings/sections/shop/ShopDomainTabs.js +61 -0
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +526 -0
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +426 -0
- package/src/react/pages/settings/sections/shop/ShopSettingsSection.js +10 -0
- package/src/react/pages/settings/sections/shop/mapsFranchiseMapHelpers.js +163 -0
- package/src/react/pages/settings/sections/shop/shopDomainShowcasesUtils.js +68 -0
- package/src/react/pages/settings/sections/shop/shopFranchiseVisibility.js +158 -0
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +427 -0
- package/src/react/router/routes.js +135 -0
- package/src/react/utils/opportunityDate.js +82 -0
- package/src/react/utils/opportunityEditorReferences.js +76 -0
- package/src/react/utils/opportunityEmptyState.js +20 -0
- package/src/react/utils/opportunityPeople.js +111 -0
- package/src/react/utils/opportunityPhone.js +82 -0
- package/src/react/utils/opportunityStage.js +30 -0
- package/src/react/utils/opportunityStatusFilter.js +54 -0
- package/src/react/utils/proposalCreateHelpers.js +61 -0
- package/src/react/utils/proposalProductSelection.js +71 -0
- package/src/react/utils/royaltiesPayableParams.js +37 -0
- package/src/react/utils/translateWithFallback.js +42 -0
- package/src/store/crm/index.js +2 -0
- package/src/store/model/index.js +104 -0
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +149 -0
- package/src/tests/browser/crm/crm-index-status-filter.spec.js +263 -0
- package/src/tests/browser/crm/crm-opportunity-category-editor.spec.js +269 -0
- package/src/tests/browser/crm/royalties-payable.spec.js +122 -0
- package/src/tests/browser/crm/royalties-receivable.spec.js +121 -0
- package/src/tests/browser/crm/seller-commissions.spec.js +214 -0
- package/src/tests/browser/manager/general-settings-maps.spec.js +400 -0
- package/src/tests/react/pages/comissions/incomeStatementsHelpers.test.js +181 -0
- package/src/tests/react/pages/comissions/sellerCommissionsHelpers.test.js +132 -0
- package/src/tests/react/pages/crm/marketingEventsHelpers.test.cjs +53 -0
- package/src/tests/react/pages/crm/opportunitySearchParams.test.cjs +44 -0
- package/src/tests/react/pages/proposals/navigation.test.js +71 -0
- package/src/tests/react/pages/proposals/proposalListHelpers.test.js +42 -0
- package/src/tests/react/pages/royalties/royaltiesReceivableHelpers.test.js +60 -0
- package/src/tests/react/pages/settings/generalSettings.shared.test.js +102 -0
- package/src/tests/react/pages/settings/sections/shop/shopDomainShowcasesUtils.test.js +60 -0
- package/src/tests/react/pages/settings/sections/shop/shopFranchiseVisibility.test.js +80 -0
- package/src/tests/react/utils/opportunityEditorReferences.test.js +70 -0
- package/src/tests/react/utils/opportunityEmptyState.test.js +39 -0
- package/src/tests/react/utils/opportunityStatusFilter.test.cjs +81 -0
- package/src/tests/react/utils/proposalCreateHelpers.test.js +25 -0
- package/src/tests/react/utils/proposalProductSelection.test.js +76 -0
- package/src/tests/react/utils/royaltiesPayableParams.test.js +44 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents This section controls the Google login gate for the main company.
|
|
3
|
+
* The save action must stay tied to the shared config contract and the current company context.
|
|
4
|
+
*/
|
|
5
|
+
import React, {useCallback, useEffect, useState} from 'react';
|
|
6
|
+
import {Text, TextInput} from 'react-native';
|
|
7
|
+
|
|
8
|
+
import useToastMessage from '@controleonline/ui-crm/src/react/hooks/useToastMessage';
|
|
9
|
+
import {
|
|
10
|
+
OAUTH_GOOGLE_CLIENT_ID_CONFIG_KEY,
|
|
11
|
+
resolveCompanyGoogleOauthClientId,
|
|
12
|
+
} from '@controleonline/ui-common/src/utils/oauth';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
useGeneralSettingsPalette,
|
|
16
|
+
useGeneralSettingsStyles,
|
|
17
|
+
} from '../GeneralSettings.styles';
|
|
18
|
+
import GeneralSettingsSection from '../GeneralSettingsSection';
|
|
19
|
+
import {toConfigRequestValue, useGeneralSettingsConfig} from '../GeneralSettings.shared';
|
|
20
|
+
|
|
21
|
+
const LoginSection = () => {
|
|
22
|
+
const localStyles = useGeneralSettingsStyles();
|
|
23
|
+
const themePalette = useGeneralSettingsPalette();
|
|
24
|
+
const {showError, showSuccess} = useToastMessage();
|
|
25
|
+
const {
|
|
26
|
+
configActions,
|
|
27
|
+
mainCompany,
|
|
28
|
+
mainCompanyLabel,
|
|
29
|
+
hasMainCompanyAccess,
|
|
30
|
+
isMainCompanySelected,
|
|
31
|
+
peopleActions,
|
|
32
|
+
} = useGeneralSettingsConfig();
|
|
33
|
+
|
|
34
|
+
const [googleClientId, setGoogleClientId] = useState('');
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setGoogleClientId(resolveCompanyGoogleOauthClientId(mainCompany));
|
|
38
|
+
}, [mainCompany?.configs]);
|
|
39
|
+
|
|
40
|
+
const saveGoogleOauthConfig = useCallback(() => {
|
|
41
|
+
if (!hasMainCompanyAccess || !mainCompany?.id) {
|
|
42
|
+
showError(
|
|
43
|
+
'Nao foi possivel identificar a empresa principal para salvar o login Google.',
|
|
44
|
+
);
|
|
45
|
+
return Promise.resolve(false);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!isMainCompanySelected) {
|
|
49
|
+
showError(
|
|
50
|
+
'Abra as configuracoes da empresa principal para editar o Google OAuth.',
|
|
51
|
+
);
|
|
52
|
+
return Promise.resolve(false);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const normalizedGoogleClientId = String(googleClientId || '').trim();
|
|
56
|
+
|
|
57
|
+
return new Promise(resolve => {
|
|
58
|
+
configActions.addToQueue(() =>
|
|
59
|
+
configActions
|
|
60
|
+
.addConfigs({
|
|
61
|
+
configKey: OAUTH_GOOGLE_CLIENT_ID_CONFIG_KEY,
|
|
62
|
+
configValue: toConfigRequestValue(normalizedGoogleClientId),
|
|
63
|
+
people: '/people/' + mainCompany.id,
|
|
64
|
+
module: 4,
|
|
65
|
+
visibility: 'public',
|
|
66
|
+
})
|
|
67
|
+
.then(async data => {
|
|
68
|
+
setGoogleClientId(normalizedGoogleClientId);
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
await peopleActions.mainCompany();
|
|
72
|
+
} catch {}
|
|
73
|
+
|
|
74
|
+
showSuccess('Google OAuth salvo com sucesso.');
|
|
75
|
+
resolve(true);
|
|
76
|
+
return data;
|
|
77
|
+
})
|
|
78
|
+
.catch(err => {
|
|
79
|
+
showError(err?.message || JSON.stringify(err));
|
|
80
|
+
resolve(false);
|
|
81
|
+
return null;
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
configActions.initQueue();
|
|
85
|
+
});
|
|
86
|
+
}, [
|
|
87
|
+
configActions,
|
|
88
|
+
mainCompany?.id,
|
|
89
|
+
hasMainCompanyAccess,
|
|
90
|
+
googleClientId,
|
|
91
|
+
isMainCompanySelected,
|
|
92
|
+
peopleActions,
|
|
93
|
+
showError,
|
|
94
|
+
showSuccess,
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<GeneralSettingsSection
|
|
99
|
+
description="Centraliza a chave publica usada pelo login Google da tela React."
|
|
100
|
+
icon="login"
|
|
101
|
+
iconBackgroundColor={themePalette.cardIconBackground}
|
|
102
|
+
iconColor={themePalette.cardIconColor}
|
|
103
|
+
title="Login e autenticacao">
|
|
104
|
+
<Text style={localStyles.helperText}>
|
|
105
|
+
{`Esse client ID e salvo na empresa principal (${mainCompanyLabel}) e controla quando o botao "Entrar com Google" aparece no login web.`}
|
|
106
|
+
</Text>
|
|
107
|
+
|
|
108
|
+
{!isMainCompanySelected && (
|
|
109
|
+
<Text style={localStyles.helperText}>
|
|
110
|
+
Abra a empresa principal para editar essa configuracao.
|
|
111
|
+
</Text>
|
|
112
|
+
)}
|
|
113
|
+
|
|
114
|
+
<Text style={localStyles.fieldLabel}>OAUTH_GOOGLE_CLIENT_ID</Text>
|
|
115
|
+
<TextInput
|
|
116
|
+
style={[
|
|
117
|
+
localStyles.input,
|
|
118
|
+
(!mainCompany?.id || !isMainCompanySelected) &&
|
|
119
|
+
localStyles.inputDisabled,
|
|
120
|
+
]}
|
|
121
|
+
value={googleClientId}
|
|
122
|
+
onChangeText={setGoogleClientId}
|
|
123
|
+
onBlur={saveGoogleOauthConfig}
|
|
124
|
+
editable={!!mainCompany?.id && isMainCompanySelected}
|
|
125
|
+
autoCapitalize="none"
|
|
126
|
+
autoCorrect={false}
|
|
127
|
+
placeholder="1234567890-abc123def456.apps.googleusercontent.com"
|
|
128
|
+
/>
|
|
129
|
+
<Text style={localStyles.helperText}>
|
|
130
|
+
Deixe vazio para ocultar o login Google no React sem depender de
|
|
131
|
+
variavel de ambiente.
|
|
132
|
+
</Text>
|
|
133
|
+
</GeneralSettingsSection>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export default LoginSection;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents Shared product picker helpers for Loyalty (Fidelidade) settings.
|
|
3
|
+
*/
|
|
4
|
+
import React, {useEffect, useState} from 'react';
|
|
5
|
+
import {
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
ScrollView,
|
|
8
|
+
Text,
|
|
9
|
+
TextInput,
|
|
10
|
+
TouchableOpacity,
|
|
11
|
+
View,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
14
|
+
import AnimatedModal from '@controleonline/ui-common/src/react/components/AnimatedModal';
|
|
15
|
+
import {searchCompanyProducts} from '@controleonline/ui-common/src/react/utils/commercialDocumentOrders';
|
|
16
|
+
import {normalizeShopProductId} from '@controleonline/ui-common/src/react/utils/shopConfig';
|
|
17
|
+
|
|
18
|
+
export const resolveProductLabel = product => {
|
|
19
|
+
const normalizedId = normalizeShopProductId(product);
|
|
20
|
+
return (
|
|
21
|
+
String(
|
|
22
|
+
product?.product ||
|
|
23
|
+
product?.name ||
|
|
24
|
+
product?.description ||
|
|
25
|
+
(normalizedId ? `Produto #${normalizedId}` : 'Produto'),
|
|
26
|
+
).trim() || 'Produto'
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const resolveProductMeta = product => {
|
|
31
|
+
const sku = String(product?.sku || '').trim();
|
|
32
|
+
const price = Number(product?.price || 0);
|
|
33
|
+
const priceLabel = Number.isFinite(price)
|
|
34
|
+
? `R$ ${price.toFixed(2).replace('.', ',')}`
|
|
35
|
+
: '';
|
|
36
|
+
|
|
37
|
+
return [sku ? `SKU ${sku}` : null, price > 0 ? priceLabel : null]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(' • ');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const useProductBrowser = ({companyId, visible}) => {
|
|
43
|
+
const [query, setQuery] = useState('');
|
|
44
|
+
const [results, setResults] = useState([]);
|
|
45
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!visible || !companyId) {
|
|
49
|
+
setResults([]);
|
|
50
|
+
setIsLoading(false);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const trimmedQuery = String(query || '').trim();
|
|
55
|
+
let cancelled = false;
|
|
56
|
+
|
|
57
|
+
const timeoutId = setTimeout(async () => {
|
|
58
|
+
setIsLoading(true);
|
|
59
|
+
try {
|
|
60
|
+
const items = await searchCompanyProducts({
|
|
61
|
+
companyId,
|
|
62
|
+
query: trimmedQuery,
|
|
63
|
+
});
|
|
64
|
+
if (!cancelled) {
|
|
65
|
+
setResults(Array.isArray(items) ? items : []);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
if (!cancelled) {
|
|
69
|
+
setResults([]);
|
|
70
|
+
}
|
|
71
|
+
} finally {
|
|
72
|
+
if (!cancelled) {
|
|
73
|
+
setIsLoading(false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, trimmedQuery ? 250 : 0);
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
cancelled = true;
|
|
80
|
+
clearTimeout(timeoutId);
|
|
81
|
+
};
|
|
82
|
+
}, [companyId, query, visible]);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!visible) {
|
|
86
|
+
setQuery('');
|
|
87
|
+
setResults([]);
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
}
|
|
90
|
+
}, [visible]);
|
|
91
|
+
|
|
92
|
+
return {isLoading, query, results, setQuery};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const ProductSelectionModal = ({
|
|
96
|
+
visible,
|
|
97
|
+
title,
|
|
98
|
+
helperText,
|
|
99
|
+
browser,
|
|
100
|
+
onClose,
|
|
101
|
+
onSelect,
|
|
102
|
+
selectedIds,
|
|
103
|
+
selectedItemId,
|
|
104
|
+
multiSelect = false,
|
|
105
|
+
palette,
|
|
106
|
+
styles,
|
|
107
|
+
globalStyles,
|
|
108
|
+
}) => {
|
|
109
|
+
const selectedSet = selectedIds || new Set();
|
|
110
|
+
const selectedId = String(selectedItemId || '').trim();
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<AnimatedModal visible={visible} onRequestClose={onClose}>
|
|
114
|
+
<View style={styles.selectionModal}>
|
|
115
|
+
<View style={styles.selectionModalHeader}>
|
|
116
|
+
<View style={styles.selectionModalHeaderCopy}>
|
|
117
|
+
<Text style={styles.selectionModalTitle}>{title}</Text>
|
|
118
|
+
{helperText ? (
|
|
119
|
+
<Text style={styles.selectionModalSubtitle}>{helperText}</Text>
|
|
120
|
+
) : null}
|
|
121
|
+
</View>
|
|
122
|
+
<TouchableOpacity
|
|
123
|
+
style={styles.selectionModalClose}
|
|
124
|
+
onPress={onClose}
|
|
125
|
+
activeOpacity={0.85}>
|
|
126
|
+
<Icon name="close" size={20} color={palette.iconDefault} />
|
|
127
|
+
</TouchableOpacity>
|
|
128
|
+
</View>
|
|
129
|
+
|
|
130
|
+
<View style={styles.selectorRow}>
|
|
131
|
+
<Icon
|
|
132
|
+
name="search"
|
|
133
|
+
size={18}
|
|
134
|
+
color={palette.iconMuted}
|
|
135
|
+
style={{marginRight: 8}}
|
|
136
|
+
/>
|
|
137
|
+
<TextInput
|
|
138
|
+
value={browser.query}
|
|
139
|
+
onChangeText={browser.setQuery}
|
|
140
|
+
placeholder="Pesquisar produto..."
|
|
141
|
+
placeholderTextColor={palette.inputPlaceholderText}
|
|
142
|
+
style={[styles.input, styles.selectorInput, {flex: 1}]}
|
|
143
|
+
returnKeyType="search"
|
|
144
|
+
/>
|
|
145
|
+
</View>
|
|
146
|
+
|
|
147
|
+
<ScrollView
|
|
148
|
+
style={styles.selectionModalList}
|
|
149
|
+
contentContainerStyle={styles.selectionModalListContent}
|
|
150
|
+
keyboardShouldPersistTaps="handled">
|
|
151
|
+
{browser.isLoading ? (
|
|
152
|
+
<ActivityIndicator
|
|
153
|
+
size="small"
|
|
154
|
+
color={palette.loadingSpinner}
|
|
155
|
+
style={styles.sectionLoader}
|
|
156
|
+
/>
|
|
157
|
+
) : browser.results.length === 0 ? (
|
|
158
|
+
<View style={styles.searchEmptyState}>
|
|
159
|
+
<Icon name="inventory-2" size={28} color={palette.iconMuted} />
|
|
160
|
+
<Text style={styles.searchEmptyStateTitle}>
|
|
161
|
+
Nenhum produto encontrado
|
|
162
|
+
</Text>
|
|
163
|
+
<Text style={styles.searchEmptyStateText}>
|
|
164
|
+
{String(browser.query || '').trim()
|
|
165
|
+
? 'Tente outro termo para localizar um produto existente.'
|
|
166
|
+
: 'Nenhum item disponível apareceu para seleção.'}
|
|
167
|
+
</Text>
|
|
168
|
+
</View>
|
|
169
|
+
) : (
|
|
170
|
+
browser.results.map(item => {
|
|
171
|
+
const itemId = normalizeShopProductId(item);
|
|
172
|
+
const selected = multiSelect
|
|
173
|
+
? selectedSet.has(itemId)
|
|
174
|
+
: itemId === selectedId;
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<TouchableOpacity
|
|
178
|
+
key={`loyalty-picker-${itemId}`}
|
|
179
|
+
style={[
|
|
180
|
+
styles.selectionModalItem,
|
|
181
|
+
selected && styles.selectionModalItemActive,
|
|
182
|
+
]}
|
|
183
|
+
activeOpacity={0.85}
|
|
184
|
+
onPress={() => onSelect(item)}>
|
|
185
|
+
<Icon
|
|
186
|
+
name={
|
|
187
|
+
selected
|
|
188
|
+
? multiSelect
|
|
189
|
+
? 'check-circle'
|
|
190
|
+
: 'radio-button-checked'
|
|
191
|
+
: multiSelect
|
|
192
|
+
? 'add-circle-outline'
|
|
193
|
+
: 'radio-button-unchecked'
|
|
194
|
+
}
|
|
195
|
+
size={20}
|
|
196
|
+
color={selected ? palette.iconActive : palette.iconDisabled}
|
|
197
|
+
/>
|
|
198
|
+
<View style={styles.selectionModalItemCopy}>
|
|
199
|
+
<Text style={styles.selectionModalItemTitle}>
|
|
200
|
+
{resolveProductLabel(item)}
|
|
201
|
+
</Text>
|
|
202
|
+
<Text style={styles.selectionModalItemMeta}>
|
|
203
|
+
{selected
|
|
204
|
+
? multiSelect
|
|
205
|
+
? 'Selecionado para participar da fidelidade'
|
|
206
|
+
: 'Selecionado como brinde'
|
|
207
|
+
: resolveProductMeta(item) || 'Toque para selecionar'}
|
|
208
|
+
</Text>
|
|
209
|
+
</View>
|
|
210
|
+
</TouchableOpacity>
|
|
211
|
+
);
|
|
212
|
+
})
|
|
213
|
+
)}
|
|
214
|
+
</ScrollView>
|
|
215
|
+
|
|
216
|
+
{multiSelect ? (
|
|
217
|
+
<TouchableOpacity
|
|
218
|
+
style={[
|
|
219
|
+
globalStyles.button,
|
|
220
|
+
styles.primaryButton,
|
|
221
|
+
styles.selectionModalActionButton,
|
|
222
|
+
]}
|
|
223
|
+
onPress={onClose}>
|
|
224
|
+
<Text style={styles.primaryButtonText}>Concluir seleção</Text>
|
|
225
|
+
</TouchableOpacity>
|
|
226
|
+
) : null}
|
|
227
|
+
</View>
|
|
228
|
+
</AnimatedModal>
|
|
229
|
+
);
|
|
230
|
+
};
|