@star-insure/sdk 6.0.7 → 6.0.8
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/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@star-insure/sdk",
|
|
3
3
|
"description": "The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.",
|
|
4
4
|
"author": "alexclark_nz",
|
|
5
|
-
"version": "6.0.
|
|
5
|
+
"version": "6.0.8",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -20,24 +20,38 @@ export function FilterItem({ filter }: { filter: FilterOption, path?: string })
|
|
|
20
20
|
if (typeof window !== 'undefined') {
|
|
21
21
|
const search = new URLSearchParams(window.location.search);
|
|
22
22
|
|
|
23
|
+
// Strip all index keys from the square brackets
|
|
24
|
+
const filtersFromUrl = [];
|
|
25
|
+
for (const [key, value] of search.entries()) {
|
|
26
|
+
const updatedKey = key.replaceAll(/\[\d+\]/g, '[]');
|
|
27
|
+
filtersFromUrl.push([updatedKey, value]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Conditional logic dependent on the filter type
|
|
23
31
|
if (filter.type === 'date') {
|
|
24
|
-
const fromDate =
|
|
25
|
-
const toDate =
|
|
32
|
+
const fromDate = filtersFromUrl.find(([key]) => key === `${filter.name}[from]`)?.[1];
|
|
33
|
+
const toDate = filtersFromUrl.find(([key]) => key === `${filter.name}[to]`)?.[1];
|
|
26
34
|
if (fromDate && toDate) {
|
|
27
35
|
setSelected([fromDate, toDate]);
|
|
28
36
|
}
|
|
29
37
|
} else if (filter.type === 'greaterThan') {
|
|
30
|
-
const selectedFromUrl =
|
|
38
|
+
const selectedFromUrl = filtersFromUrl
|
|
39
|
+
.filter(([key]) => key === `${filter.name}-GTE`)
|
|
40
|
+
.map(([_, value]) => value);
|
|
31
41
|
if (selectedFromUrl.length > 0) {
|
|
32
42
|
setSelected(selectedFromUrl);
|
|
33
43
|
}
|
|
34
44
|
} else if (filter.type === 'scope') {
|
|
35
|
-
const selectedFromUrl =
|
|
45
|
+
const selectedFromUrl = filtersFromUrl
|
|
46
|
+
.filter(([key]) => key === `scope${filter.name}`)
|
|
47
|
+
.map(([_, value]) => value);
|
|
36
48
|
if (selectedFromUrl.length > 0) {
|
|
37
49
|
setSelected(selectedFromUrl);
|
|
38
50
|
}
|
|
39
51
|
} else if (filter.type === 'select') {
|
|
40
|
-
const selectedFromUrl =
|
|
52
|
+
const selectedFromUrl = filtersFromUrl
|
|
53
|
+
.filter(([key]) => key === `${filter.name}[]`)
|
|
54
|
+
.map(([_, value]) => value);
|
|
41
55
|
if (selectedFromUrl.length > 0) {
|
|
42
56
|
setSelected(selectedFromUrl);
|
|
43
57
|
const selectedOptions = filter.options && filter.options.filter(item =>
|
|
@@ -49,7 +63,9 @@ export function FilterItem({ filter }: { filter: FilterOption, path?: string })
|
|
|
49
63
|
}
|
|
50
64
|
} else {
|
|
51
65
|
// Default case for 'options' type and others
|
|
52
|
-
const selectedFromUrl =
|
|
66
|
+
const selectedFromUrl = filtersFromUrl
|
|
67
|
+
.filter(([key]) => key === `${filter.name}[]`)
|
|
68
|
+
.map(([_, value]) => value);
|
|
53
69
|
if (selectedFromUrl.length > 0) {
|
|
54
70
|
setSelected(selectedFromUrl);
|
|
55
71
|
}
|