@star-insure/sdk 4.4.0 → 4.6.0

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.
@@ -9,7 +9,7 @@ export interface FilterOption {
9
9
  label: string;
10
10
  name: string;
11
11
  options?: FilterValue[];
12
- type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column' | 'text';
12
+ type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column' | 'text' | 'range';
13
13
  }
14
14
  export interface FilterValue {
15
15
  label: string;
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": "4.4.0",
5
+ "version": "4.6.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/src/lib/dates.ts CHANGED
@@ -109,3 +109,23 @@ export function formatDateTime(dateTime: Date|string|null|undefined, overrideFor
109
109
 
110
110
  return '';
111
111
  }
112
+
113
+ /**
114
+ * Attempts to create a date object from a date string
115
+ */
116
+ export function createDate(dateString: Date | string | null | undefined): Date | null {
117
+ // Re-use our logic from formatDateTime
118
+ const formattedDateTime = formatDateTime(dateString);
119
+
120
+ if (!formattedDateTime) {
121
+ return null;
122
+ }
123
+
124
+ // Attempt to parse the formatted date to a date object
125
+ try {
126
+ return parse(formattedDateTime, 'dd/MM/yyyy HH:mm', new Date());
127
+ } catch (error) {
128
+ console.error(`Error parsing date: ${dateString?.toString()}`);
129
+ return null;
130
+ }
131
+ }
@@ -11,7 +11,7 @@ export interface FilterOption {
11
11
  label: string;
12
12
  name: string;
13
13
  options?: FilterValue[];
14
- type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column' | 'text';
14
+ type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column' | 'text' | 'range';
15
15
  }
16
16
 
17
17
  export interface FilterValue {