Skip to content

Commit

Permalink
Fix TS issues, date-fns 2
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhand committed Dec 16, 2024
1 parent 8cffc60 commit ee0c6b9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
9 changes: 6 additions & 3 deletions functions/hrm/prepopulateForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ const mapGenericOption = (options: string[]) => (value: string) => {
const getUnknownOption = (key: string, definition: FormItemDefinition[]) => {
const inputDef = definition.find((e) => e.name === key);

if (inputDef && inputDef.type === 'select') {
// inputDef.options check needed whilst we use an el cheapo copy of the type, once we share the flex type it won't be needed
if (inputDef?.type === 'select' && inputDef.options) {
const unknownOption = inputDef.unknownOption
? inputDef.options.find((e) => e.value === inputDef.unknownOption)
: inputDef.options.find((e) => e.value === 'Unknown');
Expand All @@ -221,8 +222,10 @@ const getUnknownOption = (key: string, definition: FormItemDefinition[]) => {
*/
const getSelectOptions = (key: string) => (definition: FormItemDefinition[]) => {
const inputDef = definition.find((e) => e.name === key);

if (inputDef?.type === 'select') return inputDef.options.map((e) => e.value) || [];
// inputDef.options check needed whilst we use an el cheapo copy of the type, once we share the flex type it won't be needed
if (inputDef?.type === 'select' && inputDef.options) {
return inputDef.options.map((e) => e.value) || [];
}

console.error(`getSelectOptions called with key ${key} but is a non-select input type.`);
return [];
Expand Down
56 changes: 47 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@twilio/runtime-handler": "1.2.4",
"aws-sdk": "2.1366.0",
"axios": "0.28.0",
"date-fns": "^3.6.0",
"date-fns": "^2.30.0",
"form-data": "^4.0.0",
"lodash": "4.17.21",
"moment-timezone": "0.5.37",
Expand Down

0 comments on commit ee0c6b9

Please sign in to comment.