ecotransac-shared-js 1.1.4 → 1.1.5
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/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +53 -0
- package/dist/index.mjs +47 -0
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -867,10 +867,19 @@ type User = {
|
|
|
867
867
|
stripePortalUrl?: Maybe<Scalars['String']['output']>;
|
|
868
868
|
};
|
|
869
869
|
|
|
870
|
+
declare const getLabel: <T>(list: {
|
|
871
|
+
value: T;
|
|
872
|
+
label: string;
|
|
873
|
+
}[], value: T) => string | null;
|
|
870
874
|
declare const formatAddress: (address: Pick<Address, "address" | "postalCode" | "locality">) => string;
|
|
871
875
|
declare const formatSeconds: (seconds: number) => string;
|
|
872
876
|
declare const formatDate: (date?: Date | null, withTime?: boolean) => string | null;
|
|
873
877
|
declare const formatPrice: (price: number) => string;
|
|
878
|
+
declare const formatPhone: (phone?: string | null) => string | null;
|
|
879
|
+
declare const formatMandateNumber: (number: number) => string;
|
|
880
|
+
declare const formatAgentLegalData: (profile?: Pick<Profile, "legalStatus" | "registrationNumber" | "registrationPlace"> | null) => string | null;
|
|
881
|
+
declare const getPropertyTitle: (property: Pick<Property, "propertyType" | "roomCount" | "livingArea" | "isForProfessionalUse" | "floorLevel">) => string;
|
|
882
|
+
declare const formatNumber: (number?: number | null) => string;
|
|
874
883
|
|
|
875
884
|
type Field<T> = {
|
|
876
885
|
name: keyof T;
|
|
@@ -957,4 +966,4 @@ declare const MANDATE_EXCLUSIVITY: {
|
|
|
957
966
|
label: string;
|
|
958
967
|
}[];
|
|
959
968
|
|
|
960
|
-
export { COMPANY_INFO, CONDITIONS, COUNTRIES, ESTATE_CONDITION, EXPOSURES, GENDER, HEATING_ENERGY, IDENTIFICATION_DOCUMENTS, KITCHEN_TYPE, LEASE_ESTABLISHMENT, LEASE_TRANSFERT_PERMISSIONS, LEGAL_NATURE, MANDATE_EXCLUSIVITY, MARITAL_STATUS, PRENUP_TYPES, SHARING_CONFIGURATION, STANDINGS, VIEWS, featuresFormFields, formatAddress, formatDate, formatPrice, formatSeconds, propertyFields, surfacesFormFields, technicalFormFields };
|
|
969
|
+
export { COMPANY_INFO, CONDITIONS, COUNTRIES, ESTATE_CONDITION, EXPOSURES, GENDER, HEATING_ENERGY, IDENTIFICATION_DOCUMENTS, KITCHEN_TYPE, LEASE_ESTABLISHMENT, LEASE_TRANSFERT_PERMISSIONS, LEGAL_NATURE, MANDATE_EXCLUSIVITY, MARITAL_STATUS, PRENUP_TYPES, SHARING_CONFIGURATION, STANDINGS, VIEWS, featuresFormFields, formatAddress, formatAgentLegalData, formatDate, formatMandateNumber, formatNumber, formatPhone, formatPrice, formatSeconds, getLabel, getPropertyTitle, propertyFields, surfacesFormFields, technicalFormFields };
|
package/dist/index.d.ts
CHANGED
|
@@ -867,10 +867,19 @@ type User = {
|
|
|
867
867
|
stripePortalUrl?: Maybe<Scalars['String']['output']>;
|
|
868
868
|
};
|
|
869
869
|
|
|
870
|
+
declare const getLabel: <T>(list: {
|
|
871
|
+
value: T;
|
|
872
|
+
label: string;
|
|
873
|
+
}[], value: T) => string | null;
|
|
870
874
|
declare const formatAddress: (address: Pick<Address, "address" | "postalCode" | "locality">) => string;
|
|
871
875
|
declare const formatSeconds: (seconds: number) => string;
|
|
872
876
|
declare const formatDate: (date?: Date | null, withTime?: boolean) => string | null;
|
|
873
877
|
declare const formatPrice: (price: number) => string;
|
|
878
|
+
declare const formatPhone: (phone?: string | null) => string | null;
|
|
879
|
+
declare const formatMandateNumber: (number: number) => string;
|
|
880
|
+
declare const formatAgentLegalData: (profile?: Pick<Profile, "legalStatus" | "registrationNumber" | "registrationPlace"> | null) => string | null;
|
|
881
|
+
declare const getPropertyTitle: (property: Pick<Property, "propertyType" | "roomCount" | "livingArea" | "isForProfessionalUse" | "floorLevel">) => string;
|
|
882
|
+
declare const formatNumber: (number?: number | null) => string;
|
|
874
883
|
|
|
875
884
|
type Field<T> = {
|
|
876
885
|
name: keyof T;
|
|
@@ -957,4 +966,4 @@ declare const MANDATE_EXCLUSIVITY: {
|
|
|
957
966
|
label: string;
|
|
958
967
|
}[];
|
|
959
968
|
|
|
960
|
-
export { COMPANY_INFO, CONDITIONS, COUNTRIES, ESTATE_CONDITION, EXPOSURES, GENDER, HEATING_ENERGY, IDENTIFICATION_DOCUMENTS, KITCHEN_TYPE, LEASE_ESTABLISHMENT, LEASE_TRANSFERT_PERMISSIONS, LEGAL_NATURE, MANDATE_EXCLUSIVITY, MARITAL_STATUS, PRENUP_TYPES, SHARING_CONFIGURATION, STANDINGS, VIEWS, featuresFormFields, formatAddress, formatDate, formatPrice, formatSeconds, propertyFields, surfacesFormFields, technicalFormFields };
|
|
969
|
+
export { COMPANY_INFO, CONDITIONS, COUNTRIES, ESTATE_CONDITION, EXPOSURES, GENDER, HEATING_ENERGY, IDENTIFICATION_DOCUMENTS, KITCHEN_TYPE, LEASE_ESTABLISHMENT, LEASE_TRANSFERT_PERMISSIONS, LEGAL_NATURE, MANDATE_EXCLUSIVITY, MARITAL_STATUS, PRENUP_TYPES, SHARING_CONFIGURATION, STANDINGS, VIEWS, featuresFormFields, formatAddress, formatAgentLegalData, formatDate, formatMandateNumber, formatNumber, formatPhone, formatPrice, formatSeconds, getLabel, getPropertyTitle, propertyFields, surfacesFormFields, technicalFormFields };
|
package/dist/index.js
CHANGED
|
@@ -50,9 +50,15 @@ __export(src_exports, {
|
|
|
50
50
|
VIEWS: () => VIEWS,
|
|
51
51
|
featuresFormFields: () => featuresFormFields,
|
|
52
52
|
formatAddress: () => formatAddress,
|
|
53
|
+
formatAgentLegalData: () => formatAgentLegalData,
|
|
53
54
|
formatDate: () => formatDate,
|
|
55
|
+
formatMandateNumber: () => formatMandateNumber,
|
|
56
|
+
formatNumber: () => formatNumber,
|
|
57
|
+
formatPhone: () => formatPhone,
|
|
54
58
|
formatPrice: () => formatPrice,
|
|
55
59
|
formatSeconds: () => formatSeconds,
|
|
60
|
+
getLabel: () => getLabel,
|
|
61
|
+
getPropertyTitle: () => getPropertyTitle,
|
|
56
62
|
propertyFields: () => propertyFields,
|
|
57
63
|
surfacesFormFields: () => surfacesFormFields,
|
|
58
64
|
technicalFormFields: () => technicalFormFields
|
|
@@ -62,6 +68,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
62
68
|
// src/functions/format.ts
|
|
63
69
|
var import_currency = __toESM(require("currency.js"));
|
|
64
70
|
var import_date_fns = require("date-fns");
|
|
71
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
72
|
+
var getLabel = (list, value) => {
|
|
73
|
+
var _a;
|
|
74
|
+
return ((_a = list.find((item) => item.value === value)) == null ? void 0 : _a.label) || null;
|
|
75
|
+
};
|
|
65
76
|
var formatAddress = (address) => `${address.address}, ${address.postalCode} ${address.locality}`;
|
|
66
77
|
var formatSeconds = (seconds) => {
|
|
67
78
|
const hours = Math.floor(seconds / 3600);
|
|
@@ -80,6 +91,42 @@ var formatPrice = (price) => (0, import_currency.default)(price, {
|
|
|
80
91
|
precision: 0,
|
|
81
92
|
pattern: "# !"
|
|
82
93
|
}).format();
|
|
94
|
+
var formatPhone = (phone) => {
|
|
95
|
+
if (!phone) return null;
|
|
96
|
+
return (0, import_libphonenumber_js.format)(phone, "NATIONAL");
|
|
97
|
+
};
|
|
98
|
+
var formatMandateNumber = (number) => number.toString().padStart(5, "0");
|
|
99
|
+
var formatRegistrationNumber = (rawNumber) => {
|
|
100
|
+
if (!rawNumber) return null;
|
|
101
|
+
const parts = rawNumber.match(/.{1,3}/g);
|
|
102
|
+
if (parts) {
|
|
103
|
+
return parts.join(" ");
|
|
104
|
+
}
|
|
105
|
+
throw new Error("Unexpected error splitting the registration number");
|
|
106
|
+
};
|
|
107
|
+
var formatAgentLegalData = (profile) => {
|
|
108
|
+
if (!profile) return null;
|
|
109
|
+
const data = [
|
|
110
|
+
profile.legalStatus ? [profile.legalStatus] : [],
|
|
111
|
+
"Agent commercial",
|
|
112
|
+
profile.registrationNumber ? [`${formatRegistrationNumber(profile.registrationNumber)} RSAC`] : [],
|
|
113
|
+
profile.registrationPlace ? [profile.registrationPlace] : []
|
|
114
|
+
].flat(1);
|
|
115
|
+
return data.join(" - ");
|
|
116
|
+
};
|
|
117
|
+
var getPropertyTitle = (property) => {
|
|
118
|
+
if (!property) return "";
|
|
119
|
+
const base = `${property.propertyType}${property.isForProfessionalUse ? " professionnel" : ""} \xE0 vendre`;
|
|
120
|
+
const infos = [base];
|
|
121
|
+
if (property.roomCount) infos.push(`${property.roomCount} pi\xE8ces`);
|
|
122
|
+
if (property.floorLevel) {
|
|
123
|
+
const floorLabel = property.floorLevel === 1 ? "er" : "\xE8me";
|
|
124
|
+
infos.push(`${property.floorLevel}${floorLabel} \xE9tage`);
|
|
125
|
+
}
|
|
126
|
+
if (property.livingArea) infos.push(`${property.livingArea} m\xB2`);
|
|
127
|
+
return infos.join(" - ");
|
|
128
|
+
};
|
|
129
|
+
var formatNumber = (number) => number ? number.toLocaleString("fr-FR") : "";
|
|
83
130
|
|
|
84
131
|
// src/utils/render-logic.ts
|
|
85
132
|
var only = (condition) => (state) => typeof condition === "string" ? state[condition] || false : condition(state);
|
|
@@ -1184,9 +1231,15 @@ var MANDATE_EXCLUSIVITY = [
|
|
|
1184
1231
|
VIEWS,
|
|
1185
1232
|
featuresFormFields,
|
|
1186
1233
|
formatAddress,
|
|
1234
|
+
formatAgentLegalData,
|
|
1187
1235
|
formatDate,
|
|
1236
|
+
formatMandateNumber,
|
|
1237
|
+
formatNumber,
|
|
1238
|
+
formatPhone,
|
|
1188
1239
|
formatPrice,
|
|
1189
1240
|
formatSeconds,
|
|
1241
|
+
getLabel,
|
|
1242
|
+
getPropertyTitle,
|
|
1190
1243
|
propertyFields,
|
|
1191
1244
|
surfacesFormFields,
|
|
1192
1245
|
technicalFormFields
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// src/functions/format.ts
|
|
2
2
|
import currency from "currency.js";
|
|
3
3
|
import { format } from "date-fns";
|
|
4
|
+
import { format as formatPhoneFn } from "libphonenumber-js";
|
|
5
|
+
var getLabel = (list, value) => {
|
|
6
|
+
var _a;
|
|
7
|
+
return ((_a = list.find((item) => item.value === value)) == null ? void 0 : _a.label) || null;
|
|
8
|
+
};
|
|
4
9
|
var formatAddress = (address) => `${address.address}, ${address.postalCode} ${address.locality}`;
|
|
5
10
|
var formatSeconds = (seconds) => {
|
|
6
11
|
const hours = Math.floor(seconds / 3600);
|
|
@@ -19,6 +24,42 @@ var formatPrice = (price) => currency(price, {
|
|
|
19
24
|
precision: 0,
|
|
20
25
|
pattern: "# !"
|
|
21
26
|
}).format();
|
|
27
|
+
var formatPhone = (phone) => {
|
|
28
|
+
if (!phone) return null;
|
|
29
|
+
return formatPhoneFn(phone, "NATIONAL");
|
|
30
|
+
};
|
|
31
|
+
var formatMandateNumber = (number) => number.toString().padStart(5, "0");
|
|
32
|
+
var formatRegistrationNumber = (rawNumber) => {
|
|
33
|
+
if (!rawNumber) return null;
|
|
34
|
+
const parts = rawNumber.match(/.{1,3}/g);
|
|
35
|
+
if (parts) {
|
|
36
|
+
return parts.join(" ");
|
|
37
|
+
}
|
|
38
|
+
throw new Error("Unexpected error splitting the registration number");
|
|
39
|
+
};
|
|
40
|
+
var formatAgentLegalData = (profile) => {
|
|
41
|
+
if (!profile) return null;
|
|
42
|
+
const data = [
|
|
43
|
+
profile.legalStatus ? [profile.legalStatus] : [],
|
|
44
|
+
"Agent commercial",
|
|
45
|
+
profile.registrationNumber ? [`${formatRegistrationNumber(profile.registrationNumber)} RSAC`] : [],
|
|
46
|
+
profile.registrationPlace ? [profile.registrationPlace] : []
|
|
47
|
+
].flat(1);
|
|
48
|
+
return data.join(" - ");
|
|
49
|
+
};
|
|
50
|
+
var getPropertyTitle = (property) => {
|
|
51
|
+
if (!property) return "";
|
|
52
|
+
const base = `${property.propertyType}${property.isForProfessionalUse ? " professionnel" : ""} \xE0 vendre`;
|
|
53
|
+
const infos = [base];
|
|
54
|
+
if (property.roomCount) infos.push(`${property.roomCount} pi\xE8ces`);
|
|
55
|
+
if (property.floorLevel) {
|
|
56
|
+
const floorLabel = property.floorLevel === 1 ? "er" : "\xE8me";
|
|
57
|
+
infos.push(`${property.floorLevel}${floorLabel} \xE9tage`);
|
|
58
|
+
}
|
|
59
|
+
if (property.livingArea) infos.push(`${property.livingArea} m\xB2`);
|
|
60
|
+
return infos.join(" - ");
|
|
61
|
+
};
|
|
62
|
+
var formatNumber = (number) => number ? number.toLocaleString("fr-FR") : "";
|
|
22
63
|
|
|
23
64
|
// src/utils/render-logic.ts
|
|
24
65
|
var only = (condition) => (state) => typeof condition === "string" ? state[condition] || false : condition(state);
|
|
@@ -1122,9 +1163,15 @@ export {
|
|
|
1122
1163
|
VIEWS,
|
|
1123
1164
|
featuresFormFields,
|
|
1124
1165
|
formatAddress,
|
|
1166
|
+
formatAgentLegalData,
|
|
1125
1167
|
formatDate,
|
|
1168
|
+
formatMandateNumber,
|
|
1169
|
+
formatNumber,
|
|
1170
|
+
formatPhone,
|
|
1126
1171
|
formatPrice,
|
|
1127
1172
|
formatSeconds,
|
|
1173
|
+
getLabel,
|
|
1174
|
+
getPropertyTitle,
|
|
1128
1175
|
propertyFields,
|
|
1129
1176
|
surfacesFormFields,
|
|
1130
1177
|
technicalFormFields
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecotransac-shared-js",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"modules": "dist/index.mjs",
|
|
@@ -20,11 +20,14 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"currency.js": "^2.0.4",
|
|
22
22
|
"date-fns": "^4.1.0",
|
|
23
|
-
"dotenv": "^16.4.5"
|
|
23
|
+
"dotenv": "^16.4.5",
|
|
24
|
+
"libphonenumber-js": "^1.11.11",
|
|
25
|
+
"lodash": "^4.17.21"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@graphql-codegen/cli": "^5.0.3",
|
|
27
29
|
"@graphql-codegen/typescript": "^4.1.0",
|
|
30
|
+
"@types/lodash": "^4.17.10",
|
|
28
31
|
"husky": "^9.1.6",
|
|
29
32
|
"tsup": "^8.3.0",
|
|
30
33
|
"typescript": "^5.6.3"
|