Spaces:
Paused
Paused
Deploy Bot commited on
Commit ·
2cd8edd
1
Parent(s): c04d99a
Fix: Explicit delivery method check to prevent Pickup fallback to Yandex
Browse files- src/scenes/user/checkout.js +24 -14
src/scenes/user/checkout.js
CHANGED
|
@@ -199,10 +199,10 @@ const checkoutScene = new Scenes.WizardScene(
|
|
| 199 |
return ctx.wizard.selectStep(0) && ctx.wizard.steps[0](ctx);
|
| 200 |
}
|
| 201 |
|
| 202 |
-
const text = ctx.message.text;
|
| 203 |
ctx.wizard.state.deliveryMethod = text;
|
| 204 |
|
| 205 |
-
if (text === i18n.delivery_pickup) {
|
| 206 |
ctx.wizard.state.location = null;
|
| 207 |
|
| 208 |
const Settings = require('../../models/Settings');
|
|
@@ -224,24 +224,34 @@ const checkoutScene = new Scenes.WizardScene(
|
|
| 224 |
return ctx.wizard.selectStep(6);
|
| 225 |
}
|
| 226 |
|
| 227 |
-
if (text === i18n.delivery_bts) {
|
| 228 |
ctx.reply("📝 " + i18n.settings_addr, navKeyboard(ctx, i18n));
|
| 229 |
return ctx.wizard.next(); // Step 3
|
| 230 |
}
|
| 231 |
|
| 232 |
-
// Yandex
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
user.addresses
|
| 237 |
-
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
-
btns.push([Markup.button.locationRequest(i18n.location_button)]);
|
| 241 |
-
btns.push([i18n.btn_back_nav, i18n.btn_cancel]);
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
},
|
| 246 |
// Step 3: BTS Address
|
| 247 |
(ctx) => {
|
|
|
|
| 199 |
return ctx.wizard.selectStep(0) && ctx.wizard.steps[0](ctx);
|
| 200 |
}
|
| 201 |
|
| 202 |
+
const text = ctx.message.text.trim(); // Trim input
|
| 203 |
ctx.wizard.state.deliveryMethod = text;
|
| 204 |
|
| 205 |
+
if (text === i18n.delivery_pickup.trim()) {
|
| 206 |
ctx.wizard.state.location = null;
|
| 207 |
|
| 208 |
const Settings = require('../../models/Settings');
|
|
|
|
| 224 |
return ctx.wizard.selectStep(6);
|
| 225 |
}
|
| 226 |
|
| 227 |
+
if (text === i18n.delivery_bts.trim()) {
|
| 228 |
ctx.reply("📝 " + i18n.settings_addr, navKeyboard(ctx, i18n));
|
| 229 |
return ctx.wizard.next(); // Step 3
|
| 230 |
}
|
| 231 |
|
| 232 |
+
// Yandex Explicit Check
|
| 233 |
+
if (text === i18n.delivery_yandex.trim()) {
|
| 234 |
+
const user = ctx.wizard.state.user;
|
| 235 |
+
const btns = [];
|
| 236 |
+
if (user && user.addresses && user.addresses.length > 0) {
|
| 237 |
+
user.addresses.forEach((addr, i) => {
|
| 238 |
+
btns.push([i18n.checkout_location_saved.replace('{name}', addr.name || 'Saved Address')]);
|
| 239 |
+
});
|
| 240 |
+
}
|
| 241 |
+
btns.push([Markup.button.locationRequest(i18n.location_button)]);
|
| 242 |
+
btns.push([i18n.btn_back_nav, i18n.btn_cancel]);
|
| 243 |
+
|
| 244 |
+
ctx.reply(i18n.address_prompt, Markup.keyboard(btns).resize().oneTime());
|
| 245 |
+
return ctx.wizard.selectStep(5); // Step 5
|
| 246 |
}
|
|
|
|
|
|
|
| 247 |
|
| 248 |
+
// Unknown Input
|
| 249 |
+
ctx.reply(i18n.delivery_select, Markup.keyboard([
|
| 250 |
+
[i18n.delivery_yandex, i18n.delivery_bts],
|
| 251 |
+
[i18n.delivery_pickup],
|
| 252 |
+
[i18n.btn_back_nav, i18n.btn_cancel]
|
| 253 |
+
]).resize().oneTime());
|
| 254 |
+
return; // Stay in step
|
| 255 |
},
|
| 256 |
// Step 3: BTS Address
|
| 257 |
(ctx) => {
|