@bisondesk/core-sdk 1.0.23-B → 1.0.25
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/lib/constants.d.ts +0 -77
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -924
- package/lib/constants.js.map +1 -1
- package/lib/types/crm.d.ts +30 -102
- package/lib/types/crm.d.ts.map +1 -1
- package/lib/types/crm.js +0 -16
- package/lib/types/crm.js.map +1 -1
- package/lib/types/definitions.d.ts +13 -15
- package/lib/types/definitions.d.ts.map +1 -1
- package/lib/types/fields.d.ts +25 -26
- package/lib/types/fields.d.ts.map +1 -1
- package/lib/types/fields.js +0 -4
- package/lib/types/fields.js.map +1 -1
- package/lib/types/interests.d.ts +31 -0
- package/lib/types/interests.d.ts.map +1 -0
- package/lib/types/{settings.js → interests.js} +1 -1
- package/lib/types/interests.js.map +1 -0
- package/lib/types/picklists.d.ts +4 -15
- package/lib/types/picklists.d.ts.map +1 -1
- package/lib/types/search.d.ts +4 -26
- package/lib/types/search.d.ts.map +1 -1
- package/lib/types/search.js.map +1 -1
- package/lib/types/storage.d.ts +11 -1
- package/lib/types/storage.d.ts.map +1 -1
- package/lib/types/storage.js +0 -15
- package/lib/types/storage.js.map +1 -1
- package/lib/types/tenants.d.ts +9 -32
- package/lib/types/tenants.d.ts.map +1 -1
- package/lib/types/tenants.js +0 -11
- package/lib/types/tenants.js.map +1 -1
- package/lib/types/users.d.ts +3 -11
- package/lib/types/users.d.ts.map +1 -1
- package/lib/types/utils.d.ts +0 -20
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +0 -6
- package/lib/types/utils.js.map +1 -1
- package/lib/types/vehicles.d.ts +92 -406
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js +1 -54
- package/lib/types/vehicles.js.map +1 -1
- package/package.json +6 -8
- package/src/constants.ts +1 -930
- package/src/types/crm.ts +30 -117
- package/src/types/definitions.ts +12 -19
- package/src/types/fields.ts +31 -72
- package/src/types/interests.ts +28 -0
- package/src/types/picklists.ts +7 -26
- package/src/types/search.ts +4 -34
- package/src/types/storage.ts +12 -1
- package/src/types/tenants.ts +11 -37
- package/src/types/users.ts +3 -17
- package/src/types/utils.ts +0 -25
- package/src/types/vehicles.ts +93 -461
- package/tsconfig.tsbuildinfo +2995 -1
- package/lib/apis/crm.d.ts +0 -39
- package/lib/apis/crm.d.ts.map +0 -1
- package/lib/apis/crm.js +0 -201
- package/lib/apis/crm.js.map +0 -1
- package/lib/apis/documents.d.ts +0 -4
- package/lib/apis/documents.d.ts.map +0 -1
- package/lib/apis/documents.js +0 -47
- package/lib/apis/documents.js.map +0 -1
- package/lib/apis/internet-vehicles.d.ts +0 -3
- package/lib/apis/internet-vehicles.d.ts.map +0 -1
- package/lib/apis/internet-vehicles.js +0 -27
- package/lib/apis/internet-vehicles.js.map +0 -1
- package/lib/apis/leasing-administration.d.ts +0 -8
- package/lib/apis/leasing-administration.d.ts.map +0 -1
- package/lib/apis/leasing-administration.js +0 -49
- package/lib/apis/leasing-administration.js.map +0 -1
- package/lib/apis/leasing.d.ts +0 -19
- package/lib/apis/leasing.d.ts.map +0 -1
- package/lib/apis/leasing.js +0 -168
- package/lib/apis/leasing.js.map +0 -1
- package/lib/apis/opportunities.d.ts +0 -9
- package/lib/apis/opportunities.d.ts.map +0 -1
- package/lib/apis/opportunities.js +0 -94
- package/lib/apis/opportunities.js.map +0 -1
- package/lib/apis/picklists.d.ts +0 -5
- package/lib/apis/picklists.d.ts.map +0 -1
- package/lib/apis/picklists.js +0 -44
- package/lib/apis/picklists.js.map +0 -1
- package/lib/apis/tenants.d.ts +0 -7
- package/lib/apis/tenants.d.ts.map +0 -1
- package/lib/apis/tenants.js +0 -80
- package/lib/apis/tenants.js.map +0 -1
- package/lib/apis/users.d.ts +0 -3
- package/lib/apis/users.d.ts.map +0 -1
- package/lib/apis/users.js +0 -26
- package/lib/apis/users.js.map +0 -1
- package/lib/apis/utils.d.ts +0 -9
- package/lib/apis/utils.d.ts.map +0 -1
- package/lib/apis/utils.js +0 -23
- package/lib/apis/utils.js.map +0 -1
- package/lib/apis/vehicles.d.ts +0 -18
- package/lib/apis/vehicles.d.ts.map +0 -1
- package/lib/apis/vehicles.js +0 -159
- package/lib/apis/vehicles.js.map +0 -1
- package/lib/ddb-entities.d.ts +0 -2
- package/lib/ddb-entities.d.ts.map +0 -1
- package/lib/ddb-entities.js +0 -5
- package/lib/ddb-entities.js.map +0 -1
- package/lib/types/activities.d.ts +0 -38
- package/lib/types/activities.d.ts.map +0 -1
- package/lib/types/activities.js +0 -16
- package/lib/types/activities.js.map +0 -1
- package/lib/types/documents.d.ts +0 -105
- package/lib/types/documents.d.ts.map +0 -1
- package/lib/types/documents.js +0 -3
- package/lib/types/documents.js.map +0 -1
- package/lib/types/internet-vehicles.d.ts +0 -64
- package/lib/types/internet-vehicles.d.ts.map +0 -1
- package/lib/types/internet-vehicles.js +0 -3
- package/lib/types/internet-vehicles.js.map +0 -1
- package/lib/types/leads.d.ts +0 -134
- package/lib/types/leads.d.ts.map +0 -1
- package/lib/types/leads.js +0 -3
- package/lib/types/leads.js.map +0 -1
- package/lib/types/leasing-administration.d.ts +0 -107
- package/lib/types/leasing-administration.d.ts.map +0 -1
- package/lib/types/leasing-administration.js +0 -3
- package/lib/types/leasing-administration.js.map +0 -1
- package/lib/types/leasing-search.d.ts +0 -22
- package/lib/types/leasing-search.d.ts.map +0 -1
- package/lib/types/leasing-search.js +0 -3
- package/lib/types/leasing-search.js.map +0 -1
- package/lib/types/leasing-settings.d.ts +0 -113
- package/lib/types/leasing-settings.d.ts.map +0 -1
- package/lib/types/leasing-settings.js +0 -10
- package/lib/types/leasing-settings.js.map +0 -1
- package/lib/types/leasing.d.ts +0 -322
- package/lib/types/leasing.d.ts.map +0 -1
- package/lib/types/leasing.js +0 -24
- package/lib/types/leasing.js.map +0 -1
- package/lib/types/machines.d.ts +0 -38
- package/lib/types/machines.d.ts.map +0 -1
- package/lib/types/machines.js +0 -3
- package/lib/types/machines.js.map +0 -1
- package/lib/types/opportunities.d.ts +0 -448
- package/lib/types/opportunities.d.ts.map +0 -1
- package/lib/types/opportunities.js +0 -68
- package/lib/types/opportunities.js.map +0 -1
- package/lib/types/payments.d.ts +0 -38
- package/lib/types/payments.d.ts.map +0 -1
- package/lib/types/payments.js +0 -9
- package/lib/types/payments.js.map +0 -1
- package/lib/types/quotes.d.ts +0 -173
- package/lib/types/quotes.d.ts.map +0 -1
- package/lib/types/quotes.js +0 -26
- package/lib/types/quotes.js.map +0 -1
- package/lib/types/recently-viewed.d.ts +0 -33
- package/lib/types/recently-viewed.d.ts.map +0 -1
- package/lib/types/recently-viewed.js +0 -3
- package/lib/types/recently-viewed.js.map +0 -1
- package/lib/types/saved-filters.d.ts +0 -20
- package/lib/types/saved-filters.d.ts.map +0 -1
- package/lib/types/saved-filters.js +0 -3
- package/lib/types/saved-filters.js.map +0 -1
- package/lib/types/settings.d.ts +0 -50
- package/lib/types/settings.d.ts.map +0 -1
- package/lib/types/settings.js.map +0 -1
- package/lib/types/templates.d.ts +0 -35
- package/lib/types/templates.d.ts.map +0 -1
- package/lib/types/templates.js +0 -9
- package/lib/types/templates.js.map +0 -1
- package/lib/types/website.d.ts +0 -24
- package/lib/types/website.d.ts.map +0 -1
- package/lib/types/website.js +0 -3
- package/lib/types/website.js.map +0 -1
- package/lib/utils/forms.d.ts +0 -6
- package/lib/utils/forms.d.ts.map +0 -1
- package/lib/utils/forms.js +0 -33
- package/lib/utils/forms.js.map +0 -1
- package/lib/utils/leasing.d.ts +0 -3
- package/lib/utils/leasing.d.ts.map +0 -1
- package/lib/utils/leasing.js +0 -10
- package/lib/utils/leasing.js.map +0 -1
- package/lib/utils/slug.d.ts +0 -3
- package/lib/utils/slug.d.ts.map +0 -1
- package/lib/utils/slug.js +0 -23
- package/lib/utils/slug.js.map +0 -1
- package/lib/utils/tenants.d.ts +0 -4
- package/lib/utils/tenants.d.ts.map +0 -1
- package/lib/utils/tenants.js +0 -16
- package/lib/utils/tenants.js.map +0 -1
- package/lib/utils/vehicles.d.ts +0 -12
- package/lib/utils/vehicles.d.ts.map +0 -1
- package/lib/utils/vehicles.js +0 -73
- package/lib/utils/vehicles.js.map +0 -1
- package/src/apis/crm.ts +0 -302
- package/src/apis/documents.ts +0 -54
- package/src/apis/internet-vehicles.ts +0 -23
- package/src/apis/leasing-administration.ts +0 -70
- package/src/apis/leasing.ts +0 -257
- package/src/apis/opportunities.ts +0 -133
- package/src/apis/picklists.ts +0 -50
- package/src/apis/tenants.ts +0 -100
- package/src/apis/users.ts +0 -22
- package/src/apis/utils.ts +0 -23
- package/src/apis/vehicles.ts +0 -229
- package/src/ddb-entities.ts +0 -1
- package/src/environment.d.ts +0 -6
- package/src/types/activities.ts +0 -41
- package/src/types/documents.ts +0 -110
- package/src/types/internet-vehicles.ts +0 -67
- package/src/types/leads.ts +0 -144
- package/src/types/leasing-administration.ts +0 -131
- package/src/types/leasing-search.ts +0 -24
- package/src/types/leasing-settings.ts +0 -111
- package/src/types/leasing.ts +0 -360
- package/src/types/machines.ts +0 -40
- package/src/types/opportunities.ts +0 -496
- package/src/types/payments.ts +0 -40
- package/src/types/quotes.ts +0 -186
- package/src/types/recently-viewed.ts +0 -45
- package/src/types/saved-filters.ts +0 -21
- package/src/types/settings.ts +0 -51
- package/src/types/templates.ts +0 -40
- package/src/types/website.ts +0 -28
- package/src/utils/forms.ts +0 -32
- package/src/utils/leasing.ts +0 -14
- package/src/utils/slug.ts +0 -19
- package/src/utils/tenants.ts +0 -14
- package/src/utils/vehicles.ts +0 -92
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { AttachmentValue, Requester } from '@bisondesk/commons-sdk/lib/types';
|
|
2
|
-
import { BusinessEntityIds } from '../constants';
|
|
3
|
-
|
|
4
|
-
export type ViewedItemsRequest = {
|
|
5
|
-
businessEntity?: string;
|
|
6
|
-
id?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type NewViewedItem = {
|
|
10
|
-
businessEntity: BusinessEntityIds;
|
|
11
|
-
id: string;
|
|
12
|
-
viewedAt: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type ViewedItemMeta = {
|
|
16
|
-
title: string;
|
|
17
|
-
subtitle: string;
|
|
18
|
-
thumbnail?: AttachmentValue | null; // null signals that it can have a thumbnail, it is just not available
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ViewedItem = ViewedItemMeta & {
|
|
22
|
-
viewedAt: string;
|
|
23
|
-
id: string;
|
|
24
|
-
actions: string[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type RawViewedItem = {
|
|
28
|
-
id: string;
|
|
29
|
-
viewedAt: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type ViewedItemHandler = (
|
|
33
|
-
requester: Requester,
|
|
34
|
-
req: ViewedItemsRequest,
|
|
35
|
-
itemsBusinessEntity: BusinessEntityIds,
|
|
36
|
-
items: RawViewedItem[]
|
|
37
|
-
) => Promise<ViewedItem[]>;
|
|
38
|
-
|
|
39
|
-
export type ViewedItemsContextHandlers = {
|
|
40
|
-
[entity in BusinessEntityIds]?: ViewedItemHandler;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type ViewedItemsHandlersCollection = {
|
|
44
|
-
[entity in BusinessEntityIds]?: ViewedItemsContextHandlers;
|
|
45
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BusinessEntityIds } from '../constants';
|
|
2
|
-
import { ComplexFilter } from './search';
|
|
3
|
-
|
|
4
|
-
type SavedFilterQuery = {
|
|
5
|
-
conditions: {
|
|
6
|
-
[fieldId: string]: ComplexFilter;
|
|
7
|
-
};
|
|
8
|
-
fullText?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type SavedFilter = SavedFilterQuery & {
|
|
12
|
-
id: string;
|
|
13
|
-
businessEntityId: BusinessEntityIds;
|
|
14
|
-
name: string;
|
|
15
|
-
userId: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type NewSavedFilterRequest = SavedFilterQuery & {
|
|
19
|
-
businessEntityId: BusinessEntityIds;
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
package/src/types/settings.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export type WebsiteSettings = {
|
|
2
|
-
contacts: {
|
|
3
|
-
destinations: string[];
|
|
4
|
-
};
|
|
5
|
-
leasing?: {
|
|
6
|
-
interestRate: number;
|
|
7
|
-
initialValues: {
|
|
8
|
-
residual: number;
|
|
9
|
-
deposit: number;
|
|
10
|
-
periods: number;
|
|
11
|
-
};
|
|
12
|
-
maxPeriods: number;
|
|
13
|
-
};
|
|
14
|
-
gatsbyCloud?: {
|
|
15
|
-
webhook: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type HyperportalSettings = {
|
|
20
|
-
hcTenantId: string;
|
|
21
|
-
crm: {
|
|
22
|
-
active: boolean;
|
|
23
|
-
};
|
|
24
|
-
vehicles: {
|
|
25
|
-
active: boolean;
|
|
26
|
-
ignoreBeforeDate?: string; // do not modify vehicles created before this date;
|
|
27
|
-
};
|
|
28
|
-
leasing: {
|
|
29
|
-
active: boolean;
|
|
30
|
-
contractTransferDefinitionId: string;
|
|
31
|
-
contractDealDefinitionId: string;
|
|
32
|
-
contractOwner: { [countryCode: string]: string };
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type HyperportalMachinesSettings = {
|
|
37
|
-
hcTenantId: string;
|
|
38
|
-
active: boolean;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type LeasingCreditorBranch = {
|
|
42
|
-
bciNumber: string;
|
|
43
|
-
vatNumber: string;
|
|
44
|
-
licenceDate: string;
|
|
45
|
-
becrisFirstReportDate: string;
|
|
46
|
-
becrisStartDate: string;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type LeasingCreditorSettings = {
|
|
50
|
-
[branchId: string]: LeasingCreditorBranch;
|
|
51
|
-
};
|
package/src/types/templates.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export enum TemplateType {
|
|
2
|
-
Email = 'email',
|
|
3
|
-
Sms = 'sms',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export type TemplateContent =
|
|
7
|
-
| {
|
|
8
|
-
type: TemplateType.Email;
|
|
9
|
-
subject: string;
|
|
10
|
-
content: {
|
|
11
|
-
html: string;
|
|
12
|
-
design: any;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
type: TemplateType.Sms;
|
|
17
|
-
content: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type NewTemplateRequest = {
|
|
21
|
-
id?: string;
|
|
22
|
-
country: string;
|
|
23
|
-
name: string;
|
|
24
|
-
} & TemplateContent;
|
|
25
|
-
|
|
26
|
-
export type Template = {
|
|
27
|
-
id: string;
|
|
28
|
-
modifiedAt: string;
|
|
29
|
-
modifiedBy: string;
|
|
30
|
-
country: string;
|
|
31
|
-
name: string;
|
|
32
|
-
} & TemplateContent;
|
|
33
|
-
|
|
34
|
-
export type TemplateInfo = {
|
|
35
|
-
id: string;
|
|
36
|
-
countries: string[];
|
|
37
|
-
modifiedAt: string;
|
|
38
|
-
name: string;
|
|
39
|
-
type: TemplateType;
|
|
40
|
-
};
|
package/src/types/website.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PhoneNumberRawValue, PhoneNumberValue } from '@bisondesk/commons-sdk/lib/types';
|
|
2
|
-
|
|
3
|
-
export type ContactFormRequest = {
|
|
4
|
-
email: string;
|
|
5
|
-
name: string;
|
|
6
|
-
message: string;
|
|
7
|
-
phone: PhoneNumberRawValue;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ValidContactFormRequest = Omit<ContactFormRequest, 'phone'> & {
|
|
11
|
-
phone: PhoneNumberValue;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type ContactFormEvent = {
|
|
15
|
-
tenantId: string;
|
|
16
|
-
payload: ValidContactFormRequest;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type LeasingSimulationRequest = {
|
|
20
|
-
deposit: number;
|
|
21
|
-
residual: number;
|
|
22
|
-
durationInMonths: number;
|
|
23
|
-
vehicleId: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type LeasingSimulationResponse = {
|
|
27
|
-
monthly: string;
|
|
28
|
-
};
|
package/src/utils/forms.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Decimal from 'decimal.js';
|
|
2
|
-
import { PricePercentageMode } from '../types/utils';
|
|
3
|
-
|
|
4
|
-
export const computePricePercentage = (
|
|
5
|
-
totalAmount: string,
|
|
6
|
-
percentage: string,
|
|
7
|
-
partialAmount: string = '0',
|
|
8
|
-
mode: PricePercentageMode = PricePercentageMode.PERCENTAGE
|
|
9
|
-
): { percentageAmount: string; currencyAmount: string } => {
|
|
10
|
-
const output: { percentageAmount: string; currencyAmount: string } = {
|
|
11
|
-
percentageAmount: percentage,
|
|
12
|
-
currencyAmount: partialAmount,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
if (mode === PricePercentageMode.PERCENTAGE) {
|
|
16
|
-
output.currencyAmount = new Decimal(totalAmount)
|
|
17
|
-
.mul(percentage)
|
|
18
|
-
.div(100)
|
|
19
|
-
.toDecimalPlaces(2)
|
|
20
|
-
.clamp(0, totalAmount)
|
|
21
|
-
.toString();
|
|
22
|
-
} else {
|
|
23
|
-
output.percentageAmount = new Decimal(partialAmount)
|
|
24
|
-
.mul(100)
|
|
25
|
-
.div(totalAmount)
|
|
26
|
-
.toDecimalPlaces(4)
|
|
27
|
-
.clamp(0, 100)
|
|
28
|
-
.toString();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return output;
|
|
32
|
-
};
|
package/src/utils/leasing.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { utc } from '@bisondesk/commons-sdk/lib/dayjs-utils';
|
|
2
|
-
import { map, sortBy, uniqBy } from 'lodash';
|
|
3
|
-
import { LeasingContractClient } from '../types/leasing';
|
|
4
|
-
|
|
5
|
-
/* sort from oldest to most recent client */
|
|
6
|
-
export const sortContractClients = (clients: LeasingContractClient[]): LeasingContractClient[] =>
|
|
7
|
-
sortBy(
|
|
8
|
-
map(
|
|
9
|
-
uniqBy(clients, (c) => c.takeoverId),
|
|
10
|
-
(c) => ({ ...c, since: utc(c.since).format('YYYY-MM-DD') }) // doing a map to also fix legacy data
|
|
11
|
-
),
|
|
12
|
-
(cli) => cli.since,
|
|
13
|
-
(cli) => (cli.takeoverId ? parseInt(cli.takeoverId.replace(/[^0-9]/g, '')) : 0)
|
|
14
|
-
);
|
package/src/utils/slug.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import slugify from 'slugify';
|
|
2
|
-
import { Vehicle } from '../types/vehicles';
|
|
3
|
-
|
|
4
|
-
export const getVehicleSlug = (vehicle: Vehicle): string => {
|
|
5
|
-
return slugify(
|
|
6
|
-
[
|
|
7
|
-
vehicle.external.identification.stockNumber ?? vehicle.internal.identification.stockNumber,
|
|
8
|
-
vehicle.external.general.make,
|
|
9
|
-
vehicle.external.general.modelName,
|
|
10
|
-
vehicle.external.general.typeName,
|
|
11
|
-
`${vehicle.external.history?.advertisingYear}`,
|
|
12
|
-
vehicle.external.general.category,
|
|
13
|
-
vehicle.external.general.bodystyle,
|
|
14
|
-
vehicle.external.powertrain?.axles?.configuration,
|
|
15
|
-
]
|
|
16
|
-
.filter((f) => !!f)
|
|
17
|
-
.join(' ')
|
|
18
|
-
);
|
|
19
|
-
};
|
package/src/utils/tenants.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { XError } from '@bisondesk/commons-sdk/lib/errors';
|
|
2
|
-
import { first } from 'lodash';
|
|
3
|
-
import { Branch, Tenant } from '../types/tenants';
|
|
4
|
-
|
|
5
|
-
export const getBranch = (tenant: Tenant, branchId: string): Branch => {
|
|
6
|
-
const branch = tenant.branches.find((branch: Branch) => branch.id === branchId);
|
|
7
|
-
if (branch == null) {
|
|
8
|
-
throw new XError('tenants.branch-not-found', { tenantId: tenant.id, branchId });
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return branch;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const getDefaultBranch = (tenant: Tenant): Branch => first(tenant.branches)!;
|
package/src/utils/vehicles.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Categories } from '../constants';
|
|
2
|
-
import { CustomSearchState, Vehicle, VehicleExternalInfo } from '../types/vehicles';
|
|
3
|
-
|
|
4
|
-
export const extractCustomState = (vehicle: Vehicle): CustomSearchState[] => {
|
|
5
|
-
const state: CustomSearchState[] = [];
|
|
6
|
-
|
|
7
|
-
if (vehicle.internal.status.option != null) {
|
|
8
|
-
state.push(CustomSearchState.Reserved);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (vehicle.internal.role === 'SALE' && vehicle.internal.status.sale.dealStatus === 'NOT_SOLD') {
|
|
12
|
-
state.push(CustomSearchState.Available);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return state;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const extractCustomFeatures = (vehicle: VehicleExternalInfo): string[] => {
|
|
19
|
-
const features: {
|
|
20
|
-
getValue: (vehicle: VehicleExternalInfo) => any;
|
|
21
|
-
picklistValueId: string;
|
|
22
|
-
}[] = [
|
|
23
|
-
{
|
|
24
|
-
getValue: (vehicle) => vehicle.superstructure?.crane?.present,
|
|
25
|
-
picklistValueId: 'crane',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
getValue: (vehicle) => vehicle.superstructure?.tailgate?.present,
|
|
29
|
-
picklistValueId: 'tailgate',
|
|
30
|
-
},
|
|
31
|
-
{ getValue: (vehicle) => vehicle.accessories.adr, picklistValueId: 'adr' },
|
|
32
|
-
{
|
|
33
|
-
getValue: (vehicle) => vehicle.accessories.retarderIntarder,
|
|
34
|
-
picklistValueId: 'retarderIntarder',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
getValue: (vehicle) => vehicle.accessories.hydraulicTipperKit,
|
|
38
|
-
picklistValueId: 'hydraulicTipperKit',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
getValue: (vehicle) => vehicle.accessories.lowDeck,
|
|
42
|
-
picklistValueId: 'lowDeck',
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
return features
|
|
47
|
-
.filter((feature) => !!feature.getValue(vehicle))
|
|
48
|
-
.map((feature) => feature.picklistValueId);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getInternalTitle = ({
|
|
52
|
-
make,
|
|
53
|
-
category,
|
|
54
|
-
modelName,
|
|
55
|
-
bodywork,
|
|
56
|
-
modelTypeName,
|
|
57
|
-
}: {
|
|
58
|
-
make: string;
|
|
59
|
-
category: string;
|
|
60
|
-
modelName?: string;
|
|
61
|
-
modelTypeName?: string;
|
|
62
|
-
bodywork?: string;
|
|
63
|
-
}): string => {
|
|
64
|
-
if (category === Categories.Trailer || category === Categories.SemiTrailer) {
|
|
65
|
-
return [make, modelName, bodywork]
|
|
66
|
-
.filter((v): v is string => !!v)
|
|
67
|
-
.map((v) => v.trim())
|
|
68
|
-
.join(' ')
|
|
69
|
-
.trim();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return [make, modelName, modelTypeName]
|
|
73
|
-
.filter((v): v is string => !!v)
|
|
74
|
-
.map((v) => v.trim())
|
|
75
|
-
.join(' ')
|
|
76
|
-
.trim();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// example: 1 -> A, 2 -> B, 26 -> Z, 27 -> AA, 28 -> AB, 52 -> AZ, 53 -> BA, 54 -> BB, 702 -> ZZ, 703 -> AAA
|
|
80
|
-
export const convertNumberToLetters = (num: number): string => {
|
|
81
|
-
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
82
|
-
const lettersLength = letters.length;
|
|
83
|
-
|
|
84
|
-
if (num < 1) {
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const remainder = num % lettersLength;
|
|
89
|
-
const quotient = Math.floor(num / lettersLength);
|
|
90
|
-
|
|
91
|
-
return convertNumberToLetters(quotient) + letters.charAt(remainder - 1);
|
|
92
|
-
};
|