-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathStatusLogEvent.vue
More file actions
100 lines (87 loc) · 2.99 KB
/
StatusLogEvent.vue
File metadata and controls
100 lines (87 loc) · 2.99 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
95
96
97
98
99
100
<template>
<div
class="relative block cursor-pointer space-y-2 px-3 py-2 text-sm hover:[&_.revision-message]:underline"
:class="{
'status-published': isCurrent,
}"
>
<div class="flex gap-3">
<Avatar v-if="event.user" :user="event.user" class="size-6 shrink-0 mt-1" />
<div v-else class="size-6 shrink-0 mt-1" />
<div class="grid gap-1">
<div class="revision-message font-medium">
{{ statusType }} changed to <span class="font-medium">{{ status }}</span>
</div>
<div v-if="event.data.reason" class="revision-message font-medium text-xs" v-text="event.data.reason" />
<Subheading class="text-xs text-gray-500! dark:text-gray-400!">
{{ time }}
<template v-if="event.user">
by {{ event.user.name || event.user.email }}
</template>
</Subheading>
</div>
<div class="flex items-center gap-1 ml-auto">
<Badge
v-if="isCurrent"
size="sm"
color="gray"
:text="__('Current')"
/>
</div>
</div>
</div>
</template>
<script>
import axios from 'axios';
import { DateFormatter } from '@statamic/cms';
import { Badge, Subheading, Avatar } 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);
},
time() {
return DateFormatter.format(this.event.timestamp * 1000, 'time');
},
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>