Skip to content

Commit 92b4334

Browse files
authored
Merge pull request #1 from sparebank1utvikling/sort-categories
sort categories alphabetically
2 parents 55de5fb + 408436a commit 92b4334

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/db.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function getCategoriesArray() {
122122
const result = await client.query("SELECT name FROM categories");
123123
const categories = result.rows.map((row) => row.name);
124124
console.log("categories", categories);
125-
return categories;
125+
return (categories ?? []).sort((a, b) => a.localeCompare(b));
126126
} catch (err) {
127127
console.error("Error fetching categories", err);
128128
}

app/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ app.event("message", async ({ event, client }) => {
100100
app.options(/category_select-.*/, async ({ options, ack }) => {
101101
try {
102102
// Fetch the list of categories dynamically
103-
const categories = (await getCategoriesArray()) ?? [];
103+
const categories = await getCategoriesArray();
104104

105105
// Get the user input from the options.value field
106106
const userInput = options.value || "";

0 commit comments

Comments
 (0)