@apextelemed/partner-core 0.17.0-dev.50 → 0.17.0-dev.52
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/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/index.jsx +5 -3
- package/dist/chunk/{EGP7AQDM.js → 2HDMTWLH.js} +6 -6
- package/dist/chunk/{EGP7AQDM.js.map → 2HDMTWLH.js.map} +1 -1
- package/dist/chunk/{3CWWN7H2.jsx → 37UEVJEC.jsx} +14 -3
- package/dist/chunk/{6QI7MVTN.jsx → 5HQAA4UO.jsx} +2 -2
- package/dist/chunk/{2CHHHNFT.js → 6V7RVUXX.js} +3 -3
- package/dist/chunk/{2CHHHNFT.js.map → 6V7RVUXX.js.map} +1 -1
- package/dist/chunk/{H7RY2N5U.js → A6FJGQIS.js} +3 -3
- package/dist/chunk/{H7RY2N5U.js.map → A6FJGQIS.js.map} +1 -1
- package/dist/chunk/{OVRA6JBK.jsx → BJXD2NQQ.jsx} +2 -2
- package/dist/chunk/{R5WTYT2O.js → BYDMO5RM.js} +295 -19
- package/dist/chunk/BYDMO5RM.js.map +1 -0
- package/dist/chunk/{YQK6OTY6.jsx → FTZ52PMM.jsx} +2 -2
- package/dist/chunk/{KADMJCZL.js → FXRGPBYU.js} +3 -3
- package/dist/chunk/{KADMJCZL.js.map → FXRGPBYU.js.map} +1 -1
- package/dist/chunk/{HADRZNID.jsx → IQDVS3XA.jsx} +5 -5
- package/dist/chunk/{BVJPX54P.js → O7H7DAWO.js} +1330 -961
- package/dist/chunk/O7H7DAWO.js.map +1 -0
- package/dist/chunk/{ISC5GVA2.js → RDZDD5UW.js} +15 -5
- package/dist/chunk/RDZDD5UW.js.map +1 -0
- package/dist/chunk/{XV5WXVPT.jsx → T37L6JE6.jsx} +1250 -1001
- package/dist/chunk/{GVXPPYZZ.jsx → TLDELI22.jsx} +308 -18
- package/dist/{client-Da9ye3z4.d.ts → client-BLh8hFAu.d.ts} +67 -2
- package/dist/flows/index.d.ts +158 -4
- package/dist/flows/index.js +6 -6
- package/dist/flows/index.jsx +24 -8
- package/dist/index/index.d.ts +2 -2
- package/dist/index/index.js +7 -7
- package/dist/index/index.jsx +27 -9
- 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/package.json +1 -1
- package/dist/chunk/BVJPX54P.js.map +0 -1
- package/dist/chunk/ISC5GVA2.js.map +0 -1
- package/dist/chunk/R5WTYT2O.js.map +0 -1
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
readResumeToken,
|
|
7
7
|
saveFunnelDraft,
|
|
8
8
|
stripResumeToken
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./5HQAA4UO.jsx";
|
|
10
10
|
import {
|
|
11
11
|
affiliateAuth_default,
|
|
12
12
|
auth_default,
|
|
13
13
|
cart_default,
|
|
14
14
|
medication_default
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./BJXD2NQQ.jsx";
|
|
16
16
|
import {
|
|
17
17
|
ApiError,
|
|
18
18
|
addressesApi,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
adminCatalogApi,
|
|
21
21
|
adminCatalogConversionApi,
|
|
22
22
|
adminProductPharmaciesApi,
|
|
23
|
+
adminProductStrengthMatchesApi,
|
|
23
24
|
affiliatePortalApi,
|
|
24
25
|
apexApi,
|
|
25
26
|
authApi,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
subscriptionsApi,
|
|
34
35
|
supportApi,
|
|
35
36
|
usersApi
|
|
36
|
-
} from "./
|
|
37
|
+
} from "./37UEVJEC.jsx";
|
|
37
38
|
import {
|
|
38
39
|
getConfig
|
|
39
40
|
} from "./QVZ7BRNO.jsx";
|
|
@@ -5961,6 +5962,14 @@ function useCatalogConversion(opts) {
|
|
|
5961
5962
|
|
|
5962
5963
|
// src/flows/addPharmacy.ts
|
|
5963
5964
|
import { createSignal as createSignal15, onCleanup as onCleanup5 } from "solid-js";
|
|
5965
|
+
var REPLAN_DEBOUNCE_MS = 300;
|
|
5966
|
+
var matchKey = (source) => JSON.stringify([source.dosage, source.apexSkuId]);
|
|
5967
|
+
function matchAnswersBody(questions, answers) {
|
|
5968
|
+
return questions.flatMap((q) => {
|
|
5969
|
+
const key = matchKey(q.source);
|
|
5970
|
+
return Object.prototype.hasOwnProperty.call(answers, key) ? [{ source: { dosage: q.source.dosage, apexSkuId: q.source.apexSkuId }, doseId: answers[key] }] : [];
|
|
5971
|
+
});
|
|
5972
|
+
}
|
|
5964
5973
|
function visibleWarnings(plan) {
|
|
5965
5974
|
return plan.warnings.filter((w) => w.audience === "admin");
|
|
5966
5975
|
}
|
|
@@ -5979,7 +5988,7 @@ function strengthsChanged(plan) {
|
|
|
5979
5988
|
return plan.strengthsAfter.some((s) => !before.has(s.dosage) || before.get(s.dosage) !== s.price);
|
|
5980
5989
|
}
|
|
5981
5990
|
function needsReview(plan) {
|
|
5982
|
-
return plan.blockers.length > 0 || visibleWarnings(plan).length > 0 || plan.pricesRequired.length > 0 || strengthsChanged(plan);
|
|
5991
|
+
return plan.blockers.length > 0 || visibleWarnings(plan).length > 0 || plan.pricesRequired.length > 0 || (plan.matchQuestions?.length ?? 0) > 0 || strengthsChanged(plan);
|
|
5983
5992
|
}
|
|
5984
5993
|
function compareStrengths(plan) {
|
|
5985
5994
|
const after = new Map(plan.strengthsAfter.map((s) => [s.dosage, s]));
|
|
@@ -5996,17 +6005,19 @@ function compareStrengths(plan) {
|
|
|
5996
6005
|
function pharmacyLabel(plan) {
|
|
5997
6006
|
return plan.pharmacy.pharmacyName ?? plan.pharmacy.drugName;
|
|
5998
6007
|
}
|
|
5999
|
-
function buildSaveBody(plan, prices, savingsPrices = {}) {
|
|
6008
|
+
function buildSaveBody(plan, prices, savingsPrices = {}, matchAnswers = {}) {
|
|
6000
6009
|
const entries = plan.pricesRequired.flatMap((r) => {
|
|
6001
6010
|
const price = parseMoney(prices[r.doseId]);
|
|
6002
6011
|
if (price === null) return [];
|
|
6003
6012
|
const savings = parseMoney(savingsPrices[r.doseId]);
|
|
6004
6013
|
return [{ doseId: r.doseId, price, ...savings !== null ? { savingsPrice: savings } : {} }];
|
|
6005
6014
|
});
|
|
6015
|
+
const doseMatches = matchAnswersBody(plan.matchQuestions ?? [], matchAnswers);
|
|
6006
6016
|
return {
|
|
6007
6017
|
drugId: plan.pharmacy.drugId,
|
|
6008
6018
|
...plan.planHash ? { planHash: plan.planHash } : {},
|
|
6009
|
-
...entries.length > 0 ? { prices: entries } : {}
|
|
6019
|
+
...entries.length > 0 ? { prices: entries } : {},
|
|
6020
|
+
...doseMatches.length > 0 ? { doseMatches } : {}
|
|
6010
6021
|
};
|
|
6011
6022
|
}
|
|
6012
6023
|
function pharmacyIsOnProduct(product, plan) {
|
|
@@ -6058,9 +6069,22 @@ function useAddPharmacy(opts) {
|
|
|
6058
6069
|
const [prices, setPrices] = createSignal15({});
|
|
6059
6070
|
const [savingsPrices, setSavingsPrices] = createSignal15({});
|
|
6060
6071
|
const [flagged, setFlagged] = createSignal15(/* @__PURE__ */ new Set());
|
|
6072
|
+
const [matchAnswers, setMatchAnswers] = createSignal15({});
|
|
6073
|
+
const [replanning, setReplanning] = createSignal15(false);
|
|
6074
|
+
const [replanStale, setReplanStale] = createSignal15(false);
|
|
6061
6075
|
let generation = 0;
|
|
6076
|
+
let replanTimer;
|
|
6077
|
+
let replanSeq = 0;
|
|
6078
|
+
const dropReplan = () => {
|
|
6079
|
+
clearTimeout(replanTimer);
|
|
6080
|
+
replanTimer = void 0;
|
|
6081
|
+
replanSeq++;
|
|
6082
|
+
setReplanning(false);
|
|
6083
|
+
setReplanStale(false);
|
|
6084
|
+
};
|
|
6062
6085
|
onCleanup5(() => {
|
|
6063
6086
|
generation++;
|
|
6087
|
+
dropReplan();
|
|
6064
6088
|
});
|
|
6065
6089
|
const current = () => state();
|
|
6066
6090
|
const kindIs = (k) => current().kind === k;
|
|
@@ -6081,7 +6105,7 @@ function useAddPharmacy(opts) {
|
|
|
6081
6105
|
};
|
|
6082
6106
|
const canSave = () => {
|
|
6083
6107
|
const plan2 = reviewingPlan();
|
|
6084
|
-
return !!plan2 && plan2.ready && plan2.blockers.length === 0 && missing().length === 0 && savingsInvalid().length === 0;
|
|
6108
|
+
return !!plan2 && !replanning() && !replanStale() && plan2.ready && plan2.blockers.length === 0 && missing().length === 0 && savingsInvalid().length === 0;
|
|
6085
6109
|
};
|
|
6086
6110
|
const loadDrugs = async (gen) => {
|
|
6087
6111
|
setDrugsStatus("loading");
|
|
@@ -6098,6 +6122,8 @@ function useAddPharmacy(opts) {
|
|
|
6098
6122
|
const open = (drugId) => {
|
|
6099
6123
|
if (busy()) return;
|
|
6100
6124
|
const gen = ++generation;
|
|
6125
|
+
dropReplan();
|
|
6126
|
+
setMatchAnswers({});
|
|
6101
6127
|
setNotice(null);
|
|
6102
6128
|
setSelected(drugId ?? "");
|
|
6103
6129
|
setState({ kind: "picking" });
|
|
@@ -6106,12 +6132,15 @@ function useAddPharmacy(opts) {
|
|
|
6106
6132
|
const cancel = () => {
|
|
6107
6133
|
if (kindIs("saving")) return;
|
|
6108
6134
|
generation++;
|
|
6135
|
+
dropReplan();
|
|
6109
6136
|
setNotice(null);
|
|
6110
6137
|
setState({ kind: "idle" });
|
|
6111
6138
|
};
|
|
6112
6139
|
const backToPicking = () => {
|
|
6113
6140
|
if (busy()) return;
|
|
6114
6141
|
const gen = ++generation;
|
|
6142
|
+
dropReplan();
|
|
6143
|
+
setMatchAnswers({});
|
|
6115
6144
|
setNotice(null);
|
|
6116
6145
|
setState({ kind: "picking" });
|
|
6117
6146
|
if (drugsStatus() !== "ready") void loadDrugs(gen);
|
|
@@ -6127,6 +6156,8 @@ function useAddPharmacy(opts) {
|
|
|
6127
6156
|
}
|
|
6128
6157
|
setPrices(nextPrices);
|
|
6129
6158
|
setSavingsPrices(nextSavings);
|
|
6159
|
+
const questions = new Set((plan2.matchQuestions ?? []).map((q) => matchKey(q.source)));
|
|
6160
|
+
setMatchAnswers((prev) => Object.fromEntries(Object.entries(prev).filter(([k]) => questions.has(k))));
|
|
6130
6161
|
setFlagged(/* @__PURE__ */ new Set());
|
|
6131
6162
|
setNotice(next);
|
|
6132
6163
|
setState({ kind: "reviewing", plan: plan2 });
|
|
@@ -6135,12 +6166,15 @@ function useAddPharmacy(opts) {
|
|
|
6135
6166
|
setNotice(null);
|
|
6136
6167
|
setState({ kind: "failed", message, drugId, plan: plan2, unconfirmed: flags.unconfirmed ?? false, canRetry: flags.canRetry ?? true });
|
|
6137
6168
|
};
|
|
6138
|
-
const runPlan = async (drugId, next = null) => {
|
|
6169
|
+
const runPlan = async (drugId, next = null, prior) => {
|
|
6139
6170
|
const gen = ++generation;
|
|
6171
|
+
dropReplan();
|
|
6172
|
+
const doseMatches = prior ? matchAnswersBody(prior.matchQuestions ?? [], matchAnswers()) : [];
|
|
6173
|
+
if (!prior) setMatchAnswers({});
|
|
6140
6174
|
setNotice(null);
|
|
6141
6175
|
setState({ kind: "planning", drugId });
|
|
6142
6176
|
try {
|
|
6143
|
-
const plan2 = await adminProductPharmaciesApi.plan(opts.productId(), drugId);
|
|
6177
|
+
const plan2 = await (doseMatches.length > 0 ? adminProductPharmaciesApi.plan(opts.productId(), drugId, doseMatches) : adminProductPharmaciesApi.plan(opts.productId(), drugId));
|
|
6144
6178
|
if (gen !== generation) return;
|
|
6145
6179
|
adoptPlan(plan2, next);
|
|
6146
6180
|
} catch (err) {
|
|
@@ -6154,6 +6188,40 @@ function useAddPharmacy(opts) {
|
|
|
6154
6188
|
if (!kindIs("picking") || !drugId) return;
|
|
6155
6189
|
await runPlan(drugId);
|
|
6156
6190
|
};
|
|
6191
|
+
const replan = async (gen) => {
|
|
6192
|
+
const p = reviewingPlan();
|
|
6193
|
+
if (!p || gen !== generation) return;
|
|
6194
|
+
const seq = ++replanSeq;
|
|
6195
|
+
const doseMatches = matchAnswersBody(p.matchQuestions ?? [], matchAnswers());
|
|
6196
|
+
try {
|
|
6197
|
+
const fresh = await adminProductPharmaciesApi.plan(opts.productId(), p.pharmacy.drugId, doseMatches);
|
|
6198
|
+
if (gen !== generation || seq !== replanSeq) return;
|
|
6199
|
+
setReplanning(false);
|
|
6200
|
+
setReplanStale(false);
|
|
6201
|
+
adoptPlan(fresh, null);
|
|
6202
|
+
} catch (err) {
|
|
6203
|
+
if (gen !== generation || seq !== replanSeq) return;
|
|
6204
|
+
setReplanning(false);
|
|
6205
|
+
setReplanStale(true);
|
|
6206
|
+
setNotice({
|
|
6207
|
+
tone: "danger",
|
|
6208
|
+
code: "replan_failed",
|
|
6209
|
+
message: `We couldn\u2019t update the prices for that choice: ${classifyAddPharmacyError(err).message} Choose again to retry.`
|
|
6210
|
+
});
|
|
6211
|
+
}
|
|
6212
|
+
};
|
|
6213
|
+
const setMatchAnswer = (source, doseId) => {
|
|
6214
|
+
if (!reviewingPlan()) return;
|
|
6215
|
+
setMatchAnswers((prev) => ({ ...prev, [matchKey(source)]: doseId }));
|
|
6216
|
+
const gen = generation;
|
|
6217
|
+
clearTimeout(replanTimer);
|
|
6218
|
+
replanSeq++;
|
|
6219
|
+
setReplanning(true);
|
|
6220
|
+
replanTimer = setTimeout(() => {
|
|
6221
|
+
replanTimer = void 0;
|
|
6222
|
+
void replan(gen);
|
|
6223
|
+
}, REPLAN_DEBOUNCE_MS);
|
|
6224
|
+
};
|
|
6157
6225
|
const confirmOnProduct = async (p) => {
|
|
6158
6226
|
const res = await adminApi.getProduct(opts.productId());
|
|
6159
6227
|
return pharmacyIsOnProduct(res?.product, p);
|
|
@@ -6173,7 +6241,7 @@ function useAddPharmacy(opts) {
|
|
|
6173
6241
|
const p = reviewingPlan();
|
|
6174
6242
|
if (!p || !canSave()) return;
|
|
6175
6243
|
const gen = ++generation;
|
|
6176
|
-
const body = buildSaveBody(p, prices(), savingsPrices());
|
|
6244
|
+
const body = buildSaveBody(p, prices(), savingsPrices(), matchAnswers());
|
|
6177
6245
|
setNotice(null);
|
|
6178
6246
|
setState({ kind: "saving", plan: p });
|
|
6179
6247
|
try {
|
|
@@ -6185,17 +6253,21 @@ function useAddPharmacy(opts) {
|
|
|
6185
6253
|
const f = classifyAddPharmacyError(err);
|
|
6186
6254
|
const drugId = p.pharmacy.drugId;
|
|
6187
6255
|
if (f.kind === "replan") {
|
|
6188
|
-
await runPlan(
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6256
|
+
await runPlan(
|
|
6257
|
+
drugId,
|
|
6258
|
+
{
|
|
6259
|
+
tone: "warn",
|
|
6260
|
+
code: f.code,
|
|
6261
|
+
message: "Something changed while you were reviewing, so we updated this. Check it over, then save again."
|
|
6262
|
+
},
|
|
6263
|
+
p
|
|
6264
|
+
);
|
|
6193
6265
|
return;
|
|
6194
6266
|
}
|
|
6195
6267
|
if (f.kind === "prices_required") {
|
|
6196
6268
|
const owed = new Set(p.pricesRequired.map((r) => r.doseId));
|
|
6197
6269
|
if (f.missing.some((id) => !owed.has(id))) {
|
|
6198
|
-
await runPlan(drugId, { tone: "warn", code: "prices_required", message: "More prices are needed than we first showed. Enter them below." });
|
|
6270
|
+
await runPlan(drugId, { tone: "warn", code: "prices_required", message: "More prices are needed than we first showed. Enter them below." }, p);
|
|
6199
6271
|
return;
|
|
6200
6272
|
}
|
|
6201
6273
|
setFlagged(new Set(f.missing));
|
|
@@ -6290,12 +6362,220 @@ function useAddPharmacy(opts) {
|
|
|
6290
6362
|
flagged,
|
|
6291
6363
|
savingsInvalid,
|
|
6292
6364
|
canSave,
|
|
6365
|
+
matchAnswers,
|
|
6366
|
+
setMatchAnswer,
|
|
6367
|
+
replanning,
|
|
6293
6368
|
save,
|
|
6294
6369
|
retry,
|
|
6295
6370
|
startOver
|
|
6296
6371
|
};
|
|
6297
6372
|
}
|
|
6298
6373
|
|
|
6374
|
+
// src/flows/strengthMatches.ts
|
|
6375
|
+
import { createEffect as createEffect11, createMemo as createMemo4, createSignal as createSignal16, on as on5, onCleanup as onCleanup6 } from "solid-js";
|
|
6376
|
+
function wantsStrengthMatches(product, enabled) {
|
|
6377
|
+
return enabled && !!product && product.pricingMode !== "flat_fee";
|
|
6378
|
+
}
|
|
6379
|
+
function matchBody(dosage, doseId, carryPrice) {
|
|
6380
|
+
return { dosage, doseId, ...carryPrice === void 0 ? {} : { carryPrice } };
|
|
6381
|
+
}
|
|
6382
|
+
var matchValue = (row) => row.doseId ?? "";
|
|
6383
|
+
var doseIdOf = (value) => value === "" ? null : value;
|
|
6384
|
+
var isLeftForReview = (row) => row.doseId === null;
|
|
6385
|
+
function normalizeMatches(raw) {
|
|
6386
|
+
return {
|
|
6387
|
+
rows: Array.isArray(raw?.rows) ? raw.rows : [],
|
|
6388
|
+
doseOptions: Array.isArray(raw?.doseOptions) ? raw.doseOptions : []
|
|
6389
|
+
};
|
|
6390
|
+
}
|
|
6391
|
+
function decisionFromDetails(details, doseId) {
|
|
6392
|
+
const d = details ?? {};
|
|
6393
|
+
if (typeof d.dosage !== "string" || typeof d.doseLabel !== "string") return null;
|
|
6394
|
+
if (typeof d.price !== "number" || !Number.isFinite(d.price)) return null;
|
|
6395
|
+
return { dosage: d.dosage, doseId, price: d.price, doseLabel: d.doseLabel };
|
|
6396
|
+
}
|
|
6397
|
+
var STALE_CODES = ["product_changed", "not_a_row", "not_applicable", "invalid_strength_match"];
|
|
6398
|
+
var messageOf4 = (err) => err instanceof Error && err.message ? err.message : "Something went wrong talking to the server.";
|
|
6399
|
+
function classifyStrengthMatchError(err, doseId) {
|
|
6400
|
+
const e = err ?? {};
|
|
6401
|
+
const status = typeof e.status === "number" ? e.status : void 0;
|
|
6402
|
+
const code = typeof e.code === "string" ? e.code : void 0;
|
|
6403
|
+
const message = messageOf4(err);
|
|
6404
|
+
if (code === "price_decision_required" && doseId !== null) {
|
|
6405
|
+
const decision = decisionFromDetails(e.details, doseId);
|
|
6406
|
+
if (decision) return { kind: "decision", decision };
|
|
6407
|
+
return { kind: "refused", message, code };
|
|
6408
|
+
}
|
|
6409
|
+
if (code && STALE_CODES.includes(code)) return { kind: "stale", code, message };
|
|
6410
|
+
if (code === "could_not_read") return { kind: "refused", message, code };
|
|
6411
|
+
if (code === void 0 && (e.ambiguous === true || status === void 0 || status >= 500)) {
|
|
6412
|
+
return { kind: "ambiguous", message };
|
|
6413
|
+
}
|
|
6414
|
+
if (code === void 0 && status !== void 0 && status < 500) return { kind: "refused", message };
|
|
6415
|
+
if (status !== void 0 && status >= 500) return { kind: "ambiguous", message };
|
|
6416
|
+
return { kind: "refused", message, ...code ? { code } : {} };
|
|
6417
|
+
}
|
|
6418
|
+
function useStrengthMatches(opts) {
|
|
6419
|
+
const [status, setStatus] = createSignal16("idle");
|
|
6420
|
+
const [rows, setRows] = createSignal16([]);
|
|
6421
|
+
const [doseOptions, setDoseOptions] = createSignal16([]);
|
|
6422
|
+
const [pending, setPending] = createSignal16(null);
|
|
6423
|
+
const [writing, setWriting] = createSignal16(null);
|
|
6424
|
+
const [errors, setErrors] = createSignal16({});
|
|
6425
|
+
const [notice, setNotice] = createSignal16(null);
|
|
6426
|
+
let generation = 0;
|
|
6427
|
+
let loadSeq = 0;
|
|
6428
|
+
onCleanup6(() => {
|
|
6429
|
+
generation++;
|
|
6430
|
+
loadSeq++;
|
|
6431
|
+
});
|
|
6432
|
+
const busy = () => writing() !== null;
|
|
6433
|
+
const setError = (dosage, message) => setErrors((prev) => ({ ...prev, [dosage]: message }));
|
|
6434
|
+
const clearError = (dosage) => setErrors((prev) => {
|
|
6435
|
+
if (!(dosage in prev)) return prev;
|
|
6436
|
+
const { [dosage]: _gone, ...rest } = prev;
|
|
6437
|
+
return rest;
|
|
6438
|
+
});
|
|
6439
|
+
const adopt = (raw) => {
|
|
6440
|
+
const next = normalizeMatches(raw);
|
|
6441
|
+
setRows(next.rows);
|
|
6442
|
+
setDoseOptions(next.doseOptions);
|
|
6443
|
+
const p = pending();
|
|
6444
|
+
if (p && !next.rows.some((r) => r.dosage === p.dosage)) setPending(null);
|
|
6445
|
+
setErrors((prev) => Object.fromEntries(Object.entries(prev).filter(([d]) => next.rows.some((r) => r.dosage === d))));
|
|
6446
|
+
setStatus("ready");
|
|
6447
|
+
};
|
|
6448
|
+
const read = async () => {
|
|
6449
|
+
const gen = generation;
|
|
6450
|
+
const seq = ++loadSeq;
|
|
6451
|
+
const product = opts.product();
|
|
6452
|
+
if (!wantsStrengthMatches(product, opts.enabled())) {
|
|
6453
|
+
setRows([]);
|
|
6454
|
+
setDoseOptions([]);
|
|
6455
|
+
setStatus("idle");
|
|
6456
|
+
return true;
|
|
6457
|
+
}
|
|
6458
|
+
setStatus((prev) => prev === "idle" ? "loading" : prev);
|
|
6459
|
+
try {
|
|
6460
|
+
const res = await adminProductStrengthMatchesApi.list(product.id);
|
|
6461
|
+
if (gen !== generation || seq !== loadSeq) return false;
|
|
6462
|
+
adopt(res);
|
|
6463
|
+
return true;
|
|
6464
|
+
} catch (err) {
|
|
6465
|
+
if (gen !== generation || seq !== loadSeq) return false;
|
|
6466
|
+
if (err?.code === "not_applicable") {
|
|
6467
|
+
adopt({ rows: [], doseOptions: [] });
|
|
6468
|
+
return true;
|
|
6469
|
+
}
|
|
6470
|
+
setStatus("failed");
|
|
6471
|
+
return false;
|
|
6472
|
+
}
|
|
6473
|
+
};
|
|
6474
|
+
const reload = async () => {
|
|
6475
|
+
setNotice(null);
|
|
6476
|
+
await read();
|
|
6477
|
+
};
|
|
6478
|
+
const key = createMemo4(() => {
|
|
6479
|
+
const p = opts.product();
|
|
6480
|
+
const ids = (p.strengths ?? []).map((s) => s.apexSkuId ?? s.dosage).join(",");
|
|
6481
|
+
return `${p.id}|${p.apexDrugId ?? ""}|${p.pricingMode}|${opts.enabled()}|${ids}`;
|
|
6482
|
+
});
|
|
6483
|
+
createEffect11(
|
|
6484
|
+
on5(key, () => {
|
|
6485
|
+
generation++;
|
|
6486
|
+
loadSeq++;
|
|
6487
|
+
setRows([]);
|
|
6488
|
+
setDoseOptions([]);
|
|
6489
|
+
setPending(null);
|
|
6490
|
+
setWriting(null);
|
|
6491
|
+
setErrors({});
|
|
6492
|
+
setNotice(null);
|
|
6493
|
+
setStatus("idle");
|
|
6494
|
+
void read();
|
|
6495
|
+
})
|
|
6496
|
+
);
|
|
6497
|
+
const notifyChanged = async () => {
|
|
6498
|
+
try {
|
|
6499
|
+
await opts.onChanged?.();
|
|
6500
|
+
} catch {
|
|
6501
|
+
}
|
|
6502
|
+
};
|
|
6503
|
+
const write = async (dosage, doseId, carryPrice) => {
|
|
6504
|
+
if (busy() || status() !== "ready") return;
|
|
6505
|
+
const gen = generation;
|
|
6506
|
+
const productId = opts.product().id;
|
|
6507
|
+
clearError(dosage);
|
|
6508
|
+
setNotice(null);
|
|
6509
|
+
setWriting({ dosage, doseId });
|
|
6510
|
+
try {
|
|
6511
|
+
let fresh;
|
|
6512
|
+
try {
|
|
6513
|
+
fresh = await adminProductStrengthMatchesApi.set(productId, matchBody(dosage, doseId, carryPrice));
|
|
6514
|
+
} catch (err) {
|
|
6515
|
+
if (gen !== generation) return;
|
|
6516
|
+
const f = classifyStrengthMatchError(err, doseId);
|
|
6517
|
+
if (f.kind === "decision") {
|
|
6518
|
+
setPending(f.decision);
|
|
6519
|
+
return;
|
|
6520
|
+
}
|
|
6521
|
+
if (f.kind === "refused") {
|
|
6522
|
+
setPending(null);
|
|
6523
|
+
setError(dosage, f.message);
|
|
6524
|
+
return;
|
|
6525
|
+
}
|
|
6526
|
+
setPending(null);
|
|
6527
|
+
const read1 = await read();
|
|
6528
|
+
if (gen !== generation) return;
|
|
6529
|
+
setNotice(
|
|
6530
|
+
f.kind === "stale" ? "This changed while you were looking, so the list was refreshed. Check it, then choose again." : read1 ? "We lost the connection while saving that. This is what is saved now." : "We lost the connection while saving that, and could not check what was saved."
|
|
6531
|
+
);
|
|
6532
|
+
if (f.kind === "ambiguous" || f.code === "product_changed") await notifyChanged();
|
|
6533
|
+
return;
|
|
6534
|
+
}
|
|
6535
|
+
if (gen !== generation) return;
|
|
6536
|
+
setPending(null);
|
|
6537
|
+
adopt(fresh);
|
|
6538
|
+
await notifyChanged();
|
|
6539
|
+
} finally {
|
|
6540
|
+
if (gen === generation) setWriting(null);
|
|
6541
|
+
}
|
|
6542
|
+
};
|
|
6543
|
+
return {
|
|
6544
|
+
status,
|
|
6545
|
+
rows,
|
|
6546
|
+
doseOptions,
|
|
6547
|
+
pending,
|
|
6548
|
+
writing,
|
|
6549
|
+
busy,
|
|
6550
|
+
errors,
|
|
6551
|
+
notice,
|
|
6552
|
+
dismissNotice: () => setNotice(null),
|
|
6553
|
+
valueOf: (dosage) => {
|
|
6554
|
+
const w = writing();
|
|
6555
|
+
if (w && w.dosage === dosage) return w.doseId ?? "";
|
|
6556
|
+
const row = rows().find((r) => r.dosage === dosage);
|
|
6557
|
+
return row ? matchValue(row) : "";
|
|
6558
|
+
},
|
|
6559
|
+
setMatch: async (dosage, doseId) => {
|
|
6560
|
+
const row = rows().find((r) => r.dosage === dosage);
|
|
6561
|
+
if (!row || busy()) return;
|
|
6562
|
+
if (pending() && pending().dosage !== dosage) setPending(null);
|
|
6563
|
+
if (row.doseId === doseId) {
|
|
6564
|
+
setPending(null);
|
|
6565
|
+
return;
|
|
6566
|
+
}
|
|
6567
|
+
await write(dosage, doseId);
|
|
6568
|
+
},
|
|
6569
|
+
decide: async (carryPrice) => {
|
|
6570
|
+
const p = pending();
|
|
6571
|
+
if (!p) return;
|
|
6572
|
+
await write(p.dosage, p.doseId, carryPrice);
|
|
6573
|
+
},
|
|
6574
|
+
cancelDecision: () => setPending(null),
|
|
6575
|
+
reload
|
|
6576
|
+
};
|
|
6577
|
+
}
|
|
6578
|
+
|
|
6299
6579
|
export {
|
|
6300
6580
|
isQuestionVisible,
|
|
6301
6581
|
useSurveyFlow,
|
|
@@ -6427,6 +6707,7 @@ export {
|
|
|
6427
6707
|
hasBlockers,
|
|
6428
6708
|
hasConversion,
|
|
6429
6709
|
useCatalogConversion,
|
|
6710
|
+
matchKey,
|
|
6430
6711
|
visibleWarnings,
|
|
6431
6712
|
parseMoney,
|
|
6432
6713
|
missingPrices,
|
|
@@ -6437,6 +6718,15 @@ export {
|
|
|
6437
6718
|
buildSaveBody,
|
|
6438
6719
|
pharmacyIsOnProduct,
|
|
6439
6720
|
classifyAddPharmacyError,
|
|
6440
|
-
useAddPharmacy
|
|
6721
|
+
useAddPharmacy,
|
|
6722
|
+
wantsStrengthMatches,
|
|
6723
|
+
matchBody,
|
|
6724
|
+
matchValue,
|
|
6725
|
+
doseIdOf,
|
|
6726
|
+
isLeftForReview,
|
|
6727
|
+
normalizeMatches,
|
|
6728
|
+
decisionFromDetails,
|
|
6729
|
+
classifyStrengthMatchError,
|
|
6730
|
+
useStrengthMatches
|
|
6441
6731
|
};
|
|
6442
|
-
//# sourceMappingURL=
|
|
6732
|
+
//# sourceMappingURL=TLDELI22.jsx.map
|
|
@@ -2042,6 +2042,35 @@ interface AddPharmacyPlan {
|
|
|
2042
2042
|
}>;
|
|
2043
2043
|
/** Sent back with the save. Null on `kind: 'add'`. */
|
|
2044
2044
|
planHash: string | null;
|
|
2045
|
+
/**
|
|
2046
|
+
* Old strengths that subscribers are on and that matched no new strength by
|
|
2047
|
+
* themselves (typical for GLP-1 vials against mg doses). `doseId` echoes the
|
|
2048
|
+
* answer the plan was computed with; null = left for review.
|
|
2049
|
+
*/
|
|
2050
|
+
matchQuestions: AddPharmacyMatchQuestion[];
|
|
2051
|
+
/** The strengths a `matchQuestions` answer can pick. */
|
|
2052
|
+
doseOptions: AddPharmacyDoseOption[];
|
|
2053
|
+
}
|
|
2054
|
+
/** The old strength a subscriber is on: identifies a match question, and is echoed back in `doseMatches`. */
|
|
2055
|
+
interface AddPharmacyMatchSource {
|
|
2056
|
+
dosage: string | null;
|
|
2057
|
+
apexSkuId: string | null;
|
|
2058
|
+
}
|
|
2059
|
+
interface AddPharmacyMatchQuestion {
|
|
2060
|
+
source: AddPharmacyMatchSource;
|
|
2061
|
+
dosage: string | null;
|
|
2062
|
+
subscriberCount: number;
|
|
2063
|
+
price: number | null;
|
|
2064
|
+
doseId: string | null;
|
|
2065
|
+
}
|
|
2066
|
+
interface AddPharmacyDoseOption {
|
|
2067
|
+
doseId: string;
|
|
2068
|
+
label: string;
|
|
2069
|
+
}
|
|
2070
|
+
/** The admin's answer to one match question; `doseId: null` leaves those subscribers for review. */
|
|
2071
|
+
interface AddPharmacyDoseMatch {
|
|
2072
|
+
source: AddPharmacyMatchSource;
|
|
2073
|
+
doseId: string | null;
|
|
2045
2074
|
}
|
|
2046
2075
|
interface AddPharmacyPrice {
|
|
2047
2076
|
doseId: string;
|
|
@@ -2052,6 +2081,8 @@ interface AddPharmacyBody {
|
|
|
2052
2081
|
drugId: string;
|
|
2053
2082
|
planHash?: string;
|
|
2054
2083
|
prices?: AddPharmacyPrice[];
|
|
2084
|
+
/** Answers to the plan's `matchQuestions` (only the answered ones). */
|
|
2085
|
+
doseMatches?: AddPharmacyDoseMatch[];
|
|
2055
2086
|
}
|
|
2056
2087
|
interface AddPharmacyResult {
|
|
2057
2088
|
status: 'added' | 'converted';
|
|
@@ -2061,10 +2092,44 @@ interface AddPharmacyResult {
|
|
|
2061
2092
|
}
|
|
2062
2093
|
declare const adminProductPharmaciesApi: {
|
|
2063
2094
|
/** What adding this pharmacy drug would do. Read-only for the admin; safe to repeat. */
|
|
2064
|
-
plan(productId: string, drugId: string): Promise<AddPharmacyPlan>;
|
|
2095
|
+
plan(productId: string, drugId: string, doseMatches?: AddPharmacyDoseMatch[]): Promise<AddPharmacyPlan>;
|
|
2065
2096
|
/** Adds it. Up to ~40 seconds on a single-pharmacy product; never retry blindly — re-read the product first. */
|
|
2066
2097
|
add(productId: string, body: AddPharmacyBody): Promise<AddPharmacyResult>;
|
|
2067
2098
|
};
|
|
2099
|
+
/** An old strength subscribers are still on, and the strength it is now (`doseId: null` = left for review). */
|
|
2100
|
+
interface StrengthMatchRow {
|
|
2101
|
+
dosage: string;
|
|
2102
|
+
subscriberCount: number;
|
|
2103
|
+
/** What the old strength sold for, or null when it had no price. */
|
|
2104
|
+
price: number | null;
|
|
2105
|
+
doseId: string | null;
|
|
2106
|
+
doseLabel: string | null;
|
|
2107
|
+
}
|
|
2108
|
+
/** A strength an old one can be matched to. */
|
|
2109
|
+
interface StrengthMatchDoseOption {
|
|
2110
|
+
doseId: string;
|
|
2111
|
+
label: string;
|
|
2112
|
+
/** The strength's own price, or null when it has none yet. */
|
|
2113
|
+
price: number | null;
|
|
2114
|
+
}
|
|
2115
|
+
interface ProductStrengthMatches {
|
|
2116
|
+
productId: string;
|
|
2117
|
+
/** Empty for a flat-fee product and for one not yet moved. */
|
|
2118
|
+
rows: StrengthMatchRow[];
|
|
2119
|
+
doseOptions: StrengthMatchDoseOption[];
|
|
2120
|
+
}
|
|
2121
|
+
interface StrengthMatchBody {
|
|
2122
|
+
dosage: string;
|
|
2123
|
+
/** null leaves the subscribers for review. */
|
|
2124
|
+
doseId: string | null;
|
|
2125
|
+
/** Answer to a `price_decision_required` refusal: sell the strength at the old price (true) or not (false). */
|
|
2126
|
+
carryPrice?: boolean;
|
|
2127
|
+
}
|
|
2128
|
+
declare const adminProductStrengthMatchesApi: {
|
|
2129
|
+
list(productId: string): Promise<ProductStrengthMatches>;
|
|
2130
|
+
/** Changes one match; answers with the fresh list. Rewrites the product's stored `dosagePrices`. */
|
|
2131
|
+
set(productId: string, body: StrengthMatchBody): Promise<ProductStrengthMatches>;
|
|
2132
|
+
};
|
|
2068
2133
|
declare const adminApi: {
|
|
2069
2134
|
getDashboard(): Promise<AdminDashboardStats>;
|
|
2070
2135
|
getRecurringRevenue(): Promise<AdminRecurringRevenue>;
|
|
@@ -2851,4 +2916,4 @@ declare const affiliatePortalApi: {
|
|
|
2851
2916
|
track(refCode: string, landingPage?: string): Promise<AffiliateTrackResponse>;
|
|
2852
2917
|
};
|
|
2853
2918
|
|
|
2854
|
-
export { type
|
|
2919
|
+
export { type AdminScheduledRefund as $, type AddPharmacyBody as A, type AdminCustomerSupportThread as B, type AdminDashboardStats as C, type AdminLifecycle as D, type AdminLifecycleBucket as E, type AdminListParams as F, type AdminOffer as G, type AdminOfferBase as H, type AdminOfferGrant as I, type AdminOfferGrantBase as J, type AdminOfferInput as K, type AdminOrderSummary as L, type AdminOrphanReason as M, type AdminOrphanedDosePrice as N, type AdminPayment as O, type AdminPaymentDetail as P, type AdminProduct as Q, type AdminProductOverlayField as R, type AdminProductPharmacy as S, type AdminProductStrength as T, type AdminPromoCode as U, type AdminPromoCodeInput as V, type AdminRecurringPricePoint as W, type AdminRecurringRevenue as X, type AdminRefundResult as Y, type AdminSale as Z, type AdminSaleInput as _, type AddPharmacyDoseMatch as a, type CategoryMetadata as a$, type AdminScheduledRefundProblem as a0, type AdminSubscription as a1, type AdminSubscriptionDetail as a2, type AdminSubscriptionPatch as a3, type AdminSubscriptionWriteResult as a4, type AdminSupportCustomer as a5, type AdminSupportStats as a6, type AdminSupportThread as a7, type AdminWebhookEvent as a8, type Affiliate as a9, type CatalogConversionCommitResult as aA, type CatalogConversionDose as aB, type CatalogConversionDoseMatch as aC, type CatalogConversionFinding as aD, type CatalogConversionPointers as aE, type CatalogConversionPrepareResult as aF, type CatalogConversionPreview as aG, type CatalogConversionRun as aH, type CatalogConversionSource as aI, type CatalogConversionStage as aJ, type CatalogConversionTarget as aK, type CatalogConversionUndoOptions as aL, type CatalogConversionUndoResult as aM, type CatalogDose as aN, type CatalogDoseInput as aO, type CatalogDoseModel as aP, type CatalogDoseSuggestion as aQ, type CatalogDoseSuggestions as aR, type CatalogEquivalentSuggestions as aS, type CatalogFulfillment as aT, type CatalogFulfillmentInput as aU, type CatalogItem as aV, type CatalogItemInput as aW, type CatalogMappableDrug as aX, type CatalogMatrixCell as aY, type CatalogProduct as aZ, type CatalogReadiness as a_, type AffiliateAuthTokens as aa, type AffiliateClickRecord as ab, type AffiliateConversion as ac, type AffiliateDashboardLinks as ad, type AffiliateDashboardProfile as ae, type AffiliateDashboardStats as af, type AffiliateDownlineMember as ag, type AffiliateEarningsBreakdown as ah, type AffiliatePaymentMethod as ai, type AffiliateProgram as aj, type AffiliateRegisterInput as ak, type AffiliateRegisterResponse as al, type AffiliateSession as am, type AffiliateStatsResponse as an, type AffiliateStatus as ao, type AffiliateTrackResponse as ap, ApiError as aq, type ApiResponse as ar, type AttributionMethod as as, type AuthTokens as at, type BillingReminderSettings as au, type CatalogAvailabilityItem as av, type CatalogAvailabilityReason as aw, type CatalogAvailabilityResult as ax, type CatalogClassification as ay, type CatalogConversionChoice as az, type AddPharmacyDoseOption as b, type SurveySubmitPayload as b$, type CheckoutAddress as b0, type CheckoutPayload as b1, type CheckoutResult as b2, type CommissionConfig as b3, type CommissionStatus as b4, type CompleteSurveyPayload as b5, type CreateAffiliatePayload as b6, type CreateAffiliateProgramPayload as b7, type CreateOrderPayload as b8, type CreateRequestPayload as b9, type PlaceholderKind as bA, type ProductSaleSummary as bB, type ProductStrengthMatches as bC, type PromoValidationResponse as bD, type PublicCategory as bE, type RegisterAndSubscribePayload as bF, type RegisterPayload as bG, type RenewalStatus as bH, SUPPORT_ATTACHMENT_MAX_BYTES as bI, SUPPORT_ATTACHMENT_MIME_TYPES as bJ, type SelectDrugPayload as bK, type SendMessagePayload as bL, type SendToPharmacyPayload as bM, type StrengthMatchBody as bN, type StrengthMatchDoseOption as bO, type StrengthMatchRow as bP, type SubscriptionPreview as bQ, type SubscriptionPreviewLine as bR, type SubscriptionPreviewPayload as bS, type SupportAttachment as bT, type SupportChannel as bU, type SupportChannelSettings as bV, type SupportMessage as bW, type SupportRealtimeToken as bX, type SupportThread as bY, type SupportThreadCategory as bZ, type SupportThreadStatus as b_, type CreateSubscriptionPayload as ba, type CustomTemplate as bb, type CustomTemplateInput as bc, type CustomerDiscountConfig as bd, type DeliveryInfo as be, type DiscountType as bf, type EmailNotificationSettings as bg, type EmailTemplatesMap as bh, type LoginPayload as bi, type MemberOffer as bj, type MemberPrescriptionRequest as bk, type MemberSurveyMode as bl, type MemberSurveyResponseSummary as bm, type MemberSurveyTranscript as bn, type MemberSurveyTranscriptItem as bo, type MemberSurveyTranscriptSection as bp, type MembersMeResponse as bq, type OfferGrantState as br, type Order as bs, type OrderItemInput as bt, type PaginationParams as bu, type PaymentCallbackPayload as bv, type PaymentInitiatePayload as bw, type PaymentType as bx, type PendingRenewalSurvey as by, type Placeholder as bz, type AddPharmacyFinding as c, type TemplatePlaceholdersMap as c0, type TemplateText as c1, type TenantFeature as c2, type TenantFeatureAccess as c3, type TokenTrackName as c4, type UpdateAffiliatePayload as c5, type UpdateAffiliateProgramPayload as c6, type UpdatePaymentMethodPayload as c7, type UpdateProfilePayload as c8, type User as c9, promoCodesApi as cA, setAffiliateTokens as cB, setTokens as cC, subscriptionsApi as cD, supportApi as cE, usersApi as cF, addressesApi as ca, adminAffiliatesApi as cb, adminApi as cc, adminCatalogApi as cd, adminCatalogConversionApi as ce, adminProductPharmaciesApi as cf, adminProductStrengthMatchesApi as cg, affiliateAuthStorageKey as ch, affiliatePortalApi as ci, apexApi as cj, apiFetch as ck, authApi as cl, authStorageKey as cm, catalogApi as cn, clearAffiliateTokens as co, clearTokens as cp, getAffiliateTokens as cq, getTokens as cr, membersApi as cs, messagesApi as ct, newIdempotencyKey as cu, offersApi as cv, onTokensCleared as cw, ordersApi as cx, paymentsApi as cy, productsApi as cz, type AddPharmacyMatchQuestion as d, type AddPharmacyMatchSource as e, type AddPharmacyPlan as f, type AddPharmacyPrice as g, type AddPharmacyResult as h, type AddPharmacyStrengthAfter as i, type AddPharmacyStrengthBefore as j, type AddressVerifyResult as k, type AdminApexDrug as l, type AdminApexItemStatus as m, type AdminBillingAttempt as n, type AdminCategory as o, type AdminCategoryInput as p, type AdminCategoryUpdate as q, type AdminCustomer as r, type AdminCustomerFacts as s, type AdminCustomerFunnel as t, type AdminCustomerListParams as u, type AdminCustomerOverview as v, type AdminCustomerProfile as w, type AdminCustomerRequest as x, type AdminCustomerRow as y, type AdminCustomerSupport as z };
|