@escalated-dev/escalated 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,39 @@
1
- <script setup>
2
- import { inject, computed } from 'vue';
3
-
4
- const props = defineProps({
5
- priority: { type: String, required: true },
6
- });
7
-
8
- const escDark = inject('esc-dark', computed(() => false));
9
-
10
- const darkConfig = {
11
- low: { label: 'Low', color: 'bg-gray-500/10 text-gray-400 ring-1 ring-gray-500/20' },
12
- medium: { label: 'Medium', color: 'bg-cyan-500/10 text-white ring-1 ring-cyan-500/20' },
13
- high: { label: 'High', color: 'bg-amber-500/10 text-amber-400 ring-1 ring-amber-500/20' },
14
- urgent: { label: 'Urgent', color: 'bg-orange-500/10 text-orange-400 ring-1 ring-orange-500/20' },
15
- critical: { label: 'Critical', color: 'bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20' },
16
- };
17
-
18
- const lightConfig = {
19
- low: { label: 'Low', color: 'bg-gray-100 text-gray-800' },
20
- medium: { label: 'Medium', color: 'bg-blue-100 text-blue-800' },
21
- high: { label: 'High', color: 'bg-yellow-100 text-yellow-800' },
22
- urgent: { label: 'Urgent', color: 'bg-orange-100 text-orange-800' },
23
- critical: { label: 'Critical', color: 'bg-red-100 text-red-800' },
24
- };
25
-
26
- const config = computed(() => {
27
- const map = escDark.value ? darkConfig : lightConfig;
28
- const fallback = escDark.value
29
- ? { label: props.priority, color: 'bg-gray-500/10 text-gray-400 ring-1 ring-gray-500/20' }
30
- : { label: props.priority, color: 'bg-gray-100 text-gray-800' };
31
- return map[props.priority] || fallback;
32
- });
33
- </script>
34
-
35
- <template>
36
- <span :class="['inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium', config.color]">
37
- {{ config.label }}
38
- </span>
39
- </template>
1
+ <script setup>
2
+ import { inject, computed } from 'vue';
3
+
4
+ const props = defineProps({
5
+ priority: { type: String, required: true },
6
+ });
7
+
8
+ const escDark = inject('esc-dark', computed(() => false));
9
+
10
+ const darkConfig = {
11
+ low: { label: 'Low', color: 'bg-gray-500/10 text-gray-400 ring-1 ring-gray-500/20' },
12
+ medium: { label: 'Medium', color: 'bg-cyan-500/10 text-white ring-1 ring-cyan-500/20' },
13
+ high: { label: 'High', color: 'bg-amber-500/10 text-amber-400 ring-1 ring-amber-500/20' },
14
+ urgent: { label: 'Urgent', color: 'bg-orange-500/10 text-orange-400 ring-1 ring-orange-500/20' },
15
+ critical: { label: 'Critical', color: 'bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20' },
16
+ };
17
+
18
+ const lightConfig = {
19
+ low: { label: 'Low', color: 'bg-gray-100 text-gray-800' },
20
+ medium: { label: 'Medium', color: 'bg-blue-100 text-blue-800' },
21
+ high: { label: 'High', color: 'bg-yellow-100 text-yellow-800' },
22
+ urgent: { label: 'Urgent', color: 'bg-orange-100 text-orange-800' },
23
+ critical: { label: 'Critical', color: 'bg-red-100 text-red-800' },
24
+ };
25
+
26
+ const config = computed(() => {
27
+ const map = escDark.value ? darkConfig : lightConfig;
28
+ const fallback = escDark.value
29
+ ? { label: props.priority, color: 'bg-gray-500/10 text-gray-400 ring-1 ring-gray-500/20' }
30
+ : { label: props.priority, color: 'bg-gray-100 text-gray-800' };
31
+ return map[props.priority] || fallback;
32
+ });
33
+ </script>
34
+
35
+ <template>
36
+ <span :class="['inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium', config.color]">
37
+ {{ config.label }}
38
+ </span>
39
+ </template>
@@ -1,159 +1,159 @@
1
- <script setup>
2
- import { ref, computed, inject } from 'vue';
3
- import { router } from '@inertiajs/vue3';
4
- import FileDropzone from './FileDropzone.vue';
5
-
6
- const props = defineProps({
7
- action: { type: String, required: true },
8
- cannedResponses: { type: Array, default: () => [] },
9
- allowNotes: { type: Boolean, default: false },
10
- placeholder: { type: String, default: 'Type your reply...' },
11
- submitLabel: { type: String, default: null },
12
- });
13
-
14
- const emit = defineEmits(['submit']);
15
- const escDark = inject('esc-dark', computed(() => false));
16
-
17
- const body = ref('');
18
- const isNote = ref(false);
19
- const files = ref([]);
20
- const submitting = ref(false);
21
-
22
- function insertCanned(response) {
23
- body.value += response.body;
24
- }
25
-
26
- function handleFiles(newFiles) {
27
- files.value = [...files.value, ...newFiles];
28
- }
29
-
30
- function removeFile(index) {
31
- files.value.splice(index, 1);
32
- }
33
-
34
- function submit() {
35
- if (!body.value.trim() || submitting.value) return;
36
- submitting.value = true;
37
-
38
- const payload = {
39
- body: body.value,
40
- is_internal_note: isNote.value,
41
- attachments: files.value,
42
- };
43
-
44
- emit('submit', payload);
45
-
46
- router.post(props.action, payload, {
47
- preserveScroll: true,
48
- onSuccess: () => {
49
- body.value = '';
50
- files.value = [];
51
- isNote.value = false;
52
- },
53
- onFinish: () => {
54
- submitting.value = false;
55
- },
56
- });
57
- }
58
-
59
- const buttonLabel = computed(() => {
60
- if (props.submitLabel) return props.submitLabel;
61
- return isNote.value ? 'Add Note' : 'Send Reply';
62
- });
63
- </script>
64
-
65
- <template>
66
- <!-- Dark mode -->
67
- <div v-if="escDark" class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-4">
68
- <div v-if="allowNotes" class="mb-3 flex gap-2">
69
- <button @click="isNote = false"
70
- :class="['rounded-lg px-3 py-1.5 text-sm font-medium transition-colors', !isNote ? 'bg-cyan-500/15 text-white ring-1 ring-cyan-500/20' : 'text-gray-400 hover:bg-white/[0.04]']">
71
- Reply
72
- </button>
73
- <button @click="isNote = true"
74
- :class="['rounded-lg px-3 py-1.5 text-sm font-medium transition-colors', isNote ? 'bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/20' : 'text-gray-400 hover:bg-white/[0.04]']">
75
- Internal Note
76
- </button>
77
- </div>
78
-
79
- <div v-if="isNote" class="mb-2 rounded-lg bg-amber-500/10 px-3 py-1.5 text-xs text-amber-400 ring-1 ring-amber-500/20">
80
- This note is only visible to agents.
81
- </div>
82
-
83
- <textarea v-model="body" rows="4" :placeholder="placeholder"
84
- class="w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"></textarea>
85
-
86
- <FileDropzone @files="handleFiles" class="mt-2" />
87
-
88
- <div v-if="files.length" class="mt-2 space-y-1">
89
- <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-400">
90
- <span>{{ file.name }}</span>
91
- <button @click="removeFile(i)" class="text-rose-400 hover:text-rose-300">&times;</button>
92
- </div>
93
- </div>
94
-
95
- <div class="mt-3 flex items-center justify-between">
96
- <div v-if="cannedResponses.length">
97
- <select @change="insertCanned(cannedResponses[$event.target.value]); $event.target.value = ''"
98
- class="rounded-lg border border-white/10 bg-gray-900 px-2 py-1 text-xs text-gray-400">
99
- <option value="">Canned responses...</option>
100
- <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
101
- </select>
102
- </div>
103
- <div v-else></div>
104
- <button @click="submit" :disabled="!body.trim() || submitting"
105
- :class="['rounded-lg px-4 py-2 text-sm font-medium text-white transition-all',
106
- isNote ? 'bg-amber-500 hover:bg-amber-400' : 'bg-gradient-to-r from-cyan-500 to-violet-500 hover:from-cyan-400 hover:to-violet-400',
107
- (!body.trim() || submitting) && 'cursor-not-allowed opacity-40']">
108
- {{ buttonLabel }}
109
- </button>
110
- </div>
111
- </div>
112
-
113
- <!-- Light mode -->
114
- <div v-else class="rounded-lg border border-gray-200 bg-white p-4">
115
- <div v-if="allowNotes" class="mb-3 flex gap-2">
116
- <button @click="isNote = false"
117
- :class="['rounded-md px-3 py-1 text-sm font-medium', !isNote ? 'bg-blue-100 text-blue-700' : 'text-gray-500 hover:bg-gray-100']">
118
- Reply
119
- </button>
120
- <button @click="isNote = true"
121
- :class="['rounded-md px-3 py-1 text-sm font-medium', isNote ? 'bg-yellow-100 text-yellow-700' : 'text-gray-500 hover:bg-gray-100']">
122
- Internal Note
123
- </button>
124
- </div>
125
-
126
- <div v-if="isNote" class="mb-2 rounded bg-yellow-50 px-3 py-1.5 text-xs text-yellow-700">
127
- This note is only visible to agents.
128
- </div>
129
-
130
- <textarea v-model="body" rows="4" :placeholder="placeholder"
131
- class="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"></textarea>
132
-
133
- <FileDropzone @files="handleFiles" class="mt-2" />
134
-
135
- <div v-if="files.length" class="mt-2 space-y-1">
136
- <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-600">
137
- <span>{{ file.name }}</span>
138
- <button @click="removeFile(i)" class="text-red-500 hover:text-red-700">&times;</button>
139
- </div>
140
- </div>
141
-
142
- <div class="mt-3 flex items-center justify-between">
143
- <div v-if="cannedResponses.length">
144
- <select @change="insertCanned(cannedResponses[$event.target.value]); $event.target.value = ''"
145
- class="rounded border border-gray-300 px-2 py-1 text-xs text-gray-600">
146
- <option value="">Canned responses...</option>
147
- <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
148
- </select>
149
- </div>
150
- <div v-else></div>
151
- <button @click="submit" :disabled="!body.trim() || submitting"
152
- :class="['rounded-md px-4 py-2 text-sm font-medium text-white',
153
- isNote ? 'bg-yellow-500 hover:bg-yellow-600' : 'bg-blue-600 hover:bg-blue-700',
154
- (!body.trim() || submitting) && 'cursor-not-allowed opacity-50']">
155
- {{ buttonLabel }}
156
- </button>
157
- </div>
158
- </div>
159
- </template>
1
+ <script setup>
2
+ import { ref, computed, inject } from 'vue';
3
+ import { router } from '@inertiajs/vue3';
4
+ import FileDropzone from './FileDropzone.vue';
5
+
6
+ const props = defineProps({
7
+ action: { type: String, required: true },
8
+ cannedResponses: { type: Array, default: () => [] },
9
+ allowNotes: { type: Boolean, default: false },
10
+ placeholder: { type: String, default: 'Type your reply...' },
11
+ submitLabel: { type: String, default: null },
12
+ });
13
+
14
+ const emit = defineEmits(['submit']);
15
+ const escDark = inject('esc-dark', computed(() => false));
16
+
17
+ const body = ref('');
18
+ const isNote = ref(false);
19
+ const files = ref([]);
20
+ const submitting = ref(false);
21
+
22
+ function insertCanned(response) {
23
+ body.value += response.body;
24
+ }
25
+
26
+ function handleFiles(newFiles) {
27
+ files.value = [...files.value, ...newFiles];
28
+ }
29
+
30
+ function removeFile(index) {
31
+ files.value.splice(index, 1);
32
+ }
33
+
34
+ function submit() {
35
+ if (!body.value.trim() || submitting.value) return;
36
+ submitting.value = true;
37
+
38
+ const payload = {
39
+ body: body.value,
40
+ is_internal_note: isNote.value,
41
+ attachments: files.value,
42
+ };
43
+
44
+ emit('submit', payload);
45
+
46
+ router.post(props.action, payload, {
47
+ preserveScroll: true,
48
+ onSuccess: () => {
49
+ body.value = '';
50
+ files.value = [];
51
+ isNote.value = false;
52
+ },
53
+ onFinish: () => {
54
+ submitting.value = false;
55
+ },
56
+ });
57
+ }
58
+
59
+ const buttonLabel = computed(() => {
60
+ if (props.submitLabel) return props.submitLabel;
61
+ return isNote.value ? 'Add Note' : 'Send Reply';
62
+ });
63
+ </script>
64
+
65
+ <template>
66
+ <!-- Dark mode -->
67
+ <div v-if="escDark" class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-4">
68
+ <div v-if="allowNotes" class="mb-3 flex gap-2">
69
+ <button @click="isNote = false"
70
+ :class="['rounded-lg px-3 py-1.5 text-sm font-medium transition-colors', !isNote ? 'bg-cyan-500/15 text-white ring-1 ring-cyan-500/20' : 'text-gray-400 hover:bg-white/[0.04]']">
71
+ Reply
72
+ </button>
73
+ <button @click="isNote = true"
74
+ :class="['rounded-lg px-3 py-1.5 text-sm font-medium transition-colors', isNote ? 'bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/20' : 'text-gray-400 hover:bg-white/[0.04]']">
75
+ Internal Note
76
+ </button>
77
+ </div>
78
+
79
+ <div v-if="isNote" class="mb-2 rounded-lg bg-amber-500/10 px-3 py-1.5 text-xs text-amber-400 ring-1 ring-amber-500/20">
80
+ This note is only visible to agents.
81
+ </div>
82
+
83
+ <textarea v-model="body" rows="4" :placeholder="placeholder"
84
+ class="w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"></textarea>
85
+
86
+ <FileDropzone @files="handleFiles" class="mt-2" />
87
+
88
+ <div v-if="files.length" class="mt-2 space-y-1">
89
+ <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-400">
90
+ <span>{{ file.name }}</span>
91
+ <button @click="removeFile(i)" class="text-rose-400 hover:text-rose-300">&times;</button>
92
+ </div>
93
+ </div>
94
+
95
+ <div class="mt-3 flex items-center justify-between">
96
+ <div v-if="cannedResponses.length">
97
+ <select @change="insertCanned(cannedResponses[$event.target.value]); $event.target.value = ''"
98
+ class="rounded-lg border border-white/10 bg-gray-900 px-2 py-1 text-xs text-gray-400">
99
+ <option value="">Canned responses...</option>
100
+ <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
101
+ </select>
102
+ </div>
103
+ <div v-else></div>
104
+ <button @click="submit" :disabled="!body.trim() || submitting"
105
+ :class="['rounded-lg px-4 py-2 text-sm font-medium text-white transition-all',
106
+ isNote ? 'bg-amber-500 hover:bg-amber-400' : 'bg-gradient-to-r from-cyan-500 to-violet-500 hover:from-cyan-400 hover:to-violet-400',
107
+ (!body.trim() || submitting) && 'cursor-not-allowed opacity-40']">
108
+ {{ buttonLabel }}
109
+ </button>
110
+ </div>
111
+ </div>
112
+
113
+ <!-- Light mode -->
114
+ <div v-else class="rounded-lg border border-gray-200 bg-white p-4">
115
+ <div v-if="allowNotes" class="mb-3 flex gap-2">
116
+ <button @click="isNote = false"
117
+ :class="['rounded-md px-3 py-1 text-sm font-medium', !isNote ? 'bg-blue-100 text-blue-700' : 'text-gray-500 hover:bg-gray-100']">
118
+ Reply
119
+ </button>
120
+ <button @click="isNote = true"
121
+ :class="['rounded-md px-3 py-1 text-sm font-medium', isNote ? 'bg-yellow-100 text-yellow-700' : 'text-gray-500 hover:bg-gray-100']">
122
+ Internal Note
123
+ </button>
124
+ </div>
125
+
126
+ <div v-if="isNote" class="mb-2 rounded bg-yellow-50 px-3 py-1.5 text-xs text-yellow-700">
127
+ This note is only visible to agents.
128
+ </div>
129
+
130
+ <textarea v-model="body" rows="4" :placeholder="placeholder"
131
+ class="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"></textarea>
132
+
133
+ <FileDropzone @files="handleFiles" class="mt-2" />
134
+
135
+ <div v-if="files.length" class="mt-2 space-y-1">
136
+ <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-600">
137
+ <span>{{ file.name }}</span>
138
+ <button @click="removeFile(i)" class="text-red-500 hover:text-red-700">&times;</button>
139
+ </div>
140
+ </div>
141
+
142
+ <div class="mt-3 flex items-center justify-between">
143
+ <div v-if="cannedResponses.length">
144
+ <select @change="insertCanned(cannedResponses[$event.target.value]); $event.target.value = ''"
145
+ class="rounded border border-gray-300 px-2 py-1 text-xs text-gray-600">
146
+ <option value="">Canned responses...</option>
147
+ <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
148
+ </select>
149
+ </div>
150
+ <div v-else></div>
151
+ <button @click="submit" :disabled="!body.trim() || submitting"
152
+ :class="['rounded-md px-4 py-2 text-sm font-medium text-white',
153
+ isNote ? 'bg-yellow-500 hover:bg-yellow-600' : 'bg-blue-600 hover:bg-blue-700',
154
+ (!body.trim() || submitting) && 'cursor-not-allowed opacity-50']">
155
+ {{ buttonLabel }}
156
+ </button>
157
+ </div>
158
+ </div>
159
+ </template>
@@ -2,6 +2,8 @@
2
2
  import { inject, computed } from 'vue';
3
3
  import { router } from '@inertiajs/vue3';
4
4
  import AttachmentList from './AttachmentList.vue';
5
+ import { sanitizeHtml } from '../utils/sanitizeHtml';
6
+ import { useI18n } from '../composables/useI18n';
5
7
 
6
8
  const props = defineProps({
7
9
  replies: { type: Array, required: true },
@@ -12,6 +14,7 @@ const props = defineProps({
12
14
  });
13
15
 
14
16
  const escDark = inject('esc-dark', computed(() => false));
17
+ const { t } = useI18n();
15
18
 
16
19
  function formatDate(date) {
17
20
  return new Date(date).toLocaleString();
@@ -31,14 +34,14 @@ function togglePin(reply) {
31
34
  : (reply.is_internal_note ? 'border-yellow-200 bg-yellow-50' : 'border-gray-200 bg-white')]">
32
35
  <div class="mb-2 flex items-center justify-between">
33
36
  <div class="flex items-center gap-2">
34
- <span :class="['font-medium', escDark ? 'text-gray-200' : 'text-gray-900']">{{ reply.author?.name || 'Unknown' }}</span>
37
+ <span :class="['font-medium', escDark ? 'text-gray-200' : 'text-gray-900']">{{ reply.author?.name || t('ticket.unknown') }}</span>
35
38
  <span v-if="reply.is_internal_note"
36
39
  :class="['rounded px-1.5 py-0.5 text-xs font-medium', escDark ? 'bg-amber-500/15 text-amber-400' : 'bg-yellow-200 text-yellow-800']">
37
- Internal Note
40
+ {{ t('reply.internal_note') }}
38
41
  </span>
39
42
  <span v-if="reply.is_pinned"
40
43
  :class="['rounded px-1.5 py-0.5 text-xs font-medium', escDark ? 'bg-cyan-500/15 text-cyan-400' : 'bg-blue-100 text-blue-700']">
41
- Pinned
44
+ {{ t('reply.pinned') }}
42
45
  </span>
43
46
  </div>
44
47
  <div class="flex items-center gap-2">
@@ -47,14 +50,14 @@ function togglePin(reply) {
47
50
  escDark
48
51
  ? (reply.is_pinned ? 'bg-cyan-500/15 text-cyan-400 hover:bg-cyan-500/25' : 'text-neutral-500 hover:bg-white/[0.06] hover:text-neutral-300')
49
52
  : (reply.is_pinned ? 'bg-blue-100 text-blue-700 hover:bg-blue-200' : 'text-gray-400 hover:bg-gray-100 hover:text-gray-600')]">
50
- {{ reply.is_pinned ? 'Unpin' : 'Pin' }}
53
+ {{ reply.is_pinned ? t('reply.unpin') : t('reply.pin') }}
51
54
  </button>
52
55
  <span :class="['text-xs', escDark ? 'text-gray-500' : 'text-gray-500']">{{ formatDate(reply.created_at) }}</span>
53
56
  </div>
54
57
  </div>
55
- <div :class="['prose prose-sm max-w-none', escDark ? 'prose-invert text-gray-300' : 'text-gray-700']" v-html="reply.body"></div>
58
+ <div :class="['prose prose-sm max-w-none', escDark ? 'prose-invert text-gray-300' : 'text-gray-700']" v-html="sanitizeHtml(reply.body)"></div>
56
59
  <AttachmentList v-if="reply.attachments?.length" :attachments="reply.attachments" class="mt-3" />
57
60
  </div>
58
- <div v-if="!replies?.length" :class="['py-8 text-center text-sm', escDark ? 'text-gray-500' : 'text-gray-500']">No replies yet.</div>
61
+ <div v-if="!replies?.length" :class="['py-8 text-center text-sm', escDark ? 'text-gray-500' : 'text-gray-500']">{{ t('ticket.no_replies') }}</div>
59
62
  </div>
60
63
  </template>
@@ -1,49 +1,49 @@
1
- <script setup>
2
- import { computed, inject } from 'vue';
3
-
4
- const props = defineProps({
5
- dueAt: { type: String, default: null },
6
- breached: { type: Boolean, default: false },
7
- label: { type: String, default: 'Due' },
8
- });
9
-
10
- const dark = inject('esc-dark', computed(() => false));
11
-
12
- const timeRemaining = computed(() => {
13
- if (!props.dueAt) return null;
14
- const now = new Date();
15
- const due = new Date(props.dueAt);
16
- const diff = due - now;
17
- if (diff <= 0) return { text: 'Overdue', overdue: true };
18
-
19
- const hours = Math.floor(diff / 3600000);
20
- const minutes = Math.floor((diff % 3600000) / 60000);
21
- if (hours > 24) {
22
- const days = Math.floor(hours / 24);
23
- return { text: `${days}d ${hours % 24}h`, overdue: false };
24
- }
25
- return { text: `${hours}h ${minutes}m`, overdue: false };
26
- });
27
-
28
- const statusClass = computed(() => {
29
- if (props.breached || timeRemaining.value?.overdue) {
30
- return dark ? 'border-rose-500/20 bg-rose-500/10 text-rose-400' : 'border-red-300 bg-red-50 text-red-700';
31
- }
32
- const due = new Date(props.dueAt);
33
- const hoursLeft = (due - new Date()) / 3600000;
34
- if (hoursLeft < 2) {
35
- return dark ? 'border-amber-500/20 bg-amber-500/10 text-amber-400' : 'border-yellow-300 bg-yellow-50 text-yellow-700';
36
- }
37
- return dark ? 'border-emerald-500/20 bg-emerald-500/10 text-emerald-400' : 'border-green-300 bg-green-50 text-green-700';
38
- });
39
- </script>
40
-
41
- <template>
42
- <div v-if="dueAt" :class="['rounded-lg border px-3 py-2 text-sm', statusClass]">
43
- <div class="font-medium">{{ label }}</div>
44
- <div class="text-xs">
45
- <span v-if="breached">SLA Breached</span>
46
- <span v-else>{{ timeRemaining?.text }}</span>
47
- </div>
48
- </div>
49
- </template>
1
+ <script setup>
2
+ import { computed, inject } from 'vue';
3
+
4
+ const props = defineProps({
5
+ dueAt: { type: String, default: null },
6
+ breached: { type: Boolean, default: false },
7
+ label: { type: String, default: 'Due' },
8
+ });
9
+
10
+ const dark = inject('esc-dark', computed(() => false));
11
+
12
+ const timeRemaining = computed(() => {
13
+ if (!props.dueAt) return null;
14
+ const now = new Date();
15
+ const due = new Date(props.dueAt);
16
+ const diff = due - now;
17
+ if (diff <= 0) return { text: 'Overdue', overdue: true };
18
+
19
+ const hours = Math.floor(diff / 3600000);
20
+ const minutes = Math.floor((diff % 3600000) / 60000);
21
+ if (hours > 24) {
22
+ const days = Math.floor(hours / 24);
23
+ return { text: `${days}d ${hours % 24}h`, overdue: false };
24
+ }
25
+ return { text: `${hours}h ${minutes}m`, overdue: false };
26
+ });
27
+
28
+ const statusClass = computed(() => {
29
+ if (props.breached || timeRemaining.value?.overdue) {
30
+ return dark ? 'border-rose-500/20 bg-rose-500/10 text-rose-400' : 'border-red-300 bg-red-50 text-red-700';
31
+ }
32
+ const due = new Date(props.dueAt);
33
+ const hoursLeft = (due - new Date()) / 3600000;
34
+ if (hoursLeft < 2) {
35
+ return dark ? 'border-amber-500/20 bg-amber-500/10 text-amber-400' : 'border-yellow-300 bg-yellow-50 text-yellow-700';
36
+ }
37
+ return dark ? 'border-emerald-500/20 bg-emerald-500/10 text-emerald-400' : 'border-green-300 bg-green-50 text-green-700';
38
+ });
39
+ </script>
40
+
41
+ <template>
42
+ <div v-if="dueAt" :class="['rounded-lg border px-3 py-2 text-sm', statusClass]">
43
+ <div class="font-medium">{{ label }}</div>
44
+ <div class="text-xs">
45
+ <span v-if="breached">SLA Breached</span>
46
+ <span v-else>{{ timeRemaining?.text }}</span>
47
+ </div>
48
+ </div>
49
+ </template>