cronofy-elements
Advanced tools
Comparing version 1.48.1 to 1.48.2
{ | ||
"name": "cronofy-elements", | ||
"version": "1.48.1", | ||
"version": "1.48.2", | ||
"description": "Fast track scheduling with Cronofy's embeddable UI Elements", | ||
@@ -5,0 +5,0 @@ "main": "build/npm/CronofyElements.js", |
@@ -45,1 +45,18 @@ import moment from "moment-timezone"; | ||
}; | ||
export const addTzidToTzList = (tzList, tzid) => { | ||
const isValidTimeZone = !!moment.tz.zone(tzid); | ||
if (isValidTimeZone) { | ||
const newTzList = [...tzList]; | ||
const item = createTzObject(tzid); | ||
newTzList.push(item); | ||
newTzList.sort((tzA, tzB) => tzA.offsetMins - tzB.offsetMins); | ||
return { | ||
tzList: newTzList, | ||
selectedTzid: item, | ||
}; | ||
} else { | ||
throw `There was an error setting the selected tzid as ${tzid}.`; | ||
} | ||
}; |
@@ -17,3 +17,3 @@ import React, { useState, useEffect } from "react"; | ||
} from "../../helpers/utils.AvailabilityRules"; | ||
import { getInitialSelectedTzid } from "./utils/tz-utils"; | ||
import { getInitialSelectedTzid, addTzidToTzList } from "./utils/tz-utils"; | ||
import { parseStyleOptions, classBuilder } from "../../helpers/theming"; | ||
@@ -202,6 +202,15 @@ import { globals } from "../../styles/utils"; | ||
); | ||
setTz({ | ||
list: tz.list, | ||
selectedTzid: selectedTzid, | ||
}); | ||
if (selectedTzid) { | ||
setTz({ | ||
list: tz.list, | ||
selectedTzid: selectedTzid, | ||
}); | ||
} else { | ||
//If we get here the tzid from the availbility rule is not in the tz.list so we need to add it. | ||
const result = addTzidToTzList(tz.list, rulesResponse.availability_rule.tzid); | ||
setTz({ | ||
list: result.tzList, | ||
selectedTzid: result.selectedTzid, | ||
}); | ||
} | ||
@@ -208,0 +217,0 @@ setSlots(slots => { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3347792
28015