0 update adminHandlers
This commit is contained in:
@@ -908,22 +908,22 @@ Coordinates: ${product.hidden_coordinates}
|
|||||||
if (!this.isAdmin(callbackQuery.from.id)) {
|
if (!this.isAdmin(callbackQuery.from.id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chatId = callbackQuery.message.chat.id;
|
const chatId = callbackQuery.message.chat.id;
|
||||||
const messageId = callbackQuery.message.message_id;
|
const messageId = callbackQuery.message.message_id;
|
||||||
const productId = callbackQuery.data.replace('edit_product_', '');
|
const productId = callbackQuery.data.replace('edit_product_', '');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const product = await ProductService.getDetailedProductById(productId);
|
const product = await ProductService.getDetailedProductById(productId);
|
||||||
|
|
||||||
if (!product) {
|
if (!product) {
|
||||||
throw new Error('Product not found');
|
throw new Error('Product not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const locationId = product.location_id;
|
const locationId = product.location_id;
|
||||||
const categoryId = product.category_id;
|
const categoryId = product.category_id;
|
||||||
const subcategoryId = product.subcategory_id;
|
const subcategoryId = product.subcategory_id;
|
||||||
|
|
||||||
const sampleProduct = {
|
const sampleProduct = {
|
||||||
name: product.name,
|
name: product.name,
|
||||||
price: product.price,
|
price: product.price,
|
||||||
@@ -935,10 +935,10 @@ Coordinates: ${product.hidden_coordinates}
|
|||||||
hidden_coordinates: product.hidden_coordinates,
|
hidden_coordinates: product.hidden_coordinates,
|
||||||
hidden_description: product.hidden_description
|
hidden_description: product.hidden_description
|
||||||
};
|
};
|
||||||
|
|
||||||
const jsonExample = JSON.stringify(sampleProduct, null, 2);
|
const jsonExample = JSON.stringify(sampleProduct, null, 2);
|
||||||
const message = `To edit product, send a JSON file with product in the following format:\n\n<pre>${jsonExample}</pre>\n\nProduct must have all the fields shown above.\n\nYou can either:\n1. Send the JSON as text\n2. Upload a .json file`;
|
const message = `To edit product, send a JSON file with product in the following format:\n\n<pre>${jsonExample}</pre>\n\nProduct must have all the fields shown above.\n\nYou can either:\n1. Send the JSON as text\n2. Upload a .json file`;
|
||||||
|
|
||||||
userStates.set(chatId, {
|
userStates.set(chatId, {
|
||||||
action: 'edit_product',
|
action: 'edit_product',
|
||||||
locationId,
|
locationId,
|
||||||
@@ -946,7 +946,7 @@ Coordinates: ${product.hidden_coordinates}
|
|||||||
subcategoryId,
|
subcategoryId,
|
||||||
productId
|
productId
|
||||||
});
|
});
|
||||||
|
|
||||||
await bot.editMessageText(message, {
|
await bot.editMessageText(message, {
|
||||||
chat_id: chatId,
|
chat_id: chatId,
|
||||||
message_id: messageId,
|
message_id: messageId,
|
||||||
|
|||||||
Reference in New Issue
Block a user