@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,113 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatList, RefreshControl, View } from 'react-native';
|
|
3
|
+
import { Text } from 'react-native-animatable';
|
|
4
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
5
|
+
|
|
6
|
+
import OpportunityCard from './OpportunityCard';
|
|
7
|
+
import { OpportunitySkeletonCard } from './OpportunitySkeletons';
|
|
8
|
+
import styles from '../index.styles';
|
|
9
|
+
|
|
10
|
+
const EmptyOpportunities = ({ error, opportunityEmptyStateMode }) => (
|
|
11
|
+
<View style={styles.emptyContainer}>
|
|
12
|
+
{error ? (
|
|
13
|
+
<>
|
|
14
|
+
<Icon name="exclamation-triangle" size={48} color="#c10015" />
|
|
15
|
+
<Text style={styles.loadingText}>
|
|
16
|
+
{global.t?.t('people', 'state', 'loadError')}
|
|
17
|
+
</Text>
|
|
18
|
+
</>
|
|
19
|
+
) : (
|
|
20
|
+
<>
|
|
21
|
+
<Icon name="line-chart" size={64} color="#bdc3c7" />
|
|
22
|
+
<Text style={styles.emptyTitle}>
|
|
23
|
+
{opportunityEmptyStateMode === 'filtered'
|
|
24
|
+
? global.t?.t('people', 'state', 'noOpportunityFound')
|
|
25
|
+
: global.t?.t('people', 'state', 'noOpportunity')}
|
|
26
|
+
</Text>
|
|
27
|
+
<Text style={styles.emptySubtitle}>
|
|
28
|
+
{opportunityEmptyStateMode === 'filtered'
|
|
29
|
+
? global.t?.t('people', 'state', 'tryOtherTerms')
|
|
30
|
+
: global.t?.t('people', 'state', 'addFirstOpportunity')}
|
|
31
|
+
</Text>
|
|
32
|
+
</>
|
|
33
|
+
)}
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const OpportunityList = ({
|
|
38
|
+
allOpportunities,
|
|
39
|
+
error,
|
|
40
|
+
getProviderName,
|
|
41
|
+
handleEditProvider,
|
|
42
|
+
handleEditOpportunity,
|
|
43
|
+
handleOpportunityPress,
|
|
44
|
+
isLoading,
|
|
45
|
+
isPeopleLoading,
|
|
46
|
+
isStatusLoading,
|
|
47
|
+
knownPeople,
|
|
48
|
+
onRefresh,
|
|
49
|
+
opportunityEmptyStateMode,
|
|
50
|
+
refreshing,
|
|
51
|
+
setCurrentPage,
|
|
52
|
+
showOpportunityCardsSkeleton,
|
|
53
|
+
toggleStatus,
|
|
54
|
+
totalItems,
|
|
55
|
+
visibleOpportunities,
|
|
56
|
+
}) => (
|
|
57
|
+
<FlatList
|
|
58
|
+
data={showOpportunityCardsSkeleton ? [] : visibleOpportunities}
|
|
59
|
+
keyExtractor={item => String(item.id)}
|
|
60
|
+
renderItem={({ item }) => (
|
|
61
|
+
<OpportunityCard
|
|
62
|
+
opportunity={item}
|
|
63
|
+
getProviderName={getProviderName}
|
|
64
|
+
handleEditProvider={handleEditProvider}
|
|
65
|
+
handleEditOpportunity={handleEditOpportunity}
|
|
66
|
+
handleOpportunityPress={handleOpportunityPress}
|
|
67
|
+
isPeopleLoading={isPeopleLoading}
|
|
68
|
+
isStatusLoading={isStatusLoading}
|
|
69
|
+
knownPeople={knownPeople}
|
|
70
|
+
toggleStatus={toggleStatus}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
refreshControl={
|
|
74
|
+
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
|
|
75
|
+
}
|
|
76
|
+
contentContainerStyle={[
|
|
77
|
+
styles.scrollContent,
|
|
78
|
+
showOpportunityCardsSkeleton && styles.scrollContentSkeleton,
|
|
79
|
+
]}
|
|
80
|
+
ListEmptyComponent={() =>
|
|
81
|
+
showOpportunityCardsSkeleton ? (
|
|
82
|
+
<View style={styles.skeletonListWrapper}>
|
|
83
|
+
{[1, 2, 3, 4, 5].map(key => (
|
|
84
|
+
<View key={key}>
|
|
85
|
+
<OpportunitySkeletonCard />
|
|
86
|
+
</View>
|
|
87
|
+
))}
|
|
88
|
+
</View>
|
|
89
|
+
) : (
|
|
90
|
+
<EmptyOpportunities
|
|
91
|
+
error={error}
|
|
92
|
+
opportunityEmptyStateMode={opportunityEmptyStateMode}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
onEndReached={() => {
|
|
97
|
+
if (!isLoading && allOpportunities.length < totalItems) {
|
|
98
|
+
setCurrentPage(prev => prev + 1);
|
|
99
|
+
}
|
|
100
|
+
}}
|
|
101
|
+
onEndReachedThreshold={0.5}
|
|
102
|
+
ListFooterComponent={() =>
|
|
103
|
+
isLoading && allOpportunities.length > 0 ? (
|
|
104
|
+
<View style={styles.skeletonFooter}>
|
|
105
|
+
<OpportunitySkeletonCard />
|
|
106
|
+
<OpportunitySkeletonCard />
|
|
107
|
+
</View>
|
|
108
|
+
) : null
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
export default OpportunityList;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import styles from '../index.styles';
|
|
5
|
+
|
|
6
|
+
export const OpportunitySkeletonCard = () => (
|
|
7
|
+
<View style={styles.cardWrapper}>
|
|
8
|
+
<View style={styles.card}>
|
|
9
|
+
<View style={styles.cardHeader}>
|
|
10
|
+
<View style={styles.titleContainer}>
|
|
11
|
+
<View style={[styles.skeletonLine, { width: '60%', height: 16, marginBottom: 8 }]} />
|
|
12
|
+
<View style={[styles.skeletonLine, { width: '80%', height: 13 }]} />
|
|
13
|
+
</View>
|
|
14
|
+
<View style={[styles.skeletonLine, { width: 72, height: 28, borderRadius: 10 }]} />
|
|
15
|
+
</View>
|
|
16
|
+
<View style={styles.cardBody}>
|
|
17
|
+
<View style={styles.infoRow}>
|
|
18
|
+
<View style={[styles.skeletonLine, { flex: 1, height: 12, marginRight: 8 }]} />
|
|
19
|
+
<View style={[styles.skeletonLine, { flex: 1, height: 12 }]} />
|
|
20
|
+
</View>
|
|
21
|
+
<View style={styles.infoRow}>
|
|
22
|
+
<View style={[styles.skeletonLine, { flex: 1, height: 12, marginRight: 8 }]} />
|
|
23
|
+
<View style={[styles.skeletonLine, { flex: 1, height: 12 }]} />
|
|
24
|
+
</View>
|
|
25
|
+
</View>
|
|
26
|
+
<View style={[styles.actionContainer, { marginTop: 12 }]}>
|
|
27
|
+
<View style={[styles.skeletonLine, { flex: 1, height: 40, borderRadius: 12 }]} />
|
|
28
|
+
<View style={[styles.skeletonLine, { flex: 1, height: 40, borderRadius: 12 }]} />
|
|
29
|
+
</View>
|
|
30
|
+
</View>
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const CrmTopSkeleton = () => (
|
|
35
|
+
<View style={styles.subHeader}>
|
|
36
|
+
<View style={styles.searchRow}>
|
|
37
|
+
<View style={[styles.skeletonLine, styles.searchSkeletonInput]} />
|
|
38
|
+
<View style={[styles.skeletonLine, styles.searchSkeletonButton]} />
|
|
39
|
+
</View>
|
|
40
|
+
|
|
41
|
+
<View style={styles.statusFilterSection}>
|
|
42
|
+
<View style={[styles.skeletonLine, styles.statusLabelSkeleton]} />
|
|
43
|
+
<View style={styles.statusSkeletonRow}>
|
|
44
|
+
{[1, 2, 3, 4].map(key => (
|
|
45
|
+
<View
|
|
46
|
+
key={key}
|
|
47
|
+
style={[styles.skeletonLine, styles.statusChipSkeleton]}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</View>
|
|
51
|
+
</View>
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
ScrollView,
|
|
5
|
+
TextInput,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { Text } from 'react-native-animatable';
|
|
10
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
11
|
+
|
|
12
|
+
import AnimatedModal from '@controleonline/ui-common/src/react/components/AnimatedModal';
|
|
13
|
+
import { colors } from '@controleonline/../../src/styles/colors';
|
|
14
|
+
import { formatDisplayUppercase } from '@controleonline/ui-common/src/react/utils/entityDisplay';
|
|
15
|
+
import { normalizePeopleReferenceValue } from '../../../utils/opportunityPeople';
|
|
16
|
+
import styles from '../index.styles';
|
|
17
|
+
|
|
18
|
+
const ProviderSelectModal = ({
|
|
19
|
+
closeProviderPicker,
|
|
20
|
+
editModalVisible,
|
|
21
|
+
editingOpportunity,
|
|
22
|
+
isProviderSearchLoading,
|
|
23
|
+
newOpportunity,
|
|
24
|
+
providerOptions,
|
|
25
|
+
providerPickerVisible,
|
|
26
|
+
providerSearchText,
|
|
27
|
+
setEditingOpportunity,
|
|
28
|
+
setNewOpportunity,
|
|
29
|
+
setProviderSearchText,
|
|
30
|
+
}) => (
|
|
31
|
+
<AnimatedModal
|
|
32
|
+
visible={providerPickerVisible}
|
|
33
|
+
onRequestClose={closeProviderPicker}>
|
|
34
|
+
<View style={styles.selectModalContent}>
|
|
35
|
+
<View style={styles.selectModalHeader}>
|
|
36
|
+
<Text style={styles.selectModalTitle}>
|
|
37
|
+
{global.t?.t('people', 'modal', 'selectProvider')}
|
|
38
|
+
</Text>
|
|
39
|
+
<TouchableOpacity
|
|
40
|
+
onPress={closeProviderPicker}
|
|
41
|
+
style={styles.closeButton}>
|
|
42
|
+
<Icon name="times" size={20} color="#7f8c8d" />
|
|
43
|
+
</TouchableOpacity>
|
|
44
|
+
</View>
|
|
45
|
+
|
|
46
|
+
<View style={styles.selectModalSearchSection}>
|
|
47
|
+
<View style={styles.searchInputContainer}>
|
|
48
|
+
<Icon name="search" size={16} color="#94A3B8" />
|
|
49
|
+
<TextInput
|
|
50
|
+
style={styles.searchInput}
|
|
51
|
+
placeholder={global.t?.t('people', 'search', 'placeholder')}
|
|
52
|
+
placeholderTextColor="#94A3B8"
|
|
53
|
+
value={providerSearchText}
|
|
54
|
+
onChangeText={setProviderSearchText}
|
|
55
|
+
/>
|
|
56
|
+
{providerSearchText.length > 0 && (
|
|
57
|
+
<TouchableOpacity
|
|
58
|
+
onPress={() => setProviderSearchText('')}
|
|
59
|
+
style={styles.clearSearchButton}>
|
|
60
|
+
<Icon name="times-circle" size={16} color="#94A3B8" />
|
|
61
|
+
</TouchableOpacity>
|
|
62
|
+
)}
|
|
63
|
+
</View>
|
|
64
|
+
</View>
|
|
65
|
+
|
|
66
|
+
<ScrollView style={styles.selectModalBody}>
|
|
67
|
+
{isProviderSearchLoading && providerOptions.length === 0 ? (
|
|
68
|
+
<View style={styles.providerSearchLoadingState}>
|
|
69
|
+
<ActivityIndicator color={colors.primary} size="small" />
|
|
70
|
+
</View>
|
|
71
|
+
) : providerOptions.length > 0 ? (
|
|
72
|
+
providerOptions
|
|
73
|
+
.filter((person, index, source) => {
|
|
74
|
+
const currentRef = normalizePeopleReferenceValue(person);
|
|
75
|
+
if (!currentRef) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
source.findIndex(
|
|
81
|
+
candidate =>
|
|
82
|
+
normalizePeopleReferenceValue(candidate) === currentRef,
|
|
83
|
+
) === index
|
|
84
|
+
);
|
|
85
|
+
})
|
|
86
|
+
.map((person, index) => {
|
|
87
|
+
const selectedClientRef = normalizePeopleReferenceValue(
|
|
88
|
+
editModalVisible
|
|
89
|
+
? editingOpportunity?.client
|
|
90
|
+
: newOpportunity?.client,
|
|
91
|
+
);
|
|
92
|
+
const personRef = normalizePeopleReferenceValue(person);
|
|
93
|
+
const personKey =
|
|
94
|
+
personRef ||
|
|
95
|
+
`person-${person.id || 'sem-id'}-${person.document || 'sem-doc'}-${person.name || 'sem-nome'}-${index}`;
|
|
96
|
+
const isSelected =
|
|
97
|
+
Boolean(selectedClientRef) &&
|
|
98
|
+
Boolean(personRef) &&
|
|
99
|
+
selectedClientRef === personRef;
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<TouchableOpacity
|
|
103
|
+
key={personKey}
|
|
104
|
+
style={[
|
|
105
|
+
styles.selectOption,
|
|
106
|
+
isSelected && styles.selectOptionActive,
|
|
107
|
+
]}
|
|
108
|
+
onPress={() => {
|
|
109
|
+
const clientData = {
|
|
110
|
+
'@id': personRef || person['@id'] || '',
|
|
111
|
+
id: person.id ?? personRef,
|
|
112
|
+
name: person.name,
|
|
113
|
+
document: person.document,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (editModalVisible) {
|
|
117
|
+
setEditingOpportunity(prev => ({
|
|
118
|
+
...prev,
|
|
119
|
+
client: clientData,
|
|
120
|
+
}));
|
|
121
|
+
} else {
|
|
122
|
+
setNewOpportunity(prev => ({
|
|
123
|
+
...prev,
|
|
124
|
+
client: clientData,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
closeProviderPicker();
|
|
128
|
+
}}>
|
|
129
|
+
<View style={styles.personInfo}>
|
|
130
|
+
<View style={styles.avatarContainer}>
|
|
131
|
+
<Icon name="user" size={20} color="#3498db" />
|
|
132
|
+
</View>
|
|
133
|
+
<View style={styles.personDetails}>
|
|
134
|
+
<Text
|
|
135
|
+
style={[
|
|
136
|
+
styles.personAlias,
|
|
137
|
+
isSelected && styles.selectOptionTextActive,
|
|
138
|
+
]}>
|
|
139
|
+
{formatDisplayUppercase(person.alias)}
|
|
140
|
+
</Text>
|
|
141
|
+
<Text style={styles.personName}>
|
|
142
|
+
{person.peopleType === 'J' ? ' (PJ)' : ' (PF)'}{' '}
|
|
143
|
+
{formatDisplayUppercase(person.name)}
|
|
144
|
+
</Text>
|
|
145
|
+
</View>
|
|
146
|
+
</View>
|
|
147
|
+
{isSelected && (
|
|
148
|
+
<Icon name="check-circle" size={20} color="#10b981" />
|
|
149
|
+
)}
|
|
150
|
+
</TouchableOpacity>
|
|
151
|
+
);
|
|
152
|
+
})
|
|
153
|
+
) : (
|
|
154
|
+
<View style={styles.emptyState}>
|
|
155
|
+
<Icon name="user" size={48} color="#bdc3c7" />
|
|
156
|
+
<Text style={styles.emptyText}>
|
|
157
|
+
{global.t?.t('people', 'empty', 'noProviderFound')}
|
|
158
|
+
</Text>
|
|
159
|
+
</View>
|
|
160
|
+
)}
|
|
161
|
+
</ScrollView>
|
|
162
|
+
</View>
|
|
163
|
+
</AnimatedModal>
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
export default ProviderSelectModal;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { Text } from 'react-native-animatable';
|
|
4
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
5
|
+
|
|
6
|
+
import AnimatedModal from '@controleonline/ui-common/src/react/components/AnimatedModal';
|
|
7
|
+
import { colors } from '@controleonline/../../src/styles/colors';
|
|
8
|
+
import styles from '../index.styles';
|
|
9
|
+
|
|
10
|
+
const getSelectModalEmptyConfig = title => {
|
|
11
|
+
const normalizedTitle = String(title || '').toLowerCase();
|
|
12
|
+
|
|
13
|
+
if (normalizedTitle.includes('categoria')) {
|
|
14
|
+
return {
|
|
15
|
+
icon: 'tags',
|
|
16
|
+
title: global.t?.t('people', 'modal', 'noCategories'),
|
|
17
|
+
subtitle: global.t?.t('people', 'modal', 'noCategoriesHint'),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (normalizedTitle.includes('status')) {
|
|
22
|
+
return {
|
|
23
|
+
icon: 'flag',
|
|
24
|
+
title: global.t?.t('people', 'modal', 'noStatus'),
|
|
25
|
+
subtitle: global.t?.t('people', 'modal', 'noStatusHint'),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (normalizedTitle.includes('criticidade')) {
|
|
30
|
+
return {
|
|
31
|
+
icon: 'exclamation-circle',
|
|
32
|
+
title: global.t?.t('people', 'modal', 'noCriticalities'),
|
|
33
|
+
subtitle: global.t?.t('people', 'modal', 'noCriticalitiesHint'),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (normalizedTitle.includes('motivo')) {
|
|
38
|
+
return {
|
|
39
|
+
icon: 'question-circle',
|
|
40
|
+
title: global.t?.t('people', 'modal', 'noReasons'),
|
|
41
|
+
subtitle: global.t?.t('people', 'modal', 'noReasonsHint'),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (normalizedTitle.includes('dia') || normalizedTitle.includes('mês')) {
|
|
46
|
+
return {
|
|
47
|
+
icon: 'calendar',
|
|
48
|
+
title: global.t?.t('people', 'modal', 'noOptions'),
|
|
49
|
+
subtitle: global.t?.t('people', 'modal', 'tryAgainSoon'),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
icon: 'inbox',
|
|
55
|
+
title: global.t?.t('people', 'modal', 'nothingToShow'),
|
|
56
|
+
subtitle: global.t?.t('people', 'modal', 'noOptionsNow'),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const SelectModal = ({
|
|
61
|
+
getOptionIdentity,
|
|
62
|
+
getStatusFilterLabel,
|
|
63
|
+
isQuestionLikeIcon,
|
|
64
|
+
isValidFontAwesomeIcon,
|
|
65
|
+
items,
|
|
66
|
+
onSelect,
|
|
67
|
+
renderKey = 'name',
|
|
68
|
+
selectedItem,
|
|
69
|
+
setVisible,
|
|
70
|
+
title,
|
|
71
|
+
visible,
|
|
72
|
+
}) => {
|
|
73
|
+
const emptyCfg = getSelectModalEmptyConfig(title);
|
|
74
|
+
const safeItems = Array.isArray(items) ? items : [];
|
|
75
|
+
const normalizedTitle = String(title || '').toLowerCase();
|
|
76
|
+
const selectedIdentity = getOptionIdentity(selectedItem);
|
|
77
|
+
const isStatusModal =
|
|
78
|
+
normalizedTitle.includes('status') || renderKey === 'status';
|
|
79
|
+
const isCategoryOrCriticalityModal =
|
|
80
|
+
normalizedTitle.includes('categoria') ||
|
|
81
|
+
normalizedTitle.includes('criticidade');
|
|
82
|
+
const isReasonModal = normalizedTitle.includes('motivo');
|
|
83
|
+
const itemsToRender =
|
|
84
|
+
selectedItem && selectedIdentity
|
|
85
|
+
? safeItems.some(item => getOptionIdentity(item) === selectedIdentity)
|
|
86
|
+
? safeItems
|
|
87
|
+
: [selectedItem, ...safeItems]
|
|
88
|
+
: safeItems;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<AnimatedModal visible={visible} onRequestClose={() => setVisible(false)}>
|
|
92
|
+
<View style={styles.selectModalContent}>
|
|
93
|
+
<View style={styles.selectModalHeader}>
|
|
94
|
+
<Text style={styles.selectModalTitle}>{title}</Text>
|
|
95
|
+
<TouchableOpacity
|
|
96
|
+
onPress={() => setVisible(false)}
|
|
97
|
+
style={styles.closeButton}>
|
|
98
|
+
<Icon name="times" size={20} color="#7f8c8d" />
|
|
99
|
+
</TouchableOpacity>
|
|
100
|
+
</View>
|
|
101
|
+
|
|
102
|
+
{itemsToRender.length === 0 ? (
|
|
103
|
+
<View style={styles.selectModalEmptyState}>
|
|
104
|
+
<View style={styles.selectModalEmptyIcon}>
|
|
105
|
+
<Icon name={emptyCfg.icon} size={22} color="#94A3B8" />
|
|
106
|
+
</View>
|
|
107
|
+
<Text style={styles.selectModalEmptyTitle}>{emptyCfg.title}</Text>
|
|
108
|
+
<Text style={styles.selectModalEmptySubtitle}>
|
|
109
|
+
{emptyCfg.subtitle}
|
|
110
|
+
</Text>
|
|
111
|
+
</View>
|
|
112
|
+
) : (
|
|
113
|
+
<ScrollView
|
|
114
|
+
style={styles.selectModalBody}
|
|
115
|
+
contentContainerStyle={styles.selectModalBodyContent}>
|
|
116
|
+
{itemsToRender.map(item => {
|
|
117
|
+
const optionIdentity = getOptionIdentity(item);
|
|
118
|
+
const isSelected = selectedIdentity === optionIdentity;
|
|
119
|
+
const optionLabel = isStatusModal
|
|
120
|
+
? getStatusFilterLabel(item)
|
|
121
|
+
: item[renderKey] ||
|
|
122
|
+
item.name ||
|
|
123
|
+
item.status ||
|
|
124
|
+
global.t?.t('people', 'label', 'withoutName');
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<TouchableOpacity
|
|
128
|
+
key={String(optionIdentity || item[renderKey])}
|
|
129
|
+
style={[
|
|
130
|
+
styles.selectOption,
|
|
131
|
+
isSelected && styles.selectOptionActive,
|
|
132
|
+
]}
|
|
133
|
+
onPress={() => {
|
|
134
|
+
onSelect(item);
|
|
135
|
+
setVisible(false);
|
|
136
|
+
}}>
|
|
137
|
+
{item.color && (
|
|
138
|
+
<View
|
|
139
|
+
style={[
|
|
140
|
+
styles.selectOptionDot,
|
|
141
|
+
{ backgroundColor: item.color },
|
|
142
|
+
]}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
{item.icon &&
|
|
146
|
+
!isCategoryOrCriticalityModal &&
|
|
147
|
+
(!isReasonModal ||
|
|
148
|
+
(isValidFontAwesomeIcon(item.icon) &&
|
|
149
|
+
!isQuestionLikeIcon(item.icon))) && (
|
|
150
|
+
<Icon
|
|
151
|
+
name={
|
|
152
|
+
item.icon === 'keyboard-arrow-down'
|
|
153
|
+
? 'angle-down'
|
|
154
|
+
: item.icon
|
|
155
|
+
}
|
|
156
|
+
size={16}
|
|
157
|
+
color={isSelected ? colors.primary : '#3498db'}
|
|
158
|
+
style={styles.selectOptionIcon}
|
|
159
|
+
/>
|
|
160
|
+
)}
|
|
161
|
+
<Text
|
|
162
|
+
style={[
|
|
163
|
+
styles.selectOptionText,
|
|
164
|
+
isSelected && styles.selectOptionTextActive,
|
|
165
|
+
]}>
|
|
166
|
+
{optionLabel}
|
|
167
|
+
</Text>
|
|
168
|
+
</TouchableOpacity>
|
|
169
|
+
);
|
|
170
|
+
})}
|
|
171
|
+
</ScrollView>
|
|
172
|
+
)}
|
|
173
|
+
</View>
|
|
174
|
+
</AnimatedModal>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default SelectModal;
|