@feedmepos/mf-connect 0.1.123-dev → 0.1.124-dev
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/{App-BHqbxq_5.js → App-C7BnLHSt.js} +10 -10
- package/dist/{AuditLogs-FB5BGl_F.js → AuditLogs-BPKQdFga.js} +12 -12
- package/dist/{Bin-Bc5C_yvE.js → Bin-Bq7yY0I2.js} +8 -8
- package/dist/{Broadcast-CEJc8daU.js → Broadcast-D52rPmVl.js} +12 -12
- package/dist/{CampaignAnalytic-wUhISw-Z.js → CampaignAnalytic-DpiWtzIp.js} +7 -7
- package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BlLw8Tb5.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-B1eAAN64.js} +8 -8
- package/dist/{Card-uviAfIRX.js → Card-BQc7vud2.js} +22 -22
- package/dist/{Collections-COA2uZGw.js → Collections--VzkneGp.js} +8 -8
- package/dist/{Credit-Dh4GleW1.js → Credit-DhfAcw-p.js} +12 -12
- package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-DM-uzm4_.js → DateRangeChip.vue_vue_type_script_setup_true_lang-D2Csdg-3.js} +1 -1
- package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-9fDPd8x9.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-DFz_2GZ1.js} +35 -35
- package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-DorkQcT5.js → EffectSheet.vue_vue_type_style_index_0_lang-Cr2_XbyY.js} +6 -6
- package/dist/{Experience-oOmPXIh-.js → Experience-CUwbHfo5.js} +13 -13
- package/dist/{FileSaver.min-_q7Dx4wn.js → FileSaver.min-DvZpiwMd.js} +1 -1
- package/dist/{Game-BTfpDAXf.js → Game-CI5-y0JJ.js} +13 -13
- package/dist/{GiftCardSetup-FhOKl3OA.js → GiftCardSetup-CGacqQ0j.js} +10 -10
- package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-BWP_vdpd.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-B6POxDLJ.js} +7 -7
- package/dist/{Goals-A5qHITPJ.js → Goals-fqJY9iMx.js} +4 -4
- package/dist/{Grab-D7BOmVRB.js → Grab-CAx1cCE4.js} +9 -9
- package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-CqkwVS2r.js → ImageInput.vue_vue_type_script_setup_true_lang-DTKf7uR-.js} +1 -1
- package/dist/{Index-CuSQjKgG.js → Index-CT1Gnjsv.js} +10 -10
- package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-D6bURd7V.js → LocationPicker.vue_vue_type_script_setup_true_lang-BRQ12Yum.js} +1 -1
- package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-C3Nt5VLS.js → LottieAnimation.vue_vue_type_script_setup_true_lang-BRzuWJ1Y.js} +1 -1
- package/dist/{LoyaltyDashboard-B66W2agI.js → LoyaltyDashboard-IJIDEBWf.js} +15 -15
- package/dist/{MainLayout-CguQ_XOG.js → MainLayout-BMghr-wf.js} +1 -1
- package/dist/{MainLayout.vue_vue_type_script_setup_true_lang-ByHEOOgE.js → MainLayout.vue_vue_type_script_setup_true_lang-BitJKgvd.js} +3 -3
- package/dist/{Marketing-DsRvHFfJ.js → Marketing-Ckr9cp3w.js} +4 -4
- package/dist/{MarketingMaterialEdit-DLqupGle.js → MarketingMaterialEdit-BIZnE8CY.js} +6 -6
- package/dist/{Member-BlRWRmf7.js → Member-d1nPxr74.js} +7 -7
- package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-GZ5gUgb8.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-DI4XM_rJ.js} +23 -23
- package/dist/{MemberImportHistory-DxpuDRx4.js → MemberImportHistory-CxX9iYhV.js} +7 -7
- package/dist/{MemberList-DnKQ0nCm.js → MemberList-DUzYpxhj.js} +14 -14
- package/dist/{MemberTransactions-bs3canOe.js → MemberTransactions-BFM3ybeo.js} +1 -1
- package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-DRU6aeH8.js → MessageInput.vue_vue_type_script_setup_true_lang-B5j0YBix.js} +10 -10
- package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-BYH3qzyb.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-DsSHSbBB.js} +1 -1
- package/dist/{Mission-DHXh7T93.js → Mission-De9BF5wb.js} +14 -14
- package/dist/{Overview-CVQBgphM.js → Overview-DeHo3gef.js} +4 -4
- package/dist/{Overview-UAF9JSio.js → Overview-Pmxqv6qp.js} +20 -20
- package/dist/{Point-C6wv1uzT.js → Point-DE_Cc85N.js} +14 -14
- package/dist/{Promotion-CeZRHUed.js → Promotion-cZDzgho4.js} +14 -14
- package/dist/{Queue-BxTSJ6LA.js → Queue-DmDbrtTk.js} +12 -12
- package/dist/{Record-DoOyOT7I.js → Record-uxNNOvmK.js} +9 -9
- package/dist/{Review-BSpjwVxg.js → Review-CIIn_Bdx.js} +2 -2
- package/dist/{ReviewFacebookCallback-CMAQ_PXJ.js → ReviewFacebookCallback-CO6FxHzc.js} +5 -5
- package/dist/{ReviewGoogleCallback-D---BE3G.js → ReviewGoogleCallback-B7kmGwb_.js} +5 -5
- package/dist/{Reward-BC2PCxwA.js → Reward-Bj1snFu8.js} +16 -16
- package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-VV8I4Pnl.js → RewardGroup.vue_vue_type_script_setup_true_lang-BO-36dE4.js} +13 -13
- package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-DmOKmXkP.js → RuleGroup.vue_vue_type_script_setup_true_lang-b7ZEMd4s.js} +14 -14
- package/dist/{Segment-CcRapIdF.js → Segment-BgJgWa6C.js} +25 -25
- package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-D9Ino3uS.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-D2TDoZgQ.js} +14 -14
- package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-C42YDmfw.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-CEBH11hR.js} +4 -4
- package/dist/{Setting-CTWV-j-u.js → Setting-DpEI72mW.js} +14 -14
- package/dist/{SettingAdvertisements-1WCqp0FF.js → SettingAdvertisements-vdUtIXwC.js} +12 -12
- package/dist/{Settings-BxgqmIBl.js → Settings-C6yJ1WEB.js} +5 -5
- package/dist/{Store-uhCU5WYY.js → Store-DgltT0RA.js} +26 -26
- package/dist/{StoreRewards-DjgbbZsB.js → StoreRewards-BXH_5cYL.js} +15 -15
- package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-BgT5nChN.js → StoreTransactions.vue_vue_type_script_setup_true_lang-DqlluwMB.js} +24 -24
- package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BAUBxdV2.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DjCO9U0c.js} +2 -2
- package/dist/{Tier-B6sp_dj5.js → Tier-CqfHGUX0.js} +26 -26
- package/dist/{Title-Dew9vKN4.js → Title-B5VnUNiS.js} +22 -22
- package/dist/{Transaction-ITefNWob.js → Transaction-BZh1Q9Lj.js} +2 -2
- package/dist/{Upselling-AMpfgEvH.js → Upselling-Cf24ub-9.js} +318 -305
- package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-B4LP8LZ-.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Buj7CRlQ.js} +6 -6
- package/dist/{Voucher-CRP6KY1f.js → Voucher-CZJdV2Ok.js} +18 -18
- package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-BZEJecca.js → VoucherEditor.vue_vue_type_script_setup_true_lang-65x2VrpD.js} +12 -12
- package/dist/{WhatsappAccount-MkutDvBs.js → WhatsappAccount-DsRilNC5.js} +6 -6
- package/dist/{WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-vDLl0J7v.js → WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-Bn26qwx5.js} +1 -1
- package/dist/{WhatsappBot-B0m21qPb.js → WhatsappBot-CpzMaTss.js} +6 -6
- package/dist/{WhatsappBotLogs-BHyoUuef.js → WhatsappBotLogs-DRF8VufQ.js} +6 -6
- package/dist/{WhatsappBotSettings-BbiHQ3Qb.js → WhatsappBotSettings-DSUPGC-p.js} +4 -4
- package/dist/{WhatsappLayout-yq05I3IA.js → WhatsappLayout-BCWYcQmD.js} +3 -3
- package/dist/{WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-BrjbWgKf.js → WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-DyxyISRP.js} +3 -3
- package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-CLiZ6jd6.js → ZodTextField.vue_vue_type_script_setup_true_lang-Db-Z7cY_.js} +2 -2
- package/dist/{app-Ce3Q-VS4.js → app-BQeODViN.js} +70 -70
- package/dist/app.js +1 -1
- package/dist/{base.export-Ds3PiiHA.js → base.export-kSFLDDoC.js} +2 -2
- package/dist/{business-CfxfaERu.js → business-EP-Do3Ew.js} +1 -1
- package/dist/{campaign-CtX-q7KI.js → campaign-BjnUPowX.js} +2 -2
- package/dist/{campaign-COuKKIRA.js → campaign-C8GgaCub.js} +8 -8
- package/dist/{campaign.fn-oUqhH0SU.js → campaign.fn-DQ--gL4B.js} +30 -30
- package/dist/{collection.fn-PhjmENfo.js → collection.fn-BhXecwh5.js} +2 -2
- package/dist/{currency-DmSaw6iQ.js → currency-CGMNh1Q_.js} +1 -1
- package/dist/{duplicateCampaign-DzF45eaZ.js → duplicateCampaign-icqF8Na9.js} +2 -2
- package/dist/{effect-sAKjjlrO.js → effect-Bc6oGIWd.js} +1 -1
- package/dist/{email-addresses-jSqlPLwS.js → email-addresses-B3KWfUMk.js} +2 -2
- package/dist/{feature-flag-Dvz3D7kC.js → feature-flag-HhjvSuDm.js} +1 -1
- package/dist/{helper-Dn6pU0yd.js → helper-D1BYvcED.js} +1 -1
- package/dist/{index-BrqespAR.js → index-BIBcfAw5.js} +1 -1
- package/dist/{index-CUaL0i4I.js → index-BkevK_Hp.js} +1 -1
- package/dist/{index-8wWIydMw.js → index-Br2SLVsn.js} +7 -7
- package/dist/{index-2B_HRy_7.js → index-Bunp1bt_.js} +1 -1
- package/dist/{index--A062GN8.js → index-C-46QHFh.js} +4 -4
- package/dist/{index-BoFxBf97.js → index-C3MK8Twg.js} +1 -1
- package/dist/{index-DFAceV6T.js → index-CsYTLmPa.js} +1 -1
- package/dist/{index-BiBBY6Sk.js → index-D2TnjKPP.js} +2 -2
- package/dist/{index-CjAhwLNW.js → index-DCC3pLug.js} +2 -2
- package/dist/{index-CRFiQOrt.js → index-DOSuhtdE.js} +1 -1
- package/dist/{index-pCmNLjIj.js → index-DeqpfWLa.js} +3 -3
- package/dist/{index-D6wQPKHc.js → index-DiCgGQoC.js} +2 -2
- package/dist/{index-C4O-Fym0.js → index-GQv1_jaJ.js} +2 -2
- package/dist/{index-Bu2uqM4e.js → index-Ptcqv0W6.js} +2 -2
- package/dist/{index-B_GA0PSb.js → index-VLFerh-X.js} +8 -8
- package/dist/{index-C8fp9YtA.js → index-VyoufKYY.js} +1 -1
- package/dist/{index-Cgg1NNfN.js → index-Yw4M7v7m.js} +2 -2
- package/dist/{index-Aqx0Hc_6.js → index-cPPWotJe.js} +2 -2
- package/dist/{index-B_aWWeg9.js → index-gMrtUwSD.js} +129 -129
- package/dist/{index-bGITzW-d.js → index-oIo5Cful.js} +4 -4
- package/dist/{index.esm2017-ChJMTCyQ.js → index.esm2017-DUZpLdEB.js} +1 -1
- package/dist/{loading-DhiMqWJA.js → loading-DhpcQgdj.js} +1 -1
- package/dist/{lodash-CCBK4pXz.js → lodash-r4AR7GJC.js} +1 -1
- package/dist/{member-import-BUvsg-Lu.js → member-import-CogEef9H.js} +1 -1
- package/dist/{membership-7X3Uc50t.js → membership-BQFkjRjs.js} +2 -2
- package/dist/{money-D5EIeVr_.js → money-Ifqd4pyC.js} +1 -1
- package/dist/{number-Bj7X6VoA.js → number-C9Tw_Ncm.js} +1 -1
- package/dist/{objectid-CzFM8vy5.js → objectid-D7dqM1a3.js} +6 -6
- package/dist/{onboarding-0mA1gXrv.js → onboarding-D4dm_rxU.js} +3 -3
- package/dist/{onboardingSetup-BBPg-cAT.js → onboardingSetup-DtNZUoRr.js} +2 -2
- package/dist/{plugins-bprg7ahs.js → plugins-DGI9Fkiu.js} +3 -3
- package/dist/{reward-WTxymIQH.js → reward-DTtejZqM.js} +1 -1
- package/dist/{rule-hJuK8Yqw.js → rule-C4N3ce3c.js} +9 -9
- package/dist/{template-wt4Q2S3f.js → template-YhWRyNGp.js} +6 -6
- package/dist/{timezone-BWkDzpwA.js → timezone-5rYhX7XZ.js} +1 -1
- package/dist/{transaction.fn-DzwtEBIZ.js → transaction.fn-Ba_U7HdT.js} +2 -2
- package/dist/{trigger-D6hitqvM.js → trigger-B8I1aO6Y.js} +5 -5
- package/dist/{useMarketingMaterialActions-ByWwvQRt.js → useMarketingMaterialActions-CTOFHmlL.js} +4 -4
- package/dist/{usePagination-Mr6qWVOa.js → usePagination-3wAPVCOp.js} +1 -1
- package/dist/{user-Dpl2lhox.js → user-Ds4DW_-Y.js} +1 -1
- package/dist/{vue-i18n-BEFR04bc.js → vue-i18n-Bqlt_-jA.js} +109 -109
- package/dist/{xlsx-Cu5ybiy4.js → xlsx-xlOCvuAq.js} +166 -166
- package/dist/{zod-CcKqtEqX.js → zod-GVNjvrpT.js} +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as he, computed as W, ref as O, watch as K, reactive as Ce, onMounted as Te, onBeforeUnmount as ce, openBlock as p, createElementBlock as w, unref as i, createElementVNode as h, toDisplayString as b, createCommentVNode as _, createBlock as ne, createVNode as se, createTextVNode as $e, Fragment as ue, renderList as ie, withCtx as Se, normalizeClass as Ee, normalizeStyle as je, shallowRef as xe, TransitionGroup as Me } from "vue";
|
|
2
2
|
import { onBeforeRouteLeave as Ne } from "vue-router";
|
|
3
|
-
import { useCoreStore as
|
|
4
|
-
import { components as
|
|
5
|
-
import { z as c } from "./app-
|
|
6
|
-
import { S as
|
|
7
|
-
import { f as Le } from "./currency-
|
|
8
|
-
const
|
|
3
|
+
import { useCoreStore as pe } from "@feedmepos/mf-common";
|
|
4
|
+
import { components as Pe } from "@feedmepos/ui-library";
|
|
5
|
+
import { z as c } from "./app-BQeODViN.js";
|
|
6
|
+
import { S as Ue, a as _e } from "./index-cPPWotJe.js";
|
|
7
|
+
import { f as Le } from "./currency-CGMNh1Q_.js";
|
|
8
|
+
const Be = {
|
|
9
9
|
title: "Upselling settings",
|
|
10
10
|
description: "Adjust product weight. Higher weight gives a product more priority in recommendations.",
|
|
11
11
|
businessDefault: "Business defaults",
|
|
@@ -90,79 +90,79 @@ const We = {
|
|
|
90
90
|
}, re = (e) => e.map((t) => ({ ...t })), de = (e) => JSON.stringify(
|
|
91
91
|
[...e].sort((t, a) => t.productId.localeCompare(a.productId))
|
|
92
92
|
);
|
|
93
|
-
function
|
|
94
|
-
const t =
|
|
93
|
+
function We(e) {
|
|
94
|
+
const t = xe([]), a = O([]), r = O([]), m = O(!1), I = O(!1), k = O(!1), l = O(null), A = O(!1), s = O(!1), P = W(() => de(a.value) !== de(r.value)), R = Ce(/* @__PURE__ */ new Map()), T = W(() => P.value || R.size > 0), L = (E) => JSON.stringify([E.businessId, E.restaurantId]);
|
|
95
95
|
let N = "", S = 0;
|
|
96
|
-
const
|
|
97
|
-
const
|
|
96
|
+
const B = W(() => new Map(a.value.map((E) => [E.productId, E]))), X = W(() => {
|
|
97
|
+
const E = new Set(t.value.map((U) => U.productId));
|
|
98
98
|
return [
|
|
99
|
-
...t.value.map((
|
|
100
|
-
...a.value.filter((
|
|
101
|
-
productId:
|
|
102
|
-
name:
|
|
99
|
+
...t.value.map((U) => ({ ...U, unavailable: !1 })),
|
|
100
|
+
...a.value.filter((U) => !E.has(U.productId)).map((U) => ({
|
|
101
|
+
productId: U.productId,
|
|
102
|
+
name: U.productId,
|
|
103
103
|
unavailable: !0
|
|
104
104
|
}))
|
|
105
105
|
];
|
|
106
106
|
});
|
|
107
107
|
function q() {
|
|
108
|
-
N && k.value && (
|
|
108
|
+
N && k.value && (P.value ? R.set(N, { items: re(a.value), baseline: re(r.value) }) : R.delete(N));
|
|
109
109
|
}
|
|
110
110
|
async function F() {
|
|
111
111
|
q();
|
|
112
|
-
const
|
|
113
|
-
if (N = L(
|
|
112
|
+
const E = ++S, U = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
|
|
113
|
+
if (N = L(U), a.value = [], r.value = [], t.value = [], k.value = !1, I.value = !1, l.value = null, A.value = !1, s.value = !1, m.value = !!U.businessId, !!m.value)
|
|
114
114
|
try {
|
|
115
|
-
const [j, V] = await Promise.all([e.api.get(
|
|
116
|
-
if (
|
|
117
|
-
if (j.businessId !==
|
|
115
|
+
const [j, V] = await Promise.all([e.api.get(U), e.loadProducts(U)]);
|
|
116
|
+
if (E !== S) return;
|
|
117
|
+
if (j.businessId !== U.businessId || (j.restaurantId || void 0) !== U.restaurantId)
|
|
118
118
|
throw new Error("Settings scope mismatch");
|
|
119
|
-
const M =
|
|
120
|
-
r.value = re((M == null ? void 0 : M.baseline) ?? j.items), a.value = re((M == null ? void 0 : M.items) ?? j.items),
|
|
119
|
+
const M = R.get(N);
|
|
120
|
+
r.value = re((M == null ? void 0 : M.baseline) ?? j.items), a.value = re((M == null ? void 0 : M.items) ?? j.items), s.value = j.inherited === !0, t.value = V, k.value = !0;
|
|
121
121
|
} catch {
|
|
122
|
-
|
|
122
|
+
E === S && (l.value = "load");
|
|
123
123
|
} finally {
|
|
124
|
-
|
|
124
|
+
E === S && (m.value = !1);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
function D(
|
|
127
|
+
function D(E, U) {
|
|
128
128
|
if (!k.value || I.value) return;
|
|
129
|
-
const j =
|
|
130
|
-
j ? Object.assign(j,
|
|
129
|
+
const j = B.value.get(E);
|
|
130
|
+
j ? Object.assign(j, U) : a.value.push({ productId: E, adjustWeight: !1, weight: 0.5, ...U }), l.value = null, A.value = !1;
|
|
131
131
|
}
|
|
132
132
|
function J() {
|
|
133
|
-
I.value || (a.value = re(r.value),
|
|
133
|
+
I.value || (a.value = re(r.value), R.delete(N), l.value = null, A.value = !1);
|
|
134
134
|
}
|
|
135
|
-
async function x(
|
|
136
|
-
if (!k.value || I.value || !
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
135
|
+
async function x(E = !1) {
|
|
136
|
+
if (!k.value || I.value || !E && !P.value) return;
|
|
137
|
+
const U = S, j = N, V = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
|
|
138
|
+
if (E && (!V.restaurantId || !e.api.reset) || L(V) !== j) return;
|
|
139
139
|
const M = re(a.value);
|
|
140
|
-
I.value = !0,
|
|
140
|
+
I.value = !0, A.value = !1, l.value = null;
|
|
141
141
|
try {
|
|
142
|
-
const z =
|
|
142
|
+
const z = E ? await e.api.reset(V) : await e.api.save(V, M);
|
|
143
143
|
if (z.businessId !== V.businessId || (z.restaurantId || void 0) !== V.restaurantId)
|
|
144
144
|
throw new Error("Settings scope mismatch");
|
|
145
|
-
if (
|
|
146
|
-
const G =
|
|
147
|
-
j !== N && G && de(G.items) === de(M) &&
|
|
145
|
+
if (U !== S) {
|
|
146
|
+
const G = R.get(j);
|
|
147
|
+
j !== N && G && de(G.items) === de(M) && R.delete(j);
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
return a.value = re(z.items), r.value = re(z.items),
|
|
150
|
+
return a.value = re(z.items), r.value = re(z.items), s.value = z.inherited === !0, R.delete(j), A.value = !0, z;
|
|
151
151
|
} catch {
|
|
152
|
-
|
|
152
|
+
U === S && (l.value = "save");
|
|
153
153
|
} finally {
|
|
154
|
-
|
|
154
|
+
U === S && (I.value = !1);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return K(() => [e.businessId, e.restaurantId, e.api, e.loadProducts], F, { immediate: !0, flush: "sync" }), ce(() => {
|
|
158
158
|
S++;
|
|
159
|
-
}), { hasUnsaved:
|
|
159
|
+
}), { hasUnsaved: T, items: a, baseline: r, itemMap: B, rows: X, loaded: k, loading: m, saving: I, dirty: P, error: l, saved: A, inherited: s, load: F, save: () => x(), reset: () => x(!0), change: D, discard: J };
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function me(e, t = 5) {
|
|
162
162
|
const a = e.filter((m) => !m.unit && !m.perXUnit && !m.isOutOfStocked), r = Math.min(a.length, 5, Math.max(0, Math.floor(t)));
|
|
163
163
|
return a.slice(0, r % 2 === 0 ? Math.max(0, r - 1) : r);
|
|
164
164
|
}
|
|
165
|
-
const
|
|
165
|
+
const be = (e) => JSON.stringify([e.businessId, e.restaurantId || void 0]), Fe = (e, t) => (e == null ? void 0 : e.adjustWeight) === t.adjustWeight && (e == null ? void 0 : e.weight) === t.weight;
|
|
166
166
|
function De(e, t) {
|
|
167
167
|
const a = new Map(e.map((r) => [r.productId, r]));
|
|
168
168
|
return t.filter((r) => !Fe(a.get(r.productId), r)).map((r) => ({ ...r }));
|
|
@@ -185,10 +185,10 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
185
185
|
}, dt = ["data-active"], ct = ["data-active"], pt = ["role"], vt = {
|
|
186
186
|
key: 2,
|
|
187
187
|
class: "upsell-preview-none"
|
|
188
|
-
}, mt = ["data-preview-product"],
|
|
188
|
+
}, mt = ["data-preview-product"], gt = ["src", "onError"], ht = {
|
|
189
189
|
key: 1,
|
|
190
190
|
class: "upsell-preview-photo"
|
|
191
|
-
}, wt = { key: 0 }, yt = /* @__PURE__ */
|
|
191
|
+
}, wt = { key: 0 }, yt = /* @__PURE__ */ he({
|
|
192
192
|
__name: "UpsellPreview",
|
|
193
193
|
props: {
|
|
194
194
|
host: {},
|
|
@@ -199,95 +199,95 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
199
199
|
touchpoints: {}
|
|
200
200
|
},
|
|
201
201
|
setup(e) {
|
|
202
|
-
const t = e, { FmSelect: a, FmButton: r } =
|
|
203
|
-
let L = 0, N = "", S,
|
|
202
|
+
const t = e, { FmSelect: a, FmButton: r } = Pe, m = O([]), I = O(""), k = O("restaurant"), l = O([]), A = O(!1), s = O(!1), P = O(!1), R = O(/* @__PURE__ */ new Set()), T = O(null);
|
|
203
|
+
let L = 0, N = "", S, B, X = !1, q;
|
|
204
204
|
ce(() => {
|
|
205
205
|
X = !0, L++, clearTimeout(q);
|
|
206
206
|
});
|
|
207
|
-
const F =
|
|
208
|
-
var
|
|
209
|
-
return ((
|
|
210
|
-
}), J =
|
|
207
|
+
const F = W(() => m.value.find((g) => g.scope.restaurantId === I.value)), D = W(() => {
|
|
208
|
+
var g;
|
|
209
|
+
return ((g = F.value) == null ? void 0 : g.products) ?? [];
|
|
210
|
+
}), J = W(() => D.value.filter((g) => !l.value.some((C) => C.productId === g.productId)).map((g) => ({ value: g.productId, label: g.name }))), x = W(() => m.value.map((g) => ({ value: g.scope.restaurantId, label: g.name }))), E = W(() => [
|
|
211
211
|
{ value: "restaurant", label: t.text.previewRestaurant },
|
|
212
212
|
{ value: "cart", label: t.text.previewCartBased }
|
|
213
|
-
]),
|
|
214
|
-
var
|
|
213
|
+
]), U = W(() => {
|
|
214
|
+
var g, C, v, y, o, $;
|
|
215
215
|
return [
|
|
216
|
-
{ id: "saved", title: t.text.previewSaved, products: ((
|
|
217
|
-
{ id: "draft", title: t.text.previewDraft, products: ((y =
|
|
216
|
+
{ id: "saved", title: t.text.previewSaved, products: ((g = T.value) == null ? void 0 : g.saved.products) ?? [], source: (C = T.value) == null ? void 0 : C.saved.source, weightsEnabled: (v = T.value) == null ? void 0 : v.saved.weightsEnabled },
|
|
217
|
+
{ id: "draft", title: t.text.previewDraft, products: ((y = T.value) == null ? void 0 : y.draft.products) ?? [], source: (o = T.value) == null ? void 0 : o.draft.source, weightsEnabled: ($ = T.value) == null ? void 0 : $.draft.weightsEnabled }
|
|
218
218
|
];
|
|
219
|
-
}), j =
|
|
220
|
-
var
|
|
221
|
-
return
|
|
219
|
+
}), j = W(() => {
|
|
220
|
+
var g;
|
|
221
|
+
return P.value || s.value ? t.text.previewLoadError : F.value ? k.value === "cart" && !l.value.length ? t.text.previewCartEmpty : (g = t.host) != null && g.loadPreview ? A.value && !T.value ? t.text.previewLoading : "" : t.text.previewUnavailable : t.text.previewChooseOutlet;
|
|
222
222
|
});
|
|
223
223
|
async function V() {
|
|
224
|
-
var
|
|
225
|
-
|
|
224
|
+
var g, C;
|
|
225
|
+
P.value = !1;
|
|
226
226
|
try {
|
|
227
227
|
const v = t.host;
|
|
228
228
|
let y = [];
|
|
229
229
|
if (v != null && v.loadApplyTargets ? y = await v.loadApplyTargets(v.businessId) : v != null && v.restaurantId && (y = [{ scope: { businessId: v.businessId, restaurantId: v.restaurantId }, name: v.restaurantName ?? v.restaurantId, products: t.products }]), X) return;
|
|
230
|
-
m.value = y.filter((o) => (!(v != null && v.restaurantId) || o.scope.restaurantId === v.restaurantId) && o.scope.restaurantId && o.scope.businessId === (v == null ? void 0 : v.businessId) && !o.unavailableReason), I.value = ((
|
|
230
|
+
m.value = y.filter((o) => (!(v != null && v.restaurantId) || o.scope.restaurantId === v.restaurantId) && o.scope.restaurantId && o.scope.businessId === (v == null ? void 0 : v.businessId) && !o.unavailableReason), I.value = ((g = m.value.find((o) => o.scope.restaurantId === (v == null ? void 0 : v.restaurantId))) == null ? void 0 : g.scope.restaurantId) ?? ((C = m.value[0]) == null ? void 0 : C.scope.restaurantId) ?? "";
|
|
231
231
|
} catch {
|
|
232
|
-
X || (
|
|
232
|
+
X || (P.value = !0);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
Te(V), K(I, () => {
|
|
236
|
+
l.value = [], R.value = /* @__PURE__ */ new Set();
|
|
237
237
|
});
|
|
238
|
-
function M(
|
|
239
|
-
J.value.some((C) => C.value ===
|
|
238
|
+
function M(g) {
|
|
239
|
+
J.value.some((C) => C.value === g) && (l.value = [...l.value, { productId: g, quantity: 1 }]);
|
|
240
240
|
}
|
|
241
|
-
function z(
|
|
242
|
-
const v = Number(C.target.value), y =
|
|
241
|
+
function z(g, C) {
|
|
242
|
+
const v = Number(C.target.value), y = l.value.find((o) => o.productId === g);
|
|
243
243
|
y && (y.quantity = Number.isInteger(v) && v >= 1 && v <= 99 ? v : 1), C.target.value = String((y == null ? void 0 : y.quantity) ?? 1);
|
|
244
244
|
}
|
|
245
|
-
function G(
|
|
246
|
-
if (!
|
|
247
|
-
const v =
|
|
245
|
+
function G(g, C) {
|
|
246
|
+
if (!g || !["historical", "weight_only", "no_data", "unknown"].includes(g.source) || !Array.isArray(g.products)) throw new Error("Invalid preview products");
|
|
247
|
+
const v = g.products.map((y) => y.productId);
|
|
248
248
|
if (v.some((y) => !C.has(y)) || new Set(v).size !== v.length) throw new Error("Invalid preview products");
|
|
249
249
|
}
|
|
250
|
-
async function Z(
|
|
251
|
-
|
|
250
|
+
async function Z(g = !0) {
|
|
251
|
+
g && (S = void 0, B = void 0), clearTimeout(q);
|
|
252
252
|
const C = ++L;
|
|
253
|
-
|
|
253
|
+
s.value = !1, A.value = !1;
|
|
254
254
|
const v = t.host, y = F.value, o = `${v == null ? void 0 : v.businessId}:${y == null ? void 0 : y.scope.restaurantId}:${k.value}`;
|
|
255
|
-
if (o !== N && (
|
|
256
|
-
|
|
255
|
+
if (o !== N && (T.value = null), N = o, !(v != null && v.loadPreview) || !(y != null && y.scope.restaurantId) || k.value === "cart" && !l.value.length) {
|
|
256
|
+
T.value = null;
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
const $ = { businessId: v.businessId, restaurantId: y.scope.restaurantId }, ee = k.value,
|
|
260
|
-
|
|
259
|
+
const $ = { businessId: v.businessId, restaurantId: y.scope.restaurantId }, ee = k.value, Y = ee === "cart" ? l.value.map((Q) => ({ ...Q })) : [], te = new Set(y.products.map((Q) => Q.productId)), H = De(t.savedItems, t.draftItems).filter((Q) => te.has(Q.productId)), ae = v.loadPreview;
|
|
260
|
+
A.value = !0;
|
|
261
261
|
try {
|
|
262
262
|
const Q = await (S ?? (S = v.api.get($)));
|
|
263
263
|
if (C !== L) return;
|
|
264
|
-
if (
|
|
265
|
-
const oe = (f) => ({ ...$, catalog: y.products, recommendationType: ee, cart:
|
|
266
|
-
|
|
267
|
-
const n = await Promise.all([
|
|
264
|
+
if (be(Q) !== be($)) throw new Error("Preview scope mismatch");
|
|
265
|
+
const oe = (f) => ({ ...$, catalog: y.products, recommendationType: ee, cart: Y.map((le) => ({ ...le })), items: f.filter((le) => te.has(le.productId)).map((le) => ({ ...le })), limit: 5 }), u = v.restaurantId || Q.inherited === !0 ? H : [], d = [{ ...oe(Q.items), mode: "current" }, { ...oe(Ve(Q.items, u)), mode: "preview" }];
|
|
266
|
+
B ?? (B = ae(d[0]));
|
|
267
|
+
const n = await Promise.all([B, ae(d[1])]);
|
|
268
268
|
if (C !== L) return;
|
|
269
|
-
n.forEach((f) => G(f, te)),
|
|
269
|
+
n.forEach((f) => G(f, te)), T.value = { saved: { ...n[0], weightsEnabled: d[0].items.some((f) => f.adjustWeight), products: me(n[0].products) }, draft: { ...n[1], weightsEnabled: d[1].items.some((f) => f.adjustWeight), products: me(n[1].products) } };
|
|
270
270
|
} catch {
|
|
271
|
-
C === L && (S = void 0,
|
|
271
|
+
C === L && (S = void 0, B = void 0, T.value = null, s.value = !0);
|
|
272
272
|
} finally {
|
|
273
|
-
C === L && (
|
|
273
|
+
C === L && (A.value = !1);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
return
|
|
277
|
-
var
|
|
278
|
-
return [F.value, k.value,
|
|
279
|
-
}, () => Z(), { deep: !0, flush: "post" }),
|
|
280
|
-
var
|
|
281
|
-
L++,
|
|
282
|
-
}, { deep: !0 }), (
|
|
276
|
+
return K(() => {
|
|
277
|
+
var g, C, v, y;
|
|
278
|
+
return [F.value, k.value, l.value, t.savedItems, (g = t.host) == null ? void 0 : g.loadPreview, (C = t.host) == null ? void 0 : C.api, (v = t.host) == null ? void 0 : v.businessId, (y = t.host) == null ? void 0 : y.restaurantId];
|
|
279
|
+
}, () => Z(), { deep: !0, flush: "post" }), K(() => t.draftItems, () => {
|
|
280
|
+
var g;
|
|
281
|
+
L++, s.value = !1, A.value = !!((g = t.host) != null && g.loadPreview), clearTimeout(q), q = setTimeout(() => Z(!1), 250);
|
|
282
|
+
}, { deep: !0 }), (g, C) => {
|
|
283
283
|
var v, y;
|
|
284
284
|
return ((v = e.touchpoints) == null ? void 0 : v.length) !== 0 ? (p(), w("section", {
|
|
285
285
|
key: 0,
|
|
286
286
|
class: "upsell-preview",
|
|
287
287
|
"aria-label": e.text.preview
|
|
288
288
|
}, [
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
h("header", qe, [
|
|
290
|
+
h("h2", ze, b(e.text.preview), 1),
|
|
291
291
|
(y = e.host) != null && y.restaurantId ? _("", !0) : (p(), ne(i(a), {
|
|
292
292
|
key: 0,
|
|
293
293
|
modelValue: I.value,
|
|
@@ -295,12 +295,12 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
295
295
|
label: e.text.previewOutlet,
|
|
296
296
|
items: x.value
|
|
297
297
|
}, null, 8, ["modelValue", "label", "items"])),
|
|
298
|
-
|
|
298
|
+
h("div", {
|
|
299
299
|
class: "upsell-preview-tabs",
|
|
300
300
|
role: "group",
|
|
301
301
|
"aria-label": e.text.preview
|
|
302
302
|
}, [
|
|
303
|
-
(p(!0), w(ue, null, ie(
|
|
303
|
+
(p(!0), w(ue, null, ie(E.value, (o) => (p(), w("button", {
|
|
304
304
|
key: o.value,
|
|
305
305
|
type: "button",
|
|
306
306
|
"aria-pressed": k.value === o.value,
|
|
@@ -315,18 +315,18 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
315
315
|
items: J.value,
|
|
316
316
|
"onUpdate:modelValue": M
|
|
317
317
|
}, null, 8, ["label", "items"]),
|
|
318
|
-
|
|
319
|
-
(p(!0), w(ue, null, ie(
|
|
320
|
-
var $, ee,
|
|
318
|
+
h("ul", Ke, [
|
|
319
|
+
(p(!0), w(ue, null, ie(l.value, (o) => {
|
|
320
|
+
var $, ee, Y, te;
|
|
321
321
|
return p(), w("li", {
|
|
322
322
|
key: o.productId,
|
|
323
323
|
"data-cart-product": o.productId
|
|
324
324
|
}, [
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
C[2] || (C[2] =
|
|
329
|
-
|
|
325
|
+
h("span", null, b(($ = D.value.find((H) => H.productId === o.productId)) == null ? void 0 : $.name), 1),
|
|
326
|
+
h("label", Ge, [
|
|
327
|
+
h("span", Ze, b(e.text.previewQuantity) + ": " + b((ee = D.value.find((H) => H.productId === o.productId)) == null ? void 0 : ee.name), 1),
|
|
328
|
+
C[2] || (C[2] = h("span", { "aria-hidden": "true" }, "×", -1)),
|
|
329
|
+
h("input", {
|
|
330
330
|
type: "number",
|
|
331
331
|
min: "1",
|
|
332
332
|
max: "99",
|
|
@@ -334,21 +334,21 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
334
334
|
onChange: (H) => z(o.productId, H)
|
|
335
335
|
}, null, 40, et)
|
|
336
336
|
]),
|
|
337
|
-
|
|
337
|
+
h("button", {
|
|
338
338
|
type: "button",
|
|
339
339
|
class: "upsell-preview-remove",
|
|
340
|
-
"aria-label": `${e.text.previewRemove} ${(
|
|
340
|
+
"aria-label": `${e.text.previewRemove} ${(Y = D.value.find((H) => H.productId === o.productId)) == null ? void 0 : Y.name}`,
|
|
341
341
|
title: `${e.text.previewRemove} ${(te = D.value.find((H) => H.productId === o.productId)) == null ? void 0 : te.name}`,
|
|
342
|
-
onClick: (H) =>
|
|
342
|
+
onClick: (H) => l.value = l.value.filter((ae) => ae.productId !== o.productId)
|
|
343
343
|
}, [...C[3] || (C[3] = [
|
|
344
|
-
|
|
344
|
+
h("svg", {
|
|
345
345
|
width: "16",
|
|
346
346
|
height: "16",
|
|
347
347
|
viewBox: "0 0 24 24",
|
|
348
348
|
fill: "none",
|
|
349
349
|
"aria-hidden": "true"
|
|
350
350
|
}, [
|
|
351
|
-
|
|
351
|
+
h("path", {
|
|
352
352
|
d: "m6 6 12 12M18 6 6 18",
|
|
353
353
|
stroke: "currentColor",
|
|
354
354
|
"stroke-width": "1.8",
|
|
@@ -359,35 +359,35 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
359
359
|
], 8, Ye);
|
|
360
360
|
}), 128))
|
|
361
361
|
]),
|
|
362
|
-
|
|
362
|
+
h("p", at, b(e.text.previewCartQuantities), 1)
|
|
363
363
|
])) : _("", !0),
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
A.value && T.value ? (p(), w("p", rt, b(e.text.previewLoading), 1)) : _("", !0),
|
|
365
|
+
h("div", {
|
|
366
366
|
class: "upsell-preview-panels",
|
|
367
|
-
"aria-busy":
|
|
367
|
+
"aria-busy": A.value
|
|
368
368
|
}, [
|
|
369
|
-
(p(!0), w(ue, null, ie(
|
|
369
|
+
(p(!0), w(ue, null, ie(U.value, (o) => (p(), w("article", {
|
|
370
370
|
key: o.id,
|
|
371
371
|
"data-preview": o.id,
|
|
372
372
|
class: "upsell-preview-panel"
|
|
373
373
|
}, [
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
h("div", nt, [
|
|
375
|
+
h("h3", ot, b(o.title), 1)
|
|
376
376
|
]),
|
|
377
|
-
|
|
377
|
+
h("div", ut, [
|
|
378
378
|
o.source && o.source !== "unknown" ? (p(), w("div", it, [
|
|
379
|
-
|
|
379
|
+
h("span", {
|
|
380
380
|
"data-active": o.weightsEnabled
|
|
381
381
|
}, b(o.weightsEnabled ? e.text.previewWeightsOn : e.text.previewWeightsOff), 9, dt),
|
|
382
|
-
|
|
382
|
+
h("span", {
|
|
383
383
|
"data-active": o.source === "historical"
|
|
384
384
|
}, b(o.source === "historical" ? e.text.previewRelevanceOn : e.text.previewRelevanceOff), 9, ct)
|
|
385
385
|
])) : _("", !0),
|
|
386
386
|
j.value ? (p(), w("p", {
|
|
387
387
|
key: 1,
|
|
388
|
-
class:
|
|
389
|
-
role:
|
|
390
|
-
}, b(j.value), 11, pt)) :
|
|
388
|
+
class: Ee(["upsell-preview-none", { "upsell-error": s.value || P.value }]),
|
|
389
|
+
role: s.value || P.value ? "alert" : "status"
|
|
390
|
+
}, b(j.value), 11, pt)) : T.value && !o.products.length ? (p(), w("p", vt, b(o.source === "no_data" ? e.text.previewNoData : e.text.previewEmpty), 1)) : (p(), ne(Me, {
|
|
391
391
|
key: 3,
|
|
392
392
|
tag: "ul",
|
|
393
393
|
name: "upsell-suggestion",
|
|
@@ -398,15 +398,15 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
398
398
|
key: $.productId,
|
|
399
399
|
"data-preview-product": $.productId
|
|
400
400
|
}, [
|
|
401
|
-
$.imageUrl && !
|
|
401
|
+
$.imageUrl && !R.value.has($.productId) ? (p(), w("img", {
|
|
402
402
|
key: 0,
|
|
403
403
|
src: $.imageUrl,
|
|
404
404
|
alt: "",
|
|
405
405
|
loading: "lazy",
|
|
406
|
-
onError: (ee) =>
|
|
407
|
-
}, null, 40,
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
onError: (ee) => R.value.add($.productId)
|
|
407
|
+
}, null, 40, gt)) : (p(), w("span", ht, b(e.text.missingPhoto), 1)),
|
|
408
|
+
h("div", null, [
|
|
409
|
+
h("h4", null, b($.name), 1),
|
|
410
410
|
$.priceLabel ? (p(), w("p", wt, b($.priceLabel), 1)) : _("", !0)
|
|
411
411
|
])
|
|
412
412
|
], 8, mt))), 128))
|
|
@@ -416,11 +416,11 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
416
416
|
])
|
|
417
417
|
], 8, st))), 128))
|
|
418
418
|
], 8, lt),
|
|
419
|
-
|
|
419
|
+
s.value || P.value ? (p(), ne(i(r), {
|
|
420
420
|
key: 2,
|
|
421
421
|
label: e.text.retry,
|
|
422
422
|
variant: "secondary",
|
|
423
|
-
onClick: C[1] || (C[1] = (o) =>
|
|
423
|
+
onClick: C[1] || (C[1] = (o) => P.value ? V() : Z())
|
|
424
424
|
}, null, 8, ["label"])) : _("", !0)
|
|
425
425
|
], 8, He)) : _("", !0);
|
|
426
426
|
};
|
|
@@ -431,7 +431,7 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
431
431
|
}, kt = {
|
|
432
432
|
key: 1,
|
|
433
433
|
class: "upsell-eyebrow"
|
|
434
|
-
}, Ct = { class: "upsell-actions" },
|
|
434
|
+
}, Ct = { class: "upsell-actions" }, Tt = { class: "upsell-note" }, St = {
|
|
435
435
|
key: 0,
|
|
436
436
|
class: "upsell-scope"
|
|
437
437
|
}, Et = { class: "upsell-description" }, xt = {
|
|
@@ -441,14 +441,14 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
441
441
|
}, Pt = {
|
|
442
442
|
key: 1,
|
|
443
443
|
class: "upsell-description"
|
|
444
|
-
},
|
|
444
|
+
}, Ut = {
|
|
445
445
|
class: "upsell-feedback",
|
|
446
446
|
"aria-live": "polite"
|
|
447
|
-
},
|
|
447
|
+
}, At = {
|
|
448
448
|
key: 0,
|
|
449
449
|
role: "alert",
|
|
450
450
|
class: "upsell-error"
|
|
451
|
-
},
|
|
451
|
+
}, Ot = {
|
|
452
452
|
key: 1,
|
|
453
453
|
class: "upsell-success"
|
|
454
454
|
}, Rt = { key: 2 }, $t = {
|
|
@@ -464,7 +464,7 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
464
464
|
}, Nt = {
|
|
465
465
|
key: 5,
|
|
466
466
|
class: "upsell-editor"
|
|
467
|
-
}, _t = { class: "upsell-editor-products" }, Lt = { class: "upsell-toolbar" },
|
|
467
|
+
}, _t = { class: "upsell-editor-products" }, Lt = { class: "upsell-toolbar" }, Bt = { class: "upsell-search" }, Wt = {
|
|
468
468
|
key: 0,
|
|
469
469
|
class: "upsell-empty"
|
|
470
470
|
}, Ft = {
|
|
@@ -479,7 +479,7 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
479
479
|
}, Xt = { key: 0 }, Jt = { key: 1 }, Qt = {
|
|
480
480
|
key: 2,
|
|
481
481
|
class: "upsell-unavailable"
|
|
482
|
-
}, Kt = { class: "upsell-switch" }, Yt = { class: "upsell-sr-only" }, Gt = { class: "upsell-weight-heading" }, Zt = { key: 0 }, ea = ["aria-label"], ta = ["value", "aria-label", "aria-valuetext", "disabled", "data-boosted", "onInput", "onPointermove", "onPointerup", "onPointercancel", "onLostpointercapture"], aa = /* @__PURE__ */
|
|
482
|
+
}, Kt = { class: "upsell-switch" }, Yt = { class: "upsell-sr-only" }, Gt = { class: "upsell-weight-heading" }, Zt = { key: 0 }, ea = ["aria-label"], ta = ["value", "aria-label", "aria-valuetext", "disabled", "data-boosted", "onInput", "onPointermove", "onPointerup", "onPointercancel", "onLostpointercapture"], aa = /* @__PURE__ */ he({
|
|
483
483
|
__name: "UpsellingSettings",
|
|
484
484
|
props: {
|
|
485
485
|
loadPreview: { type: Function },
|
|
@@ -494,15 +494,15 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
494
494
|
},
|
|
495
495
|
emits: ["dirty-change", "busy-change", "saved"],
|
|
496
496
|
setup(e, { expose: t, emit: a }) {
|
|
497
|
-
const { FmButton: r, FmSwitch: m, FmTextField: I, FmSelect: k } =
|
|
498
|
-
let
|
|
499
|
-
const X =
|
|
500
|
-
const u =
|
|
497
|
+
const { FmButton: r, FmSwitch: m, FmTextField: I, FmSelect: k } = Pe, l = e, A = a, s = W(() => ({ ...Be, ...l.messages })), P = O(""), R = O(/* @__PURE__ */ new Set()), T = O(l.restaurantId ?? ""), L = O([]), N = O(!1), S = O(!1);
|
|
498
|
+
let B = 0;
|
|
499
|
+
const X = W(() => {
|
|
500
|
+
const u = l.businessId, d = l.loadApplyTargets;
|
|
501
501
|
let n;
|
|
502
502
|
return () => n ?? (n = d(u).catch((f) => {
|
|
503
503
|
throw n = void 0, f;
|
|
504
504
|
}));
|
|
505
|
-
}), q =
|
|
505
|
+
}), q = W(() => {
|
|
506
506
|
const u = X.value;
|
|
507
507
|
return async (d) => {
|
|
508
508
|
const n = (await u()).find((f) => f.scope.businessId === d.businessId && f.scope.restaurantId === d.restaurantId);
|
|
@@ -510,54 +510,54 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
510
510
|
return n.products;
|
|
511
511
|
};
|
|
512
512
|
});
|
|
513
|
-
|
|
514
|
-
|
|
513
|
+
K(() => [l.businessId, l.restaurantId], () => {
|
|
514
|
+
T.value = l.restaurantId ?? "";
|
|
515
515
|
}, { flush: "sync" });
|
|
516
516
|
async function F() {
|
|
517
|
-
const u = ++
|
|
518
|
-
L.value = [], S.value = !1, N.value = !!
|
|
517
|
+
const u = ++B;
|
|
518
|
+
L.value = [], S.value = !1, N.value = !!l.loadApplyTargets;
|
|
519
519
|
try {
|
|
520
|
-
const d =
|
|
521
|
-
u ===
|
|
520
|
+
const d = l.loadApplyTargets ? await X.value() : [];
|
|
521
|
+
u === B && (L.value = d.filter((n) => n.scope.businessId === l.businessId));
|
|
522
522
|
} catch {
|
|
523
|
-
u ===
|
|
523
|
+
u === B && (S.value = !0);
|
|
524
524
|
} finally {
|
|
525
|
-
u ===
|
|
525
|
+
u === B && (N.value = !1);
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
|
|
529
|
-
const D =
|
|
530
|
-
{ value: "", label:
|
|
528
|
+
K(() => [l.businessId, l.loadApplyTargets], F, { immediate: !0 });
|
|
529
|
+
const D = W(() => [
|
|
530
|
+
{ value: "", label: s.value.businessDefault },
|
|
531
531
|
...L.value.filter((u) => u.scope.restaurantId && !u.unavailableReason).map((u) => ({ value: u.scope.restaurantId, label: u.name }))
|
|
532
|
-
]), J =
|
|
532
|
+
]), J = Ce({
|
|
533
533
|
get businessId() {
|
|
534
|
-
return
|
|
534
|
+
return l.businessId;
|
|
535
535
|
},
|
|
536
536
|
get restaurantId() {
|
|
537
|
-
return
|
|
537
|
+
return T.value || void 0;
|
|
538
538
|
},
|
|
539
539
|
get restaurantName() {
|
|
540
540
|
var u;
|
|
541
|
-
return ((u = L.value.find((d) => d.scope.restaurantId ===
|
|
541
|
+
return ((u = L.value.find((d) => d.scope.restaurantId === T.value)) == null ? void 0 : u.name) ?? l.restaurantName;
|
|
542
542
|
},
|
|
543
543
|
get api() {
|
|
544
|
-
return
|
|
544
|
+
return l.api;
|
|
545
545
|
},
|
|
546
546
|
get loadProducts() {
|
|
547
|
-
return
|
|
547
|
+
return l.loadApplyTargets ? q.value : l.loadProducts;
|
|
548
548
|
},
|
|
549
549
|
get loadApplyTargets() {
|
|
550
|
-
return
|
|
550
|
+
return l.loadApplyTargets ? X.value : void 0;
|
|
551
551
|
},
|
|
552
552
|
get loadPreview() {
|
|
553
|
-
return
|
|
553
|
+
return l.loadPreview;
|
|
554
554
|
}
|
|
555
|
-
}), x =
|
|
556
|
-
async function
|
|
555
|
+
}), x = We(J), { hasUnsaved: E } = x;
|
|
556
|
+
async function U() {
|
|
557
557
|
await Promise.all([F(), x.load()]);
|
|
558
558
|
}
|
|
559
|
-
const { itemMap: j, loading: V, saving: M, loaded: z, error: G, dirty: Z, saved:
|
|
560
|
-
const u =
|
|
559
|
+
const { itemMap: j, loading: V, saving: M, loaded: z, error: G, dirty: Z, saved: g, inherited: C } = x, v = W(() => {
|
|
560
|
+
const u = P.value.trim().toLocaleLowerCase();
|
|
561
561
|
return x.rows.value.filter((d) => !d.unavailable).filter((d) => `${d.name} ${d.category ?? ""} ${d.productId}`.toLocaleLowerCase().includes(u));
|
|
562
562
|
});
|
|
563
563
|
function y(u) {
|
|
@@ -569,115 +569,115 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
569
569
|
return ((d = j.value.get(u)) == null ? void 0 : d.adjustWeight) ?? !1;
|
|
570
570
|
}
|
|
571
571
|
function $(u) {
|
|
572
|
-
return o(u) ? y(u) === 0 ?
|
|
572
|
+
return o(u) ? y(u) === 0 ? s.value.excluded : y(u) < 0.4 ? s.value.weak : y(u) < 0.6 ? s.value.normal : y(u) < 0.8 ? s.value.strong : s.value.strongest : s.value.automatic;
|
|
573
573
|
}
|
|
574
574
|
function ee(u, d) {
|
|
575
575
|
const n = Number(d.target.value);
|
|
576
576
|
x.change(u, { weight: n / 100 });
|
|
577
577
|
}
|
|
578
|
-
const
|
|
578
|
+
const Y = /* @__PURE__ */ new WeakMap();
|
|
579
579
|
function te(u) {
|
|
580
580
|
const d = u.currentTarget;
|
|
581
|
-
d.disabled || u.button !== 0 || (u.preventDefault(), d.focus({ preventScroll: !0 }),
|
|
581
|
+
d.disabled || u.button !== 0 || (u.preventDefault(), d.focus({ preventScroll: !0 }), Y.set(d, { pointerId: u.pointerId, x: u.clientX, value: Number(d.value), width: d.clientWidth || 1 }), d.setPointerCapture(u.pointerId), d.dataset.dragging = "true");
|
|
582
582
|
}
|
|
583
583
|
function H(u, d) {
|
|
584
|
-
const n = d.currentTarget, f =
|
|
584
|
+
const n = d.currentTarget, f = Y.get(n);
|
|
585
585
|
if (!f || f.pointerId !== d.pointerId) return;
|
|
586
|
-
const le = d.clientX - f.x,
|
|
587
|
-
x.change(u, { weight:
|
|
588
|
-
const
|
|
589
|
-
|
|
586
|
+
const le = d.clientX - f.x, ye = f.value + le / f.width * 100, fe = Math.max(0, Math.min(100, ye)), Re = Math.round(fe);
|
|
587
|
+
x.change(u, { weight: Re / 100 });
|
|
588
|
+
const ve = (ye - fe) / 100 * f.width;
|
|
589
|
+
ve !== 0 && n.style.setProperty("--upsell-origin", ve > 0 ? "left center" : "right center"), n.style.setProperty("--upsell-stretch", `${1 + 10 * Math.tanh(Math.abs(ve) / 90) / f.width}`);
|
|
590
590
|
}
|
|
591
591
|
function ae(u, d) {
|
|
592
592
|
var n;
|
|
593
593
|
const f = d.currentTarget;
|
|
594
|
-
((n =
|
|
594
|
+
((n = Y.get(f)) == null ? void 0 : n.pointerId) === d.pointerId && (Y.delete(f), delete f.dataset.dragging, d.type === "pointerup" && x.change(u, { weight: Math.round(y(u) * 20) / 20 }), f.style.removeProperty("--upsell-stretch"), f.hasPointerCapture(d.pointerId) && f.releasePointerCapture(d.pointerId));
|
|
595
595
|
}
|
|
596
596
|
async function Q() {
|
|
597
597
|
const u = await x.save();
|
|
598
|
-
u &&
|
|
598
|
+
u && A("saved", u);
|
|
599
599
|
}
|
|
600
600
|
function oe(u) {
|
|
601
|
-
(
|
|
601
|
+
(E.value || M.value) && (u.preventDefault(), u.returnValue = "");
|
|
602
602
|
}
|
|
603
|
-
return
|
|
604
|
-
|
|
605
|
-
}),
|
|
606
|
-
|
|
607
|
-
}), ce(() => window.removeEventListener("beforeunload", oe)), t({ dirty:
|
|
603
|
+
return K(E, (u) => A("dirty-change", u), { immediate: !0 }), K(() => M.value, (u) => A("busy-change", u), { immediate: !0 }), K(() => [l.businessId, T.value], () => {
|
|
604
|
+
P.value = "", R.value = /* @__PURE__ */ new Set();
|
|
605
|
+
}), Te(() => window.addEventListener("beforeunload", oe)), ce(() => {
|
|
606
|
+
B++;
|
|
607
|
+
}), ce(() => window.removeEventListener("beforeunload", oe)), t({ dirty: E, saving: M, discard: x.discard }), (u, d) => (p(), w("section", {
|
|
608
608
|
class: "fm-upselling",
|
|
609
|
-
"aria-label":
|
|
609
|
+
"aria-label": s.value.title,
|
|
610
610
|
"aria-busy": i(V) || i(M)
|
|
611
611
|
}, [
|
|
612
|
-
|
|
613
|
-
|
|
612
|
+
h("header", bt, [
|
|
613
|
+
h("div", null, [
|
|
614
614
|
!e.loadApplyTargets && e.restaurantName ? (p(), w("p", It, b(e.restaurantName), 1)) : _("", !0),
|
|
615
|
-
e.loadApplyTargets ? _("", !0) : (p(), w("p", kt, b(e.restaurantId ?
|
|
616
|
-
|
|
615
|
+
e.loadApplyTargets ? _("", !0) : (p(), w("p", kt, b(e.restaurantId ? s.value.restaurantOverride : s.value.businessDefault), 1)),
|
|
616
|
+
h("h1", null, b(s.value.title), 1)
|
|
617
617
|
]),
|
|
618
|
-
|
|
619
|
-
|
|
618
|
+
h("div", Ct, [
|
|
619
|
+
T.value && e.api.reset ? (p(), ne(i(r), {
|
|
620
620
|
key: 0,
|
|
621
621
|
variant: "secondary",
|
|
622
|
-
label:
|
|
622
|
+
label: s.value.reset,
|
|
623
623
|
disabled: i(M) || !i(z) || i(C) && !i(Z),
|
|
624
624
|
onClick: i(x).reset
|
|
625
625
|
}, null, 8, ["label", "disabled", "onClick"])) : _("", !0),
|
|
626
626
|
se(i(r), {
|
|
627
627
|
variant: "secondary",
|
|
628
|
-
label:
|
|
628
|
+
label: s.value.discard,
|
|
629
629
|
disabled: !i(Z) || i(M) || !i(z),
|
|
630
630
|
onClick: i(x).discard
|
|
631
631
|
}, null, 8, ["label", "disabled", "onClick"]),
|
|
632
632
|
se(i(r), {
|
|
633
|
-
label: i(M) ?
|
|
633
|
+
label: i(M) ? s.value.saving : e.loadApplyTargets ? s.value.apply : s.value.save,
|
|
634
634
|
loading: i(M),
|
|
635
635
|
disabled: !i(Z) || i(M) || N.value || S.value || !i(z),
|
|
636
636
|
onClick: Q
|
|
637
637
|
}, null, 8, ["label", "loading", "disabled"])
|
|
638
638
|
])
|
|
639
639
|
]),
|
|
640
|
-
|
|
641
|
-
e.loadApplyTargets ? (p(), w("div",
|
|
640
|
+
h("p", Tt, b(s.value.hint), 1),
|
|
641
|
+
e.loadApplyTargets ? (p(), w("div", St, [
|
|
642
642
|
se(i(k), {
|
|
643
|
-
modelValue:
|
|
644
|
-
"onUpdate:modelValue": d[0] || (d[0] = (n) =>
|
|
645
|
-
label:
|
|
643
|
+
modelValue: T.value,
|
|
644
|
+
"onUpdate:modelValue": d[0] || (d[0] = (n) => T.value = n),
|
|
645
|
+
label: s.value.editingScope,
|
|
646
646
|
items: D.value,
|
|
647
647
|
disabled: i(M) || N.value || S.value
|
|
648
648
|
}, null, 8, ["modelValue", "label", "items", "disabled"]),
|
|
649
|
-
|
|
650
|
-
S.value ? (p(), w("p", xt, b(
|
|
649
|
+
h("p", Et, b(T.value ? s.value.editingOutletHint : s.value.editingBusinessHint), 1),
|
|
650
|
+
S.value ? (p(), w("p", xt, b(s.value.loadError), 1)) : _("", !0),
|
|
651
651
|
S.value ? (p(), ne(i(r), {
|
|
652
652
|
key: 1,
|
|
653
653
|
variant: "secondary",
|
|
654
|
-
label:
|
|
655
|
-
onClick:
|
|
654
|
+
label: s.value.retry,
|
|
655
|
+
onClick: U
|
|
656
656
|
}, null, 8, ["label"])) : _("", !0)
|
|
657
657
|
])) : _("", !0),
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
i(G) ? (p(), w("p",
|
|
658
|
+
T.value && i(C) ? (p(), w("p", Pt, b(s.value.inherited), 1)) : _("", !0),
|
|
659
|
+
h("div", Ut, [
|
|
660
|
+
i(G) ? (p(), w("p", At, b(i(G) === "load" ? s.value.loadError : s.value.saveError), 1)) : i(g) ? (p(), w("p", Ot, b(s.value.saved), 1)) : i(Z) ? (p(), w("p", Rt, b(s.value.dirty), 1)) : _("", !0)
|
|
661
661
|
]),
|
|
662
|
-
e.businessId ? i(V) ? (p(), w("p", jt, b(
|
|
662
|
+
e.businessId ? i(V) ? (p(), w("p", jt, b(s.value.loading), 1)) : i(G) === "load" ? (p(), w("div", Mt, [
|
|
663
663
|
se(i(r), {
|
|
664
664
|
variant: "secondary",
|
|
665
|
-
label:
|
|
665
|
+
label: s.value.retry,
|
|
666
666
|
onClick: i(x).load
|
|
667
667
|
}, null, 8, ["label", "onClick"])
|
|
668
668
|
])) : i(z) ? (p(), w("div", Nt, [
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
669
|
+
h("div", _t, [
|
|
670
|
+
h("div", Lt, [
|
|
671
|
+
h("h2", null, [
|
|
672
|
+
$e(b(s.value.products) + " ", 1),
|
|
673
|
+
h("span", null, b(i(x).rows.value.filter((n) => !n.unavailable).length), 1)
|
|
674
674
|
]),
|
|
675
|
-
|
|
675
|
+
h("div", Bt, [
|
|
676
676
|
se(i(I), {
|
|
677
|
-
modelValue:
|
|
678
|
-
"onUpdate:modelValue": d[1] || (d[1] = (n) =>
|
|
679
|
-
label:
|
|
680
|
-
placeholder:
|
|
677
|
+
modelValue: P.value,
|
|
678
|
+
"onUpdate:modelValue": d[1] || (d[1] = (n) => P.value = n),
|
|
679
|
+
label: s.value.search,
|
|
680
|
+
placeholder: s.value.search
|
|
681
681
|
}, null, 8, ["modelValue", "label", "placeholder"])
|
|
682
682
|
])
|
|
683
683
|
]),
|
|
@@ -687,53 +687,53 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
687
687
|
class: "upsell-row",
|
|
688
688
|
"data-product-id": n.productId
|
|
689
689
|
}, [
|
|
690
|
-
|
|
691
|
-
n.imageUrl && !
|
|
690
|
+
h("div", Ht, [
|
|
691
|
+
n.imageUrl && !R.value.has(n.productId) ? (p(), w("img", {
|
|
692
692
|
key: 0,
|
|
693
693
|
src: n.imageUrl,
|
|
694
694
|
alt: "",
|
|
695
695
|
class: "upsell-photo",
|
|
696
696
|
loading: "lazy",
|
|
697
|
-
onError: (f) =>
|
|
698
|
-
}, null, 40, qt)) : (p(), w("span", zt, b(
|
|
699
|
-
|
|
700
|
-
|
|
697
|
+
onError: (f) => R.value.add(n.productId)
|
|
698
|
+
}, null, 40, qt)) : (p(), w("span", zt, b(s.value.missingPhoto), 1)),
|
|
699
|
+
h("div", null, [
|
|
700
|
+
h("h3", null, b(n.unavailable ? s.value.unavailable : n.name), 1),
|
|
701
701
|
n.unavailable ? (p(), w("p", Xt, b(n.productId), 1)) : (p(), w("p", Jt, b([n.category, n.priceLabel].filter(Boolean).join(" · ")), 1)),
|
|
702
|
-
n.unavailable ? (p(), w("p", Qt, b(
|
|
702
|
+
n.unavailable ? (p(), w("p", Qt, b(s.value.unavailableHint), 1)) : _("", !0)
|
|
703
703
|
])
|
|
704
704
|
]),
|
|
705
|
-
|
|
705
|
+
h("div", Kt, [
|
|
706
706
|
se(i(m), {
|
|
707
707
|
"model-value": o(n.productId),
|
|
708
708
|
disabled: i(M),
|
|
709
709
|
"onUpdate:modelValue": (f) => i(x).change(n.productId, { adjustWeight: f })
|
|
710
710
|
}, {
|
|
711
711
|
label: Se(() => [
|
|
712
|
-
|
|
712
|
+
h("span", Yt, b(s.value.adjust) + ": " + b(n.name), 1)
|
|
713
713
|
]),
|
|
714
714
|
_: 2
|
|
715
715
|
}, 1032, ["model-value", "disabled", "onUpdate:modelValue"])
|
|
716
716
|
]),
|
|
717
|
-
|
|
718
|
-
class:
|
|
717
|
+
h("div", {
|
|
718
|
+
class: Ee(["upsell-weight", { "upsell-weight-auto": !o(n.productId) }])
|
|
719
719
|
}, [
|
|
720
|
-
|
|
720
|
+
h("div", Gt, [
|
|
721
721
|
o(n.productId) ? (p(), w("span", Zt, b($(n.productId)), 1)) : _("", !0),
|
|
722
|
-
|
|
723
|
-
"aria-label": `${
|
|
724
|
-
}, b(o(n.productId) ? `${Math.round(y(n.productId) * 100)}%` :
|
|
722
|
+
h("output", {
|
|
723
|
+
"aria-label": `${s.value.weight}: ${n.name}`
|
|
724
|
+
}, b(o(n.productId) ? `${Math.round(y(n.productId) * 100)}%` : s.value.automatic), 9, ea)
|
|
725
725
|
]),
|
|
726
|
-
|
|
726
|
+
h("input", {
|
|
727
727
|
type: "range",
|
|
728
728
|
min: "0",
|
|
729
729
|
max: "100",
|
|
730
730
|
step: "1",
|
|
731
731
|
value: Math.round(y(n.productId) * 100),
|
|
732
|
-
"aria-label": `${
|
|
732
|
+
"aria-label": `${s.value.weight}: ${n.name}`,
|
|
733
733
|
"aria-valuetext": `${Math.round(y(n.productId) * 100)}% — ${$(n.productId)}`,
|
|
734
734
|
disabled: !o(n.productId) || i(M),
|
|
735
735
|
"data-boosted": o(n.productId) && y(n.productId) >= 0.8,
|
|
736
|
-
style:
|
|
736
|
+
style: je({ "--upsell-fill": `${o(n.productId) ? y(n.productId) * 100 : 0}%` }),
|
|
737
737
|
onInput: (f) => ee(n.productId, f),
|
|
738
738
|
onPointerdown: te,
|
|
739
739
|
onPointermove: (f) => H(n.productId, f),
|
|
@@ -743,18 +743,18 @@ const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class
|
|
|
743
743
|
}, null, 44, ta)
|
|
744
744
|
], 2)
|
|
745
745
|
], 8, Vt))), 128))
|
|
746
|
-
])) : (p(), w("p", Ft, b(
|
|
746
|
+
])) : (p(), w("p", Ft, b(s.value.noMatches), 1)) : (p(), w("p", Wt, b(s.value.empty), 1))
|
|
747
747
|
]),
|
|
748
748
|
(p(), ne(yt, {
|
|
749
749
|
host: J,
|
|
750
|
-
key: JSON.stringify([e.businessId,
|
|
750
|
+
key: JSON.stringify([e.businessId, T.value]),
|
|
751
751
|
products: i(x).rows.value.filter((n) => !n.unavailable),
|
|
752
752
|
"saved-items": i(x).baseline.value,
|
|
753
753
|
"draft-items": i(x).items.value,
|
|
754
|
-
text:
|
|
754
|
+
text: s.value,
|
|
755
755
|
touchpoints: e.previewTouchpoints
|
|
756
756
|
}, null, 8, ["host", "products", "saved-items", "draft-items", "text", "touchpoints"]))
|
|
757
|
-
])) : _("", !0) : (p(), w("p", $t, b(
|
|
757
|
+
])) : _("", !0) : (p(), w("p", $t, b(s.value.chooseRestaurant), 1))
|
|
758
758
|
], 8, ft));
|
|
759
759
|
}
|
|
760
760
|
});
|
|
@@ -767,15 +767,15 @@ function ra(e) {
|
|
|
767
767
|
async function a(r, m, I = m === void 0 ? "GET" : "PUT") {
|
|
768
768
|
const k = await e.getToken();
|
|
769
769
|
if (!k) throw new Error("Sign in to Portal to load upselling settings.");
|
|
770
|
-
const
|
|
770
|
+
const l = await fetch(`${t.href.replace(/\/$/, "")}${r}`, {
|
|
771
771
|
method: I,
|
|
772
772
|
headers: { Authorization: `Bearer ${k}`, ...m === void 0 ? {} : { "Content-Type": "application/json" } },
|
|
773
773
|
body: m === void 0 ? void 0 : JSON.stringify(m),
|
|
774
774
|
cache: "no-store",
|
|
775
775
|
redirect: "error"
|
|
776
776
|
});
|
|
777
|
-
if (!
|
|
778
|
-
return { data: await
|
|
777
|
+
if (!l.ok) throw new Error(`Unable to ${m === void 0 ? "load" : "save"} upselling settings (${l.status}).`);
|
|
778
|
+
return { data: await l.json() };
|
|
779
779
|
}
|
|
780
780
|
return la({ get: (r) => a(r), put: (r, m) => a(r, m), delete: (r) => a(r, void 0, "DELETE") });
|
|
781
781
|
}
|
|
@@ -786,7 +786,7 @@ function la(e) {
|
|
|
786
786
|
return (await e.get(t(a))).data;
|
|
787
787
|
},
|
|
788
788
|
async save(a, r) {
|
|
789
|
-
const m = { items: r.map(({ productId: I, adjustWeight: k, weight:
|
|
789
|
+
const m = { items: r.map(({ productId: I, adjustWeight: k, weight: l }) => ({ productId: I, adjustWeight: k, weight: l })) };
|
|
790
790
|
return (await e.put(t(a), m)).data;
|
|
791
791
|
},
|
|
792
792
|
...e.delete ? { async reset(a) {
|
|
@@ -829,8 +829,8 @@ function ua(e) {
|
|
|
829
829
|
body: JSON.stringify({
|
|
830
830
|
restaurant_id: a.restaurantId,
|
|
831
831
|
type: a.recommendationType === "cart" ? "cart" : "whats_hot",
|
|
832
|
-
...a.recommendationType === "cart" ? { cart_item: [...new Set(a.cart.map((
|
|
833
|
-
...I === "preview" ? { items: a.items.map(({ productId:
|
|
832
|
+
...a.recommendationType === "cart" ? { cart_item: [...new Set(a.cart.map((s) => s.productId))] } : {},
|
|
833
|
+
...I === "preview" ? { items: a.items.map(({ productId: s, adjustWeight: P, weight: R }) => ({ productId: s, adjustWeight: P, weight: R })) } : {}
|
|
834
834
|
})
|
|
835
835
|
});
|
|
836
836
|
if (!k.ok) {
|
|
@@ -839,13 +839,13 @@ function ua(e) {
|
|
|
839
839
|
return { products: [], source: "no_data" };
|
|
840
840
|
throw new Error(`Recommendation preview failed (${k.status})`);
|
|
841
841
|
}
|
|
842
|
-
const
|
|
843
|
-
if (!na(
|
|
844
|
-
const
|
|
845
|
-
return { products:
|
|
842
|
+
const l = await k.json();
|
|
843
|
+
if (!na(l, a)) throw new Error("Preview response is not supported");
|
|
844
|
+
const A = new Map((a.catalog ?? await e.loadProducts({ businessId: a.businessId, restaurantId: a.restaurantId })).map((s) => [s.productId, s]));
|
|
845
|
+
return { products: me(l.product_id.flatMap((s) => A.has(s) ? [A.get(s)] : []), a.limit), source: "unknown" };
|
|
846
846
|
};
|
|
847
847
|
}
|
|
848
|
-
const
|
|
848
|
+
const Ie = c.object({
|
|
849
849
|
catalog: c.array(
|
|
850
850
|
c.object({
|
|
851
851
|
_id: c.string(),
|
|
@@ -880,26 +880,26 @@ const be = c.object({
|
|
|
880
880
|
}).nullish()
|
|
881
881
|
})
|
|
882
882
|
)
|
|
883
|
-
}),
|
|
883
|
+
}), Ae = c.object({
|
|
884
884
|
_id: c.string().min(1),
|
|
885
885
|
menuMode: c.enum(["businessLevel", "restaurantLevel"]).optional(),
|
|
886
|
-
modules:
|
|
886
|
+
modules: Ie.nullish(),
|
|
887
887
|
restaurants: c.array(
|
|
888
888
|
c.object({
|
|
889
889
|
restaurantId: c.string(),
|
|
890
|
-
modules:
|
|
890
|
+
modules: Ie.nullish()
|
|
891
891
|
})
|
|
892
892
|
).nullish()
|
|
893
893
|
});
|
|
894
|
-
function
|
|
895
|
-
const e =
|
|
894
|
+
function we() {
|
|
895
|
+
const e = pe();
|
|
896
896
|
if (e.namespace.value !== "dev" || e.currentCountry.value !== "MY")
|
|
897
897
|
throw new Error("Upselling is available in MY dev only.");
|
|
898
898
|
}
|
|
899
899
|
function ia() {
|
|
900
900
|
return ra({
|
|
901
901
|
baseUrl: "https://query-engine.feedmeapidev.com",
|
|
902
|
-
getToken: () => (
|
|
902
|
+
getToken: () => (we(), Ue.getIdToken() ?? "")
|
|
903
903
|
});
|
|
904
904
|
}
|
|
905
905
|
function da(e) {
|
|
@@ -910,33 +910,33 @@ function da(e) {
|
|
|
910
910
|
);
|
|
911
911
|
return ua({
|
|
912
912
|
baseUrl: t.origin,
|
|
913
|
-
getToken: () => (
|
|
913
|
+
getToken: () => (we(), Ue.getIdToken() ?? ""),
|
|
914
914
|
loadProducts: Oe
|
|
915
915
|
});
|
|
916
916
|
}
|
|
917
|
-
function
|
|
917
|
+
function ke(e, t) {
|
|
918
918
|
var I, k;
|
|
919
|
-
const a =
|
|
919
|
+
const a = Ae.parse(e), r = a.restaurants || a.menuMode === "restaurantLevel" ? (k = (I = a.restaurants) == null ? void 0 : I.find((l) => l.restaurantId === t)) == null ? void 0 : k.modules : a.modules;
|
|
920
920
|
if (!r) return [];
|
|
921
921
|
const m = new Map(
|
|
922
|
-
r.category.map((
|
|
922
|
+
r.category.map((l) => [l._id, l.name])
|
|
923
923
|
);
|
|
924
|
-
return r.item.map((
|
|
925
|
-
productId:
|
|
926
|
-
name:
|
|
927
|
-
...
|
|
928
|
-
...
|
|
929
|
-
...
|
|
930
|
-
imageUrl:
|
|
931
|
-
category: m.get(
|
|
932
|
-
priceLabel:
|
|
924
|
+
return r.item.map((l) => ({
|
|
925
|
+
productId: l._id,
|
|
926
|
+
name: l.name,
|
|
927
|
+
...l.unit != null ? { unit: l.unit } : {},
|
|
928
|
+
...l.perXUnit != null ? { perXUnit: l.perXUnit } : {},
|
|
929
|
+
...l.isOutOfStocked != null ? { isOutOfStocked: l.isOutOfStocked } : {},
|
|
930
|
+
imageUrl: l.thumbnail ?? void 0,
|
|
931
|
+
category: m.get(l.category ?? ""),
|
|
932
|
+
priceLabel: l.price ? Le(l.price) : void 0
|
|
933
933
|
}));
|
|
934
934
|
}
|
|
935
935
|
const Oe = async ({
|
|
936
936
|
businessId: e,
|
|
937
937
|
restaurantId: t
|
|
938
938
|
}) => {
|
|
939
|
-
const r = (await
|
|
939
|
+
const r = (await ge(e)).find((m) => m.scope.restaurantId === t);
|
|
940
940
|
if (!r)
|
|
941
941
|
throw new Error("This outlet is not available in the current business.");
|
|
942
942
|
if (r.unavailableReason) throw new Error(r.unavailableReason);
|
|
@@ -951,92 +951,105 @@ const Oe = async ({
|
|
|
951
951
|
takeaway: c.object({ catalogId: c.string().nullish() }).passthrough().nullish(),
|
|
952
952
|
pickup: c.object({ catalogId: c.string().nullish() }).passthrough().nullish()
|
|
953
953
|
}).passthrough()
|
|
954
|
-
),
|
|
955
|
-
var
|
|
956
|
-
|
|
957
|
-
const t =
|
|
954
|
+
), ge = async (e) => {
|
|
955
|
+
var A, s, P, R, T, L, N;
|
|
956
|
+
we();
|
|
957
|
+
const t = pe(), a = ca.parse(t.restaurants.value).filter((S) => S.businessId === e), r = c.object({ menuVersion: c.enum(["v3", "v4"]).nullish() }).parse(t.currentBusiness.value).menuVersion, m = await _e(
|
|
958
958
|
`menu-v4/businesses/${encodeURIComponent(
|
|
959
959
|
e
|
|
960
960
|
)}/menu-v4/effective-menu?modules=item,category,catalog`
|
|
961
|
-
).get(""), I =
|
|
961
|
+
).get(""), I = Ae.parse(m.data), k = I.menuMode === "restaurantLevel", l = [
|
|
962
962
|
{
|
|
963
963
|
name: "Business default",
|
|
964
964
|
scope: { businessId: e },
|
|
965
|
-
products: k ? [] :
|
|
965
|
+
products: k ? [] : ke(m.data),
|
|
966
966
|
...k ? {
|
|
967
967
|
unavailableReason: "This business uses separate outlet menus. Apply to selected outlets instead; product IDs cannot be combined into one shared catalog."
|
|
968
968
|
} : {}
|
|
969
969
|
}
|
|
970
970
|
];
|
|
971
971
|
for (const S of a) {
|
|
972
|
-
const
|
|
972
|
+
const B = k ? (s = (A = I.restaurants) == null ? void 0 : A.find((F) => F.restaurantId === S._id)) == null ? void 0 : s.modules : I.modules, X = /* @__PURE__ */ new Set();
|
|
973
973
|
let q;
|
|
974
|
-
if (!
|
|
974
|
+
if (!B) q = "No menu is available for this outlet.";
|
|
975
975
|
else if (r !== "v3" && r !== "v4")
|
|
976
976
|
q = "Menu version could not be verified. Nothing will be applied.";
|
|
977
977
|
else {
|
|
978
978
|
const F = [
|
|
979
979
|
S.catalogId ?? null,
|
|
980
980
|
...S.additionalCatalogs ?? [],
|
|
981
|
-
(
|
|
982
|
-
(
|
|
981
|
+
(P = S.takeaway) == null ? void 0 : P.catalogId,
|
|
982
|
+
(R = S.pickup) == null ? void 0 : R.catalogId
|
|
983
983
|
].filter((D) => D !== void 0);
|
|
984
984
|
for (const D of F) {
|
|
985
|
-
const J = D ?
|
|
985
|
+
const J = D ? B.catalog.find((x) => x._id === D) : void 0;
|
|
986
986
|
if (D && !J) {
|
|
987
987
|
q = "An assigned catalog is unavailable. Reload this outlet’s menu before applying.";
|
|
988
988
|
break;
|
|
989
989
|
}
|
|
990
|
-
for (const x of
|
|
991
|
-
const
|
|
990
|
+
for (const x of B.item) {
|
|
991
|
+
const E = (L = (T = J == null ? void 0 : J.override.items) == null ? void 0 : T[x._id]) == null ? void 0 : L.find(
|
|
992
992
|
(j) => !j.combinationKey
|
|
993
993
|
);
|
|
994
|
-
((
|
|
994
|
+
((E == null ? void 0 : E.orderFrom) ?? x.orderFrom) !== "NONE" && (r === "v4" || (E == null ? void 0 : E.category) !== "") && X.add(x._id);
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
}
|
|
998
|
-
|
|
998
|
+
l.push({
|
|
999
999
|
name: ((N = S.profile) == null ? void 0 : N.name) ?? S._id,
|
|
1000
1000
|
scope: { businessId: e, restaurantId: S._id },
|
|
1001
|
-
products:
|
|
1001
|
+
products: ke(m.data, S._id).filter(
|
|
1002
1002
|
(F) => X.has(F.productId)
|
|
1003
1003
|
),
|
|
1004
1004
|
unavailableReason: q
|
|
1005
1005
|
});
|
|
1006
1006
|
}
|
|
1007
|
-
return
|
|
1007
|
+
return l;
|
|
1008
1008
|
};
|
|
1009
|
-
|
|
1010
|
-
const
|
|
1009
|
+
function pa() {
|
|
1010
|
+
const e = pe(), t = xe(ge);
|
|
1011
|
+
return K(
|
|
1012
|
+
[() => e.restaurants.value, () => {
|
|
1013
|
+
var a;
|
|
1014
|
+
return (a = e.currentBusiness.value) == null ? void 0 : a.menuVersion;
|
|
1015
|
+
}],
|
|
1016
|
+
() => {
|
|
1017
|
+
t.value = (a) => ge(a);
|
|
1018
|
+
},
|
|
1019
|
+
{ deep: !0 }
|
|
1020
|
+
), t;
|
|
1021
|
+
}
|
|
1022
|
+
var va = { mode: "development", appMode: "mf" };
|
|
1023
|
+
const Ia = /* @__PURE__ */ he({
|
|
1011
1024
|
__name: "Upselling",
|
|
1012
1025
|
setup(e) {
|
|
1013
|
-
const t =
|
|
1026
|
+
const t = pe(), a = pa(), r = ia(), m = da(
|
|
1014
1027
|
"https://public-query-engine.feedmeapidev.com"
|
|
1015
|
-
),
|
|
1016
|
-
() =>
|
|
1017
|
-
),
|
|
1028
|
+
), I = O(!1), k = O(!1), l = W(
|
|
1029
|
+
() => va.mode === "development" && t.namespace.value === "dev" && t.currentCountry.value === "MY"
|
|
1030
|
+
), A = W(
|
|
1018
1031
|
() => {
|
|
1019
|
-
var
|
|
1020
|
-
return `${t.namespace.value}:${t.currentCountry.value}:${(
|
|
1032
|
+
var s;
|
|
1033
|
+
return `${t.namespace.value}:${t.currentCountry.value}:${(s = t.sessionUser.value) == null ? void 0 : s.id}`;
|
|
1021
1034
|
}
|
|
1022
1035
|
);
|
|
1023
1036
|
return Ne(
|
|
1024
|
-
() => !
|
|
1025
|
-
), (
|
|
1026
|
-
var
|
|
1027
|
-
return
|
|
1028
|
-
key:
|
|
1029
|
-
"business-id": ((
|
|
1030
|
-
api: i(
|
|
1037
|
+
() => !k.value && (!I.value || window.confirm("Discard unsaved changes?"))
|
|
1038
|
+
), (s, P) => {
|
|
1039
|
+
var R;
|
|
1040
|
+
return l.value ? (p(), ne(i(aa), {
|
|
1041
|
+
key: A.value,
|
|
1042
|
+
"business-id": ((R = i(t).currentBusiness.value) == null ? void 0 : R._id) ?? "",
|
|
1043
|
+
api: i(r),
|
|
1031
1044
|
"load-products": i(Oe),
|
|
1032
|
-
"load-apply-targets": i(
|
|
1033
|
-
"load-preview": i(
|
|
1034
|
-
onDirtyChange:
|
|
1035
|
-
onBusyChange:
|
|
1045
|
+
"load-apply-targets": i(a),
|
|
1046
|
+
"load-preview": i(m),
|
|
1047
|
+
onDirtyChange: P[0] || (P[0] = (T) => I.value = T),
|
|
1048
|
+
onBusyChange: P[1] || (P[1] = (T) => k.value = T)
|
|
1036
1049
|
}, null, 8, ["business-id", "api", "load-products", "load-apply-targets", "load-preview"])) : _("", !0);
|
|
1037
1050
|
};
|
|
1038
1051
|
}
|
|
1039
1052
|
});
|
|
1040
1053
|
export {
|
|
1041
|
-
|
|
1054
|
+
Ia as default
|
|
1042
1055
|
};
|