cronofy-elements
Advanced tools
Comparing version 1.12.0 to 1.12.1
@@ -11,5 +11,16 @@ require("@babel/polyfill"); | ||
const env = require("../src/js/env"); | ||
const apiDomain = env.API_DOMAIN || "https://api.cronofy.com"; | ||
let apiDomain = "https://api.cronofy.com"; | ||
let rawApiDomain = apiDomain; | ||
const appDomain = env.APP_DOMAIN || "https://app.cronofy.com"; | ||
if (env.API_DOMAIN) { | ||
// The the "domain" starts with a protocol, we can assume it is | ||
// a full path. Otherwise assume it is a pure domain, so add our | ||
// protocol (everyone should be using HTTPS) | ||
apiDomain = env.API_DOMAIN.startsWith("http") | ||
? env.API_DOMAIN | ||
: `https://${env.API_DOMAIN}`; | ||
rawApiDomain = env.API_DOMAIN; | ||
} | ||
console.log("Firing up server..."); | ||
@@ -153,3 +164,3 @@ | ||
// agenda_token: agenda_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -168,3 +179,3 @@ sub: env.SUB, | ||
availability_token: availability_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -180,3 +191,3 @@ sub: env.SUB, | ||
rules_token: rules_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -192,3 +203,3 @@ sub: env.SUB, | ||
agenda_token: agenda_token.element_token.token, | ||
api_domain: apiDomain | ||
api_domain: rawApiDomain | ||
}); | ||
@@ -212,3 +223,3 @@ }); | ||
cal_sync_token: cal_sync_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -235,3 +246,3 @@ sub: env.SUB, | ||
cal_sync_token: cal_sync_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -247,3 +258,3 @@ sub: env.SUB, | ||
slot_picker_token: slot_picker_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -259,3 +270,3 @@ sub: env.SUB, | ||
cal_sync_token: cal_sync_token.element_token.token, | ||
api_domain: apiDomain, | ||
api_domain: rawApiDomain, | ||
app_domain: appDomain, | ||
@@ -262,0 +273,0 @@ sub: env.SUB, |
{ | ||
"name": "cronofy-elements", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"description": "Fast track scheduling with Cronofy's embeddable UI Elements", | ||
@@ -5,0 +5,0 @@ "main": "build/npm/CronofyElements.js", |
@@ -113,3 +113,3 @@ import React, { useState, useEffect } from "react"; | ||
const rulesResponse = isNewRule | ||
? buildRuleTemplate(options) | ||
? buildRuleTemplate(options.tzid) | ||
: res[0]; | ||
@@ -116,0 +116,0 @@ |
@@ -0,1 +1,3 @@ | ||
import moment from "moment-timezone"; | ||
import { | ||
@@ -68,7 +70,4 @@ parseToken, | ||
if (typeof options.tzid === "undefined") { | ||
options.error = true; | ||
log.error( | ||
"You need to include a `tzid`. Full details can be found on the Cronofy Elements documention page: https://docs.cronofy.com/developers/ui-elements/availability-rules/#tzid" | ||
); | ||
return false; | ||
const sniffedTimezone = moment.tz.guess(); | ||
options.tzid = sniffedTimezone; | ||
} | ||
@@ -75,0 +74,0 @@ |
@@ -11,4 +11,15 @@ import merge from "deepmerge"; | ||
dataCenter && dataCenter !== "us" ? `-${dataCenter}` : ""; | ||
let apiDomain = | ||
customApiDomain || `https://api${dataCenterSuffix}.cronofy.com`; | ||
let apiDomain; | ||
if (customApiDomain) { | ||
// If the "domain" starts with a protocol, we can assume it is | ||
// a full path. Otherwise assume it is *actually* a domain, so add our | ||
// protocol (everyone should be using HTTPS) | ||
apiDomain = customApiDomain.startsWith("http") | ||
? customApiDomain | ||
: `https://${customApiDomain}`; | ||
} else { | ||
apiDomain = `https://api${dataCenterSuffix}.cronofy.com`; | ||
} | ||
let appDomain = | ||
@@ -15,0 +26,0 @@ customAppDomain || `https://app${dataCenterSuffix}.cronofy.com`; |
@@ -1,2 +0,1 @@ | ||
import * as connections from "./connections"; | ||
import moment from "moment-timezone"; | ||
@@ -79,3 +78,3 @@ import { default_availability_rules } from "./mocks"; | ||
const tzid = options.tzid ? options.tzid : "Etc/UTC"; | ||
const tzid = options.tzid ? options.tzid : moment.tz.guess(); | ||
const slotHeight = { | ||
@@ -111,12 +110,9 @@ height: heightsDictionary[duration] //(16 * 4) / (duration / interval) | ||
export const buildRuleTemplate = (options = {}) => { | ||
const tzid = options.tzid || "Etc/UTC"; | ||
return { | ||
availability_rule: { | ||
availability_rule_id: "default", | ||
tzid, | ||
calendar_ids: [], | ||
weekly_periods: default_availability_rules | ||
} | ||
}; | ||
}; | ||
export const buildRuleTemplate = tzid => ({ | ||
availability_rule: { | ||
availability_rule_id: "default", | ||
tzid: tzid || moment.tz.guess(), | ||
calendar_ids: [], | ||
weekly_periods: default_availability_rules | ||
} | ||
}); |
@@ -64,3 +64,3 @@ import * as utils from "../src/js/helpers/utils.AvailabilityRules"; | ||
start: "09:00", | ||
tzid: "Etc/UTC", | ||
tzid: moment.tz.guess(), | ||
slotsPerDay: 8 | ||
@@ -122,5 +122,3 @@ }, | ||
it("builds a rules template", () => { | ||
const input = { | ||
tzid: "TEST_TIMEZONE" | ||
}; | ||
const tzid = "TEST_TIMEZONE"; | ||
const expectedOutput = { | ||
@@ -160,7 +158,7 @@ availability_rule: { | ||
}; | ||
expect(utils.buildRuleTemplate(input)).toEqual(expectedOutput); | ||
expect(utils.buildRuleTemplate(tzid)).toEqual(expectedOutput); | ||
}); | ||
// buildRuleTemplate | ||
it("builds a rules template when no options are provided", () => { | ||
it("builds a rules template when no tzid is provided", () => { | ||
const expectedOutput = { | ||
@@ -170,3 +168,3 @@ availability_rule: { | ||
calendar_ids: [], | ||
tzid: "Etc/UTC", | ||
tzid: moment.tz.guess(), | ||
weekly_periods: [ | ||
@@ -202,4 +200,3 @@ { | ||
expect(utils.buildRuleTemplate()).toEqual(expectedOutput); | ||
expect(utils.buildRuleTemplate({})).toEqual(expectedOutput); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
2470153
21746