@jsb188/mday 1.1.4 → 1.1.6

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.
@@ -0,0 +1,44 @@
1
+ import type { ChildOrgsFilterArgs, OrganizationOperationEnum } from '../types/organization.d';
2
+
3
+ /**
4
+ * Create a filter object for productsList() query from the URL search query.
5
+ * @param operationType - The organization operation type
6
+ * @param searchQuery - The search query string from the URL
7
+ * @param otherFiltersObj - Additional filter properties to merge into the result
8
+ * @returns ProductsFilterArgs - The filter object to be used in the productsList() query
9
+ */
10
+
11
+ export function getChildOrgsFilterFromURL(
12
+ _operationType: OrganizationOperationEnum | null,
13
+ searchQuery: string,
14
+ otherFiltersObj?: {
15
+ withoutPreset?: Partial<ChildOrgsFilterArgs>;
16
+ withPreset?: Partial<ChildOrgsFilterArgs>;
17
+ }
18
+ ) {
19
+ if (!searchQuery && otherFiltersObj?.withPreset) {
20
+ return otherFiltersObj.withPreset;
21
+ } else if (searchQuery === '?preset=none' && otherFiltersObj?.withoutPreset) {
22
+ return otherFiltersObj.withoutPreset;
23
+ }
24
+
25
+ const urlParams = new URLSearchParams(searchQuery);
26
+
27
+ // let startDate = urlParams.get('sd');
28
+ // let endDate = urlParams.get('ed');
29
+ // if (startDate && !endDate) {
30
+ // endDate = startDate;
31
+ // } else if (endDate && !startDate) {
32
+ // startDate = endDate;
33
+ // }
34
+
35
+ const filter: ChildOrgsFilterArgs = {
36
+ // startDate,
37
+ // endDate,
38
+ // timeZone: indexToTimeZone(urlParams.get('z')),
39
+ // query: urlParams.get('q') || '',
40
+ ...otherFiltersObj?.withoutPreset,
41
+ };
42
+
43
+ return filter;
44
+ }