Spaces:
Paused
Paused
Deploy Bot commited on
Commit ·
f9c77d2
1
Parent(s): 9da5043
Fix: Crash in Add Product (Markup error)
Browse files
src/scenes/admin/addProduct.js
CHANGED
|
@@ -20,11 +20,14 @@ const addProductScene = new Scenes.WizardScene(
|
|
| 20 |
ctx.wizard.state.product = { media: [] };
|
| 21 |
|
| 22 |
const categories = await Category.find();
|
| 23 |
-
|
| 24 |
-
buttons.push(i18n.admin.new_cat || "➕ Yangi Kategoriya");
|
| 25 |
-
buttons.push(i18n.btn_cancel);
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
return ctx.wizard.next();
|
| 29 |
},
|
| 30 |
// Step 2: Handle Category -> Ask Name
|
|
|
|
| 20 |
ctx.wizard.state.product = { media: [] };
|
| 21 |
|
| 22 |
const categories = await Category.find();
|
| 23 |
+
let buttons = categories.map(c => c.name);
|
| 24 |
+
buttons.push(i18n.admin.new_cat || "➕ Yangi Kategoriya");
|
| 25 |
+
buttons.push(i18n.btn_cancel || "❌ Bekor qilish");
|
| 26 |
|
| 27 |
+
// Filter out any undefined values to prevent crashes
|
| 28 |
+
buttons = buttons.filter(b => b);
|
| 29 |
+
|
| 30 |
+
ctx.reply(i18n.admin.enter_cat || "📂 Kategoriyani tanlang:", Markup.keyboard(buttons, { columns: 2 }).resize());
|
| 31 |
return ctx.wizard.next();
|
| 32 |
},
|
| 33 |
// Step 2: Handle Category -> Ask Name
|