@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,82 @@
|
|
|
1
|
+
const getCurrentDateComponents = () => {
|
|
2
|
+
const today = new Date();
|
|
3
|
+
return {
|
|
4
|
+
day: String(today.getDate()).padStart(2, '0'),
|
|
5
|
+
month: String(today.getMonth() + 1).padStart(2, '0'),
|
|
6
|
+
year: String(today.getFullYear()),
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const formatDate = dateString => {
|
|
11
|
+
const date = new Date(dateString);
|
|
12
|
+
return date.toLocaleDateString('pt-br', {
|
|
13
|
+
day: '2-digit',
|
|
14
|
+
month: '2-digit',
|
|
15
|
+
year: 'numeric',
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const formatDateForInput = dateString => {
|
|
20
|
+
const date = new Date(dateString);
|
|
21
|
+
const year = date.getFullYear();
|
|
22
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
23
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
24
|
+
return `${year}-${month}-${day}`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const parseDateComponents = dateString => {
|
|
28
|
+
if (!dateString) {
|
|
29
|
+
return { day: '', month: '', year: '' };
|
|
30
|
+
}
|
|
31
|
+
const date = new Date(dateString);
|
|
32
|
+
return {
|
|
33
|
+
day: String(date.getDate()).padStart(2, '0'),
|
|
34
|
+
month: String(date.getMonth() + 1).padStart(2, '0'),
|
|
35
|
+
year: String(date.getFullYear()),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const formatDateFromComponents = (day, month, year) => {
|
|
40
|
+
if (!day || !month || !year) {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getDaysArray = () => {
|
|
47
|
+
return Array.from({ length: 31 }, (_, i) => ({
|
|
48
|
+
id: String(i + 1).padStart(2, '0'),
|
|
49
|
+
name: String(i + 1).padStart(2, '0'),
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getMonthsArray = () => {
|
|
54
|
+
const months = [
|
|
55
|
+
global.t?.t('people', 'month', 'january'),
|
|
56
|
+
global.t?.t('people', 'month', 'february'),
|
|
57
|
+
global.t?.t('people', 'month', 'march'),
|
|
58
|
+
global.t?.t('people', 'month', 'april'),
|
|
59
|
+
global.t?.t('people', 'month', 'may'),
|
|
60
|
+
global.t?.t('people', 'month', 'june'),
|
|
61
|
+
global.t?.t('people', 'month', 'july'),
|
|
62
|
+
global.t?.t('people', 'month', 'august'),
|
|
63
|
+
global.t?.t('people', 'month', 'september'),
|
|
64
|
+
global.t?.t('people', 'month', 'october'),
|
|
65
|
+
global.t?.t('people', 'month', 'november'),
|
|
66
|
+
global.t?.t('people', 'month', 'december'),
|
|
67
|
+
];
|
|
68
|
+
return months.map((month, index) => ({
|
|
69
|
+
id: String(index + 1).padStart(2, '0'),
|
|
70
|
+
name: month,
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
formatDate,
|
|
76
|
+
formatDateForInput,
|
|
77
|
+
formatDateFromComponents,
|
|
78
|
+
getCurrentDateComponents,
|
|
79
|
+
getDaysArray,
|
|
80
|
+
getMonthsArray,
|
|
81
|
+
parseDateComponents,
|
|
82
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const getOpportunityEditorReferenceValue = value => {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const rawValue =
|
|
7
|
+
typeof value === 'object'
|
|
8
|
+
? value['@id'] ?? value.id ?? value.value
|
|
9
|
+
: value;
|
|
10
|
+
|
|
11
|
+
return String(rawValue || '').trim();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getComparableOpportunityEditorReferenceValue = value => {
|
|
15
|
+
const identity = getOpportunityEditorReferenceValue(value);
|
|
16
|
+
|
|
17
|
+
if (!identity) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const match = identity.match(/\/(\d+)$/);
|
|
22
|
+
return match ? match[1] : identity;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const resolveOpportunityEditorOption = (value, options = []) => {
|
|
26
|
+
const identity = getComparableOpportunityEditorReferenceValue(value);
|
|
27
|
+
|
|
28
|
+
if (!identity) {
|
|
29
|
+
return value || null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
options.find(
|
|
34
|
+
option =>
|
|
35
|
+
getComparableOpportunityEditorReferenceValue(option) === identity,
|
|
36
|
+
) || value
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const normalizeOpportunityEditorDraft = ({
|
|
41
|
+
opportunity,
|
|
42
|
+
statusOptions = [],
|
|
43
|
+
categoryOptions = [],
|
|
44
|
+
criticalityOptions = [],
|
|
45
|
+
reasonOptions = [],
|
|
46
|
+
}) => {
|
|
47
|
+
if (!opportunity || typeof opportunity !== 'object') {
|
|
48
|
+
return opportunity || null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
...opportunity,
|
|
53
|
+
taskStatus: resolveOpportunityEditorOption(
|
|
54
|
+
opportunity.taskStatus,
|
|
55
|
+
statusOptions,
|
|
56
|
+
),
|
|
57
|
+
category: resolveOpportunityEditorOption(
|
|
58
|
+
opportunity.category,
|
|
59
|
+
categoryOptions,
|
|
60
|
+
),
|
|
61
|
+
criticality: resolveOpportunityEditorOption(
|
|
62
|
+
opportunity.criticality,
|
|
63
|
+
criticalityOptions,
|
|
64
|
+
),
|
|
65
|
+
reason: resolveOpportunityEditorOption(
|
|
66
|
+
opportunity.reason,
|
|
67
|
+
reasonOptions,
|
|
68
|
+
),
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
module.exports = {
|
|
73
|
+
getOpportunityEditorReferenceValue,
|
|
74
|
+
normalizeOpportunityEditorDraft,
|
|
75
|
+
resolveOpportunityEditorOption,
|
|
76
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const normalizeSearchValue = value =>
|
|
2
|
+
String(value || '')
|
|
3
|
+
.trim()
|
|
4
|
+
.toLowerCase();
|
|
5
|
+
|
|
6
|
+
const hasActiveOpportunityFilters = ({
|
|
7
|
+
searchQuery = '',
|
|
8
|
+
selectedStatusFilterKey = '',
|
|
9
|
+
} = {}) =>
|
|
10
|
+
Boolean(
|
|
11
|
+
normalizeSearchValue(searchQuery) || String(selectedStatusFilterKey || '').trim(),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const getOpportunityEmptyStateMode = filters =>
|
|
15
|
+
hasActiveOpportunityFilters(filters) ? 'filtered' : 'empty';
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
getOpportunityEmptyStateMode,
|
|
19
|
+
hasActiveOpportunityFilters,
|
|
20
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const extractCollectionItems = response => {
|
|
2
|
+
if (Array.isArray(response)) {
|
|
3
|
+
return response;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (Array.isArray(response?.['hydra:member'])) {
|
|
7
|
+
return response['hydra:member'];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return [];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const normalizePeopleReferenceValue = value => {
|
|
14
|
+
if (!value) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const rawValue =
|
|
19
|
+
typeof value === 'object' ? value['@id'] ?? value.id : value;
|
|
20
|
+
|
|
21
|
+
if (rawValue == null) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const normalized = String(rawValue).trim();
|
|
26
|
+
if (!normalized) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (normalized.startsWith('/people/') || normalized.startsWith('/peoples/')) {
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (normalized.startsWith('/')) {
|
|
35
|
+
return normalized;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (/^\d+$/.test(normalized)) {
|
|
39
|
+
return `/people/${normalized}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return normalized;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const extractId = value => String(value || '').replace(/\D/g, '');
|
|
46
|
+
|
|
47
|
+
const mergePeopleEntries = (currentItems = [], nextItems = []) => {
|
|
48
|
+
const itemsByReference = new Map();
|
|
49
|
+
|
|
50
|
+
[...currentItems, ...nextItems].forEach((item, index) => {
|
|
51
|
+
const reference = normalizePeopleReferenceValue(item);
|
|
52
|
+
const fallbackKey = `person-${item?.id || 'sem-id'}-${item?.document || 'sem-doc'}-${item?.name || 'sem-nome'}-${index}`;
|
|
53
|
+
itemsByReference.set(reference || fallbackKey, item);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return Array.from(itemsByReference.values());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const normalizeSearchValue = value => {
|
|
60
|
+
if (value == null) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return String(value)
|
|
65
|
+
.normalize('NFD')
|
|
66
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
67
|
+
.toLowerCase()
|
|
68
|
+
.trim();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const getOpportunityClientIdentity = ({
|
|
72
|
+
opportunity,
|
|
73
|
+
knownPeople = [],
|
|
74
|
+
normalizePeopleReference = normalizePeopleReferenceValue,
|
|
75
|
+
}) => {
|
|
76
|
+
const client = opportunity?.client;
|
|
77
|
+
let name = '';
|
|
78
|
+
let alias = '';
|
|
79
|
+
|
|
80
|
+
if (client && typeof client === 'object') {
|
|
81
|
+
name = String(client?.name || client?.realname || '').trim();
|
|
82
|
+
alias = String(client?.alias || client?.nickname || '').trim();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const clientReference = normalizePeopleReference(client);
|
|
86
|
+
if (clientReference && Array.isArray(knownPeople)) {
|
|
87
|
+
const matched = knownPeople.find(item => {
|
|
88
|
+
return normalizePeopleReference(item) === clientReference;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (matched) {
|
|
92
|
+
if (!name) {
|
|
93
|
+
name = String(matched?.name || matched?.realname || '').trim();
|
|
94
|
+
}
|
|
95
|
+
if (!alias) {
|
|
96
|
+
alias = String(matched?.alias || matched?.nickname || '').trim();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return { name, alias };
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
module.exports = {
|
|
105
|
+
extractCollectionItems,
|
|
106
|
+
extractId,
|
|
107
|
+
getOpportunityClientIdentity,
|
|
108
|
+
mergePeopleEntries,
|
|
109
|
+
normalizePeopleReferenceValue,
|
|
110
|
+
normalizeSearchValue,
|
|
111
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const sanitizePhoneValue = value =>
|
|
2
|
+
String(value || '')
|
|
3
|
+
.replace(/\D/g, '')
|
|
4
|
+
.slice(0, 11);
|
|
5
|
+
|
|
6
|
+
const hasDuplicatePhones = phones => {
|
|
7
|
+
const uniquePhones = new Set();
|
|
8
|
+
|
|
9
|
+
for (const phone of phones) {
|
|
10
|
+
if (uniquePhones.has(phone)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
uniquePhones.add(phone);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const formatPhoneValue = value => {
|
|
20
|
+
const digits = sanitizePhoneValue(value);
|
|
21
|
+
if (!digits) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ddd = digits.slice(0, 2);
|
|
26
|
+
const number = digits.slice(2);
|
|
27
|
+
|
|
28
|
+
if (digits.length <= 2) {
|
|
29
|
+
return `(${ddd}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (number.length <= 4) {
|
|
33
|
+
return `(${ddd}) ${number}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (number.length <= 8) {
|
|
37
|
+
return `(${ddd}) ${number.slice(0, 4)}-${number.slice(4)}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return `(${ddd}) ${number.slice(0, 5)}-${number.slice(5, 9)}`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const parsePhoneNumbers = announce => {
|
|
44
|
+
if (!announce) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const asFormattedList = value => {
|
|
49
|
+
const formatted = formatPhoneValue(value);
|
|
50
|
+
return formatted ? [formatted] : [];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const parsed = JSON.parse(announce);
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(parsed)) {
|
|
57
|
+
return parsed.map(item => formatPhoneValue(item)).filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (typeof parsed === 'string' || typeof parsed === 'number') {
|
|
61
|
+
return asFormattedList(parsed);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (parsed && typeof parsed === 'object') {
|
|
65
|
+
const mergedPhone = parsed.ddd && parsed.phone
|
|
66
|
+
? `${parsed.ddd}${parsed.phone}`
|
|
67
|
+
: parsed.phone || parsed.number || parsed.value;
|
|
68
|
+
return asFormattedList(mergedPhone);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return [];
|
|
72
|
+
} catch {
|
|
73
|
+
return asFormattedList(announce);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = {
|
|
78
|
+
formatPhoneValue,
|
|
79
|
+
hasDuplicatePhones,
|
|
80
|
+
parsePhoneNumbers,
|
|
81
|
+
sanitizePhoneValue,
|
|
82
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const getStageColor = status => {
|
|
2
|
+
const colors = {
|
|
3
|
+
open: '#e67e22',
|
|
4
|
+
closed: '#10b981',
|
|
5
|
+
pending: '#3498db',
|
|
6
|
+
canceled: '#c10015',
|
|
7
|
+
};
|
|
8
|
+
return colors[status];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getStageLabel = status => {
|
|
12
|
+
const labels = {
|
|
13
|
+
open: global.t?.t('people', 'status', 'open'),
|
|
14
|
+
closed: global.t?.t('people', 'status', 'closed'),
|
|
15
|
+
pending: global.t?.t('people', 'status', 'pending'),
|
|
16
|
+
canceled: global.t?.t('people', 'status', 'canceled'),
|
|
17
|
+
};
|
|
18
|
+
return labels[status] || status || global.t?.t('people', 'status', 'noStatus');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getColorWithAlpha = (colorValue, alpha = '20') => {
|
|
22
|
+
const color = String(colorValue || '').trim();
|
|
23
|
+
return /^#[0-9a-fA-F]{6}$/.test(color) ? `${color}${alpha}` : '#EEF2FF';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
getColorWithAlpha,
|
|
28
|
+
getStageColor,
|
|
29
|
+
getStageLabel,
|
|
30
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const normalizeOpportunityStatus = item =>
|
|
2
|
+
String(item?.realStatus || item?.status || '')
|
|
3
|
+
.trim()
|
|
4
|
+
.toLowerCase();
|
|
5
|
+
|
|
6
|
+
const getOpportunityStatusFilterKey = item => {
|
|
7
|
+
if (!item) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (item['@id']) {
|
|
12
|
+
return item['@id'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (item.id != null) {
|
|
16
|
+
return `/statuses/${item.id}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const normalizedStatus = normalizeOpportunityStatus(item);
|
|
20
|
+
return normalizedStatus ? `realStatus:${normalizedStatus}` : '';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const resolveDefaultOpportunityStatusFilterKey = statusItems => {
|
|
24
|
+
if (!Array.isArray(statusItems) || statusItems.length === 0) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const defaultOpenStatus = statusItems.find(
|
|
29
|
+
item => normalizeOpportunityStatus(item) === 'open',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return getOpportunityStatusFilterKey(defaultOpenStatus);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* True only before the default has been applied and statuses are available.
|
|
37
|
+
* After first apply, empty selectedStatusFilterKey means intentional "all".
|
|
38
|
+
*/
|
|
39
|
+
const shouldApplyDefaultOpportunityStatusFilter = ({
|
|
40
|
+
hasAppliedDefault,
|
|
41
|
+
statusItemsLength,
|
|
42
|
+
}) => {
|
|
43
|
+
if (hasAppliedDefault) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return statusItemsLength > 0;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
getOpportunityStatusFilterKey,
|
|
51
|
+
normalizeOpportunityStatus,
|
|
52
|
+
resolveDefaultOpportunityStatusFilterKey,
|
|
53
|
+
shouldApplyDefaultOpportunityStatusFilter,
|
|
54
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const MONTHS = [
|
|
2
|
+
'Janeiro',
|
|
3
|
+
'Fevereiro',
|
|
4
|
+
'Marco',
|
|
5
|
+
'Abril',
|
|
6
|
+
'Maio',
|
|
7
|
+
'Junho',
|
|
8
|
+
'Julho',
|
|
9
|
+
'Agosto',
|
|
10
|
+
'Setembro',
|
|
11
|
+
'Outubro',
|
|
12
|
+
'Novembro',
|
|
13
|
+
'Dezembro',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const MONTHS_SHORT = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'];
|
|
17
|
+
|
|
18
|
+
const formatApiError = error => {
|
|
19
|
+
if (!error) return 'Nao foi possivel criar a proposta.';
|
|
20
|
+
if (typeof error === 'string') return error;
|
|
21
|
+
if (Array.isArray(error?.message)) {
|
|
22
|
+
return error.message
|
|
23
|
+
.map(item => item?.message || item?.title || String(item))
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.join('\n');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return error?.message || error?.description || error?.errmsg || 'Nao foi possivel criar a proposta.';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const formatProposalStartDate = (year, month, day) => {
|
|
32
|
+
const normalizedYear = String(year || '').replace(/\D/g, '');
|
|
33
|
+
const normalizedMonth = String(month || '').replace(/\D/g, '');
|
|
34
|
+
const normalizedDay = String(day || '').replace(/\D/g, '');
|
|
35
|
+
|
|
36
|
+
if (normalizedYear.length !== 4 || !normalizedMonth || !normalizedDay) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const parsedYear = parseInt(normalizedYear, 10);
|
|
41
|
+
const parsedMonth = parseInt(normalizedMonth, 10);
|
|
42
|
+
const parsedDay = parseInt(normalizedDay, 10);
|
|
43
|
+
const candidate = new Date(parsedYear, parsedMonth - 1, parsedDay);
|
|
44
|
+
const isValidDate =
|
|
45
|
+
candidate.getFullYear() === parsedYear &&
|
|
46
|
+
candidate.getMonth() === parsedMonth - 1 &&
|
|
47
|
+
candidate.getDate() === parsedDay;
|
|
48
|
+
|
|
49
|
+
if (!isValidDate) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return `${normalizedYear}-${normalizedMonth.padStart(2, '0')}-${normalizedDay.padStart(2, '0')}`;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
MONTHS,
|
|
58
|
+
MONTHS_SHORT,
|
|
59
|
+
formatApiError,
|
|
60
|
+
formatProposalStartDate,
|
|
61
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const normalizeEntityId = value => {
|
|
2
|
+
if (value === null || value === undefined || value === '') {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (typeof value === 'number') {
|
|
7
|
+
return String(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof value === 'string') {
|
|
11
|
+
const trimmedValue = value.trim();
|
|
12
|
+
if (!trimmedValue) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const entityIdMatch = trimmedValue.match(/\/([^/]+)\/?$/);
|
|
17
|
+
return entityIdMatch?.[1] || trimmedValue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof value === 'object') {
|
|
21
|
+
return normalizeEntityId(value['@id'] || value.id || value.value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return String(value);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const normalizeCategoryId = value =>
|
|
28
|
+
normalizeEntityId(
|
|
29
|
+
value?.category ||
|
|
30
|
+
value?.parent ||
|
|
31
|
+
value?.['@id'] ||
|
|
32
|
+
value?.id ||
|
|
33
|
+
value,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const getProposalModelCategoryId = model => normalizeCategoryId(model?.category);
|
|
37
|
+
|
|
38
|
+
const getProposalModelCategoryName = model =>
|
|
39
|
+
String(model?.category?.name || model?.category?.category || '').trim();
|
|
40
|
+
|
|
41
|
+
const filterProductsByModelCategory = ({ products, selectedModelCategoryId }) => {
|
|
42
|
+
const normalizedProducts = Array.isArray(products) ? products : [];
|
|
43
|
+
|
|
44
|
+
if (!selectedModelCategoryId) {
|
|
45
|
+
return normalizedProducts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return normalizedProducts.filter(
|
|
49
|
+
product => normalizeCategoryId(product?.category) === selectedModelCategoryId,
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const keepCompatibleSelectedProducts = ({ selectedProducts, selectedModelCategoryId }) => {
|
|
54
|
+
if (!selectedModelCategoryId) {
|
|
55
|
+
return Array.isArray(selectedProducts) ? selectedProducts : [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return filterProductsByModelCategory({
|
|
59
|
+
products: selectedProducts,
|
|
60
|
+
selectedModelCategoryId,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
filterProductsByModelCategory,
|
|
66
|
+
getProposalModelCategoryId,
|
|
67
|
+
getProposalModelCategoryName,
|
|
68
|
+
keepCompatibleSelectedProducts,
|
|
69
|
+
normalizeCategoryId,
|
|
70
|
+
normalizeEntityId,
|
|
71
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request params for the franchisee "royalties a pagar" view.
|
|
3
|
+
* Franchisee (current company) is the payer; invoice type is royalties.
|
|
4
|
+
* Counterparty filter (franqueadora) uses the receiver column via DefaultTable filters.
|
|
5
|
+
*/
|
|
6
|
+
export const ROYALTIES_INVOICE_TYPE = 'royalties';
|
|
7
|
+
|
|
8
|
+
export const resolveRoyaltiesPayableRequestParams = ({ companyId } = {}) => {
|
|
9
|
+
const params = {
|
|
10
|
+
invoiceType: ROYALTIES_INVOICE_TYPE,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
if (!companyId) {
|
|
14
|
+
return params;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
...params,
|
|
19
|
+
payer: companyId,
|
|
20
|
+
excludeOwnTransfers: 1,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const resolveRoyaltiesPayableVisibleColumnsKey = () =>
|
|
25
|
+
'financialEntries:royaltiesPayable';
|
|
26
|
+
|
|
27
|
+
export const DEFAULT_ROYALTIES_DATE_FILTER = {
|
|
28
|
+
shortcut: 'this_month',
|
|
29
|
+
customRange: { from: '', to: '' },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
ROYALTIES_INVOICE_TYPE,
|
|
34
|
+
resolveRoyaltiesPayableRequestParams,
|
|
35
|
+
resolveRoyaltiesPayableVisibleColumnsKey,
|
|
36
|
+
DEFAULT_ROYALTIES_DATE_FILTER,
|
|
37
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const formatTranslationKey = key => {
|
|
2
|
+
if (!key) return '';
|
|
3
|
+
|
|
4
|
+
return String(key)
|
|
5
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
6
|
+
.replace(/_/g, ' ')
|
|
7
|
+
.replace(/-/g, ' ')
|
|
8
|
+
.replace(/^\w/, c => c.toUpperCase());
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const translateWithFallback = (store, type, key, fallback) => {
|
|
12
|
+
const translated = global.t?.t(store, type, key);
|
|
13
|
+
const formattedKey = formatTranslationKey(key);
|
|
14
|
+
let configLanguage = '';
|
|
15
|
+
try {
|
|
16
|
+
if (typeof localStorage !== 'undefined') {
|
|
17
|
+
configLanguage = JSON.parse(localStorage.getItem('config') || '{}').language || '';
|
|
18
|
+
}
|
|
19
|
+
} catch (e) {}
|
|
20
|
+
|
|
21
|
+
const language = String(global.t?.language || configLanguage || 'pt-br')
|
|
22
|
+
.trim()
|
|
23
|
+
.replace('_', '-')
|
|
24
|
+
.toLowerCase();
|
|
25
|
+
const isPtBr = language === 'pt-br';
|
|
26
|
+
|
|
27
|
+
if (!fallback) {
|
|
28
|
+
return translated || formattedKey;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isPtBr) {
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!translated || translated === formattedKey) {
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return translated;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default translateWithFallback;
|