@wikicasa-dev/utilities 0.2.0 → 0.2.1
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/ArrayUtils.cjs +1 -0
- package/dist/ArrayUtils.js +4 -0
- package/dist/ColorUtils.cjs +1 -0
- package/dist/ColorUtils.js +8 -0
- package/dist/Control.Geocoder-Dyvby5gX.cjs +1 -0
- package/dist/Control.Geocoder-l0sNRNKZ.js +1 -0
- package/dist/CookieUtils.cjs +1 -0
- package/dist/CookieUtils.js +32 -0
- package/dist/CurrencyUtils.cjs +1 -0
- package/dist/CurrencyUtils.js +14 -0
- package/dist/DOMUtils.cjs +1 -0
- package/dist/DOMUtils.js +18 -0
- package/dist/DateUtils.cjs +1 -0
- package/dist/DateUtils.js +7 -0
- package/dist/DeviceDetectionUtils.cjs +1 -0
- package/dist/DeviceDetectionUtils.js +8 -0
- package/dist/EmailUtils.cjs +1 -0
- package/dist/EmailUtils.js +27 -0
- package/dist/FavoriteUtils.cjs +1 -0
- package/dist/FavoriteUtils.js +13 -0
- package/dist/FunctionUtils.cjs +1 -0
- package/dist/FunctionUtils.js +21 -0
- package/dist/GAutocompleteUtils.cjs +1 -0
- package/dist/GAutocompleteUtils.js +23 -0
- package/dist/GenericUtils.cjs +1 -0
- package/dist/GenericUtils.js +25 -0
- package/dist/LazyLoadingBg.cjs +1 -0
- package/dist/LazyLoadingBg.js +13 -0
- package/dist/Leaflet-BKkoCsyw.js +6436 -0
- package/dist/Leaflet-CHOsN941.cjs +1 -0
- package/dist/MapUtils.cjs +1 -0
- package/dist/MapUtils.js +79 -0
- package/dist/NumberUtils.cjs +1 -0
- package/dist/NumberUtils.js +50 -0
- package/dist/ObjectUtils.cjs +1 -0
- package/dist/ObjectUtils.js +23 -0
- package/dist/ObserverUtils.cjs +1 -0
- package/dist/ObserverUtils.js +20 -0
- package/dist/PermissionUtils.cjs +1 -0
- package/dist/PermissionUtils.js +18 -0
- package/dist/RESB_UrlBuilder.cjs +1 -0
- package/dist/RESB_UrlBuilder.js +30 -0
- package/dist/RequestUtils.cjs +1 -0
- package/dist/RequestUtils.js +13 -0
- package/dist/StringUtils.cjs +1 -0
- package/dist/StringUtils.js +40 -0
- package/dist/URLBuilderUtils.cjs +1 -0
- package/dist/URLBuilderUtils.js +11 -0
- package/dist/URLPagesFactory.cjs +1 -0
- package/dist/URLPagesFactory.js +12 -0
- package/dist/agencyAPI.cjs +1 -0
- package/dist/agencyAPI.js +61 -0
- package/dist/constants.cjs +1 -0
- package/dist/constants.js +5 -0
- package/dist/geographyAPI.cjs +1 -0
- package/dist/geographyAPI.js +73 -0
- package/dist/icons.cjs +1 -0
- package/dist/icons.js +32 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +33 -33
- package/dist/index.js +142 -0
- package/dist/insightsAPI.cjs +1 -0
- package/dist/insightsAPI.js +15 -0
- package/dist/leaflet-Dyvby5gX.cjs +1 -0
- package/dist/leaflet-freedraw.esm-D8SxeKC1.js +26934 -0
- package/dist/leaflet-freedraw.esm-DSDVLXDC.cjs +7 -0
- package/dist/leaflet-l0sNRNKZ.js +1 -0
- package/dist/leaflet.draw-Dyvby5gX.cjs +1 -0
- package/dist/leaflet.draw-l0sNRNKZ.js +1 -0
- package/dist/leaflet_map.cjs +1 -0
- package/dist/leaflet_map.js +454 -0
- package/dist/mailAPI.cjs +1 -0
- package/dist/mailAPI.js +51 -0
- package/dist/main.cjs +1 -0
- package/dist/placesAPI.cjs +1 -0
- package/dist/placesAPI.js +47 -0
- package/dist/portfolioCustomerAPI.cjs +1 -0
- package/dist/portfolioCustomerAPI.js +14 -0
- package/dist/publicUserAPI.cjs +1 -0
- package/dist/publicUserAPI.js +142 -0
- package/dist/realEstateAPI.cjs +1 -0
- package/dist/realEstateAPI.js +67 -0
- package/dist/requestAPI.cjs +1 -0
- package/dist/requestAPI.js +17 -0
- package/dist/services/wikicasaPro.d.ts +1 -1
- package/dist/servicesUtils.cjs +3 -0
- package/dist/servicesUtils.js +12 -0
- package/dist/statisticsAPI.cjs +1 -0
- package/dist/statisticsAPI.js +58 -0
- package/dist/style.css +1 -0
- package/dist/types-BaBnqzzG.js +85 -0
- package/dist/types-CwWBrQCP.cjs +1 -0
- package/dist/valuationAPI.cjs +1 -0
- package/dist/valuationAPI.js +21 -0
- package/dist/vite-env.cjs +1 -0
- package/dist/vite-env.js +1 -0
- package/dist/wikicasaPro.cjs +1 -0
- package/dist/wikicasaPro.js +14 -0
- package/package.json +17 -13
- package/dist/utilities.cjs +0 -5
- package/dist/utilities.iife.js +0 -5
- package/dist/utilities.mjs +0 -2437
- package/index.html +0 -13
- package/src/custom/constants.ts +0 -3
- package/src/custom/icons.ts +0 -63
- package/src/custom/leaflet_map.ts +0 -946
- package/src/index.ts +0 -171
- package/src/services/agencyAPI.ts +0 -105
- package/src/services/geographyAPI.ts +0 -129
- package/src/services/insightsAPI.ts +0 -20
- package/src/services/mailAPI.ts +0 -89
- package/src/services/placesAPI.ts +0 -72
- package/src/services/portfolioCustomerAPI.ts +0 -16
- package/src/services/publicUserAPI.ts +0 -216
- package/src/services/realEstateAPI.ts +0 -133
- package/src/services/requestAPI.ts +0 -40
- package/src/services/servicesUtils.ts +0 -27
- package/src/services/statisticsAPI.ts +0 -84
- package/src/services/valuationAPI.ts +0 -45
- package/src/services/wikicasaPro.ts +0 -25
- package/src/utils/ArrayUtils.ts +0 -2
- package/src/utils/ColorUtils.ts +0 -11
- package/src/utils/CookieUtils.ts +0 -43
- package/src/utils/CurrencyUtils.ts +0 -18
- package/src/utils/DOMUtils.ts +0 -28
- package/src/utils/DateUtils.ts +0 -9
- package/src/utils/DeviceDetectionUtils.ts +0 -17
- package/src/utils/EmailUtils.ts +0 -45
- package/src/utils/FavoriteUtils.ts +0 -19
- package/src/utils/FunctionUtils.ts +0 -29
- package/src/utils/GAutocompleteUtils.ts +0 -70
- package/src/utils/GenericUtils.ts +0 -37
- package/src/utils/LazyLoadingBg.ts +0 -18
- package/src/utils/MapUtils.ts +0 -118
- package/src/utils/NumberUtils.ts +0 -90
- package/src/utils/ObjectUtils.ts +0 -34
- package/src/utils/ObserverUtils.ts +0 -32
- package/src/utils/PermissionUtils.ts +0 -41
- package/src/utils/RESB_UrlBuilder.ts +0 -99
- package/src/utils/RequestUtils.ts +0 -20
- package/src/utils/StringUtils.ts +0 -75
- package/src/utils/URLBuilderUtils.ts +0 -21
- package/src/utils/URLPagesFactory.ts +0 -20
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -38
- package/vite.config.ts +0 -42
- /package/{src/main.ts → dist/main.js} +0 -0
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PublicUser,
|
|
3
|
-
PublicUserMenuInfo,
|
|
4
|
-
SaveSearchBean,
|
|
5
|
-
} from "@wikicasa-dev/types";
|
|
6
|
-
|
|
7
|
-
import { getDefaultSaveSearchBean } from "@wikicasa-dev/types";
|
|
8
|
-
import axios, { AxiosError } from "axios";
|
|
9
|
-
import { handleAxiosError } from "./servicesUtils";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const baseURL: string = window["_baseURLIt"];
|
|
13
|
-
const baseController = `${baseURL}/rest/publicUser`;
|
|
14
|
-
|
|
15
|
-
export const getMenuInfo = async (): Promise<PublicUserMenuInfo> => {
|
|
16
|
-
try {
|
|
17
|
-
const res = await axios.get(`${baseController}/getMenuInfo`);
|
|
18
|
-
return res.data as PublicUserMenuInfo;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
handleAxiosError(error as AxiosError);
|
|
21
|
-
throw null;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const getPublicUser = async (): Promise<PublicUser> => {
|
|
26
|
-
try {
|
|
27
|
-
const res = await axios.get(`${baseController}/getUser`);
|
|
28
|
-
return res.data as PublicUser;
|
|
29
|
-
} catch (err) {
|
|
30
|
-
handleAxiosError(err as AxiosError);
|
|
31
|
-
throw null;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const getMarketingConsent = async (email: string): Promise<boolean> => {
|
|
36
|
-
try {
|
|
37
|
-
const res = await axios.get(
|
|
38
|
-
`${baseController}/getMarketingConsent?email=${email}`
|
|
39
|
-
);
|
|
40
|
-
return res.data as boolean;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
handleAxiosError(error as AxiosError);
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const deleteAllSaveSearch = async (): Promise<number> => {
|
|
48
|
-
try {
|
|
49
|
-
const res = await axios.post(`${baseController}/deleteAllUserSaveSearch`);
|
|
50
|
-
return res.data as number;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
handleAxiosError(err as AxiosError);
|
|
53
|
-
throw null;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const deleteSaveSearch = async (id: number): Promise<string> => {
|
|
58
|
-
try {
|
|
59
|
-
const res = await axios.post(
|
|
60
|
-
`${baseController}/deleteUserSaveSearchParam/${id}`
|
|
61
|
-
);
|
|
62
|
-
return res.data as string;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
handleAxiosError(error as AxiosError);
|
|
65
|
-
throw null;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const getFavourites = async (): Promise<number[]> => {
|
|
70
|
-
try {
|
|
71
|
-
const res = await axios.get(`${baseController}/getFavouriteIdList`);
|
|
72
|
-
return res.data as number[];
|
|
73
|
-
} catch (error) {
|
|
74
|
-
handleAxiosError(error as AxiosError);
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const addUserFavorite = async (id: number): Promise<boolean> => {
|
|
80
|
-
try {
|
|
81
|
-
const res = await axios.post(`${baseController}/addUserFavourite/${id}`);
|
|
82
|
-
return res.data as boolean;
|
|
83
|
-
} catch (error) {
|
|
84
|
-
handleAxiosError(error as AxiosError);
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const deleteUserFavorite = async (id: number): Promise<boolean> => {
|
|
90
|
-
try {
|
|
91
|
-
const res = await axios.post(`${baseController}/deleteUserFavourite/${id}`);
|
|
92
|
-
return res.data as boolean;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
handleAxiosError(error as AxiosError);
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const updateNote = async (
|
|
100
|
-
id: number,
|
|
101
|
-
note: string | null
|
|
102
|
-
): Promise<boolean> => {
|
|
103
|
-
if (note === " " || note === " ") return false;
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const res = await axios.post(`${baseController}/updateFavouriteNote`, {
|
|
107
|
-
realEstateId: id,
|
|
108
|
-
note: note,
|
|
109
|
-
});
|
|
110
|
-
return res.data as boolean;
|
|
111
|
-
} catch (error) {
|
|
112
|
-
handleAxiosError(error as AxiosError);
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const removeFavourites = async (): Promise<boolean> => {
|
|
118
|
-
try {
|
|
119
|
-
const res = await axios.post(`${baseController}/deleteAllUserFavourite`);
|
|
120
|
-
return res.data as boolean;
|
|
121
|
-
} catch (error) {
|
|
122
|
-
handleAxiosError(error as AxiosError);
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const saveUserFirebaseToken = async (
|
|
128
|
-
firebaseToken: string
|
|
129
|
-
): Promise<boolean> => {
|
|
130
|
-
try {
|
|
131
|
-
if (!firebaseToken) return false;
|
|
132
|
-
|
|
133
|
-
await axios.post(
|
|
134
|
-
`${baseController}/refreshUserFirebaseToken?token=${firebaseToken}`
|
|
135
|
-
);
|
|
136
|
-
return true;
|
|
137
|
-
} catch (err) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const deleteUserFirebaseToken = async (
|
|
143
|
-
firebaseToken: string
|
|
144
|
-
): Promise<boolean> => {
|
|
145
|
-
try {
|
|
146
|
-
await axios.delete(
|
|
147
|
-
`${baseController}/deleteUserFirebaseToken?token=${firebaseToken}`
|
|
148
|
-
);
|
|
149
|
-
return true;
|
|
150
|
-
} catch (error) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const updateMarketingConsent = async (data: {
|
|
156
|
-
email: string;
|
|
157
|
-
marketingConsent: boolean;
|
|
158
|
-
}): Promise<boolean> => {
|
|
159
|
-
const { email, marketingConsent } = data;
|
|
160
|
-
try {
|
|
161
|
-
await axios.post(
|
|
162
|
-
`${baseController}/updateMarketingConsent?email=${email}&marketingConsent=${marketingConsent}`,
|
|
163
|
-
data
|
|
164
|
-
);
|
|
165
|
-
return true;
|
|
166
|
-
} catch (error) {
|
|
167
|
-
handleAxiosError(error as AxiosError);
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
/* return $.ajax({
|
|
171
|
-
type: "POST",
|
|
172
|
-
contentType: "application/json",
|
|
173
|
-
data: JSON.stringify(data),
|
|
174
|
-
url: `/rest/publicUser/updateMarketingConsent?email=${email}&marketingConsent=${marketingConsent}`,
|
|
175
|
-
});*/
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const getPublicUserSaveSearchList = async (
|
|
179
|
-
offset = 0,
|
|
180
|
-
limit = 10
|
|
181
|
-
): Promise<Array<any>> => {
|
|
182
|
-
try {
|
|
183
|
-
const res = await axios.get(
|
|
184
|
-
`${baseController}/getPublicUserSavedSearchBeanList/${offset}/${limit}`
|
|
185
|
-
);
|
|
186
|
-
return res.data as Array<SaveSearchBean>;
|
|
187
|
-
} catch (error) {
|
|
188
|
-
handleAxiosError(error as AxiosError);
|
|
189
|
-
return [];
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
export const updatePublicUserSavedSearchBean = async (
|
|
193
|
-
savedSearchBean: SaveSearchBean
|
|
194
|
-
): Promise<SaveSearchBean> => {
|
|
195
|
-
try {
|
|
196
|
-
const res = await axios.post(
|
|
197
|
-
`${baseController}/updatePublicUserSavedSearchBean/`,
|
|
198
|
-
savedSearchBean
|
|
199
|
-
);
|
|
200
|
-
return res.data as SaveSearchBean;
|
|
201
|
-
} catch (error) {
|
|
202
|
-
handleAxiosError(error as AxiosError);
|
|
203
|
-
return getDefaultSaveSearchBean();
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
export const getSavedSearchesCount = async (): Promise<number> => {
|
|
207
|
-
try {
|
|
208
|
-
const res = await axios.get(
|
|
209
|
-
`${baseController}/getPublicUserSaveSearchCount`
|
|
210
|
-
);
|
|
211
|
-
return res.data as number;
|
|
212
|
-
} catch (error) {
|
|
213
|
-
handleAxiosError(error as AxiosError);
|
|
214
|
-
return 0;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError, AxiosResponse } from "axios";
|
|
2
|
-
import { handleAxiosError } from "./servicesUtils";
|
|
3
|
-
import type {
|
|
4
|
-
RealEstateSearchBean,
|
|
5
|
-
MapMarker,
|
|
6
|
-
RealEstateMiniItem,
|
|
7
|
-
Nullable,
|
|
8
|
-
} from "@wikicasa-dev/types";
|
|
9
|
-
import { deepCopy } from "@utils/ObjectUtils";
|
|
10
|
-
|
|
11
|
-
declare global {
|
|
12
|
-
interface Window {
|
|
13
|
-
_serializedSearchBean?: Nullable<any>;
|
|
14
|
-
_locale: string;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const baseUrl: string = window["_baseURLIt"];
|
|
20
|
-
const baseController = `${baseUrl}/rest/realEstate`;
|
|
21
|
-
|
|
22
|
-
export const getRealEstateNotes = async (
|
|
23
|
-
realEstateId: number
|
|
24
|
-
): Promise<string> => {
|
|
25
|
-
try {
|
|
26
|
-
const res = await axios.post(
|
|
27
|
-
`${baseUrl}/rest/publicUser/getRealEstateNotes/${realEstateId}`
|
|
28
|
-
);
|
|
29
|
-
return res.data;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
handleAxiosError(error as AxiosError);
|
|
32
|
-
return "";
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const saveSearch = async (
|
|
37
|
-
email: string,
|
|
38
|
-
title: string,
|
|
39
|
-
hourly: boolean,
|
|
40
|
-
resb: RealEstateSearchBean,
|
|
41
|
-
pushNotifications = false
|
|
42
|
-
): Promise<AxiosResponse> => {
|
|
43
|
-
if (!email || !resb) throw `Email or resb are not valid, ${email}, ${resb}`;
|
|
44
|
-
|
|
45
|
-
//TODO: solo per testing dato che bisogna chiedere il consenso all'utente
|
|
46
|
-
return await axios.post(
|
|
47
|
-
`${baseController}/saveSearch?email=${email}&title=${title}&hourly=${hourly}&pushNotifications=${pushNotifications}`,
|
|
48
|
-
resb
|
|
49
|
-
);
|
|
50
|
-
// return await axios.post(`${baseController}/saveSearch?email=${email}&title=${title}&hourly=${hourly}`, resb);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const saveSearchFromRequest = async (
|
|
54
|
-
email: string,
|
|
55
|
-
searchBean: RealEstateSearchBean,
|
|
56
|
-
pushNotifications = false
|
|
57
|
-
): Promise<boolean> => {
|
|
58
|
-
try {
|
|
59
|
-
const title = "Ricerca salvata";
|
|
60
|
-
//TODO: solo per testing dato che bisogna chiedere il consenso all'utente
|
|
61
|
-
const res = await axios.post(
|
|
62
|
-
`${baseController}/saveSearch?email=${email}&title=${title}&pushNotifications=${pushNotifications}`,
|
|
63
|
-
searchBean
|
|
64
|
-
);
|
|
65
|
-
// const res = await axios.post(`/rest/realEstate/saveSearch?email=${email}`, searchBean);
|
|
66
|
-
return res.data as boolean;
|
|
67
|
-
} catch (error) {
|
|
68
|
-
handleAxiosError(error as AxiosError);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const getRealEstateCounter = async (
|
|
74
|
-
resb: RealEstateSearchBean
|
|
75
|
-
): Promise<number | null> => {
|
|
76
|
-
const tempSB = deepCopy(resb);
|
|
77
|
-
/* Use polygon for DB only if it already set */
|
|
78
|
-
if (tempSB!.polygonForDB) {
|
|
79
|
-
tempSB!.polygonFromMap = tempSB!.polygonForDB || "";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/* SOREX: BRUTAL FIX COUNTER NUOVE COSTRUZIONI */
|
|
83
|
-
if (tempSB?.listingTypologyIdList?.includes(15)) {
|
|
84
|
-
tempSB.conditionType = 5;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const res = await axios.post("/rest/realEstate/countRealEstateES", tempSB);
|
|
88
|
-
return (await res.data) as number | null;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const getRealEstatesData = async (
|
|
92
|
-
ids: Array<number>
|
|
93
|
-
): Promise<Array<RealEstateMiniItem> | null> => {
|
|
94
|
-
try {
|
|
95
|
-
const res = await axios.post(
|
|
96
|
-
`${baseUrl}/rest/realEstate/getRealEstateListForInfoWindow/${window["_locale"]}`,
|
|
97
|
-
ids
|
|
98
|
-
);
|
|
99
|
-
return res.data;
|
|
100
|
-
} catch (e) {
|
|
101
|
-
handleAxiosError(e as AxiosError);
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const getMapMarkers = async (): Promise<
|
|
107
|
-
Array<MapMarker> | undefined
|
|
108
|
-
> => {
|
|
109
|
-
if (!window["_serializedSearchBean"]) return [];
|
|
110
|
-
|
|
111
|
-
const searchBean = deepCopy(JSON.parse(window["_serializedSearchBean"]));
|
|
112
|
-
|
|
113
|
-
delete searchBean["latitude"];
|
|
114
|
-
delete searchBean["longitude"];
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
const res = await axios.post(
|
|
118
|
-
`${baseUrl}/rest/realEstate/getMapMarkers`,
|
|
119
|
-
searchBean,
|
|
120
|
-
{
|
|
121
|
-
headers: {
|
|
122
|
-
"Content-Type": "application/json",
|
|
123
|
-
Accept: "application/json",
|
|
124
|
-
},
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return res.data as MapMarker[];
|
|
129
|
-
} catch (err) {
|
|
130
|
-
handleAxiosError(err as AxiosError);
|
|
131
|
-
throw [];
|
|
132
|
-
}
|
|
133
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError } from "axios";
|
|
2
|
-
import type { Contacts } from "@wikicasa-dev/types";
|
|
3
|
-
import { baseURL, handleAxiosError } from "./servicesUtils";
|
|
4
|
-
|
|
5
|
-
const baseController = `${baseURL}/rest/request`;
|
|
6
|
-
|
|
7
|
-
export const sendSuggestion = async (suggestion: {
|
|
8
|
-
argument: string;
|
|
9
|
-
email: string;
|
|
10
|
-
message: string;
|
|
11
|
-
privacy: boolean;
|
|
12
|
-
url: string;
|
|
13
|
-
}): Promise<boolean> => {
|
|
14
|
-
const res = await axios.post(`${baseController}/sendSuggestion`, suggestion);
|
|
15
|
-
return res.data as boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const addGenericRequest = async (data: Contacts): Promise<boolean> => {
|
|
19
|
-
try {
|
|
20
|
-
const res = await axios.post("/rest/request/addRequestGeneric", data);
|
|
21
|
-
return res.data;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
handleAxiosError(error as AxiosError);
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const sendWidgetRequest = async (suggestion: {
|
|
29
|
-
name: string;
|
|
30
|
-
company: string;
|
|
31
|
-
email: string;
|
|
32
|
-
phone: string;
|
|
33
|
-
privacy: boolean;
|
|
34
|
-
}): Promise<boolean> => {
|
|
35
|
-
const res = await axios.post(
|
|
36
|
-
`${baseController}/sendWidgetRequest`,
|
|
37
|
-
suggestion
|
|
38
|
-
);
|
|
39
|
-
return res.data as boolean;
|
|
40
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AxiosError } from "axios";
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
_baseURLIt: string;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const baseURL: string = window["_baseURLIt"];
|
|
10
|
-
|
|
11
|
-
export const handleAxiosError = (error: AxiosError): void => {
|
|
12
|
-
const cause = `errorMessage: ${error.message} \n`;
|
|
13
|
-
//ErrorCode !== 200 with server response
|
|
14
|
-
if (error.response) {
|
|
15
|
-
console.error(
|
|
16
|
-
`${cause} errorCode: ${error.response.status} \\n ${error.request.data}`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
//ErrorCode !== 200 WITHOUT server response
|
|
20
|
-
else if (error.request) {
|
|
21
|
-
console.error(`${cause} \n ${error.request}`);
|
|
22
|
-
}
|
|
23
|
-
//Error in request setup
|
|
24
|
-
else {
|
|
25
|
-
console.error(cause);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { Place, GraphData } from "@wikicasa-dev/types";
|
|
2
|
-
import axios, { AxiosError } from "axios";
|
|
3
|
-
import { handleAxiosError } from "./servicesUtils";
|
|
4
|
-
|
|
5
|
-
const baseStatisticControllerUrl = "/rest/statistics";
|
|
6
|
-
|
|
7
|
-
export const updateViewListing = async (
|
|
8
|
-
data: Array<{ agencyId: number; realEstateId: number }>
|
|
9
|
-
): Promise<boolean> => {
|
|
10
|
-
try {
|
|
11
|
-
await axios.post(`${baseStatisticControllerUrl}/updateViewListing/W`, data);
|
|
12
|
-
return true;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
handleAxiosError(error as AxiosError);
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const updateRealEstateSearch = async (
|
|
20
|
-
realEstateSearchBean: any
|
|
21
|
-
): Promise<boolean> => {
|
|
22
|
-
try {
|
|
23
|
-
axios.post(
|
|
24
|
-
`${baseStatisticControllerUrl}/updateRealEstateSearch`,
|
|
25
|
-
realEstateSearchBean
|
|
26
|
-
);
|
|
27
|
-
return true;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
handleAxiosError(error as AxiosError);
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const updatePhoneView = async (
|
|
35
|
-
agencyId: number,
|
|
36
|
-
id: number
|
|
37
|
-
): Promise<boolean> => {
|
|
38
|
-
try {
|
|
39
|
-
const res = await axios.post(
|
|
40
|
-
id
|
|
41
|
-
? `${baseStatisticControllerUrl}/updatePhoneView/${agencyId}/${id}/W`
|
|
42
|
-
: `/rest/statistics/updatePhoneView/${agencyId}/W`
|
|
43
|
-
);
|
|
44
|
-
return res.data;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
handleAxiosError(error as AxiosError);
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
export const getPlaceTrendData = async (place: Place): Promise<any> => {
|
|
51
|
-
try {
|
|
52
|
-
const promiseSale = await axios.post(
|
|
53
|
-
`${baseStatisticControllerUrl}/getPlaceTrendData?sale=${true}`,
|
|
54
|
-
place
|
|
55
|
-
);
|
|
56
|
-
const promiseRent = await axios.post(
|
|
57
|
-
`${baseStatisticControllerUrl}/getPlaceTrendData?sale=${false}`,
|
|
58
|
-
place
|
|
59
|
-
);
|
|
60
|
-
return Promise.all([promiseSale, promiseRent]);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
handleAxiosError(error as AxiosError);
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const getSaleGraphData = async (
|
|
68
|
-
place: Place,
|
|
69
|
-
filters: any = {
|
|
70
|
-
contract: "sale",
|
|
71
|
-
macroTypologyId: 1,
|
|
72
|
-
}
|
|
73
|
-
): Promise<GraphData[]> => {
|
|
74
|
-
try {
|
|
75
|
-
const res = await axios.post(
|
|
76
|
-
`${baseStatisticControllerUrl}/getAveragePriceGraphData/${filters.contract}/${filters.macroTypologyId}`,
|
|
77
|
-
place
|
|
78
|
-
);
|
|
79
|
-
return res.data;
|
|
80
|
-
} catch (error) {
|
|
81
|
-
handleAxiosError(error as AxiosError);
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError } from "axios";
|
|
2
|
-
import type { PublicValuation, Nullable } from "@wikicasa-dev/types";
|
|
3
|
-
import { handleAxiosError, baseURL } from "@services/servicesUtils";
|
|
4
|
-
import { appendQueryString } from "@utils/URLBuilderUtils";
|
|
5
|
-
|
|
6
|
-
const baseController = `/rest/wikicasaPro`;
|
|
7
|
-
|
|
8
|
-
export interface ValuationResult
|
|
9
|
-
extends Record<string, number | boolean | undefined> {
|
|
10
|
-
valid: boolean;
|
|
11
|
-
upper: number;
|
|
12
|
-
mean: number;
|
|
13
|
-
lower: number;
|
|
14
|
-
estimated: number;
|
|
15
|
-
count: number;
|
|
16
|
-
maxDistance?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line max-len
|
|
20
|
-
export const evaluateRealEstateWidget = async (
|
|
21
|
-
publicValuation: PublicValuation,
|
|
22
|
-
token: Nullable<string>,
|
|
23
|
-
conditionTypeId = undefined as number | undefined,
|
|
24
|
-
floor = undefined as number | undefined
|
|
25
|
-
): Promise<PublicValuation> => {
|
|
26
|
-
if (!token) throw new Error("The token can't be null");
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
let params: Record<string, any> = { token: token };
|
|
30
|
-
|
|
31
|
-
if (conditionTypeId) params = { ...params, conditionTypeId };
|
|
32
|
-
if (floor != undefined) params = { ...params, floor };
|
|
33
|
-
|
|
34
|
-
const url = appendQueryString(
|
|
35
|
-
new URL(`${baseURL}${baseController}/evaluateRealEstateWidget`),
|
|
36
|
-
params
|
|
37
|
-
);
|
|
38
|
-
const res = await axios.post(url.toString(), publicValuation);
|
|
39
|
-
res.data.valid = !!res.data.valid;
|
|
40
|
-
return res.data as PublicValuation;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
handleAxiosError(error as AxiosError);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError } from "axios";
|
|
2
|
-
import { handleAxiosError } from "./servicesUtils";
|
|
3
|
-
import type { FEEDBACK } from "@wikicasa-dev/types/dist/index";
|
|
4
|
-
|
|
5
|
-
const baseStatisticControllerUrl = "/rest/wikicasaPro";
|
|
6
|
-
|
|
7
|
-
export const userValuationWithPhotoFeedback = async (
|
|
8
|
-
email: string,
|
|
9
|
-
token: string,
|
|
10
|
-
feedback: FEEDBACK,
|
|
11
|
-
userFeedbackValue: number = 0
|
|
12
|
-
): Promise<boolean> => {
|
|
13
|
-
try {
|
|
14
|
-
// eslint-disable-next-line max-len
|
|
15
|
-
const res = await axios.post(
|
|
16
|
-
`${baseStatisticControllerUrl}/userValuationWithPhotoFeedback/?email=${email}&token=${token}&feedback=${feedback}${
|
|
17
|
-
userFeedbackValue > 0 ? "&userFeedbackValue=" + userFeedbackValue : ""
|
|
18
|
-
}`
|
|
19
|
-
);
|
|
20
|
-
return res.data;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
handleAxiosError(error as AxiosError);
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
};
|
package/src/utils/ArrayUtils.ts
DELETED
package/src/utils/ColorUtils.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @return {string}
|
|
3
|
-
*/
|
|
4
|
-
export function rgba(hex: string, opacity: number): string {
|
|
5
|
-
hex = hex.replace("#", "");
|
|
6
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
7
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
8
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
9
|
-
|
|
10
|
-
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
11
|
-
}
|
package/src/utils/CookieUtils.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as Cookie from "js-cookie";
|
|
2
|
-
|
|
3
|
-
export function encodeCookie<T>(
|
|
4
|
-
name: string,
|
|
5
|
-
obj: T,
|
|
6
|
-
days: number = 30,
|
|
7
|
-
encodeObj = true
|
|
8
|
-
): void {
|
|
9
|
-
const d = new Date();
|
|
10
|
-
d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * days);
|
|
11
|
-
|
|
12
|
-
const stringObj = typeof obj !== "string" ? JSON.stringify(obj) : obj;
|
|
13
|
-
const cookieValue = encodeObj
|
|
14
|
-
? btoa(encodeURIComponent(stringObj))
|
|
15
|
-
: stringObj;
|
|
16
|
-
document.cookie =
|
|
17
|
-
name + "=" + cookieValue + ";path=/;expires=" + d.toUTCString();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function getCookie(name: string): string | null {
|
|
21
|
-
try {
|
|
22
|
-
const v = document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
|
|
23
|
-
return v ? v[2] : null;
|
|
24
|
-
} catch (e) {
|
|
25
|
-
console.error(e);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function decodeCookie(name: string): any {
|
|
31
|
-
try {
|
|
32
|
-
const v = document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
|
|
33
|
-
return v ? JSON.parse(decodeURIComponent(atob(v[2]))) : null;
|
|
34
|
-
} catch (e) {
|
|
35
|
-
console.error(e);
|
|
36
|
-
removeCookie(name);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function removeCookie(name: string): void {
|
|
42
|
-
Cookie.remove(name);
|
|
43
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { shallowCopyObjectTo } from "@utils/ObjectUtils";
|
|
2
|
-
|
|
3
|
-
export const formatCurrency = (
|
|
4
|
-
numberToFormat: number | undefined,
|
|
5
|
-
options?: Intl.NumberFormatOptions,
|
|
6
|
-
locale = "it-IT"
|
|
7
|
-
): string => {
|
|
8
|
-
if (numberToFormat === undefined) return `0`;
|
|
9
|
-
|
|
10
|
-
const _options: Partial<Intl.NumberFormatOptions> = {
|
|
11
|
-
style: "currency",
|
|
12
|
-
currency: "EUR",
|
|
13
|
-
maximumFractionDigits: 0,
|
|
14
|
-
};
|
|
15
|
-
shallowCopyObjectTo(options, _options);
|
|
16
|
-
|
|
17
|
-
return new Intl.NumberFormat(locale, _options).format(numberToFormat);
|
|
18
|
-
};
|
package/src/utils/DOMUtils.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Nullable } from "@wikicasa-dev/types";
|
|
2
|
-
|
|
3
|
-
export const getSingleElement = (selector: string): HTMLElement => {
|
|
4
|
-
const el = document.querySelector(selector) as HTMLElement;
|
|
5
|
-
if (!el) throw new Error(`No element found with the id: ${selector}`);
|
|
6
|
-
return el;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const emptyElem = (selectorOrElem: string | Element): void => {
|
|
10
|
-
if (typeof selectorOrElem === "string")
|
|
11
|
-
getSingleElement(selectorOrElem).textContent = "";
|
|
12
|
-
else selectorOrElem.textContent = "";
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const showElem = (
|
|
16
|
-
elem: Nullable<HTMLElement>,
|
|
17
|
-
displayValue: "block" | "d-flex" = "block"
|
|
18
|
-
): void => {
|
|
19
|
-
if (!elem) return;
|
|
20
|
-
|
|
21
|
-
elem.style.display = displayValue;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const hideElem = (elem: Nullable<HTMLElement>): void => {
|
|
25
|
-
if (!elem) return;
|
|
26
|
-
|
|
27
|
-
elem.style.display = "none";
|
|
28
|
-
};
|
package/src/utils/DateUtils.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function formatDate(date: Date, display: boolean = false): string {
|
|
2
|
-
const day = date.getDate();
|
|
3
|
-
const month = date.getMonth() + 1;
|
|
4
|
-
const year = date.getFullYear();
|
|
5
|
-
|
|
6
|
-
return display
|
|
7
|
-
? `${("0" + day).slice(-2)}-${("0" + month).slice(-2)}-${year}`
|
|
8
|
-
: `${year}-${("0" + month).slice(-2)}-${("0" + day).slice(-2)}`;
|
|
9
|
-
}
|