Skip to content

Commit

Permalink
fix keyboards and create generateOptionKeyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
oleh19127 committed Jan 18, 2024
1 parent 78f29e3 commit 17074e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bot/keyboards/generateOptionKeyboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Keyboard } from 'grammy';
import { Option } from '../../db/entity/Option';
import { logger } from '../../utils/logger/logger';

export const generateOptionKeyboard = async (
array: Option[],
): Promise<string | Keyboard> => {
if (array.length === 0) {
logger.info(
'No Option to display\nTo create question and option: /add_question\nTo create option: /add_option',
);
return 'No Option to display\nTo create question and option: /add_question\nTo create option: /add_option';
}
const optionKeyboard = new Keyboard().resized();
for (const option of array) {
optionKeyboard.add(option.optionText);
}
return optionKeyboard;
};
File renamed without changes.

0 comments on commit 17074e0

Please sign in to comment.