diff --git a/src/handlers/accept.ts b/src/handlers/accept.ts index 83d4d64..e2e816e 100644 --- a/src/handlers/accept.ts +++ b/src/handlers/accept.ts @@ -24,7 +24,7 @@ export async function handleAcceptModal({ ack, body, view, client }: SlackViewMi const time_request = data.timeRequests[request_id] await client.chat.postMessage({ channel: time_request.userId, text: getAcceptedDm(body.user.id, time_request.time, time_request.activity, body.view.state.values.message.input.value) }) - await handleAccept(time_request, body, client, "regular") + await handleAccept(time_request, body, client, body.view.state.values.type_selector.selector.selected_option?.value as keyof typeof submission_prefixes ?? "regular") delete data.timeRequests[request_id] saveData() diff --git a/src/views/respond.ts b/src/views/respond.ts index 5394455..f7f6dbf 100644 --- a/src/views/respond.ts +++ b/src/views/respond.ts @@ -1,20 +1,20 @@ import type { ModalView } from "@slack/bolt"; import { formatDuration, sanitizeCodeblock } from "../messages"; -export function getRespondMessageModal(type: "Accept"|"Reject", name:string, hours:number, activity:string, request_id:string): ModalView { +export function getRespondMessageModal(type: "Accept" | "Reject", name: string, hours: number, activity: string, request_id: string): ModalView { const callback_id = `${type.toLowerCase()}_modal` - return { + const data:ModalView = { type: "modal", private_metadata: request_id, callback_id: callback_id, title: { type: "plain_text", - text: type+"Time Request", + text: type + "Time Request", emoji: true }, submit: { type: "plain_text", - text: type+" and Send", + text: type + " and Send", emoji: true }, close: { @@ -43,10 +43,66 @@ export function getRespondMessageModal(type: "Accept"|"Reject", name:string, hou }, label: { type: "plain_text", - text: type+" and Send Message", + text: type + " and Send Message", emoji: true } } ] } + if (type == "Accept") { + data.blocks.push({ + block_id: "type_selector", + type: "input", + label: { + type: "plain_text", + text: "Type of submission", + emoji: true + }, + element: { + action_id:"selector", + type: "static_select", + initial_option: { + text: { + type: "plain_text", + text: "Regular", + emoji: true + }, + value: "regular" + }, + placeholder: { + "type": "plain_text", + "emoji": true, + text: "Select a type" + }, + // options: Object.values(metrics), + options: [ + { + text: { + type: "plain_text", + text: "Regular", + emoji: true + }, + value: "regular" + }, + { + text: { + type: "plain_text", + text: "Summer ☀️", + emoji: true + }, + value: "summer" + }, + { + text: { + type: "plain_text", + text: "Competition", + emoji: true + }, + value: "competition" + } + ], + } + }) + } + return data }