@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,149 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { Keyboard, KeyboardAvoidingView, Modal, Text, Animated, Dimensions, Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import {GestureHandlerRootView} from 'react-native-gesture-handler';
|
|
4
|
+
import {toast, Toasts} from '@backpackapp-io/react-native-toast';
|
|
5
|
+
import styles from './AnimatedModal.styles';
|
|
6
|
+
import {
|
|
7
|
+
TOAST_EXTRA_INSETS,
|
|
8
|
+
TOAST_MODAL_COUNT_KEY,
|
|
9
|
+
TOAST_PROVIDER_KEYS,
|
|
10
|
+
} from '@controleonline/ui-common/src/react/components/toastConfig';
|
|
11
|
+
|
|
12
|
+
const { height: SCREEN_HEIGHT } = Dimensions.get('window');
|
|
13
|
+
|
|
14
|
+
const incrementModalToastDepth = () => {
|
|
15
|
+
const currentDepth = Number(global?.[TOAST_MODAL_COUNT_KEY] || 0);
|
|
16
|
+
global[TOAST_MODAL_COUNT_KEY] = currentDepth + 1;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const decrementModalToastDepth = () => {
|
|
20
|
+
const currentDepth = Number(global?.[TOAST_MODAL_COUNT_KEY] || 0);
|
|
21
|
+
global[TOAST_MODAL_COUNT_KEY] = Math.max(0, currentDepth - 1);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Modal com overlay aparecendo na hora e apenas o conteúdo subindo de baixo.
|
|
26
|
+
*/
|
|
27
|
+
export default function AnimatedModal({ visible, onRequestClose, children, style }) {
|
|
28
|
+
const [showing, setShowing] = useState(visible);
|
|
29
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
30
|
+
const overlayOpacity = useRef(new Animated.Value(0)).current;
|
|
31
|
+
const slideY = useRef(new Animated.Value(SCREEN_HEIGHT)).current;
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (visible) {
|
|
35
|
+
setShowing(true);
|
|
36
|
+
slideY.setValue(SCREEN_HEIGHT);
|
|
37
|
+
overlayOpacity.setValue(0); // Reset to 0 before animating
|
|
38
|
+
|
|
39
|
+
Animated.parallel([
|
|
40
|
+
Animated.spring(slideY, {
|
|
41
|
+
toValue: 0,
|
|
42
|
+
damping: 24,
|
|
43
|
+
stiffness: 300,
|
|
44
|
+
useNativeDriver: true,
|
|
45
|
+
}),
|
|
46
|
+
Animated.timing(overlayOpacity, {
|
|
47
|
+
toValue: 1, // Store opacity 1 implies fully opaque based on overlayBg style
|
|
48
|
+
duration: 300,
|
|
49
|
+
useNativeDriver: true,
|
|
50
|
+
}),
|
|
51
|
+
]).start();
|
|
52
|
+
}
|
|
53
|
+
}, [visible, overlayOpacity, slideY]);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!visible && showing) {
|
|
57
|
+
Animated.parallel([
|
|
58
|
+
Animated.timing(overlayOpacity, {
|
|
59
|
+
toValue: 0,
|
|
60
|
+
duration: 150,
|
|
61
|
+
useNativeDriver: true,
|
|
62
|
+
}),
|
|
63
|
+
Animated.timing(slideY, {
|
|
64
|
+
toValue: SCREEN_HEIGHT,
|
|
65
|
+
duration: 200,
|
|
66
|
+
useNativeDriver: true,
|
|
67
|
+
}),
|
|
68
|
+
]).start(() => {
|
|
69
|
+
setShowing(false);
|
|
70
|
+
setKeyboardHeight(0);
|
|
71
|
+
onRequestClose?.();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, [visible, showing, overlayOpacity, slideY]);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (Platform.OS !== 'android') {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const showSub = Keyboard.addListener('keyboardDidShow', event => {
|
|
82
|
+
setKeyboardHeight(event?.endCoordinates?.height || 0);
|
|
83
|
+
});
|
|
84
|
+
const hideSub = Keyboard.addListener('keyboardDidHide', () => {
|
|
85
|
+
setKeyboardHeight(0);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return () => {
|
|
89
|
+
showSub.remove();
|
|
90
|
+
hideSub.remove();
|
|
91
|
+
};
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!visible) {
|
|
96
|
+
setKeyboardHeight(0);
|
|
97
|
+
}
|
|
98
|
+
}, [visible]);
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!showing) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
incrementModalToastDepth();
|
|
106
|
+
return () => {
|
|
107
|
+
decrementModalToastDepth();
|
|
108
|
+
};
|
|
109
|
+
}, [showing]);
|
|
110
|
+
|
|
111
|
+
const overlayStyle = [
|
|
112
|
+
styles.overlay,
|
|
113
|
+
style,
|
|
114
|
+
Platform.OS === 'android' ? { paddingBottom: keyboardHeight } : null,
|
|
115
|
+
];
|
|
116
|
+
const normalizedChildren = React.Children.toArray(children).map(child => {
|
|
117
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
118
|
+
const text = String(child).trim();
|
|
119
|
+
if (!text || text === '.') return null;
|
|
120
|
+
return <Text>{text}</Text>;
|
|
121
|
+
}
|
|
122
|
+
return child;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<Modal
|
|
127
|
+
visible={showing}
|
|
128
|
+
animationType="none"
|
|
129
|
+
transparent
|
|
130
|
+
statusBarTranslucent
|
|
131
|
+
onRequestClose={onRequestClose}>
|
|
132
|
+
<GestureHandlerRootView style={styles.gestureRoot}>
|
|
133
|
+
<KeyboardAvoidingView
|
|
134
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
135
|
+
style={overlayStyle}>
|
|
136
|
+
<Animated.View style={[StyleSheet.absoluteFillObject, styles.overlayBg, { opacity: overlayOpacity }]} />
|
|
137
|
+
<Animated.View style={[styles.content, { transform: [{ translateY: slideY }] }]}>
|
|
138
|
+
{normalizedChildren}
|
|
139
|
+
</Animated.View>
|
|
140
|
+
<Toasts
|
|
141
|
+
providerKey={TOAST_PROVIDER_KEYS.MODAL}
|
|
142
|
+
extraInsets={TOAST_EXTRA_INSETS}
|
|
143
|
+
onToastPress={currentToast => toast.dismiss(currentToast.id)}
|
|
144
|
+
/>
|
|
145
|
+
</KeyboardAvoidingView>
|
|
146
|
+
</GestureHandlerRootView>
|
|
147
|
+
</Modal>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
gestureRoot: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
},
|
|
7
|
+
overlay: {
|
|
8
|
+
flex: 1,
|
|
9
|
+
justifyContent: 'flex-end',
|
|
10
|
+
},
|
|
11
|
+
overlayBg: {
|
|
12
|
+
backgroundColor: 'rgba(15, 23, 42, 0.4)',
|
|
13
|
+
},
|
|
14
|
+
content: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
flex: 1,
|
|
17
|
+
justifyContent: 'flex-end',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export default styles;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
2
|
+
import {useStore} from '@store';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ActivityIndicator, Modal, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
7
|
+
|
|
8
|
+
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
9
|
+
import useToastMessage from '../hooks/useToastMessage';
|
|
10
|
+
import styles from './CreateContractModal.styles';
|
|
11
|
+
import { inlineStyle_11_8, inlineStyle_21_14, inlineStyle_22_71, inlineStyle_137_56 } from './CreateContractModal.styles';
|
|
12
|
+
|
|
13
|
+
const Dropdown = ({ label, value, options, onChange }) => (
|
|
14
|
+
<View style={inlineStyle_11_8}>
|
|
15
|
+
<Text style={styles.inputLabel}>{label}</Text>
|
|
16
|
+
{options.map(opt => (
|
|
17
|
+
<TouchableOpacity
|
|
18
|
+
key={opt.value}
|
|
19
|
+
style={[
|
|
20
|
+
styles.selectOption,
|
|
21
|
+
value === opt.value && styles.selectOptionActive,
|
|
22
|
+
]}
|
|
23
|
+
onPress={() => onChange(opt.value)}>
|
|
24
|
+
<View style={inlineStyle_21_14}>
|
|
25
|
+
{opt.icon && <Icon name={opt.icon} size={20} color="#2529a1" style={inlineStyle_22_71} />}
|
|
26
|
+
<Text style={[styles.selectInputText, value === opt.value && styles.selectOptionTextActive]}>
|
|
27
|
+
{opt.label}
|
|
28
|
+
</Text>
|
|
29
|
+
</View>
|
|
30
|
+
{value === opt.value && <Icon name="check-circle" size={24} color="#10b981" />}
|
|
31
|
+
</TouchableOpacity>
|
|
32
|
+
))}
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const CreateContractModal = ({ visible, onClose, onSuccess }) => {
|
|
37
|
+
const {showError, showSuccess} = useToastMessage();
|
|
38
|
+
const contractStore = useStore('contract');
|
|
39
|
+
const contractActions = contractStore.actions;
|
|
40
|
+
const peopleStore = useStore('people');
|
|
41
|
+
const peopleGetters = peopleStore.getters;
|
|
42
|
+
const peopleActions = peopleStore.actions;
|
|
43
|
+
const statusStore = useStore('status');
|
|
44
|
+
const statusGetters = statusStore.getters;
|
|
45
|
+
const statusActions = statusStore.actions;
|
|
46
|
+
|
|
47
|
+
const { items: people, currentCompany } = peopleGetters;
|
|
48
|
+
const { items: status } = statusGetters;
|
|
49
|
+
|
|
50
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
51
|
+
const [contractModels, setContractModels] = useState([]);
|
|
52
|
+
const [loadingModels, setLoadingModels] = useState(false);
|
|
53
|
+
const [date, setDate] = useState(new Date());
|
|
54
|
+
const [selectedModel, setSelectedModel] = useState('');
|
|
55
|
+
const [selectedStatus, setSelectedStatus] = useState('');
|
|
56
|
+
const [selectedProvider, setSelectedProvider] = useState('');
|
|
57
|
+
const [docKey, setDocKey] = useState('');
|
|
58
|
+
const [startDate, setStartDate] = useState('');
|
|
59
|
+
const [endDate, setEndDate] = useState('');
|
|
60
|
+
const [open, setOpen] = useState(false);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (visible) loadInitialData();
|
|
64
|
+
}, [visible]);
|
|
65
|
+
|
|
66
|
+
const loadInitialData = async () => {
|
|
67
|
+
try {
|
|
68
|
+
await peopleActions.getItems({ company: '/people/' + currentCompany.id, linkType: 'client' });
|
|
69
|
+
await statusActions.getItems({ context: 'relationship' });
|
|
70
|
+
await loadContractModels();
|
|
71
|
+
} catch (e) { console.error(e); }
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const loadContractModels = async () => {
|
|
75
|
+
setLoadingModels(true);
|
|
76
|
+
try {
|
|
77
|
+
const response = await contractActions.getItems({ 'contractModel.context': 'contract', limit: 100 });
|
|
78
|
+
const uniqueModels = [];
|
|
79
|
+
const ids = new Set();
|
|
80
|
+
response?.forEach(c => { if(c.contractModel && !ids.has(c.contractModel['@id'])) { ids.add(c.contractModel['@id']); uniqueModels.push(c.contractModel); }});
|
|
81
|
+
setContractModels(uniqueModels);
|
|
82
|
+
} catch { setContractModels([{ '@id': '/contract-models/1', model: 'Contrato de Servicos' }, { '@id': '/contract-models/2', model: 'Contrato de Locacao' }, { '@id': '/contract-models/3', model: 'Contrato de Compra e Venda' }]); }
|
|
83
|
+
finally { setLoadingModels(false); }
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleSubmit = async () => {
|
|
87
|
+
if (!selectedModel || !selectedProvider || !selectedStatus || !startDate) {
|
|
88
|
+
showError(global.t?.t('contract','error', 'requiredFields'));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setIsLoading(true);
|
|
92
|
+
try {
|
|
93
|
+
const contractData = { contractModel: selectedModel, status: selectedStatus, provider: selectedProvider, docKey: docKey || undefined, startDate, endDate: endDate || undefined, creationDate: new Date().toISOString(), alterDate: new Date().toISOString(), peoples: [] };
|
|
94
|
+
await contractActions.save(contractData);
|
|
95
|
+
showSuccess(global.t?.t('contract','success', 'created'));
|
|
96
|
+
resetForm();
|
|
97
|
+
onSuccess && onSuccess();
|
|
98
|
+
onClose();
|
|
99
|
+
} catch (e) { console.error(e); showError(global.t?.t('contract','error', 'createFailed')); }
|
|
100
|
+
finally { setIsLoading(false); }
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const resetForm = () => { setSelectedModel(''); setSelectedStatus(''); setSelectedProvider(''); setDocKey(''); setStartDate(''); setEndDate(''); };
|
|
104
|
+
const handleClose = () => { resetForm(); onClose(); };
|
|
105
|
+
const onChange = (event, selectedDate) => {
|
|
106
|
+
if (selectedDate) {
|
|
107
|
+
setDate(selectedDate);
|
|
108
|
+
const y = selectedDate.getFullYear();
|
|
109
|
+
const m = String(selectedDate.getMonth() + 1).padStart(2, '0');
|
|
110
|
+
const d = String(selectedDate.getDate()).padStart(2, '0');
|
|
111
|
+
setStartDate(`${y}-${m}-${d}`);
|
|
112
|
+
}
|
|
113
|
+
setOpen(false);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<Modal animationType="slide" transparent={true} visible={visible} onRequestClose={handleClose}>
|
|
118
|
+
<View style={styles.modalOverlay}>
|
|
119
|
+
<View style={styles.modalContent}>
|
|
120
|
+
<View style={styles.modalHeader}>
|
|
121
|
+
<Text style={styles.modalTitle}>{global.t?.t('contract','title', 'createContract')}</Text>
|
|
122
|
+
<TouchableOpacity onPress={handleClose}><Icon name="close" size={24} color="#666" /></TouchableOpacity>
|
|
123
|
+
</View>
|
|
124
|
+
<ScrollView style={styles.modalBody} showsVerticalScrollIndicator={false}>
|
|
125
|
+
<Dropdown label={`${global.t?.t('contract','label', 'contractModel')} *`} value={selectedModel} onChange={setSelectedModel} options={contractModels.map(m => ({ label: m.model, value: m['@id'], icon: 'description' }))} />
|
|
126
|
+
<Dropdown label={`${global.t?.t('contract','label', 'provider')} *`} value={selectedProvider} onChange={setSelectedProvider} options={people?.map(p => ({ label: p.name, value: p['@id'], icon: 'person' })) || []} />
|
|
127
|
+
<Dropdown label={`${global.t?.t('contract','label', 'status')} *`} value={selectedStatus} onChange={setSelectedStatus} options={status?.map(s => ({ label: s.realStatus || s.status, value: s['@id'] })) || []} />
|
|
128
|
+
|
|
129
|
+
<View style={styles.inputGroup}>
|
|
130
|
+
<Text style={styles.inputLabel}>{global.t?.t('contract','label', 'startDate')} *</Text>
|
|
131
|
+
<TextInput style={styles.textInput} onFocus={() => setOpen(true)} value={startDate} onChangeText={setStartDate} placeholder={global.t?.t('contract','placeholder', 'date')} placeholderTextColor="#999" />
|
|
132
|
+
{open && <DateTimePicker testID="dateTimePicker" value={date} mode="date" is24Hour={true} onChange={onChange} />}
|
|
133
|
+
</View>
|
|
134
|
+
</ScrollView>
|
|
135
|
+
|
|
136
|
+
<View style={styles.modalFooter}>
|
|
137
|
+
<TouchableOpacity style={styles.cancelButton} onPress={handleClose}><Text style={styles.cancelButtonText}>{global.t?.t('contract','action', 'cancel')}</Text></TouchableOpacity>
|
|
138
|
+
<TouchableOpacity style={[styles.createButton, (!selectedModel || !selectedProvider || !selectedStatus || !startDate) && styles.createButtonDisabled]} onPress={handleSubmit} disabled={isLoading || !selectedModel || !selectedProvider || !selectedStatus || !startDate}>
|
|
139
|
+
{isLoading ? <ActivityIndicator size="small" color="#FFF" /> : <>
|
|
140
|
+
<Icon name="add" size={20} color="#FFF" style={inlineStyle_137_56} />
|
|
141
|
+
<Text style={styles.createButtonText}>{global.t?.t('contract','action', 'createContract')}</Text>
|
|
142
|
+
</>}
|
|
143
|
+
</TouchableOpacity>
|
|
144
|
+
</View>
|
|
145
|
+
</View>
|
|
146
|
+
</View>
|
|
147
|
+
</Modal>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export default CreateContractModal;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
modalOverlay: { flex:1, backgroundColor:'rgba(0,0,0,0.5)', justifyContent:'center', alignItems:'center' },
|
|
5
|
+
modalContent: { backgroundColor:'#FFF', borderRadius:16, width:'90%', maxHeight:'80%', elevation:10, paddingBottom:8 },
|
|
6
|
+
modalHeader:{ flexDirection:'row', justifyContent:'space-between', alignItems:'center', paddingHorizontal:20, paddingVertical:16, borderBottomWidth:1, borderBottomColor:'#E9ECEF' },
|
|
7
|
+
modalTitle:{ fontSize:20, fontWeight:'600', color:'#1A1A1A' },
|
|
8
|
+
modalBody:{ paddingHorizontal:20, paddingVertical:16 },
|
|
9
|
+
inputGroup:{ marginBottom:20 },
|
|
10
|
+
inputLabel:{ fontSize:16, fontWeight:'500', color:'#1A1A1A', marginBottom:8 },
|
|
11
|
+
selectInputText:{ fontSize:16, flex:1 },
|
|
12
|
+
selectOption:{ flexDirection:'row', alignItems:'center', paddingHorizontal:12, paddingVertical:12, borderWidth:1, borderColor:'#E0E0E0', borderRadius:8, marginBottom:4 },
|
|
13
|
+
selectOptionActive:{ backgroundColor:'#F8F9FF' },
|
|
14
|
+
selectOptionTextActive:{ color:'#2529a1', fontWeight:'600' },
|
|
15
|
+
textInput:{ borderWidth:1, borderColor:'#E0E0E0', borderRadius:8, paddingHorizontal:12, paddingVertical:12, fontSize:16, color:'#1A1A1A', backgroundColor:'#FFF' },
|
|
16
|
+
modalFooter:{ flexDirection:'row', justifyContent:'space-between', paddingHorizontal:20, paddingVertical:16, borderTopWidth:1, borderTopColor:'#E9ECEF' },
|
|
17
|
+
cancelButton:{ flex:1, paddingVertical:12, marginRight:8, borderRadius:8, borderWidth:1, borderColor:'#E0E0E0', alignItems:'center' },
|
|
18
|
+
cancelButtonText:{ fontSize:16, fontWeight:'600', color:'#666' },
|
|
19
|
+
createButton:{ flex:1, flexDirection:'row', paddingVertical:12, marginLeft:8, borderRadius:8, backgroundColor:'#2529a1', alignItems:'center', justifyContent:'center' },
|
|
20
|
+
createButtonDisabled:{ backgroundColor:'#CCC' },
|
|
21
|
+
createButtonText:{ fontSize:16, fontWeight:'600', color:'#FFF' },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export default styles;
|
|
25
|
+
|
|
26
|
+
export const inlineStyle_11_8 = {
|
|
27
|
+
marginBottom: 20,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const inlineStyle_21_14 = {
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
flex: 1,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const inlineStyle_22_71 = {
|
|
37
|
+
marginRight: 8,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const inlineStyle_137_56 = {
|
|
41
|
+
marginRight: 8,
|
|
42
|
+
};
|
|
43
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {useCallback} from 'react';
|
|
2
|
+
import {useMessage} from '@controleonline/ui-common/src/react/components/MessageService';
|
|
3
|
+
|
|
4
|
+
export default function useToastMessage() {
|
|
5
|
+
const messageApi = useMessage() || {};
|
|
6
|
+
|
|
7
|
+
const showToast = useCallback(
|
|
8
|
+
(message, options = {}) => {
|
|
9
|
+
if (typeof messageApi.showToast === 'function') {
|
|
10
|
+
messageApi.showToast(message, {position: 'top', offsetTop: 86, ...options});
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof messageApi.showError === 'function') {
|
|
15
|
+
messageApi.showError(message);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof messageApi.showSuccess === 'function') {
|
|
20
|
+
messageApi.showSuccess(message);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log(message);
|
|
25
|
+
},
|
|
26
|
+
[messageApi],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const showSuccess = useCallback(
|
|
30
|
+
(message, options = {}) => {
|
|
31
|
+
if (typeof messageApi.showSuccess === 'function') {
|
|
32
|
+
messageApi.showSuccess(message, options);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
showToast(message, options);
|
|
37
|
+
},
|
|
38
|
+
[messageApi, showToast],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const showError = useCallback(
|
|
42
|
+
(message, options = {}) => {
|
|
43
|
+
if (typeof messageApi.showError === 'function') {
|
|
44
|
+
messageApi.showError(message, options);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
showToast(message, options);
|
|
49
|
+
},
|
|
50
|
+
[messageApi, showToast],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
showSuccess,
|
|
55
|
+
showError,
|
|
56
|
+
showInfo: showToast,
|
|
57
|
+
showDialog: messageApi.showDialog,
|
|
58
|
+
};
|
|
59
|
+
}
|