@cryptotaxi247 / CoPilot / commits / 9400b90b

Case notification count (#352)

* Add logging for case notification count increment * feat: add notification_invoked_number tooltip * refactor: remove logging from increment_case_notification_count function --------- Co-authored-by: Davide Di Modica <webmaster.ddm@gmail.com>

taylor_socfortress committed Dec 5, 2024 at 11:54 UTC 9400b90b7eb711275b9076dabf9d3ee0d464dda8
3 files changed +32 -8
frontend/src/components/incidentManagement/cases/CaseItem.vue
+6 -1
@@ -163,7 +163,12 @@
163 Delete Case
164 </n-button>
165 <CaseReportButton :case-id="caseEntity.id" size="tiny" />
166 - <CaseNotificationButton :case-id="caseEntity.id" size="tiny" />
166 + <CaseNotificationButton
167 + :case-id="caseEntity.id"
168 + :notification-invoked-number="caseEntity.notification_invoked_number || 0"
169 + size="tiny"
170 + @invoked="getCase(caseEntity.id)"
171 + />
172 </div>
173 </template>
174 <div class="flex flex-col gap-2">
frontend/src/components/incidentManagement/cases/CaseNotificationButton.vue
+25 -7
@@ -1,20 +1,37 @@
1 <template>
2 - <n-button :size :loading="invoking" secondary @click="invoke()">
3 - <template #icon>
4 - <Icon :name="NotificationIcon" />
2 + <n-tooltip trigger="hover">
3 + <template #trigger>
4 + <n-button :size :loading="invoking" secondary @click="invoke()">
5 + <template #icon>
6 + <Icon :name="NotificationIcon" />
7 + </template>
8 + Invoke Customer Notification
9 + </n-button>
10 </template>
6 - Invoke Customer Notification
7 - </n-button>
11 + <div>
12 + Invoked
13 + <code>{{ notificationInvokedNumber }}</code>
14 + {{ notificationInvokedNumber === 1 ? "time" : "times" }}
15 + </div>
16 + </n-tooltip>
17 </template>
18
19 <script setup lang="ts">
20 import type { Size } from "naive-ui/es/button/src/interface"
21 import Api from "@/api"
22 import Icon from "@/components/common/Icon.vue"
14 -import { NButton, useMessage } from "naive-ui"
23 +import { NButton, NTooltip, useMessage } from "naive-ui"
24 import { ref } from "vue"
25
17 -const { size, caseId } = defineProps<{ size?: Size; caseId: number }>()
26 +const { size, caseId, notificationInvokedNumber } = defineProps<{
27 + size?: Size
28 + caseId: number
29 + notificationInvokedNumber: number
30 +}>()
31 +
32 +const emit = defineEmits<{
33 + (e: "invoked"): void
34 +}>()
35
36 const NotificationIcon = "ph:bell"
37 const invoking = ref(false)
@@ -27,6 +44,7 @@ function invoke() {
44 .createCaseNotification(caseId)
45 .then(res => {
46 if (res.data) {
47 + emit("invoked")
48 message.success(res.data.message || "Case notification created successfully.")
49 } else {
50 message.warning("An error occurred. Please try again later.")
frontend/src/types/incidentManagement/cases.d.ts
+1
@@ -8,6 +8,7 @@ export interface Case {
8 assigned_to: null | string
9 case_status: null | CaseStatus
10 customer_code: null | string
11 + notification_invoked_number?: number
12 alerts: Alert[]
13 }
14