-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathStatusLogEvent.vue
More file actions
94 lines (80 loc) · 2.79 KB
/
StatusLogEvent.vue
File metadata and controls
94 lines (80 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
<div
class="block space-y-2 px-3 py-2 text-sm hover:bg-gray-50 dark:hover:bg-gray-900"
:class="{
'status-published': isCurrent,
}"
>
<div class="revision-item-note truncate">
{{ statusType }} changed to <span class="font-medium">{{ status }}</span>
</div>
<div class="flex items-center gap-2">
<avatar v-if="event.user" :user="event.user" class="size-6 shrink-0" />
<div class="revision-item-content flex w-full">
<div class="flex-1">
<Subheading>
<template v-if="event.user">
{{ event.user.name || event.user.email }} –
</template>
{{ time }}
</Subheading>
</div>
</div>
</div>
<div v-if="isCurrent" class="flex items-center gap-1">
<Badge size="sm" color="orange" v-text="__('Current')" />
</div>
<div v-if="event.data?.reason" class="revision-item-note truncate ml-2 mt-3 font-normal text-xs" v-text="event.data.reason" />
</div>
</template>
<script>
import axios from 'axios';
import Avatar from '../../../../vendor/statamic/cms/resources/js/components/Avatar.vue'
import { Badge, Subheading } from '@statamic/cms/ui'
export default {
components: { Badge, Subheading, Avatar },
props: {
event: Object,
orderId: String,
resendNotificationsUrl: String,
orderStatuses: Array,
paymentStatuses: Array,
currentOrderStatus: String,
currentPaymentStatus: String,
},
computed: {
status() {
let status = this.event.status;
status = status.charAt(0).toUpperCase() + status.slice(1);
return __(status);
},
statusType() {
if (this.orderStatuses.includes(this.event.status)) {
return __('Order Status');
}
if (this.paymentStatuses.includes(this.event.status)) {
return __('Payment Status');
}
},
date() {
return moment.unix(this.event.timestamp);
},
isCurrent() {
return this.event.status === this.currentOrderStatus
|| this.event.status === this.currentPaymentStatus;
},
},
methods: {
resendNotifications() {
axios.post(this.resendNotificationsUrl, {
order_id: this.orderId,
status: this.event.status,
}).then(response => {
this.$toast.success(__('Notifications resent'));
}).catch(error => {
this.$toast.error(__('Unable to resend notifications'));
})
},
},
}
</script>