@apextelemed/partner-core 0.9.0 → 0.10.0-dev.21
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.
- package/README.md +26 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/index.jsx +5 -3
- package/dist/chunk/{AJR7CBZ3.js → 4CTTOSOW.js} +3 -3
- package/dist/chunk/{AJR7CBZ3.js.map → 4CTTOSOW.js.map} +1 -1
- package/dist/chunk/{VKSLQCMA.jsx → 75F4YFYC.jsx} +725 -5
- package/dist/chunk/{NTYUIUQO.jsx → BALHOD46.jsx} +74 -2
- package/dist/chunk/{MCSS436N.js → CYGHTTCA.js} +2495 -1132
- package/dist/chunk/CYGHTTCA.js.map +1 -0
- package/dist/chunk/{MUEGVUP2.jsx → DBW2RWHV.jsx} +2 -2
- package/dist/chunk/{Y2VD7NYA.js → DHVOZQQ2.js} +3 -3
- package/dist/chunk/{Y2VD7NYA.js.map → DHVOZQQ2.js.map} +1 -1
- package/dist/chunk/{C7RXQWXM.jsx → ET3GPUTR.jsx} +5 -5
- package/dist/chunk/{65LD7XAZ.js → JL7B6RHG.js} +3 -3
- package/dist/chunk/{65LD7XAZ.js.map → JL7B6RHG.js.map} +1 -1
- package/dist/chunk/{35C2PAUI.js → L2ZMGXWR.js} +699 -6
- package/dist/chunk/L2ZMGXWR.js.map +1 -0
- package/dist/chunk/{75B7QHIN.js → NSEWFPUP.js} +75 -4
- package/dist/chunk/NSEWFPUP.js.map +1 -0
- package/dist/chunk/{IYLVDYRI.jsx → OA3A3PUC.jsx} +2028 -926
- package/dist/chunk/{DEDIHIWD.jsx → QIBVNW2V.jsx} +2 -2
- package/dist/chunk/{JOX6EJMB.js → TYXWVNC3.js} +6 -6
- package/dist/chunk/{JOX6EJMB.js.map → TYXWVNC3.js.map} +1 -1
- package/dist/chunk/{33QXG46Z.jsx → ZW2HBOS5.jsx} +2 -2
- package/dist/{client-RY9ghN5Q.d.ts → client-CDpCqI4d.d.ts} +184 -2
- package/dist/flows/index.d.ts +333 -2
- package/dist/flows/index.js +6 -6
- package/dist/flows/index.jsx +46 -6
- package/dist/index/index.d.ts +2 -2
- package/dist/index/index.js +7 -7
- package/dist/index/index.jsx +49 -7
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +5 -5
- package/dist/pages/index.jsx +5 -5
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.js +2 -2
- package/dist/stores/index.jsx +2 -2
- package/dist/theme/admin.css +161 -1
- package/package.json +1 -1
- package/dist/chunk/35C2PAUI.js.map +0 -1
- package/dist/chunk/75B7QHIN.js.map +0 -1
- package/dist/chunk/MCSS436N.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './
|
|
2
|
-
import { cart_default, medication_default, auth_default, affiliateAuth_default } from './
|
|
3
|
-
import { newIdempotencyKey, apexApi, usersApi, addressesApi, catalogApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, ApiError, ordersApi, messagesApi, authApi } from './
|
|
1
|
+
import { fetchFunnelConfig, postFunnelEvent, readResumeToken, fetchResumedDraft, stripResumeToken, adoptFunnelSessionId, saveFunnelDraft } from './JL7B6RHG.js';
|
|
2
|
+
import { cart_default, medication_default, auth_default, affiliateAuth_default } from './DHVOZQQ2.js';
|
|
3
|
+
import { newIdempotencyKey, apexApi, usersApi, addressesApi, catalogApi, paymentsApi, subscriptionsApi, membersApi, supportApi, productsApi, affiliatePortalApi, adminApi, adminCatalogApi, ApiError, ordersApi, messagesApi, authApi } from './NSEWFPUP.js';
|
|
4
4
|
import { getConfig } from './5XGPFYIJ.js';
|
|
5
5
|
import { createSignal, onMount, createEffect, on, onCleanup, createResource, createMemo } from 'solid-js';
|
|
6
6
|
import { useSurveyV2Flow as useSurveyV2Flow$1 } from '@apextelemed/survey-solid';
|
|
@@ -4471,7 +4471,700 @@ async function uploadPrescriptionPhoto(file) {
|
|
|
4471
4471
|
}
|
|
4472
4472
|
return { photoId: parsed.photoId };
|
|
4473
4473
|
}
|
|
4474
|
+
var messageOf = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
|
|
4475
|
+
function classifyCatalogError(err) {
|
|
4476
|
+
const e = err ?? {};
|
|
4477
|
+
const status = typeof e.status === "number" ? e.status : void 0;
|
|
4478
|
+
const code = typeof e.code === "string" ? e.code : void 0;
|
|
4479
|
+
const message = messageOf(err, "Something went wrong talking to the prescribing platform.");
|
|
4480
|
+
if (code === "apex_credentials_rejected" || code === "apex_not_configured") {
|
|
4481
|
+
return { kind: "blocked", code, message, definitive: true };
|
|
4482
|
+
}
|
|
4483
|
+
if (code === "apex_unavailable") {
|
|
4484
|
+
return { kind: "blocked", code, message, definitive: false };
|
|
4485
|
+
}
|
|
4486
|
+
if (e.ambiguous === true || status !== void 0 && status >= 500) {
|
|
4487
|
+
return { kind: "ambiguous", message };
|
|
4488
|
+
}
|
|
4489
|
+
if (status !== void 0 && status >= 400) return { kind: "rejected", message, status };
|
|
4490
|
+
return { kind: "ambiguous", message };
|
|
4491
|
+
}
|
|
4492
|
+
function findStoredDosePrice(stored, doseId, label) {
|
|
4493
|
+
if (doseId) {
|
|
4494
|
+
const bound = stored.find((e) => e.apexSkuId === doseId);
|
|
4495
|
+
if (bound) return bound;
|
|
4496
|
+
}
|
|
4497
|
+
return stored.find((e) => !e.apexSkuId && e.dosage === label);
|
|
4498
|
+
}
|
|
4499
|
+
var rowKeyFor = (doseId, label) => doseId ?? `label:${label}`;
|
|
4500
|
+
function buildStrengthRows(product, readiness) {
|
|
4501
|
+
const stored = product.dosagePrices ?? [];
|
|
4502
|
+
const priceOf = (doseId, label) => findStoredDosePrice(stored, doseId, label)?.price ?? null;
|
|
4503
|
+
if (readiness) {
|
|
4504
|
+
const doses = [...readiness.doses].sort(
|
|
4505
|
+
(a, b) => a.displayOrder - b.displayOrder || a.label.localeCompare(b.label)
|
|
4506
|
+
);
|
|
4507
|
+
const rows = doses.map((d) => ({
|
|
4508
|
+
key: rowKeyFor(d.id, d.label),
|
|
4509
|
+
doseId: d.id,
|
|
4510
|
+
label: d.label,
|
|
4511
|
+
value: d.value ?? null,
|
|
4512
|
+
unit: d.unit ?? null,
|
|
4513
|
+
active: d.active,
|
|
4514
|
+
ownPrice: priceOf(d.id, d.label)
|
|
4515
|
+
}));
|
|
4516
|
+
for (const s of product.strengths ?? []) {
|
|
4517
|
+
if (s.apexSkuId && !doses.some((d) => d.id === s.apexSkuId)) {
|
|
4518
|
+
rows.push({
|
|
4519
|
+
key: rowKeyFor(s.apexSkuId, s.dosage),
|
|
4520
|
+
doseId: s.apexSkuId,
|
|
4521
|
+
label: s.dosage,
|
|
4522
|
+
value: null,
|
|
4523
|
+
unit: null,
|
|
4524
|
+
active: true,
|
|
4525
|
+
ownPrice: priceOf(s.apexSkuId, s.dosage)
|
|
4526
|
+
});
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
return rows;
|
|
4530
|
+
}
|
|
4531
|
+
if ((product.strengths ?? []).length > 0) {
|
|
4532
|
+
return product.strengths.map((s) => ({
|
|
4533
|
+
key: rowKeyFor(s.apexSkuId, s.dosage),
|
|
4534
|
+
doseId: s.apexSkuId,
|
|
4535
|
+
label: s.dosage,
|
|
4536
|
+
value: null,
|
|
4537
|
+
unit: null,
|
|
4538
|
+
active: true,
|
|
4539
|
+
ownPrice: priceOf(s.apexSkuId, s.dosage)
|
|
4540
|
+
}));
|
|
4541
|
+
}
|
|
4542
|
+
const orphaned = product.orphanedDosePrices ?? [];
|
|
4543
|
+
return stored.filter((e) => !orphaned.some((o) => sameStoredEntry(e, o))).map((e) => ({
|
|
4544
|
+
key: rowKeyFor(e.apexSkuId ?? null, e.dosage),
|
|
4545
|
+
doseId: e.apexSkuId ?? null,
|
|
4546
|
+
label: e.dosage,
|
|
4547
|
+
value: null,
|
|
4548
|
+
unit: null,
|
|
4549
|
+
active: true,
|
|
4550
|
+
ownPrice: e.price ?? null
|
|
4551
|
+
}));
|
|
4552
|
+
}
|
|
4553
|
+
function parsePrice(raw) {
|
|
4554
|
+
const t = raw.trim();
|
|
4555
|
+
if (t === "") return null;
|
|
4556
|
+
const n = Number(t);
|
|
4557
|
+
return Number.isFinite(n) && n >= 0 ? n : "invalid";
|
|
4558
|
+
}
|
|
4559
|
+
function resolveStrengthPrices(rows, drafts, base, flatFee) {
|
|
4560
|
+
return rows.map((row) => {
|
|
4561
|
+
if (!row.active) return { row, price: null, source: null, needsPrice: false };
|
|
4562
|
+
let own = row.ownPrice;
|
|
4563
|
+
if (row.key in drafts) {
|
|
4564
|
+
const parsed = parsePrice(drafts[row.key]);
|
|
4565
|
+
own = parsed === "invalid" ? row.ownPrice : parsed;
|
|
4566
|
+
}
|
|
4567
|
+
if (!flatFee && own != null) return { row, price: own, source: "dose", needsPrice: false };
|
|
4568
|
+
if (base != null) return { row, price: base, source: "base", needsPrice: false };
|
|
4569
|
+
return { row, price: null, source: null, needsPrice: true };
|
|
4570
|
+
});
|
|
4571
|
+
}
|
|
4572
|
+
function invalidDraftKeys(drafts) {
|
|
4573
|
+
return Object.entries(drafts).filter(([, v]) => parsePrice(v) === "invalid").map(([k]) => k);
|
|
4574
|
+
}
|
|
4575
|
+
function applyPriceDrafts(stored, rows, drafts) {
|
|
4576
|
+
let next = [...stored];
|
|
4577
|
+
let changed = false;
|
|
4578
|
+
for (const row of rows) {
|
|
4579
|
+
if (!(row.key in drafts) || !row.active) continue;
|
|
4580
|
+
const price = parsePrice(drafts[row.key]);
|
|
4581
|
+
if (price === "invalid") continue;
|
|
4582
|
+
const at2 = next.findIndex((e) => e === findStoredDosePrice(next, row.doseId, row.label));
|
|
4583
|
+
if (at2 >= 0) {
|
|
4584
|
+
const entry = next[at2];
|
|
4585
|
+
const boundId = entry.apexSkuId ?? row.doseId ?? null;
|
|
4586
|
+
if ((entry.price ?? null) === price && (entry.apexSkuId ?? null) === boundId) continue;
|
|
4587
|
+
next[at2] = { ...entry, price, apexSkuId: boundId };
|
|
4588
|
+
changed = true;
|
|
4589
|
+
} else if (price != null) {
|
|
4590
|
+
next = [...next, { dosage: row.label, price, savingsPrice: null, apexSkuId: row.doseId }];
|
|
4591
|
+
changed = true;
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
return changed ? next : null;
|
|
4595
|
+
}
|
|
4596
|
+
function upsertDosePrice(stored, dose) {
|
|
4597
|
+
const at2 = stored.findIndex((e) => e === findStoredDosePrice(stored, dose.apexSkuId, dose.dosage));
|
|
4598
|
+
if (at2 < 0) {
|
|
4599
|
+
return [...stored, { dosage: dose.dosage, price: dose.price, savingsPrice: null, apexSkuId: dose.apexSkuId }];
|
|
4600
|
+
}
|
|
4601
|
+
return stored.map((e, i) => i === at2 ? { ...e, price: dose.price, apexSkuId: dose.apexSkuId } : e);
|
|
4602
|
+
}
|
|
4603
|
+
var sameStoredEntry = (entry, orphan) => (entry.apexSkuId ?? null) === (orphan.apexSkuId ?? null) && entry.dosage === orphan.dosage;
|
|
4604
|
+
function removeStoredDosePrice(stored, orphan) {
|
|
4605
|
+
const at2 = stored.findIndex((e) => sameStoredEntry(e, orphan));
|
|
4606
|
+
return at2 < 0 ? [...stored] : stored.filter((_, i) => i !== at2);
|
|
4607
|
+
}
|
|
4608
|
+
var orphanKey = (o) => `${o.apexSkuId ?? ""}|${o.dosage}`;
|
|
4609
|
+
function isCatalogItemId(id) {
|
|
4610
|
+
return typeof id === "string" && id.startsWith("cat_");
|
|
4611
|
+
}
|
|
4612
|
+
function skuBindingModeFor(dosagePrices, current) {
|
|
4613
|
+
if (current === "prescriber_picks") return current;
|
|
4614
|
+
return dosagePrices.some((e) => e.apexSkuId) ? "bound" : current ?? null;
|
|
4615
|
+
}
|
|
4616
|
+
var ORPHAN_REASON = {
|
|
4617
|
+
dose_not_listed: "The prescribing platform no longer lists this strength.",
|
|
4618
|
+
dose_inactive: "This strength has been withdrawn.",
|
|
4619
|
+
item_not_listed: "The prescribing platform no longer lists this product's catalog item."
|
|
4620
|
+
};
|
|
4621
|
+
function pharmacyNameOf(pharmacyId, drugs) {
|
|
4622
|
+
return drugs.find((d) => d.pharmacyId === pharmacyId && d.pharmacyName)?.pharmacyName ?? pharmacyId;
|
|
4623
|
+
}
|
|
4624
|
+
var byRank = (a, b) => a.preferenceRank - b.preferenceRank || a.pharmacyId.localeCompare(b.pharmacyId);
|
|
4625
|
+
function buildFulfillmentRows(readiness, drugs) {
|
|
4626
|
+
if (!readiness) return [];
|
|
4627
|
+
return [...readiness.fulfillments].sort(byRank).map((f, i) => ({
|
|
4628
|
+
id: f.id,
|
|
4629
|
+
rank: i + 1,
|
|
4630
|
+
pharmacyId: f.pharmacyId,
|
|
4631
|
+
pharmacyName: pharmacyNameOf(f.pharmacyId, drugs),
|
|
4632
|
+
drugId: f.drugId,
|
|
4633
|
+
drugName: drugs.find((d) => d.id === f.drugId)?.name ?? f.drugId,
|
|
4634
|
+
enabled: f.enabled,
|
|
4635
|
+
excludedStates: [...f.excludedStates ?? []],
|
|
4636
|
+
problems: readiness.fulfillmentProblems?.[f.id] ?? []
|
|
4637
|
+
}));
|
|
4638
|
+
}
|
|
4639
|
+
function moveInOrder(ids, id, direction) {
|
|
4640
|
+
const at2 = ids.indexOf(id);
|
|
4641
|
+
const to = direction === "up" ? at2 - 1 : at2 + 1;
|
|
4642
|
+
if (at2 < 0 || to < 0 || to >= ids.length) return [...ids];
|
|
4643
|
+
const next = [...ids];
|
|
4644
|
+
[next[at2], next[to]] = [next[to], next[at2]];
|
|
4645
|
+
return next;
|
|
4646
|
+
}
|
|
4647
|
+
function normalizeStates(states) {
|
|
4648
|
+
return [...new Set(states.map((s) => s.trim().toUpperCase()).filter((s) => s.length === 2))].sort();
|
|
4649
|
+
}
|
|
4650
|
+
function readinessStatus(readiness) {
|
|
4651
|
+
const { doses, fulfillments, matrix, fulfillmentProblems } = readiness;
|
|
4652
|
+
if (!fulfillments.some((f) => f.enabled)) return "unfillable";
|
|
4653
|
+
const everyDoseMade = doses.every((d) => fulfillments.some((f) => matrix[d.id]?.[f.id]?.producible));
|
|
4654
|
+
const anyProblem = fulfillments.some((f) => (fulfillmentProblems?.[f.id] ?? []).length > 0);
|
|
4655
|
+
return doses.length > 0 && everyDoseMade && !anyProblem ? "ready" : "incomplete";
|
|
4656
|
+
}
|
|
4657
|
+
var READINESS_LABEL = {
|
|
4658
|
+
ready: "Ready to fill",
|
|
4659
|
+
incomplete: "Incomplete",
|
|
4660
|
+
unfillable: "Cannot be filled"
|
|
4661
|
+
};
|
|
4662
|
+
function buildMatrixView(readiness, columns) {
|
|
4663
|
+
if (!readiness) return { doses: [], columns: [], cells: {}, problems: [] };
|
|
4664
|
+
const doses = [...readiness.doses].sort((a, b) => a.displayOrder - b.displayOrder || a.label.localeCompare(b.label)).map((d) => ({ id: d.id, label: d.label, active: d.active }));
|
|
4665
|
+
const problems = [];
|
|
4666
|
+
for (const col of columns) {
|
|
4667
|
+
for (const dose of doses) {
|
|
4668
|
+
const cell = readiness.matrix?.[dose.id]?.[col.id];
|
|
4669
|
+
if (cell && !cell.producible) {
|
|
4670
|
+
problems.push({
|
|
4671
|
+
pharmacyName: col.pharmacyName,
|
|
4672
|
+
dose: dose.label,
|
|
4673
|
+
sentence: `${col.pharmacyName} can't make ${dose.label}`,
|
|
4674
|
+
detail: cell.detail
|
|
4675
|
+
});
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
}
|
|
4679
|
+
return { doses, columns: [...columns], cells: readiness.matrix ?? {}, problems };
|
|
4680
|
+
}
|
|
4681
|
+
function groupDrugsByPharmacy(drugs, mappedPharmacyIds = /* @__PURE__ */ new Set()) {
|
|
4682
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4683
|
+
for (const d of drugs) {
|
|
4684
|
+
if (!d.pharmacyId || mappedPharmacyIds.has(d.pharmacyId)) continue;
|
|
4685
|
+
const g = groups.get(d.pharmacyId) ?? {
|
|
4686
|
+
pharmacyId: d.pharmacyId,
|
|
4687
|
+
pharmacyName: d.pharmacyName ?? d.pharmacyId,
|
|
4688
|
+
drugs: []
|
|
4689
|
+
};
|
|
4690
|
+
g.drugs.push(d);
|
|
4691
|
+
groups.set(d.pharmacyId, g);
|
|
4692
|
+
}
|
|
4693
|
+
const byName = (a, b) => a.localeCompare(b, void 0, { sensitivity: "base" });
|
|
4694
|
+
return [...groups.values()].map((g) => ({ ...g, drugs: [...g.drugs].sort((a, b) => byName(a.name, b.name)) })).sort((a, b) => byName(a.pharmacyName, b.pharmacyName));
|
|
4695
|
+
}
|
|
4696
|
+
var UNAVAILABLE_MESSAGE = "The prescribing platform is unavailable right now, so strengths and pharmacies cannot be changed.";
|
|
4697
|
+
var UNCONFIRMED_MESSAGE = "We couldn't confirm whether that was saved. Reload before changing anything else here.";
|
|
4698
|
+
function useProductCatalogEditor(opts) {
|
|
4699
|
+
const [product, setProduct] = createSignal(opts.product());
|
|
4700
|
+
const [readiness, setReadiness] = createSignal(null);
|
|
4701
|
+
const [drugs, setDrugs] = createSignal([]);
|
|
4702
|
+
const [load, setLoad] = createSignal({ kind: "loading" });
|
|
4703
|
+
const [busy, setBusy] = createSignal(null);
|
|
4704
|
+
const [errors, setErrors] = createSignal({});
|
|
4705
|
+
const [drafts, setDrafts] = createSignal({});
|
|
4706
|
+
const [doseSuggestions, setDoseSuggestions] = createSignal(null);
|
|
4707
|
+
const [equivalents, setEquivalents] = createSignal(null);
|
|
4708
|
+
let generation = 0;
|
|
4709
|
+
const itemId = () => product().apexDrugId;
|
|
4710
|
+
const setError = (key, message) => setErrors((prev) => ({ ...prev, [key]: message }));
|
|
4711
|
+
const clearError = (key) => setErrors((prev) => {
|
|
4712
|
+
if (!(key in prev)) return prev;
|
|
4713
|
+
const { [key]: _gone, ...rest } = prev;
|
|
4714
|
+
return rest;
|
|
4715
|
+
});
|
|
4716
|
+
const adopt = (p) => {
|
|
4717
|
+
setProduct(p);
|
|
4718
|
+
opts.onProductChanged?.(p);
|
|
4719
|
+
};
|
|
4720
|
+
const reload = async () => {
|
|
4721
|
+
const gen = ++generation;
|
|
4722
|
+
if (opts.enabled && !opts.enabled()) return;
|
|
4723
|
+
const id = product().id;
|
|
4724
|
+
const item = product().apexDrugId;
|
|
4725
|
+
setLoad((prev) => prev.kind === "ready" ? prev : { kind: "loading" });
|
|
4726
|
+
if (!item) {
|
|
4727
|
+
setReadiness(null);
|
|
4728
|
+
setLoad({ kind: "missing" });
|
|
4729
|
+
return;
|
|
4730
|
+
}
|
|
4731
|
+
const [itemRes, drugsRes, productRes] = await Promise.allSettled([
|
|
4732
|
+
adminCatalogApi.getItem(item),
|
|
4733
|
+
adminCatalogApi.listDrugs(),
|
|
4734
|
+
adminApi.getProduct(id)
|
|
4735
|
+
]);
|
|
4736
|
+
if (gen !== generation) return;
|
|
4737
|
+
if (productRes.status === "fulfilled" && productRes.value?.product) {
|
|
4738
|
+
const fresh = productRes.value.product;
|
|
4739
|
+
if (JSON.stringify(fresh) !== JSON.stringify(product())) adopt(fresh);
|
|
4740
|
+
}
|
|
4741
|
+
if (drugsRes.status === "fulfilled") setDrugs(drugsRes.value?.drugs ?? []);
|
|
4742
|
+
if (itemRes.status === "fulfilled") {
|
|
4743
|
+
setReadiness(itemRes.value);
|
|
4744
|
+
setLoad({ kind: "ready" });
|
|
4745
|
+
return;
|
|
4746
|
+
}
|
|
4747
|
+
setReadiness(null);
|
|
4748
|
+
const failure = classifyCatalogError(itemRes.reason);
|
|
4749
|
+
if (failure.kind === "rejected" && failure.status === 404) setLoad({ kind: "missing" });
|
|
4750
|
+
else if (failure.kind === "rejected") setLoad({ kind: "failed", message: failure.message });
|
|
4751
|
+
else setLoad({ kind: "blocked", message: failure.message });
|
|
4752
|
+
};
|
|
4753
|
+
const identity = createMemo(() => `${opts.product().id}|${opts.enabled ? opts.enabled() : true}`);
|
|
4754
|
+
createEffect(
|
|
4755
|
+
on(
|
|
4756
|
+
identity,
|
|
4757
|
+
() => {
|
|
4758
|
+
setProduct(opts.product());
|
|
4759
|
+
setReadiness(null);
|
|
4760
|
+
setDrugs([]);
|
|
4761
|
+
setErrors({});
|
|
4762
|
+
setDrafts({});
|
|
4763
|
+
setDoseSuggestions(null);
|
|
4764
|
+
setEquivalents(null);
|
|
4765
|
+
setBusy(null);
|
|
4766
|
+
setLoad({ kind: "loading" });
|
|
4767
|
+
void reload();
|
|
4768
|
+
}
|
|
4769
|
+
)
|
|
4770
|
+
);
|
|
4771
|
+
const structure = createMemo(() => {
|
|
4772
|
+
const l = load();
|
|
4773
|
+
const status2 = product().apexItemStatus;
|
|
4774
|
+
if (l.kind === "missing" || status2 === "missing") return { kind: "missing" };
|
|
4775
|
+
if (l.kind === "blocked") return { kind: "read_only", message: l.message };
|
|
4776
|
+
if (l.kind === "failed") return { kind: "read_only", message: l.message };
|
|
4777
|
+
if (status2 === "unavailable") return { kind: "read_only", message: UNAVAILABLE_MESSAGE };
|
|
4778
|
+
if (l.kind === "loading") return { kind: "loading" };
|
|
4779
|
+
return { kind: "editable" };
|
|
4780
|
+
});
|
|
4781
|
+
const canWriteStructure = () => structure().kind === "editable" && !!readiness();
|
|
4782
|
+
async function apexWrite(key, write, verify) {
|
|
4783
|
+
if (busy()) return { ok: false, kind: "busy", message: "Another change is still saving." };
|
|
4784
|
+
if (!canWriteStructure()) {
|
|
4785
|
+
return { ok: false, kind: "blocked", message: UNAVAILABLE_MESSAGE };
|
|
4786
|
+
}
|
|
4787
|
+
setBusy(key);
|
|
4788
|
+
clearError(key);
|
|
4789
|
+
try {
|
|
4790
|
+
let value;
|
|
4791
|
+
try {
|
|
4792
|
+
value = await write();
|
|
4793
|
+
} catch (err) {
|
|
4794
|
+
const failure = classifyCatalogError(err);
|
|
4795
|
+
if (failure.kind === "rejected") {
|
|
4796
|
+
setError(key, failure.message);
|
|
4797
|
+
return { ok: false, kind: "rejected", message: failure.message };
|
|
4798
|
+
}
|
|
4799
|
+
if (failure.kind === "blocked" && failure.definitive) {
|
|
4800
|
+
setLoad({ kind: "blocked", message: failure.message });
|
|
4801
|
+
setError(key, failure.message);
|
|
4802
|
+
return { ok: false, kind: "blocked", message: failure.message };
|
|
4803
|
+
}
|
|
4804
|
+
try {
|
|
4805
|
+
const fresh = await adminCatalogApi.getItem(itemId());
|
|
4806
|
+
setReadiness(fresh);
|
|
4807
|
+
const verdict = verify(fresh);
|
|
4808
|
+
if (verdict.done) {
|
|
4809
|
+
await settle();
|
|
4810
|
+
return { ok: true, value: verdict.value };
|
|
4811
|
+
}
|
|
4812
|
+
const message = `That didn't go through, and nothing was changed. ${failure.message}`;
|
|
4813
|
+
setError(key, message);
|
|
4814
|
+
return { ok: false, kind: "not_done", message };
|
|
4815
|
+
} catch {
|
|
4816
|
+
setLoad({ kind: "blocked", message: UNCONFIRMED_MESSAGE });
|
|
4817
|
+
setError(key, UNCONFIRMED_MESSAGE);
|
|
4818
|
+
return { ok: false, kind: "unknown", message: UNCONFIRMED_MESSAGE };
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4821
|
+
await settle();
|
|
4822
|
+
return { ok: true, value };
|
|
4823
|
+
} finally {
|
|
4824
|
+
setBusy(null);
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
const settle = () => reload();
|
|
4828
|
+
async function saveProduct(patch, landed) {
|
|
4829
|
+
try {
|
|
4830
|
+
const res = await adminApi.updateProduct(product().id, patch);
|
|
4831
|
+
adopt(res.product);
|
|
4832
|
+
return { ok: true };
|
|
4833
|
+
} catch (err) {
|
|
4834
|
+
const failure = classifyCatalogError(err);
|
|
4835
|
+
if (failure.kind === "ambiguous") {
|
|
4836
|
+
try {
|
|
4837
|
+
const fresh = (await adminApi.getProduct(product().id)).product;
|
|
4838
|
+
adopt(fresh);
|
|
4839
|
+
if (landed(fresh)) return { ok: true };
|
|
4840
|
+
} catch {
|
|
4841
|
+
return { ok: false, message: `${failure.message} We couldn't confirm what was saved.` };
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
return { ok: false, message: failure.message };
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
const rows = createMemo(() => buildStrengthRows(product(), readiness()));
|
|
4848
|
+
const orphans = createMemo(() => product().orphanedDosePrices ?? []);
|
|
4849
|
+
const dosagePricesUpdate = () => applyPriceDrafts(product().dosagePrices ?? [], rows(), drafts());
|
|
4850
|
+
const createDoseStep = (key, body) => {
|
|
4851
|
+
const before = new Set((readiness()?.doses ?? []).map((d) => d.id));
|
|
4852
|
+
return apexWrite(
|
|
4853
|
+
key,
|
|
4854
|
+
() => adminCatalogApi.createDose(itemId(), body),
|
|
4855
|
+
(fresh) => {
|
|
4856
|
+
const hit = fresh.doses.find((d) => d.label === body.label && !before.has(d.id));
|
|
4857
|
+
return hit ? { done: true, value: hit } : { done: false };
|
|
4858
|
+
}
|
|
4859
|
+
);
|
|
4860
|
+
};
|
|
4861
|
+
const nextDisplayOrder = () => Math.max(-1, ...(readiness()?.doses ?? []).map((d) => d.displayOrder)) + 1;
|
|
4862
|
+
const addStrength = async (input) => {
|
|
4863
|
+
const key = "strength:add";
|
|
4864
|
+
const unit = input.unit?.trim() || void 0;
|
|
4865
|
+
const value = input.value != null && Number.isFinite(input.value) ? input.value : void 0;
|
|
4866
|
+
const label = input.label?.trim() || (value != null && unit ? `${value} ${unit}` : "");
|
|
4867
|
+
if (!label) {
|
|
4868
|
+
const message2 = "Give the strength a label, e.g. \u201C2.5 mg\u201D.";
|
|
4869
|
+
setError(key, message2);
|
|
4870
|
+
return { kind: "rejected", message: message2 };
|
|
4871
|
+
}
|
|
4872
|
+
const price = parsePrice(input.price ?? "");
|
|
4873
|
+
if (price === "invalid") {
|
|
4874
|
+
const message2 = "Enter a price of 0 or more.";
|
|
4875
|
+
setError(key, message2);
|
|
4876
|
+
return { kind: "rejected", message: message2 };
|
|
4877
|
+
}
|
|
4878
|
+
const created = await createDoseStep(key, {
|
|
4879
|
+
label,
|
|
4880
|
+
...value != null ? { value } : {},
|
|
4881
|
+
...unit ? { unit } : {},
|
|
4882
|
+
displayOrder: nextDisplayOrder()
|
|
4883
|
+
});
|
|
4884
|
+
if (!created.ok) return { kind: created.kind, message: created.message };
|
|
4885
|
+
const dose = created.value;
|
|
4886
|
+
if (price == null) return { kind: "added", doseId: dose.id };
|
|
4887
|
+
const stored = product().dosagePrices ?? [];
|
|
4888
|
+
const next = upsertDosePrice(stored, { dosage: dose.label, apexSkuId: dose.id, price });
|
|
4889
|
+
const saved = await saveProduct(
|
|
4890
|
+
{ dosagePrices: next, skuBindingMode: skuBindingModeFor(next, product().skuBindingMode) },
|
|
4891
|
+
(p) => (p.dosagePrices ?? []).some((e) => e.apexSkuId === dose.id && e.price === price)
|
|
4892
|
+
);
|
|
4893
|
+
if (saved.ok) return { kind: "added", doseId: dose.id };
|
|
4894
|
+
const message = `\u201C${dose.label}\u201D was added, but its price wasn't saved: ${saved.message} It shows as needing a price \u2014 enter it and save to finish.`;
|
|
4895
|
+
setError(key, message);
|
|
4896
|
+
setDrafts((prev) => ({ ...prev, [rowKeyFor(dose.id, dose.label)]: String(price) }));
|
|
4897
|
+
return { kind: "added_unpriced", doseId: dose.id, message };
|
|
4898
|
+
};
|
|
4899
|
+
const removeStrength = async (doseId) => {
|
|
4900
|
+
const row = rows().find((r) => r.doseId === doseId);
|
|
4901
|
+
const key = `strength:${row?.key ?? doseId}`;
|
|
4902
|
+
const res = await apexWrite(
|
|
4903
|
+
key,
|
|
4904
|
+
async () => {
|
|
4905
|
+
await adminCatalogApi.deleteDose(itemId(), doseId);
|
|
4906
|
+
},
|
|
4907
|
+
(fresh) => fresh.doses.some((d) => d.id === doseId) ? { done: false } : { done: true, value: void 0 }
|
|
4908
|
+
);
|
|
4909
|
+
if (res.ok) {
|
|
4910
|
+
setDrafts((prev) => {
|
|
4911
|
+
const { [rowKeyFor(doseId, row?.label ?? "")]: _gone, ...rest } = prev;
|
|
4912
|
+
return rest;
|
|
4913
|
+
});
|
|
4914
|
+
}
|
|
4915
|
+
return res.ok;
|
|
4916
|
+
};
|
|
4917
|
+
const removeOrphan = async (orphan) => {
|
|
4918
|
+
const key = `orphan:${orphanKey(orphan)}`;
|
|
4919
|
+
if (busy()) return false;
|
|
4920
|
+
setBusy(key);
|
|
4921
|
+
clearError(key);
|
|
4922
|
+
try {
|
|
4923
|
+
const next = removeStoredDosePrice(product().dosagePrices ?? [], orphan);
|
|
4924
|
+
const saved = await saveProduct(
|
|
4925
|
+
{ dosagePrices: next, skuBindingMode: skuBindingModeFor(next, product().skuBindingMode) },
|
|
4926
|
+
(p) => !(p.dosagePrices ?? []).some((e) => sameStoredEntry(e, orphan))
|
|
4927
|
+
);
|
|
4928
|
+
if (!saved.ok) setError(key, saved.message);
|
|
4929
|
+
return saved.ok;
|
|
4930
|
+
} finally {
|
|
4931
|
+
setBusy(null);
|
|
4932
|
+
}
|
|
4933
|
+
};
|
|
4934
|
+
const loadDoseSuggestions = async () => {
|
|
4935
|
+
const key = "suggest:doses";
|
|
4936
|
+
clearError(key);
|
|
4937
|
+
if (!itemId()) return;
|
|
4938
|
+
try {
|
|
4939
|
+
const res = await adminCatalogApi.getSuggestedDoses(itemId());
|
|
4940
|
+
setDoseSuggestions(res.suggestions ?? []);
|
|
4941
|
+
} catch (err) {
|
|
4942
|
+
const failure = classifyCatalogError(err);
|
|
4943
|
+
setError(key, failure.message);
|
|
4944
|
+
if (failure.kind === "blocked") setLoad({ kind: "blocked", message: failure.message });
|
|
4945
|
+
}
|
|
4946
|
+
};
|
|
4947
|
+
const addSuggestedDoses = async (picked) => {
|
|
4948
|
+
const key = "suggest:doses";
|
|
4949
|
+
let added = 0;
|
|
4950
|
+
for (const s of picked) {
|
|
4951
|
+
const res = await createDoseStep(key, {
|
|
4952
|
+
label: s.label,
|
|
4953
|
+
...s.value != null ? { value: s.value } : {},
|
|
4954
|
+
...s.unit ? { unit: s.unit } : {},
|
|
4955
|
+
displayOrder: nextDisplayOrder()
|
|
4956
|
+
});
|
|
4957
|
+
if (!res.ok) {
|
|
4958
|
+
setError(key, `${added} of ${picked.length} added. \u201C${s.label}\u201D: ${res.message}`);
|
|
4959
|
+
return { added, stoppedAt: s.label };
|
|
4960
|
+
}
|
|
4961
|
+
added += 1;
|
|
4962
|
+
}
|
|
4963
|
+
setDoseSuggestions((prev) => prev ? prev.filter((s) => !picked.includes(s)) : prev);
|
|
4964
|
+
return { added };
|
|
4965
|
+
};
|
|
4966
|
+
const fulfillments = createMemo(() => buildFulfillmentRows(readiness(), drugs()));
|
|
4967
|
+
const addFulfillment = async (pharmacyId, drugId) => {
|
|
4968
|
+
const before = new Set((readiness()?.fulfillments ?? []).map((f) => f.id));
|
|
4969
|
+
const res = await apexWrite(
|
|
4970
|
+
"fulfillment:add",
|
|
4971
|
+
() => adminCatalogApi.createFulfillment(itemId(), { pharmacyId, drugId }),
|
|
4972
|
+
(fresh) => {
|
|
4973
|
+
const hit = fresh.fulfillments.find(
|
|
4974
|
+
(f) => f.pharmacyId === pharmacyId && f.drugId === drugId && !before.has(f.id)
|
|
4975
|
+
);
|
|
4976
|
+
return hit ? { done: true, value: hit } : { done: false };
|
|
4977
|
+
}
|
|
4978
|
+
);
|
|
4979
|
+
if (res.ok) setEquivalents(null);
|
|
4980
|
+
return res.ok;
|
|
4981
|
+
};
|
|
4982
|
+
const patchFulfillment = async (id, patch) => {
|
|
4983
|
+
const res = await apexWrite(
|
|
4984
|
+
`fulfillment:${id}`,
|
|
4985
|
+
() => adminCatalogApi.updateFulfillment(itemId(), id, patch),
|
|
4986
|
+
(fresh) => {
|
|
4987
|
+
const f = fresh.fulfillments.find((x) => x.id === id);
|
|
4988
|
+
const same = !!f && (patch.enabled === void 0 || f.enabled === patch.enabled) && (patch.excludedStates === void 0 || JSON.stringify(normalizeStates(f.excludedStates ?? [])) === JSON.stringify(patch.excludedStates));
|
|
4989
|
+
return same && f ? { done: true, value: f } : { done: false };
|
|
4990
|
+
}
|
|
4991
|
+
);
|
|
4992
|
+
return res.ok;
|
|
4993
|
+
};
|
|
4994
|
+
const setFulfillmentEnabled = (id, enabled) => patchFulfillment(id, { enabled });
|
|
4995
|
+
const setExcludedStates = (id, states) => patchFulfillment(id, { excludedStates: normalizeStates(states) });
|
|
4996
|
+
const removeFulfillment = async (id) => {
|
|
4997
|
+
const res = await apexWrite(
|
|
4998
|
+
`fulfillment:${id}`,
|
|
4999
|
+
async () => {
|
|
5000
|
+
await adminCatalogApi.deleteFulfillment(itemId(), id);
|
|
5001
|
+
},
|
|
5002
|
+
(fresh) => fresh.fulfillments.some((f) => f.id === id) ? { done: false } : { done: true, value: void 0 }
|
|
5003
|
+
);
|
|
5004
|
+
return res.ok;
|
|
5005
|
+
};
|
|
5006
|
+
const moveFulfillment = async (id, direction) => {
|
|
5007
|
+
const current = fulfillments().map((f) => f.id);
|
|
5008
|
+
const ordered = moveInOrder(current, id, direction);
|
|
5009
|
+
if (ordered.join() === current.join()) return false;
|
|
5010
|
+
const res = await apexWrite(
|
|
5011
|
+
`fulfillment:${id}`,
|
|
5012
|
+
() => adminCatalogApi.setFulfillmentOrder(itemId(), ordered),
|
|
5013
|
+
(fresh) => [...fresh.fulfillments].sort(byRank).map((f) => f.id).join() === ordered.join() ? { done: true, value: void 0 } : { done: false }
|
|
5014
|
+
);
|
|
5015
|
+
return res.ok;
|
|
5016
|
+
};
|
|
5017
|
+
const loadEquivalents = async () => {
|
|
5018
|
+
const key = "suggest:equivalents";
|
|
5019
|
+
clearError(key);
|
|
5020
|
+
const top = fulfillments()[0];
|
|
5021
|
+
if (!top) {
|
|
5022
|
+
setError(key, "Add a first pharmacy drug to see equivalents at other pharmacies.");
|
|
5023
|
+
return;
|
|
5024
|
+
}
|
|
5025
|
+
try {
|
|
5026
|
+
setEquivalents(await adminCatalogApi.suggestEquivalents(top.drugId));
|
|
5027
|
+
} catch (err) {
|
|
5028
|
+
const failure = classifyCatalogError(err);
|
|
5029
|
+
setError(key, failure.message);
|
|
5030
|
+
if (failure.kind === "blocked") setLoad({ kind: "blocked", message: failure.message });
|
|
5031
|
+
}
|
|
5032
|
+
};
|
|
5033
|
+
const status = createMemo(() => {
|
|
5034
|
+
const r = readiness();
|
|
5035
|
+
return r ? readinessStatus(r) : null;
|
|
5036
|
+
});
|
|
5037
|
+
const matrix = createMemo(() => buildMatrixView(readiness(), fulfillments()));
|
|
5038
|
+
return {
|
|
5039
|
+
product,
|
|
5040
|
+
item: () => readiness()?.item ?? null,
|
|
5041
|
+
structure,
|
|
5042
|
+
loading: () => load().kind === "loading",
|
|
5043
|
+
busy,
|
|
5044
|
+
reload,
|
|
5045
|
+
errors,
|
|
5046
|
+
clearError,
|
|
5047
|
+
rows,
|
|
5048
|
+
orphans,
|
|
5049
|
+
priceDrafts: drafts,
|
|
5050
|
+
setPriceDraft: (rowKey, value) => setDrafts((prev) => ({ ...prev, [rowKey]: value })),
|
|
5051
|
+
clearPriceDrafts: () => setDrafts({}),
|
|
5052
|
+
dosagePricesUpdate,
|
|
5053
|
+
addStrength,
|
|
5054
|
+
removeStrength,
|
|
5055
|
+
removeOrphan,
|
|
5056
|
+
doseSuggestions,
|
|
5057
|
+
loadDoseSuggestions,
|
|
5058
|
+
addSuggestedDoses,
|
|
5059
|
+
drugs,
|
|
5060
|
+
fulfillments,
|
|
5061
|
+
addFulfillment,
|
|
5062
|
+
setFulfillmentEnabled,
|
|
5063
|
+
setExcludedStates,
|
|
5064
|
+
removeFulfillment,
|
|
5065
|
+
moveFulfillment,
|
|
5066
|
+
equivalents,
|
|
5067
|
+
loadEquivalents,
|
|
5068
|
+
readiness,
|
|
5069
|
+
status,
|
|
5070
|
+
matrix,
|
|
5071
|
+
warnings: () => readiness()?.warnings ?? []
|
|
5072
|
+
};
|
|
5073
|
+
}
|
|
5074
|
+
async function addCatalogItemAsProduct(itemId, name) {
|
|
5075
|
+
const existing = async () => {
|
|
5076
|
+
const { products } = await adminApi.getProducts({ limit: 200 });
|
|
5077
|
+
return products.find((p) => p.apexDrugId === itemId)?.id ?? null;
|
|
5078
|
+
};
|
|
5079
|
+
try {
|
|
5080
|
+
const res = await adminApi.importFromApex([{ drugId: itemId, name }]);
|
|
5081
|
+
const productId = res.imported[0]?.productId;
|
|
5082
|
+
if (productId) return { kind: "created", productId };
|
|
5083
|
+
const found = await existing().catch(() => null);
|
|
5084
|
+
if (found) return { kind: "created", productId: found };
|
|
5085
|
+
return {
|
|
5086
|
+
kind: "failed",
|
|
5087
|
+
message: res.skipped[0]?.reason ?? "The product could not be created.",
|
|
5088
|
+
maybeCreated: false
|
|
5089
|
+
};
|
|
5090
|
+
} catch (err) {
|
|
5091
|
+
const failure = classifyCatalogError(err);
|
|
5092
|
+
if (failure.kind !== "ambiguous") return { kind: "failed", message: failure.message, maybeCreated: false };
|
|
5093
|
+
try {
|
|
5094
|
+
const found = await existing();
|
|
5095
|
+
if (found) return { kind: "created", productId: found };
|
|
5096
|
+
return { kind: "failed", message: failure.message, maybeCreated: false };
|
|
5097
|
+
} catch {
|
|
5098
|
+
return { kind: "failed", message: `${failure.message} We couldn't confirm whether it was created.`, maybeCreated: true };
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
async function createCatalogProduct(input) {
|
|
5103
|
+
let known;
|
|
5104
|
+
try {
|
|
5105
|
+
known = new Set((await adminCatalogApi.listItems()).items.map((r) => r.item.id));
|
|
5106
|
+
} catch (err) {
|
|
5107
|
+
return { kind: "failed", message: classifyCatalogError(err).message, retryable: true };
|
|
5108
|
+
}
|
|
5109
|
+
const newItems = async () => (await adminCatalogApi.listItems()).items.map((r) => r.item).filter((i) => !known.has(i.id));
|
|
5110
|
+
let created;
|
|
5111
|
+
let warning;
|
|
5112
|
+
try {
|
|
5113
|
+
const made = input.mode === "from_drug" ? (await adminCatalogApi.createItemFromDrug(input.drugId)).item : await adminCatalogApi.createItem({
|
|
5114
|
+
name: input.name.trim(),
|
|
5115
|
+
classification: input.classification,
|
|
5116
|
+
doseModel: input.doseModel,
|
|
5117
|
+
...input.description?.trim() ? { description: input.description.trim() } : {}
|
|
5118
|
+
});
|
|
5119
|
+
created = { id: made.id, name: made.name };
|
|
5120
|
+
} catch (err) {
|
|
5121
|
+
const failure = classifyCatalogError(err);
|
|
5122
|
+
if (failure.kind === "blocked" && failure.definitive) {
|
|
5123
|
+
return { kind: "failed", message: failure.message, retryable: false };
|
|
5124
|
+
}
|
|
5125
|
+
if (failure.kind === "rejected" && input.mode === "blank") {
|
|
5126
|
+
return { kind: "failed", message: failure.message, retryable: false };
|
|
5127
|
+
}
|
|
5128
|
+
let fresh;
|
|
5129
|
+
try {
|
|
5130
|
+
fresh = await newItems();
|
|
5131
|
+
} catch {
|
|
5132
|
+
return {
|
|
5133
|
+
kind: "unknown",
|
|
5134
|
+
message: `${failure.message} We couldn't confirm whether the item was created \u2014 check "Available to add" before trying again.`
|
|
5135
|
+
};
|
|
5136
|
+
}
|
|
5137
|
+
const matches = input.mode === "blank" ? fresh.filter((i) => i.name === input.name.trim()) : fresh;
|
|
5138
|
+
if (matches.length === 0) {
|
|
5139
|
+
return failure.kind === "rejected" ? { kind: "failed", message: failure.message, retryable: false } : { kind: "failed", message: `That didn't go through, and nothing was created. ${failure.message}`, retryable: true };
|
|
5140
|
+
}
|
|
5141
|
+
if (matches.length > 1) {
|
|
5142
|
+
return {
|
|
5143
|
+
kind: "unknown",
|
|
5144
|
+
message: 'More than one new item appeared in the catalog, so we cannot tell which is yours. Check "Available to add".'
|
|
5145
|
+
};
|
|
5146
|
+
}
|
|
5147
|
+
created = { id: matches[0].id, name: matches[0].name };
|
|
5148
|
+
if (failure.kind === "rejected") warning = `\u201C${created.name}\u201D was only partly set up: ${failure.message}`;
|
|
5149
|
+
}
|
|
5150
|
+
const product = await addCatalogItemAsProduct(created.id, created.name);
|
|
5151
|
+
if (product.kind === "created") {
|
|
5152
|
+
return {
|
|
5153
|
+
kind: "created",
|
|
5154
|
+
productId: product.productId,
|
|
5155
|
+
itemId: created.id,
|
|
5156
|
+
name: created.name,
|
|
5157
|
+
...warning ? { warning } : {}
|
|
5158
|
+
};
|
|
5159
|
+
}
|
|
5160
|
+
return {
|
|
5161
|
+
kind: "item_only",
|
|
5162
|
+
itemId: created.id,
|
|
5163
|
+
name: created.name,
|
|
5164
|
+
message: product.maybeCreated ? `\u201C${created.name}\u201D was created, but we couldn't confirm the product. Reload the list before adding it again.` : `\u201C${created.name}\u201D was created in the catalog, but adding it as a product failed: ${product.message} It now appears under Available to add.`
|
|
5165
|
+
};
|
|
5166
|
+
}
|
|
4474
5167
|
|
|
4475
|
-
export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, availableStateOptions, availableStates, buildRefillView, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, catalogUnavailableMessage, categoryColor, categoryLabel, createFunnelTelemetry, deriveAttention, deriveCatalogAvailabilityDecision, deriveJourney, emailGateAnswered, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, hasErrors, hasStateRestrictions, intakeEvidence, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, lowestPrice, lowestSalePrice, markEmailGateAnswered, normalizeState, primarySubscription, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, resetResumeRedemption, resolveCategoryColor, resolveSurveyV2DrugIntent, salePriceForBase, stateAvailabilityNote, subscribeToSupportTopic, toTrackerRequest, uploadPrescriptionPhoto, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCatalogAvailability, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
|
|
4476
|
-
//# sourceMappingURL=
|
|
4477
|
-
//# sourceMappingURL=
|
|
5168
|
+
export { ACCOUNT_SOURCE_LABEL, DEFAULT_COLOR_PALETTE, LIFECYCLE_BUCKETS, LIFECYCLE_LABEL, LIFECYCLE_TONE, LIVE_SUBSCRIPTION_STATUSES, ORPHAN_REASON, READINESS_LABEL, SUPPORT_CATEGORIES, TERMINAL_SUBSCRIPTION_STATUSES, US_STATES, US_STATE_OPTIONS, accountSource, addCatalogItemAsProduct, applyPriceDrafts, availableStateOptions, availableStates, buildFulfillmentRows, buildMatrixView, buildRefillView, buildStrengthRows, buildTimeline, buildTrackerView, buildTrackingUrl, captureFunnelEmail, catalogUnavailableMessage, categoryColor, categoryLabel, classifyCatalogError, createCatalogProduct, createFunnelTelemetry, deriveAttention, deriveCatalogAvailabilityDecision, deriveJourney, emailGateAnswered, findStoredDosePrice, firstAddressError, fmtDay, formatCalendarDate, formatCardNumber, formatConversationTime, formatCvv, formatEventDate, formatExpiry, formatMessageTime, formatRelativeTime, formatStageDate, groupDrugsByPharmacy, hasErrors, hasStateRestrictions, intakeEvidence, invalidDraftKeys, isCatalogItemId, isCssColorValue, isImageAttachment, isLive, isQuestionVisible, isReconcilable, lifecycleReason, lowestPrice, lowestSalePrice, markEmailGateAnswered, moveInOrder, normalizeState, normalizeStates, orphanKey, primarySubscription, readinessStatus, reconcileCartAgainstCatalog, reconcileCartLines, redeemResumeLink, removeStoredDosePrice, resetResumeRedemption, resolveCategoryColor, resolveStrengthPrices, resolveSurveyV2DrugIntent, salePriceForBase, skuBindingModeFor, stateAvailabilityNote, subscribeToSupportTopic, toTrackerRequest, uploadPrescriptionPhoto, upsertDosePrice, useAddressPair, useAffiliateConversions, useAffiliateDownline, useAffiliateLinks, useAffiliateStats, useCardTokenizer, useCartCheckoutFlow, useCartReconcile, useCatalog, useCatalogAvailability, useCheckoutFlow, useDashboardData, useMedicationSelect, useMemberPortalData, useMessagesThread, useProductCatalogEditor, useProductDetail, useRegisterFlow, useSignupFlow, useSubscribeFlow, useSurveyFlow, useSurveyV2Flow, useUpdatePaymentMethodFlow, validateAddress };
|
|
5169
|
+
//# sourceMappingURL=L2ZMGXWR.js.map
|
|
5170
|
+
//# sourceMappingURL=L2ZMGXWR.js.map
|