Skip to content

Commit

Permalink
Fix message listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinan-96 committed Sep 16, 2024
1 parent bc34a65 commit cc9f507
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ app.event("message", async ({ event, client, context }) => {
options: categories.map((category) => ({
text: {
type: "plain_text",
text: category,
text: category, // This is the display text for the option
},
value: category,
value: createCategoryIdentifier(category), // This is the value sent when the option is selected
})),
},
},
Expand Down Expand Up @@ -335,4 +335,12 @@ async function generateIncByCategoryChart(numberOfDays){
chart.setWidth(800);
chart.setHeight(400);
return chart.getUrl();
}

// Function to create a unique identifier from a category name
function createCategoryIdentifier(categoryName) {
return categoryName
.toLowerCase() // Convert to lowercase
.replace(/\s+/g, '-') // Replace spaces with hyphens
.replace(/[^\w-]/g, ''); // Remove any non-alphanumeric characters except hyphens
}

0 comments on commit cc9f507

Please sign in to comment.