vdb-ai-chat 1.0.15 → 1.0.17
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/chat-widget.js +1 -1
- package/lib/commonjs/api.js +55 -64
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/components/ChatWidget.js +6 -35
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/LazyProductsFetcher.js +1 -1
- package/lib/commonjs/components/LazyProductsFetcher.js.map +1 -1
- package/lib/commonjs/components/MessageBubble.js +3 -1
- package/lib/commonjs/components/MessageBubble.js.map +1 -1
- package/lib/commonjs/components/ProductsListView.js +104 -5
- package/lib/commonjs/components/ProductsListView.js.map +1 -1
- package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
- package/lib/commonjs/components/utils.js +542 -5
- package/lib/commonjs/components/utils.js.map +1 -1
- package/lib/module/api.js +55 -64
- package/lib/module/api.js.map +1 -1
- package/lib/module/components/ChatWidget.js +6 -35
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/LazyProductsFetcher.js +1 -1
- package/lib/module/components/LazyProductsFetcher.js.map +1 -1
- package/lib/module/components/MessageBubble.js +3 -1
- package/lib/module/components/MessageBubble.js.map +1 -1
- package/lib/module/components/ProductsListView.js +104 -5
- package/lib/module/components/ProductsListView.js.map +1 -1
- package/lib/module/components/SuggestionsRow.js.map +1 -1
- package/lib/module/components/utils.js +539 -4
- package/lib/module/components/utils.js.map +1 -1
- package/lib/module/hooks/useAnalytics.js.map +1 -1
- package/lib/typescript/api.d.ts +2 -2
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
- package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
- package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
- package/lib/typescript/components/utils.d.ts +7 -0
- package/lib/typescript/components/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +65 -92
- package/src/components/ChatWidget.tsx +6 -47
- package/src/components/LazyProductsFetcher.tsx +1 -1
- package/src/components/MessageBubble.tsx +15 -4
- package/src/components/ProductsListView.tsx +105 -20
- package/src/components/SuggestionsRow.tsx +1 -7
- package/src/components/utils.ts +655 -7
- package/src/hooks/useAnalytics.tsx +2 -2
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Text,
|
|
5
|
-
TouchableOpacity,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
ScrollView,
|
|
8
|
-
} from "react-native";
|
|
2
|
+
import { View, StyleSheet, ScrollView } from "react-native";
|
|
9
3
|
import styled from "styled-components/native";
|
|
10
4
|
import { useTheme } from "styled-components/native";
|
|
11
5
|
import { DefaultTheme } from "styled-components/native";
|
package/src/components/utils.ts
CHANGED
|
@@ -68,7 +68,6 @@ export const getUserCurrencySymbol = async (): Promise<string | null> => {
|
|
|
68
68
|
return userData.currency_symbol || "$";
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
|
|
72
71
|
export const roundUpPrices = async (): Promise<boolean> => {
|
|
73
72
|
const userInfo = await Storage.getJSON<UserDetails>("persist:userInfo", {});
|
|
74
73
|
const userData = userInfo?.user as UserDetails;
|
|
@@ -79,21 +78,23 @@ export const roundUpPrices = async (): Promise<boolean> => {
|
|
|
79
78
|
|
|
80
79
|
// Helper to add commas to a number
|
|
81
80
|
export function formatWithCommas(value: number | string): string {
|
|
82
|
-
const num = typeof value ===
|
|
81
|
+
const num = typeof value === "string" ? parseFloat(value) : value;
|
|
83
82
|
if (isNaN(num)) return String(value);
|
|
84
83
|
return num.toLocaleString();
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
// Format price values according to requirements
|
|
88
|
-
export function formatPriceValue(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
export function formatPriceValue(
|
|
88
|
+
key: string,
|
|
89
|
+
value: any,
|
|
90
|
+
shouldRound: boolean
|
|
91
|
+
) {
|
|
92
|
+
if (key === "price_per_carat") {
|
|
92
93
|
// Remove decimals, round, add commas
|
|
93
94
|
const num = Math.round(Number(value));
|
|
94
95
|
return formatWithCommas(num);
|
|
95
96
|
}
|
|
96
|
-
if (key ===
|
|
97
|
+
if (key === "total_sales_price") {
|
|
97
98
|
let num = Number(value);
|
|
98
99
|
if (shouldRound) {
|
|
99
100
|
num = Math.round(num);
|
|
@@ -194,3 +195,650 @@ export const useDeviceType = () => {
|
|
|
194
195
|
const isLargeScreen = isDesktop && !isTablet && !isMobile;
|
|
195
196
|
return { isMobile, isTablet, isDesktop, isLargeScreen };
|
|
196
197
|
};
|
|
198
|
+
|
|
199
|
+
export const renderSearchParams = ({searchPayload, priceMode, vdbSetting, searchResultViewType}: any) => {
|
|
200
|
+
if (
|
|
201
|
+
searchPayload?.cut_from ||
|
|
202
|
+
searchPayload?.cut_to ||
|
|
203
|
+
searchPayload?.polish_from ||
|
|
204
|
+
searchPayload?.polish_to ||
|
|
205
|
+
searchPayload?.symmetry_from ||
|
|
206
|
+
searchPayload?.symmetry_to
|
|
207
|
+
) {
|
|
208
|
+
searchPayload.cutGrades = [];
|
|
209
|
+
searchPayload.polishes = [];
|
|
210
|
+
searchPayload.symmetries = [];
|
|
211
|
+
if (!searchPayload?.shapes) {
|
|
212
|
+
searchPayload.shapes = [];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (searchPayload?.cut_from) {
|
|
216
|
+
searchPayload.cutGrades.push(searchPayload?.cut_from);
|
|
217
|
+
}
|
|
218
|
+
if (searchPayload?.cut_to) {
|
|
219
|
+
searchPayload.cutGrades.push(searchPayload?.cut_to);
|
|
220
|
+
}
|
|
221
|
+
if (searchPayload?.polish_from) {
|
|
222
|
+
searchPayload.polishes.push(searchPayload?.polish_from);
|
|
223
|
+
}
|
|
224
|
+
if (searchPayload?.polish_to) {
|
|
225
|
+
searchPayload.polishes.push(searchPayload?.polish_to);
|
|
226
|
+
}
|
|
227
|
+
if (searchPayload?.symmetry_from) {
|
|
228
|
+
searchPayload.symmetries.push(searchPayload?.symmetry_from);
|
|
229
|
+
}
|
|
230
|
+
if (searchPayload?.symmetry_to) {
|
|
231
|
+
searchPayload.symmetries.push(searchPayload?.symmetry_to);
|
|
232
|
+
}
|
|
233
|
+
if (searchPayload?.three_x) {
|
|
234
|
+
if(searchPayload.lab_grown) {
|
|
235
|
+
searchPayload.cutGrades = ["Excellent", "8X"];
|
|
236
|
+
searchPayload.polishes = ["Excellent", "8X"];
|
|
237
|
+
searchPayload.symmetries = ["Excellent", "8X"];
|
|
238
|
+
searchPayload.cps_three_x_options = ["8X", "Excellent"];
|
|
239
|
+
searchPayload.cut_from = "Excellent";
|
|
240
|
+
searchPayload.cut_to = "8X";
|
|
241
|
+
searchPayload.polish_from = "Excellent";
|
|
242
|
+
searchPayload.polish_to = "8X";
|
|
243
|
+
searchPayload.symmetry_from = "Excellent";
|
|
244
|
+
searchPayload.symmetry_to = "8X";
|
|
245
|
+
} else {
|
|
246
|
+
searchPayload.cutGrades = ["Excellent", "Excellent"];
|
|
247
|
+
searchPayload.polishes = ["Excellent", "Excellent"];
|
|
248
|
+
searchPayload.symmetries = ["Excellent", "Excellent"];
|
|
249
|
+
searchPayload.cut_from = "Excellent";
|
|
250
|
+
searchPayload.cut_to = "Excellent";
|
|
251
|
+
searchPayload.polish_from = "Excellent";
|
|
252
|
+
searchPayload.polish_to = "Excellent";
|
|
253
|
+
searchPayload.symmetry_from = "Excellent";
|
|
254
|
+
searchPayload.symmetry_to = "Excellent";
|
|
255
|
+
}
|
|
256
|
+
delete searchPayload.three_x;
|
|
257
|
+
}
|
|
258
|
+
if(searchPayload?.three_vg_plus && searchPayload.lab_grown) {
|
|
259
|
+
searchPayload.cutGrades = ["Very Good", "8X"];
|
|
260
|
+
searchPayload.polishes = ["Very Good", "8X"];
|
|
261
|
+
searchPayload.symmetries = ["Very Good", "8X"];
|
|
262
|
+
searchPayload.cut_from = "Very Good";
|
|
263
|
+
searchPayload.cut_to = "8X";
|
|
264
|
+
searchPayload.polish_from = "Very Good";
|
|
265
|
+
searchPayload.polish_to = "8X";
|
|
266
|
+
searchPayload.symmetry_from = "Very Good";
|
|
267
|
+
searchPayload.symmetry_to = "8X";
|
|
268
|
+
searchPayload.cps_three_vg_plus_options = ["8X", "Very Good"];
|
|
269
|
+
}
|
|
270
|
+
if(searchPayload?.eight_x && searchPayload.lab_grown) {
|
|
271
|
+
searchPayload.cutGrades = ["8X", "8X"];
|
|
272
|
+
searchPayload.polishes = ["8X", "8X"];
|
|
273
|
+
searchPayload.symmetries = ["8X", "8X"];
|
|
274
|
+
searchPayload.cut_from = "8X";
|
|
275
|
+
searchPayload.cut_to = "8X";
|
|
276
|
+
searchPayload.polish_from = "8X";
|
|
277
|
+
searchPayload.polish_to = "8X";
|
|
278
|
+
searchPayload.symmetry_from = "8X";
|
|
279
|
+
searchPayload.symmetry_to = "8X";
|
|
280
|
+
}
|
|
281
|
+
if(searchPayload?.page_size) {
|
|
282
|
+
delete searchPayload.page_size;
|
|
283
|
+
}
|
|
284
|
+
searchPayload.price_mode = priceMode;
|
|
285
|
+
searchPayload.vdb_setting =vdbSetting ? "true" : "false";
|
|
286
|
+
searchPayload.results_view_type = searchResultViewType || "grid";
|
|
287
|
+
searchPayload.featured = searchPayload.featured || "false";
|
|
288
|
+
searchPayload.pair = searchPayload.pair === "pair" ? "pair" : "other";
|
|
289
|
+
searchPayload.with_available_items = !!searchPayload.with_available_items;
|
|
290
|
+
if(searchPayload.page_number) {
|
|
291
|
+
delete searchPayload.page_number;
|
|
292
|
+
}
|
|
293
|
+
searchPayload.preference = searchPayload.preference || [];
|
|
294
|
+
searchPayload.depth_percent_from = searchPayload.depth_percent_from ?? "0";
|
|
295
|
+
searchPayload.depth_percent_to = searchPayload.depth_percent_to ?? "100";
|
|
296
|
+
searchPayload.table_percent_from = searchPayload.table_percent_from ?? "0";
|
|
297
|
+
searchPayload.table_percent_to = searchPayload.table_percent_to ?? "100";
|
|
298
|
+
|
|
299
|
+
if(searchPayload.price_total_from || searchPayload.price_total_to) {
|
|
300
|
+
searchPayload.total_or_price_per_carat = "total_sales_price"
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if(searchPayload.price_per_carat_from || searchPayload.price_per_carat_to) {
|
|
304
|
+
searchPayload.total_or_price_per_carat = "price_per_carat"
|
|
305
|
+
}
|
|
306
|
+
return searchPayload;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export const generateSavedSearchName = (search_params: any) => {
|
|
310
|
+
let options: { [k: string]: any } = {};
|
|
311
|
+
let title_parts = [];
|
|
312
|
+
|
|
313
|
+
//is featured items
|
|
314
|
+
options.featured =
|
|
315
|
+
!!search_params?.featured && search_params?.featured === "true"
|
|
316
|
+
? "true"
|
|
317
|
+
: "false";
|
|
318
|
+
|
|
319
|
+
//Shape
|
|
320
|
+
if (search_params?.shapes && search_params?.shapes?.length) {
|
|
321
|
+
options.shapes = search_params?.shapes || [];
|
|
322
|
+
title_parts.push(options.shapes.join(", "));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
//Carat Weight
|
|
326
|
+
let carat_title = "";
|
|
327
|
+
if (search_params?.size_from || search_params?.minCarat) {
|
|
328
|
+
options.minCarat = search_params?.size_from ?? search_params?.minCarat;
|
|
329
|
+
carat_title += options.minCarat + "ct.";
|
|
330
|
+
}
|
|
331
|
+
if (search_params?.size_to || search_params?.maxCarat) {
|
|
332
|
+
options.maxCarat = search_params?.size_to ?? search_params?.maxCarat;
|
|
333
|
+
carat_title += " - " + options.maxCarat + "ct.";
|
|
334
|
+
}
|
|
335
|
+
title_parts.push(carat_title);
|
|
336
|
+
|
|
337
|
+
// Color (simple)
|
|
338
|
+
if (search_params?.color_from || search_params?.simpleColors?.length) {
|
|
339
|
+
let color_title = "";
|
|
340
|
+
options.simpleColors = [];
|
|
341
|
+
options.simpleColors.push(search_params?.color_from ?? []);
|
|
342
|
+
color_title += search_params?.color_from;
|
|
343
|
+
if (search_params?.color_to) {
|
|
344
|
+
if (!options.simpleColors) options.simpleColors = [];
|
|
345
|
+
options.simpleColors.push(search_params?.color_to ?? []);
|
|
346
|
+
color_title += " - " + search_params?.color_to;
|
|
347
|
+
}
|
|
348
|
+
if (search_params?.simpleColors && search_params?.simpleColors?.length) {
|
|
349
|
+
options.simpleColors = search_params?.simpleColors || [];
|
|
350
|
+
color_title = options.simpleColors.join(" - ");
|
|
351
|
+
}
|
|
352
|
+
if (color_title) title_parts.push(color_title);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Fancy Color
|
|
356
|
+
if (
|
|
357
|
+
(search_params?.fancy_colors && search_params?.fancy_colors?.length) ||
|
|
358
|
+
(search_params?.fancyColors1 && search_params.fancyColors1?.length)
|
|
359
|
+
) {
|
|
360
|
+
options.fancyColors1 =
|
|
361
|
+
search_params?.fancy_colors || search_params?.fancyColors1 || [];
|
|
362
|
+
let color_title = "Fancy Color" + ": " + options.fancyColors1.join(" - ");
|
|
363
|
+
title_parts.push(color_title);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
//Fancy Color Overtones
|
|
367
|
+
if (
|
|
368
|
+
(search_params?.fancy_color_overtones &&
|
|
369
|
+
search_params?.fancy_color_overtones?.length) ||
|
|
370
|
+
(search_params?.fancyColorsOvertones &&
|
|
371
|
+
search_params.fancyColorsOvertones?.length)
|
|
372
|
+
) {
|
|
373
|
+
options.fancyColorsOvertones =
|
|
374
|
+
search_params?.fancy_color_overtones ||
|
|
375
|
+
search_params?.fancyColorsOvertones ||
|
|
376
|
+
[];
|
|
377
|
+
let overtone_color_title =
|
|
378
|
+
"FC Overtone" + ": " + options?.fancyColorsOvertones?.join(", ");
|
|
379
|
+
title_parts.push(overtone_color_title);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Clarity
|
|
383
|
+
options.clarities = [];
|
|
384
|
+
if (search_params?.clarity_from) {
|
|
385
|
+
options.clarities.push(search_params?.clarity_from);
|
|
386
|
+
}
|
|
387
|
+
if (search_params?.clarity_to) {
|
|
388
|
+
options.clarities.push(search_params?.clarity_to);
|
|
389
|
+
}
|
|
390
|
+
if (search_params?.clarities?.length)
|
|
391
|
+
options.clarities = search_params?.clarities ?? [];
|
|
392
|
+
if (options?.clarities?.length)
|
|
393
|
+
title_parts.push(options?.clarities.join(" - "));
|
|
394
|
+
|
|
395
|
+
// Cut
|
|
396
|
+
options.cutGrades = [];
|
|
397
|
+
if (search_params?.cut_from) {
|
|
398
|
+
options.cutGrades.push(search_params?.cut_from);
|
|
399
|
+
}
|
|
400
|
+
if (search_params?.cut_to) {
|
|
401
|
+
options.cutGrades.push(search_params?.cut_to);
|
|
402
|
+
}
|
|
403
|
+
if (search_params.cutGrades?.length)
|
|
404
|
+
options.cutGrades = search_params.cutGrades;
|
|
405
|
+
if (options.cutGrades.length) {
|
|
406
|
+
let cutTitle = "Cut" + ": " + options.cutGrades.join(" - ");
|
|
407
|
+
title_parts.push(cutTitle);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Polish
|
|
411
|
+
options.polishes = [];
|
|
412
|
+
if (search_params?.polish_from) {
|
|
413
|
+
options.polishes.push(search_params?.polish_from);
|
|
414
|
+
}
|
|
415
|
+
if (search_params?.polish_to) {
|
|
416
|
+
options.polishes.push(search_params?.polish_to);
|
|
417
|
+
}
|
|
418
|
+
if (search_params?.polishes?.length)
|
|
419
|
+
options.polishes = search_params?.polishes;
|
|
420
|
+
if (options.polishes?.length) {
|
|
421
|
+
let polishTitle = "Pol" + ": " + options.polishes.join(" - ");
|
|
422
|
+
title_parts.push(polishTitle);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Symmetry
|
|
426
|
+
options.symmetries = [];
|
|
427
|
+
if (search_params?.polish_from) {
|
|
428
|
+
options.symmetries.push(search_params?.symmetry_from);
|
|
429
|
+
}
|
|
430
|
+
if (search_params?.polish_to) {
|
|
431
|
+
options.symmetries.push(search_params?.symmetry_to);
|
|
432
|
+
}
|
|
433
|
+
if (search_params.symmetries?.length)
|
|
434
|
+
options.symmetries = search_params.symmetries;
|
|
435
|
+
if (options.symmetries?.length) {
|
|
436
|
+
let symTitle = "Sym" + ": " + options.symmetries.join(" - ");
|
|
437
|
+
title_parts.push(symTitle);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Fluorescence
|
|
441
|
+
if (search_params?.fluorescence_intensities?.length) {
|
|
442
|
+
options.fluorescences = search_params?.fluorescence_intensities || [];
|
|
443
|
+
} else if (search_params?.fluorescences?.length) {
|
|
444
|
+
options.fluorescences = search_params?.fluorescences || [];
|
|
445
|
+
}
|
|
446
|
+
if (options?.fluorescences?.length > 0) {
|
|
447
|
+
let flour_values = "Flour" + ": " + options.fluorescences.join(", ");
|
|
448
|
+
title_parts.push(flour_values);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Lab
|
|
452
|
+
if (search_params?.labs && search_params?.labs?.length) {
|
|
453
|
+
options.labs = search_params?.labs || [];
|
|
454
|
+
let labTitle = "Lab" + ": " + options.labs.join(", ");
|
|
455
|
+
title_parts.push(labTitle);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
//Depth
|
|
459
|
+
let depth_title = "";
|
|
460
|
+
if (
|
|
461
|
+
(search_params?.depth_percent_from &&
|
|
462
|
+
search_params?.depth_percent_from >= 0) ||
|
|
463
|
+
(search_params?.minDepth && search_params?.minDepth >= 0)
|
|
464
|
+
) {
|
|
465
|
+
options.minDepth =
|
|
466
|
+
search_params?.depth_percent_from ?? search_params.minDepth;
|
|
467
|
+
depth_title += "Depth" + ": " + options.minDepth;
|
|
468
|
+
}
|
|
469
|
+
if (
|
|
470
|
+
(search_params?.depth_percent_to && search_params?.depth_percent_to >= 0) ||
|
|
471
|
+
(search_params?.maxDepth && search_params?.maxDepth >= 0)
|
|
472
|
+
) {
|
|
473
|
+
options.maxDepth =
|
|
474
|
+
search_params?.depth_percent_to ?? search_params?.maxDepth;
|
|
475
|
+
depth_title += " - " + options.maxDepth + "%";
|
|
476
|
+
}
|
|
477
|
+
if (depth_title) title_parts.push(depth_title);
|
|
478
|
+
|
|
479
|
+
//table title
|
|
480
|
+
let table_title = "";
|
|
481
|
+
if (
|
|
482
|
+
(search_params?.table_percent_from &&
|
|
483
|
+
search_params?.table_percent_from >= 0) ||
|
|
484
|
+
(search_params?.minTable && search_params?.minTable >= 0)
|
|
485
|
+
) {
|
|
486
|
+
options.minTable =
|
|
487
|
+
search_params?.table_percent_from ?? search_params?.minTable;
|
|
488
|
+
table_title += "table" + ": " + options.minTable;
|
|
489
|
+
}
|
|
490
|
+
if (
|
|
491
|
+
(search_params?.table_percent_to && search_params?.table_percent_to >= 0) ||
|
|
492
|
+
(search_params?.maxTable && search_params?.maxTable >= 0)
|
|
493
|
+
) {
|
|
494
|
+
options.maxTable =
|
|
495
|
+
search_params?.table_percent_to ?? search_params?.maxTable;
|
|
496
|
+
table_title += " - " + options.maxTable + "%";
|
|
497
|
+
}
|
|
498
|
+
if (table_title) title_parts.push(table_title);
|
|
499
|
+
|
|
500
|
+
// Meas Length
|
|
501
|
+
let measLengthTitle = "";
|
|
502
|
+
let measLengthLabel = "Meas Length";
|
|
503
|
+
if (search_params?.meas_length_from || search_params?.meas_length_to) {
|
|
504
|
+
options.meas_length_from = search_params?.meas_length_from ?? "0";
|
|
505
|
+
measLengthTitle = measLengthLabel + ": " + options.meas_length_from;
|
|
506
|
+
}
|
|
507
|
+
if (search_params?.meas_length_to) {
|
|
508
|
+
options.meas_length_to = search_params?.meas_length_to;
|
|
509
|
+
measLengthTitle += " - " + options.meas_length_to;
|
|
510
|
+
}
|
|
511
|
+
if (measLengthTitle) title_parts.push(measLengthTitle);
|
|
512
|
+
|
|
513
|
+
// Meas Width
|
|
514
|
+
let measWidthTitle = "";
|
|
515
|
+
let measWidthLabel = "Meas Width";
|
|
516
|
+
if (search_params?.meas_width_from || search_params?.meas_width_to) {
|
|
517
|
+
options.meas_width_from = search_params?.meas_width_from ?? "0";
|
|
518
|
+
measWidthTitle = measWidthLabel + ": " + options.meas_width_from;
|
|
519
|
+
}
|
|
520
|
+
if (search_params?.meas_width_to) {
|
|
521
|
+
options.meas_width_to = search_params?.meas_width_to;
|
|
522
|
+
measWidthTitle += " - " + options.meas_width_to;
|
|
523
|
+
}
|
|
524
|
+
if (measWidthTitle) title_parts.push(measWidthTitle);
|
|
525
|
+
|
|
526
|
+
// meas_depth
|
|
527
|
+
if (search_params?.meas_height_from || search_params?.meas_height_to) {
|
|
528
|
+
options.meas_height_from = search_params?.meas_height_from ?? "0";
|
|
529
|
+
} else if (search_params?.minDepth || search_params?.maxDepth) {
|
|
530
|
+
options.meas_height_from = search_params?.minDepth ?? "0";
|
|
531
|
+
}
|
|
532
|
+
if (search_params?.meas_height_to) {
|
|
533
|
+
options.meas_height_to = search_params?.meas_height_to;
|
|
534
|
+
} else if (search_params?.maxDepth) {
|
|
535
|
+
options.meas_height_to = search_params?.maxDepth;
|
|
536
|
+
}
|
|
537
|
+
if (options.meas_height_from && options.meas_height_to) {
|
|
538
|
+
let measDepthTitle =
|
|
539
|
+
"Meas Depth" +
|
|
540
|
+
": " +
|
|
541
|
+
options.meas_height_from +
|
|
542
|
+
" - " +
|
|
543
|
+
options.meas_height_to;
|
|
544
|
+
title_parts.push(measDepthTitle);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Meas Ratio
|
|
548
|
+
if (search_params?.meas_ratio_from || search_params?.meas_ratio_to) {
|
|
549
|
+
options.meas_ratio_from = search_params?.meas_ratio_from ?? "0";
|
|
550
|
+
}
|
|
551
|
+
if (search_params?.meas_ratio_to) {
|
|
552
|
+
options.meas_ratio_to = search_params?.meas_ratio_to;
|
|
553
|
+
}
|
|
554
|
+
if (search_params?.meas_ratio_from && search_params?.meas_ratio_to) {
|
|
555
|
+
let measTitle =
|
|
556
|
+
" Ratio" + ": " + options.meas_ratio_from + " - " + options.meas_ratio_to;
|
|
557
|
+
title_parts.push(measTitle);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
//Total Price
|
|
561
|
+
let budget_title = "";
|
|
562
|
+
let totalPriceLabel = "Total";
|
|
563
|
+
if (
|
|
564
|
+
(search_params?.price_total_from && search_params?.price_total_from) ||
|
|
565
|
+
(search_params?.minBudget && search_params?.minBudget)
|
|
566
|
+
) {
|
|
567
|
+
options.minBudget =
|
|
568
|
+
search_params?.price_total_from ?? search_params?.minBudget;
|
|
569
|
+
budget_title += totalPriceLabel + ": " + options.minBudget;
|
|
570
|
+
}
|
|
571
|
+
if (
|
|
572
|
+
(search_params?.price_total_to && search_params?.price_total_to >= 0) ||
|
|
573
|
+
(search_params?.maxBudget && search_params?.maxBudget >= 0)
|
|
574
|
+
) {
|
|
575
|
+
options.maxBudget =
|
|
576
|
+
search_params?.price_total_to ?? search_params?.maxBudget;
|
|
577
|
+
budget_title += " - " + options.maxBudget;
|
|
578
|
+
}
|
|
579
|
+
if (budget_title) title_parts.push(budget_title);
|
|
580
|
+
|
|
581
|
+
// Price per Carat
|
|
582
|
+
let price_per_carat_title = "";
|
|
583
|
+
let ppcLabel = "PPC";
|
|
584
|
+
if (search_params?.price_per_carat_from || search_params?.minPricePerCt) {
|
|
585
|
+
options.minPricePerCt =
|
|
586
|
+
search_params?.price_per_carat_from ?? search_params?.minPricePerCt;
|
|
587
|
+
price_per_carat_title += ppcLabel + ": " + options.minPricePerCt;
|
|
588
|
+
}
|
|
589
|
+
if (search_params?.price_per_carat_to || search_params?.maxPricePerCt) {
|
|
590
|
+
options.maxPricePerCt =
|
|
591
|
+
search_params?.price_per_carat_to ?? search_params?.maxPricePerCt;
|
|
592
|
+
price_per_carat_title += " - " + options.maxPricePerCt;
|
|
593
|
+
}
|
|
594
|
+
if (price_per_carat_title) title_parts.push(price_per_carat_title);
|
|
595
|
+
|
|
596
|
+
// Location
|
|
597
|
+
if (search_params?.location_for) {
|
|
598
|
+
options.location_for = search_params?.location_for || "";
|
|
599
|
+
title_parts.push(options.location_for);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//Location
|
|
603
|
+
if (
|
|
604
|
+
search_params?.vendor_locations &&
|
|
605
|
+
search_params?.vendor_locations?.length
|
|
606
|
+
) {
|
|
607
|
+
options.vendor_locations = search_params?.vendor_locations || [];
|
|
608
|
+
let locationTitle = "Item Loc" + ": " + options.vendor_locations.join(", ");
|
|
609
|
+
title_parts.push(locationTitle);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Supplier
|
|
613
|
+
if (
|
|
614
|
+
(search_params?.company_names && search_params?.company_names?.length) ||
|
|
615
|
+
(search_params?.companyNames && search_params?.companyNames?.length)
|
|
616
|
+
) {
|
|
617
|
+
options.companyNames =
|
|
618
|
+
search_params?.company_names || search_params?.companyNames || [];
|
|
619
|
+
let supplerTitle = "Supplier" + ": " + options.companyNames.join(",");
|
|
620
|
+
title_parts.push(supplerTitle);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
//Countries
|
|
624
|
+
if (search_params?.countries && search_params?.countries?.length) {
|
|
625
|
+
options.countries = search_params?.countries || [];
|
|
626
|
+
title_parts.push(options.countries.join(", "));
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
//Cities
|
|
630
|
+
if (search_params?.cities && search_params?.citie?.length) {
|
|
631
|
+
options.cities = search_params?.cities || [];
|
|
632
|
+
title_parts.push(options.cities.join(", "));
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Growth
|
|
636
|
+
if (search_params?.growth_type && search_params?.growth_type?.length) {
|
|
637
|
+
options.growth_type = search_params?.growth_type || [];
|
|
638
|
+
let growthTitle = "Growth" + ": " + options.growth_type.join(",");
|
|
639
|
+
title_parts.push(growthTitle);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// Total or Price per carat
|
|
643
|
+
options.total_or_price_per_carat =
|
|
644
|
+
search_params?.total_or_price_per_carat || "";
|
|
645
|
+
|
|
646
|
+
//Argyle
|
|
647
|
+
options.argyle = search_params?.argyle || {};
|
|
648
|
+
|
|
649
|
+
//Group IDs
|
|
650
|
+
if (search_params?.group_ids && search_params?.group_ids?.length) {
|
|
651
|
+
options.group_ids = search_params?.group_ids || [];
|
|
652
|
+
title_parts.push(options.group_ids.join(", "));
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
//Certifications
|
|
656
|
+
if (search_params?.certifications && search_params?.certifications?.length) {
|
|
657
|
+
options.certifications = search_params?.certifications || [];
|
|
658
|
+
title_parts.push(options.certifications.join(", "));
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
//parcel
|
|
662
|
+
if (search_params?.parcel) {
|
|
663
|
+
options.parcel = search_params?.parcel;
|
|
664
|
+
title_parts.push("Parcel");
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
//3X
|
|
668
|
+
if (search_params?.three_x && search_params?.three_x === true) {
|
|
669
|
+
options.three_x = true;
|
|
670
|
+
title_parts.push("3X");
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
//Hearts and Arrows (H&A)
|
|
674
|
+
if (
|
|
675
|
+
search_params?.hearts_and_arrows &&
|
|
676
|
+
search_params?.hearts_and_arrows === "Hearts and Arrows"
|
|
677
|
+
) {
|
|
678
|
+
options.hearts_and_arrows = search_params?.hearts_and_arrows;
|
|
679
|
+
title_parts.push("H&A");
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
//Enhancements
|
|
683
|
+
if (search_params?.enhancements && search_params?.enhancements?.length) {
|
|
684
|
+
options.enhancements = search_params?.enhancements || [];
|
|
685
|
+
if (options.enhancements.indexOf("HPHT") !== -1) {
|
|
686
|
+
options.enhancements[options.enhancements.indexOf("HPHT")] =
|
|
687
|
+
"Color Enhanced";
|
|
688
|
+
}
|
|
689
|
+
title_parts.push(options.enhancements.join(", "));
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
//Eye Clean
|
|
693
|
+
if (search_params?.eye_clean && Array.isArray(search_params.eye_clean)) {
|
|
694
|
+
options.eye_clean = search_params.eye_clean;
|
|
695
|
+
title_parts.push(options.eye_clean.join(", "));
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
//No BGM
|
|
699
|
+
if (search_params?.no_bgm) {
|
|
700
|
+
options.no_bgm = search_params?.no_bgm;
|
|
701
|
+
title_parts.push("No BGM");
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
//3VG+
|
|
705
|
+
if (search_params?.three_vg_plus) {
|
|
706
|
+
options.three_vg_plus = search_params?.three_vg_plus;
|
|
707
|
+
title_parts.push("3VG+");
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
//8X
|
|
711
|
+
if (search_params?.eight_x) {
|
|
712
|
+
options.eight_x = search_params?.eight_x;
|
|
713
|
+
title_parts.push("8X");
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
//Inclusion Pattern
|
|
717
|
+
if (search_params?.inclusion_pattern) {
|
|
718
|
+
options.inclusion_pattern = search_params?.inclusion_pattern;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
//Intensity Black Code
|
|
722
|
+
if (search_params?.intensity_black_code) {
|
|
723
|
+
options.intensity_black_code = search_params?.intensity_black_code;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
//Inclusion Open
|
|
727
|
+
if (search_params?.inclusion_open) {
|
|
728
|
+
options.inclusion_open = search_params?.inclusion_open;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
//With Images
|
|
732
|
+
if (search_params?.with_images) {
|
|
733
|
+
options.with_images = search_params?.with_images;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
//Certified Pairs
|
|
737
|
+
if (search_params?.certified_pairs) {
|
|
738
|
+
options.certified_pairs = search_params?.certified_pairs;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
//With Available Items
|
|
742
|
+
if (search_params?.with_available_items) {
|
|
743
|
+
options.with_available_items = search_params?.with_available_items;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
//Pair
|
|
747
|
+
if (search_params?.pair) {
|
|
748
|
+
options.pair = search_params?.pair;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
//Discount Percent
|
|
752
|
+
if (search_params?.discount_percent_from) {
|
|
753
|
+
options.discount_percent_from = search_params?.discount_percent_from;
|
|
754
|
+
}
|
|
755
|
+
if (search_params?.discount_percent_to) {
|
|
756
|
+
options.discount_percent_to = search_params?.discount_percent_to;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
let crownTitle = "";
|
|
760
|
+
let crownTitleLabel = "Crown";
|
|
761
|
+
// Crown Height
|
|
762
|
+
if (
|
|
763
|
+
search_params?.crown_percent_from &&
|
|
764
|
+
search_params?.crown_percent_from >= 0
|
|
765
|
+
) {
|
|
766
|
+
options.crown_percent_from = search_params?.crown_percent_from;
|
|
767
|
+
crownTitle += crownTitleLabel + ": " + options.crown_percent_from + "%";
|
|
768
|
+
}
|
|
769
|
+
if (search_params?.crown_percent_to && search_params?.crown_percent_to >= 0) {
|
|
770
|
+
options.crown_percent_to = search_params?.crown_percent_to;
|
|
771
|
+
crownTitle +=
|
|
772
|
+
crownTitle === ""
|
|
773
|
+
? crownTitleLabel + ": 0% - " + options.crown_percent_to + "%"
|
|
774
|
+
: " - " + options.crown_percent_to + "%";
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// Crown Angle
|
|
778
|
+
if (search_params?.crown_angle_from && search_params?.crown_angle_from >= 0) {
|
|
779
|
+
options.crown_angle_from = search_params?.crown_angle_from;
|
|
780
|
+
crownTitle +=
|
|
781
|
+
crownTitle === ""
|
|
782
|
+
? crownTitleLabel + ": " + options.crown_angle_from + "°"
|
|
783
|
+
: ", " + options.crown_angle_from + "°";
|
|
784
|
+
}
|
|
785
|
+
if (search_params?.crown_angle_to && search_params?.crown_angle_to >= 0) {
|
|
786
|
+
options.crown_angle_to = search_params?.crown_angle_to;
|
|
787
|
+
crownTitle +=
|
|
788
|
+
crownTitle === ""
|
|
789
|
+
? "0° - " + options.crown_angle_to + "°"
|
|
790
|
+
: search_params?.crown_angle_from === undefined
|
|
791
|
+
? ", 0° - " + options.crown_angle_to + "°"
|
|
792
|
+
: " - " + options.crown_angle_to + "°";
|
|
793
|
+
}
|
|
794
|
+
if (crownTitle) title_parts.push(crownTitle);
|
|
795
|
+
|
|
796
|
+
let pavilionTitle = "";
|
|
797
|
+
let pavilionTitleLabel = "Pavilion";
|
|
798
|
+
// Pavilion Depth
|
|
799
|
+
if (
|
|
800
|
+
search_params?.pavilion_percent_from &&
|
|
801
|
+
search_params?.pavilion_percent_from > 0
|
|
802
|
+
) {
|
|
803
|
+
options.pavilion_percent_from = search_params?.pavilion_percent_from;
|
|
804
|
+
pavilionTitle +=
|
|
805
|
+
pavilionTitleLabel + ": " + options.pavilion_percent_from + "%";
|
|
806
|
+
}
|
|
807
|
+
if (
|
|
808
|
+
search_params?.pavilion_percent_to &&
|
|
809
|
+
search_params?.pavilion_percent_to > 0
|
|
810
|
+
) {
|
|
811
|
+
options.pavilion_percent_to = search_params?.pavilion_percent_to;
|
|
812
|
+
pavilionTitle +=
|
|
813
|
+
pavilionTitle === ""
|
|
814
|
+
? pavilionTitleLabel + ": 0% - " + options.pavilion_percent_to + "%"
|
|
815
|
+
: " - " + options.pavilion_percent_to + "%";
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// Pavilion Angle
|
|
819
|
+
if (
|
|
820
|
+
search_params?.pavilion_angle_from &&
|
|
821
|
+
search_params?.pavilion_angle_from > 0
|
|
822
|
+
) {
|
|
823
|
+
options.pavilion_angle_from = search_params?.pavilion_angle_from;
|
|
824
|
+
pavilionTitle +=
|
|
825
|
+
pavilionTitle === ""
|
|
826
|
+
? pavilionTitleLabel + ": " + options.pavilion_angle_from + "°"
|
|
827
|
+
: ", " + options.pavilion_angle_from + "°";
|
|
828
|
+
}
|
|
829
|
+
if (
|
|
830
|
+
search_params?.pavilion_angle_to &&
|
|
831
|
+
search_params?.pavilion_angle_to > 0
|
|
832
|
+
) {
|
|
833
|
+
options.pavilion_angle_to = search_params?.pavilion_angle_to;
|
|
834
|
+
pavilionTitle +=
|
|
835
|
+
pavilionTitle === ""
|
|
836
|
+
? "0° - " + options.pavilion_angle_to + "°"
|
|
837
|
+
: search_params?.pavilion_angle_from === undefined
|
|
838
|
+
? ", 0° - " + options.pavilion_angle_to + "°"
|
|
839
|
+
: " - " + options.pavilion_angle_to + "°";
|
|
840
|
+
}
|
|
841
|
+
if (pavilionTitle) title_parts.push(pavilionTitle);
|
|
842
|
+
|
|
843
|
+
return { title: title_parts.filter(Boolean).join(" | "), options: options };
|
|
844
|
+
};
|