Skip to content

Commit

Permalink
feat: add categories to message approval too
Browse files Browse the repository at this point in the history
  • Loading branch information
rutmanz committed Sep 11, 2023
1 parent 6a8baf8 commit 36dd8d8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/handlers/accept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
66 changes: 61 additions & 5 deletions src/views/respond.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -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
}

0 comments on commit 36dd8d8

Please sign in to comment.