Skip to content

Commit

Permalink
Add unassign button
Browse files Browse the repository at this point in the history
  • Loading branch information
KjellBerlin committed Sep 23, 2024
1 parent 3d8df17 commit aa34325
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/main/kotlin/com/carbonara/core/slack/SlackMessageService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SlackMessageService {
OrderStatus.DELIVERY_IN_PROGRESS -> updateOrderMessageToDeliveryInProgress(params)
OrderStatus.DELIVERED -> updateOrderMessageToDelivered(params)
OrderStatus.CANCELLED -> updateOrderMessageToCancelled(params)
OrderStatus.FINDING_AVAILABLE_RIDER -> updateOrderMessageToUnassigned(params)
else -> throw IllegalArgumentException("Cannot update slack message based on order status ${params.orderStatus}")
}

Expand Down Expand Up @@ -141,6 +142,11 @@ class SlackMessageService {
value(params.orderId)
actionId("cancelled")
}
button {
text("UNASSIGN", emoji = true)
value(params.orderId)
actionId("unassign")
}
}
divider()
}
Expand Down Expand Up @@ -195,6 +201,11 @@ class SlackMessageService {
value(params.orderId)
actionId("cancelled")
}
button {
text("UNASSIGN", emoji = true)
value(params.orderId)
actionId("unassign")
}
}
divider()
}
Expand Down Expand Up @@ -249,6 +260,11 @@ class SlackMessageService {
value(params.orderId)
actionId("cancelled")
}
button {
text("UNASSIGN", emoji = true)
value(params.orderId)
actionId("unassign")
}
}
divider()
}
Expand Down Expand Up @@ -303,6 +319,63 @@ class SlackMessageService {
value(params.orderId)
actionId("cancelled")
}
button {
text("UNASSIGN", emoji = true)
value(params.orderId)
actionId("unassign")
}
}
divider()
}
}
}

fun updateOrderMessageToUnassigned(
params: SlackMessageParams
): ChatUpdateResponse? {

val slack = Slack.getInstance()
return slack.methods(slackToken).chatUpdate { req -> req
.channel(slackChannel)
.ts(params.timeStamp)
.blocks {
section {
fields {
markdownText("*Customer Name:*\n${params.customerName}")
markdownText("*OrderId:*\n${params.orderId}")
}
}
section {
fields {
markdownText("*Address:*\n${params.address}\n${params.googleMapsLink}")
markdownText("*Products:*\n${params.productNames.joinToString(", ")}")
}
}
actions {
button {
text("ACCEPT", emoji = true)
style("primary")
value(params.orderId)
actionId("accept")
}
button {
text("DELIVERY IN PROGRESS", emoji = true)
style("primary")
value(params.orderId)
actionId("delivery_in_progress")
}
button {
text("DELIVERED", emoji = true)
style("primary")
value(params.orderId)
actionId("delivered")
}
button {
text("CANCELLED", emoji = true)
style("danger")
value(params.orderId)
actionId("cancelled")
}
}
divider()
}
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/carbonara/core/slack/SlackService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SlackService(
"delivery_in_progress" -> OrderStatus.DELIVERY_IN_PROGRESS
"delivered" -> OrderStatus.DELIVERED
"cancelled" -> OrderStatus.CANCELLED
"unassign" -> OrderStatus.FINDING_AVAILABLE_RIDER
else -> throw IllegalArgumentException("Invalid slack order status: $slackOrderStatus")
}
}
Expand Down

0 comments on commit aa34325

Please sign in to comment.