@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,142 @@
|
|
|
1
|
+
import React, {useCallback, useEffect, useMemo, useState} from 'react';
|
|
2
|
+
import {ActivityIndicator, Text, TouchableOpacity, View} from 'react-native';
|
|
3
|
+
import {api} from '@controleonline/ui-common/src/api';
|
|
4
|
+
import {colors} from '@controleonline/../../src/styles/colors';
|
|
5
|
+
import {
|
|
6
|
+
EVENT_LABELS,
|
|
7
|
+
normalizePeopleIri,
|
|
8
|
+
extractCollection,
|
|
9
|
+
buildUtmSummary,
|
|
10
|
+
} from '../marketingEventsHelpers';
|
|
11
|
+
import styles from './MarketingEventsSection.styles';
|
|
12
|
+
|
|
13
|
+
const formatEventAt = value => {
|
|
14
|
+
if (!value) return '—';
|
|
15
|
+
try {
|
|
16
|
+
const date = new Date(value);
|
|
17
|
+
if (Number.isNaN(date.getTime())) return String(value);
|
|
18
|
+
return date.toLocaleString();
|
|
19
|
+
} catch {
|
|
20
|
+
return String(value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Timeline of marketing conversion events for a People (lead) in CRM context.
|
|
26
|
+
* Consumes GET /marketing_events?people=/people/{id}&order[eventAt]=desc
|
|
27
|
+
*/
|
|
28
|
+
export default function MarketingEventsSection({peopleRef, peopleName}) {
|
|
29
|
+
const peopleIri = useMemo(() => normalizePeopleIri(peopleRef), [peopleRef]);
|
|
30
|
+
const [events, setEvents] = useState([]);
|
|
31
|
+
const [loading, setLoading] = useState(false);
|
|
32
|
+
const [error, setError] = useState(null);
|
|
33
|
+
const [expanded, setExpanded] = useState(true);
|
|
34
|
+
|
|
35
|
+
const loadEvents = useCallback(async () => {
|
|
36
|
+
if (!peopleIri) {
|
|
37
|
+
setEvents([]);
|
|
38
|
+
setError(null);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setLoading(true);
|
|
42
|
+
setError(null);
|
|
43
|
+
try {
|
|
44
|
+
const response = await api.fetch('/marketing_events', {
|
|
45
|
+
params: {
|
|
46
|
+
people: peopleIri,
|
|
47
|
+
'order[eventAt]': 'desc',
|
|
48
|
+
itemsPerPage: 50,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
setEvents(extractCollection(response));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const message =
|
|
54
|
+
err?.response?.data?.['hydra:description'] ||
|
|
55
|
+
err?.message ||
|
|
56
|
+
'Failed to load marketing events';
|
|
57
|
+
setError(String(message));
|
|
58
|
+
setEvents([]);
|
|
59
|
+
} finally {
|
|
60
|
+
setLoading(false);
|
|
61
|
+
}
|
|
62
|
+
}, [peopleIri]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
loadEvents();
|
|
66
|
+
}, [loadEvents]);
|
|
67
|
+
|
|
68
|
+
if (!peopleIri) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<View style={styles.container} testID="marketing-events-section">
|
|
74
|
+
<TouchableOpacity
|
|
75
|
+
style={styles.header}
|
|
76
|
+
onPress={() => setExpanded(prev => !prev)}
|
|
77
|
+
accessibilityRole="button">
|
|
78
|
+
<Text style={styles.title}>
|
|
79
|
+
Marketing / conversão
|
|
80
|
+
{peopleName ? ` · ${peopleName}` : ''}
|
|
81
|
+
</Text>
|
|
82
|
+
<Text style={styles.chevron}>{expanded ? '▾' : '▸'}</Text>
|
|
83
|
+
</TouchableOpacity>
|
|
84
|
+
|
|
85
|
+
{expanded ? (
|
|
86
|
+
<View style={styles.body}>
|
|
87
|
+
{loading ? (
|
|
88
|
+
<ActivityIndicator color={colors.primary} style={styles.loader} />
|
|
89
|
+
) : null}
|
|
90
|
+
|
|
91
|
+
{!loading && error ? (
|
|
92
|
+
<View style={styles.errorBox}>
|
|
93
|
+
<Text style={styles.errorText}>{error}</Text>
|
|
94
|
+
<TouchableOpacity onPress={loadEvents} style={styles.retryButton}>
|
|
95
|
+
<Text style={styles.retryText}>Tentar de novo</Text>
|
|
96
|
+
</TouchableOpacity>
|
|
97
|
+
</View>
|
|
98
|
+
) : null}
|
|
99
|
+
|
|
100
|
+
{!loading && !error && events.length === 0 ? (
|
|
101
|
+
<Text style={styles.emptyText}>
|
|
102
|
+
Nenhum evento de marketing registrado para este lead.
|
|
103
|
+
</Text>
|
|
104
|
+
) : null}
|
|
105
|
+
|
|
106
|
+
{!loading &&
|
|
107
|
+
!error &&
|
|
108
|
+
events.map(event => {
|
|
109
|
+
const key =
|
|
110
|
+
event?.id ?? event?.['@id'] ?? `${event?.eventName}-${event?.eventAt}`;
|
|
111
|
+
const label = EVENT_LABELS[event?.eventName] || event?.eventName || 'event';
|
|
112
|
+
const utm = buildUtmSummary(event);
|
|
113
|
+
return (
|
|
114
|
+
<View key={String(key)} style={styles.eventCard} testID="marketing-event-item">
|
|
115
|
+
<View style={styles.eventHeader}>
|
|
116
|
+
<Text style={styles.eventName}>{label}</Text>
|
|
117
|
+
<Text style={styles.eventAt}>{formatEventAt(event?.eventAt)}</Text>
|
|
118
|
+
</View>
|
|
119
|
+
{utm ? <Text style={styles.utmLine}>{utm}</Text> : null}
|
|
120
|
+
{event?.pageUrl ? (
|
|
121
|
+
<Text style={styles.pageUrl} numberOfLines={2}>
|
|
122
|
+
{event.pageUrl}
|
|
123
|
+
</Text>
|
|
124
|
+
) : null}
|
|
125
|
+
{event?.referrer ? (
|
|
126
|
+
<Text style={styles.metaLine} numberOfLines={1}>
|
|
127
|
+
ref: {event.referrer}
|
|
128
|
+
</Text>
|
|
129
|
+
) : null}
|
|
130
|
+
{event?.visitorId ? (
|
|
131
|
+
<Text style={styles.metaLine} numberOfLines={1}>
|
|
132
|
+
visitor: {event.visitorId}
|
|
133
|
+
</Text>
|
|
134
|
+
) : null}
|
|
135
|
+
</View>
|
|
136
|
+
);
|
|
137
|
+
})}
|
|
138
|
+
</View>
|
|
139
|
+
) : null}
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {colors} from '@controleonline/../../src/styles/colors';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
marginHorizontal: 12,
|
|
7
|
+
marginTop: 8,
|
|
8
|
+
marginBottom: 12,
|
|
9
|
+
borderRadius: 10,
|
|
10
|
+
borderWidth: 1,
|
|
11
|
+
borderColor: colors.border || '#E0E0E0',
|
|
12
|
+
backgroundColor: colors.white || '#FFFFFF',
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
},
|
|
15
|
+
header: {
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'space-between',
|
|
19
|
+
paddingHorizontal: 12,
|
|
20
|
+
paddingVertical: 10,
|
|
21
|
+
backgroundColor: colors.lightGray || '#F5F5F5',
|
|
22
|
+
},
|
|
23
|
+
title: {
|
|
24
|
+
flex: 1,
|
|
25
|
+
fontSize: 14,
|
|
26
|
+
fontWeight: '600',
|
|
27
|
+
color: colors.text || '#222',
|
|
28
|
+
},
|
|
29
|
+
chevron: {
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
color: colors.grey || '#666',
|
|
32
|
+
marginLeft: 8,
|
|
33
|
+
},
|
|
34
|
+
body: {
|
|
35
|
+
paddingHorizontal: 12,
|
|
36
|
+
paddingBottom: 12,
|
|
37
|
+
paddingTop: 4,
|
|
38
|
+
},
|
|
39
|
+
loader: {
|
|
40
|
+
marginVertical: 12,
|
|
41
|
+
},
|
|
42
|
+
emptyText: {
|
|
43
|
+
fontSize: 13,
|
|
44
|
+
color: colors.grey || '#666',
|
|
45
|
+
paddingVertical: 10,
|
|
46
|
+
},
|
|
47
|
+
errorBox: {
|
|
48
|
+
paddingVertical: 8,
|
|
49
|
+
},
|
|
50
|
+
errorText: {
|
|
51
|
+
fontSize: 13,
|
|
52
|
+
color: colors.negative || '#C62828',
|
|
53
|
+
marginBottom: 6,
|
|
54
|
+
},
|
|
55
|
+
retryButton: {
|
|
56
|
+
alignSelf: 'flex-start',
|
|
57
|
+
paddingVertical: 4,
|
|
58
|
+
paddingHorizontal: 8,
|
|
59
|
+
},
|
|
60
|
+
retryText: {
|
|
61
|
+
fontSize: 13,
|
|
62
|
+
color: colors.primary,
|
|
63
|
+
fontWeight: '600',
|
|
64
|
+
},
|
|
65
|
+
eventCard: {
|
|
66
|
+
borderLeftWidth: 3,
|
|
67
|
+
borderLeftColor: colors.primary || '#1976D2',
|
|
68
|
+
paddingLeft: 10,
|
|
69
|
+
paddingVertical: 8,
|
|
70
|
+
marginTop: 8,
|
|
71
|
+
backgroundColor: colors.lightGray || '#FAFAFA',
|
|
72
|
+
borderRadius: 6,
|
|
73
|
+
},
|
|
74
|
+
eventHeader: {
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
justifyContent: 'space-between',
|
|
77
|
+
alignItems: 'flex-start',
|
|
78
|
+
gap: 8,
|
|
79
|
+
},
|
|
80
|
+
eventName: {
|
|
81
|
+
flex: 1,
|
|
82
|
+
fontSize: 13,
|
|
83
|
+
fontWeight: '600',
|
|
84
|
+
color: colors.text || '#222',
|
|
85
|
+
},
|
|
86
|
+
eventAt: {
|
|
87
|
+
fontSize: 11,
|
|
88
|
+
color: colors.grey || '#666',
|
|
89
|
+
},
|
|
90
|
+
utmLine: {
|
|
91
|
+
marginTop: 4,
|
|
92
|
+
fontSize: 12,
|
|
93
|
+
color: colors.primary || '#1976D2',
|
|
94
|
+
},
|
|
95
|
+
pageUrl: {
|
|
96
|
+
marginTop: 2,
|
|
97
|
+
fontSize: 11,
|
|
98
|
+
color: colors.grey || '#555',
|
|
99
|
+
},
|
|
100
|
+
metaLine: {
|
|
101
|
+
marginTop: 2,
|
|
102
|
+
fontSize: 11,
|
|
103
|
+
color: colors.grey || '#777',
|
|
104
|
+
},
|
|
105
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { Text } from 'react-native-animatable';
|
|
4
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
5
|
+
import IconWhatsApp from 'react-native-vector-icons/FontAwesome';
|
|
6
|
+
|
|
7
|
+
import { colors } from '@controleonline/../../src/styles/colors';
|
|
8
|
+
import { formatDate } from '../../../utils/opportunityDate';
|
|
9
|
+
import { parsePhoneNumbers } from '../../../utils/opportunityPhone';
|
|
10
|
+
import { getStageColor, getStageLabel } from '../../../utils/opportunityStage';
|
|
11
|
+
import styles from '../index.styles';
|
|
12
|
+
|
|
13
|
+
const OpportunityCard = ({
|
|
14
|
+
opportunity,
|
|
15
|
+
getProviderName,
|
|
16
|
+
handleEditProvider,
|
|
17
|
+
handleEditOpportunity,
|
|
18
|
+
handleOpportunityPress,
|
|
19
|
+
isPeopleLoading,
|
|
20
|
+
isStatusLoading,
|
|
21
|
+
knownPeople,
|
|
22
|
+
toggleStatus,
|
|
23
|
+
}) => {
|
|
24
|
+
const providerName = getProviderName(opportunity?.client);
|
|
25
|
+
const showClientSkeleton =
|
|
26
|
+
!providerName && isPeopleLoading && knownPeople.length === 0;
|
|
27
|
+
const stageColor = getStageColor(opportunity.taskStatus?.realStatus);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<View style={styles.cardWrapper}>
|
|
31
|
+
<View style={styles.card}>
|
|
32
|
+
<View style={styles.cardHeader}>
|
|
33
|
+
<View style={styles.titleContainer}>
|
|
34
|
+
{showClientSkeleton ? (
|
|
35
|
+
<View style={[styles.skeletonLine, styles.opportunityTitleSkeleton]} />
|
|
36
|
+
) : (
|
|
37
|
+
<Text style={styles.opportunityTitle}>
|
|
38
|
+
{providerName ||
|
|
39
|
+
global.t?.t('people', 'card', 'clientNotInformed')}
|
|
40
|
+
</Text>
|
|
41
|
+
)}
|
|
42
|
+
<View style={styles.clientNameRow}>
|
|
43
|
+
<Text style={styles.clientName}>#{opportunity.id}</Text>
|
|
44
|
+
<TouchableOpacity
|
|
45
|
+
style={styles.editClientButton}
|
|
46
|
+
onPress={() => handleEditProvider(opportunity)}
|
|
47
|
+
activeOpacity={0.8}>
|
|
48
|
+
<Icon name="edit" size={12} color={colors.primary} />
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
</View>
|
|
51
|
+
</View>
|
|
52
|
+
{!opportunity?.taskStatus?.realStatus && isStatusLoading ? (
|
|
53
|
+
<View style={[styles.stageTag, styles.stageTagSkeleton]}>
|
|
54
|
+
<View style={[styles.skeletonLine, styles.stageTextSkeleton]} />
|
|
55
|
+
</View>
|
|
56
|
+
) : (
|
|
57
|
+
<TouchableOpacity
|
|
58
|
+
style={[
|
|
59
|
+
styles.stageTag,
|
|
60
|
+
{ backgroundColor: `${stageColor}20` },
|
|
61
|
+
]}
|
|
62
|
+
onPress={() => toggleStatus(opportunity)}>
|
|
63
|
+
<Text style={[styles.stageText, { color: stageColor }]}>
|
|
64
|
+
{getStageLabel(opportunity.taskStatus?.realStatus)}
|
|
65
|
+
</Text>
|
|
66
|
+
</TouchableOpacity>
|
|
67
|
+
)}
|
|
68
|
+
</View>
|
|
69
|
+
|
|
70
|
+
<View style={styles.cardBody}>
|
|
71
|
+
<View style={styles.infoRow}>
|
|
72
|
+
<View style={styles.infoContainer}>
|
|
73
|
+
<Icon name="tag" size={14} color="#9b59b6" />
|
|
74
|
+
<Text style={styles.infoText}>
|
|
75
|
+
{opportunity.category?.name ||
|
|
76
|
+
global.t?.t('people', 'card', 'withoutCategory')}
|
|
77
|
+
</Text>
|
|
78
|
+
</View>
|
|
79
|
+
<View style={styles.infoContainer}>
|
|
80
|
+
<Icon name="exclamation-circle" size={14} color="#e67e22" />
|
|
81
|
+
<Text style={styles.infoText}>
|
|
82
|
+
{opportunity.criticality?.name || 'Normal'}
|
|
83
|
+
</Text>
|
|
84
|
+
</View>
|
|
85
|
+
</View>
|
|
86
|
+
|
|
87
|
+
<View style={styles.infoRow}>
|
|
88
|
+
<View style={styles.infoContainer}>
|
|
89
|
+
<Icon name="calendar" size={14} color="#3498db" />
|
|
90
|
+
<Text style={styles.infoText}>
|
|
91
|
+
{formatDate(opportunity.dueDate)}
|
|
92
|
+
</Text>
|
|
93
|
+
</View>
|
|
94
|
+
<View style={styles.infoContainer}>
|
|
95
|
+
<Icon name="clock-o" size={14} color="#95a5a6" />
|
|
96
|
+
<Text style={styles.infoText}>
|
|
97
|
+
{formatDate(opportunity.alterDate)}
|
|
98
|
+
</Text>
|
|
99
|
+
</View>
|
|
100
|
+
</View>
|
|
101
|
+
</View>
|
|
102
|
+
|
|
103
|
+
{opportunity.announce && (
|
|
104
|
+
<View style={styles.announceContainer}>
|
|
105
|
+
<Icon name="bullhorn" size={12} color="#9b59b6" />
|
|
106
|
+
<Text style={styles.announceText}>
|
|
107
|
+
{global.t?.t('people', 'card', 'phones')}:{' '}
|
|
108
|
+
{parsePhoneNumbers(opportunity.announce).join(', ') ||
|
|
109
|
+
global.t?.t('people', 'card', 'notAvailable')}
|
|
110
|
+
</Text>
|
|
111
|
+
</View>
|
|
112
|
+
)}
|
|
113
|
+
|
|
114
|
+
<View style={styles.actionContainer}>
|
|
115
|
+
<TouchableOpacity
|
|
116
|
+
style={[styles.actionButton, styles.chatButton]}
|
|
117
|
+
onPress={() => handleOpportunityPress(opportunity)}>
|
|
118
|
+
<IconWhatsApp name="whatsapp" size={16} color="#25D366" />
|
|
119
|
+
<Text style={[styles.actionButtonText, { color: '#25D366' }]}>
|
|
120
|
+
{global.t?.t('people', 'action', 'chat')}
|
|
121
|
+
</Text>
|
|
122
|
+
</TouchableOpacity>
|
|
123
|
+
|
|
124
|
+
<TouchableOpacity
|
|
125
|
+
style={[styles.actionButton, styles.editButton]}
|
|
126
|
+
onPress={() => handleEditOpportunity(opportunity)}>
|
|
127
|
+
<Icon name="edit" size={16} color="#e67e22" />
|
|
128
|
+
<Text style={[styles.actionButtonText, { color: '#e67e22' }]}>
|
|
129
|
+
{global.t?.t('people', 'action', 'edit')}
|
|
130
|
+
</Text>
|
|
131
|
+
</TouchableOpacity>
|
|
132
|
+
</View>
|
|
133
|
+
</View>
|
|
134
|
+
</View>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default OpportunityCard;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, TextInput, 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 { formatPhoneValue } from '../../../utils/opportunityPhone';
|
|
8
|
+
import { getMonthsArray } from '../../../utils/opportunityDate';
|
|
9
|
+
import styles from '../index.styles';
|
|
10
|
+
|
|
11
|
+
const PhoneInputs = ({ isEdit, onAdd, onRemove, onUpdate, phones = [] }) => (
|
|
12
|
+
<View style={styles.phoneInputsContainer}>
|
|
13
|
+
{phones.length === 0 && (
|
|
14
|
+
<TouchableOpacity
|
|
15
|
+
style={styles.addPhoneButton}
|
|
16
|
+
onPress={() => onAdd(isEdit)}>
|
|
17
|
+
<Icon name="plus" size={16} color="#10b981" />
|
|
18
|
+
<Text style={styles.addPhoneText}>
|
|
19
|
+
{global.t?.t('people', 'action', 'addPhone')}
|
|
20
|
+
</Text>
|
|
21
|
+
</TouchableOpacity>
|
|
22
|
+
)}
|
|
23
|
+
|
|
24
|
+
{phones.map((phone, index) => (
|
|
25
|
+
<View key={index} style={styles.phoneInputRow}>
|
|
26
|
+
<TextInput
|
|
27
|
+
style={[styles.textInput, styles.phoneInput]}
|
|
28
|
+
value={phone}
|
|
29
|
+
onChangeText={text => onUpdate(index, text, isEdit)}
|
|
30
|
+
placeholder="(11) 99999-9999"
|
|
31
|
+
placeholderTextColor="#6c757d"
|
|
32
|
+
keyboardType="phone-pad"
|
|
33
|
+
maxLength={15}
|
|
34
|
+
/>
|
|
35
|
+
<TouchableOpacity
|
|
36
|
+
style={styles.removePhoneButton}
|
|
37
|
+
onPress={() => onRemove(index, isEdit)}>
|
|
38
|
+
<Icon name="trash" size={16} color="#c10015" />
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
</View>
|
|
41
|
+
))}
|
|
42
|
+
|
|
43
|
+
{phones.length > 0 && (
|
|
44
|
+
<TouchableOpacity
|
|
45
|
+
style={styles.addPhoneButton}
|
|
46
|
+
onPress={() => onAdd(isEdit)}>
|
|
47
|
+
<Icon name="plus" size={16} color="#10b981" />
|
|
48
|
+
<Text style={styles.addPhoneText}>
|
|
49
|
+
{global.t?.t('people', 'action', 'addAnotherPhone')}
|
|
50
|
+
</Text>
|
|
51
|
+
</TouchableOpacity>
|
|
52
|
+
)}
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const SelectButton = ({ children, iconName, onPress }) => (
|
|
57
|
+
<TouchableOpacity style={styles.selectButton} onPress={onPress}>
|
|
58
|
+
<View style={styles.selectButtonContent}>
|
|
59
|
+
{iconName && (
|
|
60
|
+
<Icon
|
|
61
|
+
name={iconName}
|
|
62
|
+
size={16}
|
|
63
|
+
color="#3498db"
|
|
64
|
+
style={styles.selectButtonIcon}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
{children}
|
|
68
|
+
</View>
|
|
69
|
+
<Icon name="chevron-down" size={16} color="#7f8c8d" />
|
|
70
|
+
</TouchableOpacity>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const OpportunityFormModal = ({
|
|
74
|
+
isEdit,
|
|
75
|
+
isQuestionLikeIcon,
|
|
76
|
+
isValidFontAwesomeIcon,
|
|
77
|
+
getProviderName,
|
|
78
|
+
getStatusFilterLabel,
|
|
79
|
+
onAddPhone,
|
|
80
|
+
onClose,
|
|
81
|
+
onRemovePhone,
|
|
82
|
+
onSave,
|
|
83
|
+
onUpdatePhone,
|
|
84
|
+
opportunity,
|
|
85
|
+
setCategoryPickerVisible,
|
|
86
|
+
setCriticalityPickerVisible,
|
|
87
|
+
setDueDateDayPickerVisible,
|
|
88
|
+
setDueDateMonthPickerVisible,
|
|
89
|
+
setOpportunity,
|
|
90
|
+
setProviderPickerVisible,
|
|
91
|
+
setReasonPickerVisible,
|
|
92
|
+
setStatusPickerVisible,
|
|
93
|
+
visible,
|
|
94
|
+
}) => {
|
|
95
|
+
const setField = (field, value) => {
|
|
96
|
+
setOpportunity(prev => ({
|
|
97
|
+
...prev,
|
|
98
|
+
[field]: value,
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const reasonIcon = opportunity?.reason?.icon;
|
|
103
|
+
const showReasonIcon =
|
|
104
|
+
reasonIcon &&
|
|
105
|
+
isValidFontAwesomeIcon(reasonIcon) &&
|
|
106
|
+
!isQuestionLikeIcon(reasonIcon);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<AnimatedModal visible={visible} onRequestClose={onClose}>
|
|
110
|
+
<View style={styles.modalContent}>
|
|
111
|
+
<View style={styles.modalHeader}>
|
|
112
|
+
<Text style={styles.modalTitle}>
|
|
113
|
+
{isEdit
|
|
114
|
+
? global.t?.t('people', 'modal', 'editOpportunity')
|
|
115
|
+
: global.t?.t('people', 'modal', 'newOpportunity')}
|
|
116
|
+
{isEdit ? opportunity?.id : ''}
|
|
117
|
+
</Text>
|
|
118
|
+
<TouchableOpacity onPress={onClose} style={styles.closeButton}>
|
|
119
|
+
<Icon name="times" size={20} color="#7f8c8d" />
|
|
120
|
+
</TouchableOpacity>
|
|
121
|
+
</View>
|
|
122
|
+
|
|
123
|
+
<ScrollView style={styles.modalBody}>
|
|
124
|
+
<View style={styles.editSection}>
|
|
125
|
+
<Text style={styles.editLabel}>
|
|
126
|
+
{global.t?.t('people', 'form', 'provider')}
|
|
127
|
+
</Text>
|
|
128
|
+
<SelectButton
|
|
129
|
+
iconName="user"
|
|
130
|
+
onPress={() => setProviderPickerVisible(true)}>
|
|
131
|
+
<Text style={styles.selectButtonText}>
|
|
132
|
+
{getProviderName(opportunity?.client) ||
|
|
133
|
+
global.t?.t('people', 'form', 'selectProvider')}
|
|
134
|
+
</Text>
|
|
135
|
+
</SelectButton>
|
|
136
|
+
</View>
|
|
137
|
+
|
|
138
|
+
<View style={styles.editSection}>
|
|
139
|
+
<Text style={styles.editLabel}>
|
|
140
|
+
{global.t?.t('people', 'form', 'status')}
|
|
141
|
+
</Text>
|
|
142
|
+
<SelectButton onPress={() => setStatusPickerVisible(true)}>
|
|
143
|
+
{opportunity?.taskStatus?.color && (
|
|
144
|
+
<View
|
|
145
|
+
style={[
|
|
146
|
+
styles.selectButtonDot,
|
|
147
|
+
{ backgroundColor: opportunity.taskStatus.color },
|
|
148
|
+
]}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
<Text style={styles.selectButtonText}>
|
|
152
|
+
{getStatusFilterLabel(opportunity?.taskStatus) ||
|
|
153
|
+
global.t?.t('people', 'form', 'selectStatus')}
|
|
154
|
+
</Text>
|
|
155
|
+
</SelectButton>
|
|
156
|
+
</View>
|
|
157
|
+
|
|
158
|
+
<View style={styles.editSection}>
|
|
159
|
+
<Text style={styles.editLabel}>
|
|
160
|
+
{global.t?.t('people', 'form', 'category')}
|
|
161
|
+
</Text>
|
|
162
|
+
<SelectButton onPress={() => setCategoryPickerVisible(true)}>
|
|
163
|
+
<Text style={styles.selectButtonText}>
|
|
164
|
+
{opportunity?.category?.name ||
|
|
165
|
+
global.t?.t('people', 'form', 'selectCategory')}
|
|
166
|
+
</Text>
|
|
167
|
+
</SelectButton>
|
|
168
|
+
</View>
|
|
169
|
+
|
|
170
|
+
<View style={styles.editSection}>
|
|
171
|
+
<Text style={styles.editLabel}>
|
|
172
|
+
{global.t?.t('people', 'form', 'criticality')}
|
|
173
|
+
</Text>
|
|
174
|
+
<SelectButton onPress={() => setCriticalityPickerVisible(true)}>
|
|
175
|
+
<Text style={styles.selectButtonText}>
|
|
176
|
+
{opportunity?.criticality?.name ||
|
|
177
|
+
global.t?.t('people', 'form', 'selectCriticality')}
|
|
178
|
+
</Text>
|
|
179
|
+
</SelectButton>
|
|
180
|
+
</View>
|
|
181
|
+
|
|
182
|
+
<View style={styles.editSection}>
|
|
183
|
+
<Text style={styles.editLabel}>
|
|
184
|
+
{global.t?.t('people', 'form', 'leadSource')}
|
|
185
|
+
</Text>
|
|
186
|
+
<SelectButton onPress={() => setReasonPickerVisible(true)}>
|
|
187
|
+
{showReasonIcon && (
|
|
188
|
+
<Icon
|
|
189
|
+
name={reasonIcon}
|
|
190
|
+
size={16}
|
|
191
|
+
color="#9b59b6"
|
|
192
|
+
style={styles.selectButtonIcon}
|
|
193
|
+
/>
|
|
194
|
+
)}
|
|
195
|
+
<Text style={styles.selectButtonText}>
|
|
196
|
+
{opportunity?.reason?.name ||
|
|
197
|
+
global.t?.t('people', 'form', 'selectReason')}
|
|
198
|
+
</Text>
|
|
199
|
+
</SelectButton>
|
|
200
|
+
</View>
|
|
201
|
+
|
|
202
|
+
<View style={styles.editSection}>
|
|
203
|
+
<Text style={styles.editLabel}>
|
|
204
|
+
{global.t?.t('people', 'form', 'phones')}
|
|
205
|
+
</Text>
|
|
206
|
+
<PhoneInputs
|
|
207
|
+
isEdit={isEdit}
|
|
208
|
+
onAdd={onAddPhone}
|
|
209
|
+
onRemove={onRemovePhone}
|
|
210
|
+
onUpdate={onUpdatePhone}
|
|
211
|
+
phones={opportunity?.phones || []}
|
|
212
|
+
/>
|
|
213
|
+
</View>
|
|
214
|
+
|
|
215
|
+
<View style={styles.editSection}>
|
|
216
|
+
<Text style={styles.editLabel}>
|
|
217
|
+
{global.t?.t('people', 'form', 'returnDate')}
|
|
218
|
+
</Text>
|
|
219
|
+
<View style={styles.datePickerContainer}>
|
|
220
|
+
<TouchableOpacity
|
|
221
|
+
style={[styles.dateSelectButton, { flex: 1 }]}
|
|
222
|
+
onPress={() => setDueDateDayPickerVisible(true)}>
|
|
223
|
+
<Text style={styles.dateSelectText}>
|
|
224
|
+
{opportunity?.dueDateDay ||
|
|
225
|
+
global.t?.t('people', 'form', 'day')}
|
|
226
|
+
</Text>
|
|
227
|
+
<Icon name="chevron-down" size={16} color="#7f8c8d" />
|
|
228
|
+
</TouchableOpacity>
|
|
229
|
+
|
|
230
|
+
<TouchableOpacity
|
|
231
|
+
style={[styles.dateSelectButton, { flex: 2 }]}
|
|
232
|
+
onPress={() => setDueDateMonthPickerVisible(true)}>
|
|
233
|
+
<Text style={styles.dateSelectText}>
|
|
234
|
+
{opportunity?.dueDateMonth
|
|
235
|
+
? getMonthsArray().find(
|
|
236
|
+
m => m.id === opportunity.dueDateMonth,
|
|
237
|
+
)?.name
|
|
238
|
+
: global.t?.t('people', 'form', 'month')}
|
|
239
|
+
</Text>
|
|
240
|
+
<Icon name="chevron-down" size={16} color="#7f8c8d" />
|
|
241
|
+
</TouchableOpacity>
|
|
242
|
+
|
|
243
|
+
<TextInput
|
|
244
|
+
style={[styles.dateSelectButton, styles.yearInput, { flex: 1 }]}
|
|
245
|
+
value={opportunity?.dueDateYear || ''}
|
|
246
|
+
onChangeText={text => setField('dueDateYear', text)}
|
|
247
|
+
placeholder={global.t?.t('people', 'form', 'year')}
|
|
248
|
+
placeholderTextColor="#6c757d"
|
|
249
|
+
keyboardType="numeric"
|
|
250
|
+
maxLength={4}
|
|
251
|
+
/>
|
|
252
|
+
</View>
|
|
253
|
+
</View>
|
|
254
|
+
</ScrollView>
|
|
255
|
+
|
|
256
|
+
<View style={styles.modalFooter}>
|
|
257
|
+
<TouchableOpacity
|
|
258
|
+
style={[styles.modalButton, styles.cancelButton]}
|
|
259
|
+
onPress={onClose}>
|
|
260
|
+
<Text style={styles.cancelButtonText}>
|
|
261
|
+
{global.t?.t('people', 'action', 'cancel')}
|
|
262
|
+
</Text>
|
|
263
|
+
</TouchableOpacity>
|
|
264
|
+
<TouchableOpacity
|
|
265
|
+
style={[styles.modalButton, styles.saveButton]}
|
|
266
|
+
onPress={onSave}>
|
|
267
|
+
<Text style={styles.saveButtonText}>
|
|
268
|
+
{isEdit
|
|
269
|
+
? global.t?.t('people', 'action', 'save')
|
|
270
|
+
: global.t?.t('people', 'action', 'create')}
|
|
271
|
+
</Text>
|
|
272
|
+
</TouchableOpacity>
|
|
273
|
+
</View>
|
|
274
|
+
</View>
|
|
275
|
+
</AnimatedModal>
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export default OpportunityFormModal;
|