diff --git a/public/client.js b/public/client.js index 27a8e78..599edf2 100644 --- a/public/client.js +++ b/public/client.js @@ -35,6 +35,10 @@ widget.searchParams.append("clinician", options.clinician); widget.searchParams.append("patient", options.patient); + if (options.environment) { + widget.searchParams.append("environment", options.environment); + } + if (options.drug) { widget.searchParams.append("drug", options.drug); } diff --git a/src/lib/api/api.ts b/src/lib/api/api.ts index 84151f7..c6efa02 100644 --- a/src/lib/api/api.ts +++ b/src/lib/api/api.ts @@ -6,7 +6,18 @@ export type Drug = components['schemas']['Drug']; export type Pharmacy = components['schemas']['PharmacyDetails']; export type Dosage = components['schemas']['Dosage']; -const fetcher = createClient({ baseUrl: "https://services.careconnect.dev.wellsync.io" }); +const params = new URLSearchParams(window.location.search); + +const environments = { + dev: 'https://services.careconnect.dev.wellsync.io', + stg: 'https://services.careconnect.stg.wellsync.io', + prd: 'https://services.careconnect.prd.wellsync.io', +}; + +const param = (params.get("environment") as 'dev' | 'stg' | 'prd') || "prd"; +const environment = environments[param] || environments.prd; + +const fetcher = createClient({ baseUrl: environment }); fetcher.use({ onRequest: async ({ request }) => {