@mundogamernetwork/shared-ui 1.0.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.
- package/README.md +283 -0
- package/components/PressKit/AssetGallery.vue +349 -0
- package/components/PressKit/Awards.vue +100 -0
- package/components/PressKit/Credits.vue +78 -0
- package/components/PressKit/FactSheet.vue +204 -0
- package/components/PressKit/Hero.vue +143 -0
- package/components/PressKit/Quotes.vue +80 -0
- package/components/PressKit/VideoPlayer.vue +134 -0
- package/components/checkout/MgCartItemList.vue +214 -0
- package/components/checkout/MgCartSummary.vue +204 -0
- package/components/checkout/MgCheckoutSidebar.vue +230 -0
- package/components/checkout/MgGuestEmailForm.vue +97 -0
- package/components/checkout/MgPaymentMethodSelector.vue +162 -0
- package/components/checkout/MgPixQRCode.vue +222 -0
- package/components/indie-wall/IndieWallLeaderboard.vue +208 -0
- package/components/indie-wall/MuralCanvas.vue +481 -0
- package/components/indie-wall/StepBlock.vue +314 -0
- package/components/indie-wall/StepCustomize.vue +530 -0
- package/components/indie-wall/StepGoal.vue +169 -0
- package/components/indie-wall/StepPackage.vue +145 -0
- package/components/indie-wall/StepPay.vue +209 -0
- package/components/indie-wall/SupportStepper.vue +372 -0
- package/components/invoices/MgInvoiceDownload.vue +50 -0
- package/components/pricing/MgBillingToggle.vue +74 -0
- package/components/pricing/MgPricingCard.vue +245 -0
- package/components/ui/Header/MgMessageCard.vue +147 -0
- package/components/ui/Header/MgMessageModal.vue +414 -0
- package/components/ui/Header/MgNotificationCard.vue +200 -0
- package/components/ui/Header/MgNotificationsModal.vue +125 -0
- package/components/ui/MgAnnouncementBanner.vue +147 -0
- package/components/ui/MgBanners.vue +23 -0
- package/components/ui/MgHeaderComponent.vue +283 -0
- package/components/ui/MgHeaderUIConfig.vue +225 -0
- package/components/ui/MgHeaderUIUser.vue +301 -0
- package/components/ui/MgLoginModal.vue +156 -0
- package/components/ui/MgPromotionBanner.vue +185 -0
- package/composables/useLogout.ts +42 -0
- package/composables/useMgCheckout.ts +287 -0
- package/composables/useMgUserNotifications.ts +122 -0
- package/composables/usePaymentMethods.ts +75 -0
- package/composables/useSubscription.ts +163 -0
- package/middleware/auth.global.ts +40 -0
- package/nuxt.config.ts +31 -0
- package/package.json +40 -0
- package/pages/[slug]/index.vue +112 -0
- package/pages/about.vue +133 -0
- package/pages/blog.vue +430 -0
- package/pages/careers.vue +329 -0
- package/pages/contact.vue +339 -0
- package/pages/faq.vue +317 -0
- package/pages/health-check.vue +20 -0
- package/pages/icons.vue +58 -0
- package/pages/magazine/[slug].vue +209 -0
- package/pages/magazine/index.vue +267 -0
- package/pages/media-kit/[slug].vue +625 -0
- package/pages/mural/[slug].vue +1058 -0
- package/pages/partners.vue +290 -0
- package/pages/press.vue +237 -0
- package/pages/presskit/[slug].vue +191 -0
- package/pages/roadmap.vue +355 -0
- package/pages/status.vue +199 -0
- package/pages/team.vue +266 -0
- package/pages/wall/[slug].vue +11 -0
- package/plugins/auth.client.ts +17 -0
- package/plugins/echo.client.ts +132 -0
- package/services/authService.ts +95 -0
- package/services/chatService.ts +53 -0
- package/services/contactService.ts +35 -0
- package/services/documentService.ts +16 -0
- package/services/httpService.ts +95 -0
- package/services/indieWallService.ts +174 -0
- package/services/institutionalService.ts +248 -0
- package/services/mediaKitService.ts +51 -0
- package/services/notificationsService.ts +20 -0
- package/services/pressKitService.ts +55 -0
- package/stores/announcement.ts +129 -0
- package/stores/auth.ts +86 -0
- package/stores/chat.ts +150 -0
- package/stores/contact.ts +28 -0
- package/stores/document.ts +27 -0
- package/stores/index.ts +34 -0
- package/stores/institutional.ts +231 -0
- package/stores/login.ts +27 -0
- package/stores/notifications.ts +133 -0
- package/stores/promotion.ts +154 -0
- package/types/index.ts +135 -0
- package/utils/serialize.ts +29 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section id="mg-message-modal" ref="modalRef" @click.stop>
|
|
3
|
+
<div class="search" v-if="!showChatMessage">
|
|
4
|
+
<input v-model="searchTerm" :placeholder="$t('message_component.name')" @input="searchChat()" />
|
|
5
|
+
<MGIcon icon="search" />
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class="read-all--button-wrapper" v-if="!showChatMessage">
|
|
9
|
+
<a
|
|
10
|
+
class="d-flex align-items-center chats"
|
|
11
|
+
:class="{ active: activeTab === 'chats' }"
|
|
12
|
+
@click="activeTab = 'chats'"
|
|
13
|
+
>
|
|
14
|
+
{{ $t("message_component.chats") }}
|
|
15
|
+
</a>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<!-- Chat detail view -->
|
|
19
|
+
<div v-if="showChatMessage">
|
|
20
|
+
<div class="message-detail">
|
|
21
|
+
<button @click="showChatMessage = false" class="back-button">
|
|
22
|
+
<MGIcon size="2x" icon="chevron-left" />
|
|
23
|
+
{{ $t("more.header_buttons.back") }}
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
<div class="infos" v-if="chatMessages?.data?.users[0]">
|
|
27
|
+
<div class="relative">
|
|
28
|
+
<img :src="chatMessages.data.users[0].avatar_url || '/imgs/default.jpg'" width="48" height="48" />
|
|
29
|
+
</div>
|
|
30
|
+
<div class="description">
|
|
31
|
+
<div class="title">{{ chatMessages.data.users[0].nickname }}</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="message-content">
|
|
36
|
+
<div class="chat-container" ref="chatContainer">
|
|
37
|
+
<div class="messages">
|
|
38
|
+
<div
|
|
39
|
+
v-for="(group, index) in messagesGroupedByDate"
|
|
40
|
+
:key="group.date"
|
|
41
|
+
class="message-group"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
v-for="chat in group.messages"
|
|
45
|
+
:key="chat.id"
|
|
46
|
+
:class="chat.user_is_author ? 'message-me' : 'message-user'"
|
|
47
|
+
>
|
|
48
|
+
<span class="title">
|
|
49
|
+
<p class="user-name" v-if="!chat.user_is_author">{{ chat.user?.nickname }}</p>
|
|
50
|
+
{{ chat.message }}
|
|
51
|
+
<div class="message-info">{{ chat.created_at }}</div>
|
|
52
|
+
</span>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div class="input-me">
|
|
61
|
+
<textarea
|
|
62
|
+
ref="inputRef"
|
|
63
|
+
v-model="chatMessageInput"
|
|
64
|
+
:disabled="chatMessageLoading"
|
|
65
|
+
:placeholder="$t('more.contact.message_title')"
|
|
66
|
+
@keydown.enter.exact.prevent="submitChatMessage"
|
|
67
|
+
/>
|
|
68
|
+
<button class="btn secondary send" :disabled="chatMessageLoading" @click="submitChatMessage">
|
|
69
|
+
{{ chatMessageLoading ? $t("components.loading") : $t("more.contact.btn_send_message") }}
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<!-- Chat list view -->
|
|
75
|
+
<div class="cards" v-else-if="activeTab === 'chats'">
|
|
76
|
+
<template v-if="chatList.length === 0">
|
|
77
|
+
<div class="no-content">
|
|
78
|
+
<MGIcon icon="message" />
|
|
79
|
+
<p>{{ $t("message_component.chat_no_message.title") }}</p>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
<template v-else>
|
|
83
|
+
<div class="card-list">
|
|
84
|
+
<MgMessageCard
|
|
85
|
+
v-for="chat in chatList"
|
|
86
|
+
:key="chat.id"
|
|
87
|
+
:chat="chat"
|
|
88
|
+
@show-message="handleSelectedChat(chat.id)"
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
92
|
+
</div>
|
|
93
|
+
</section>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<script lang="ts" setup>
|
|
97
|
+
import { ref, computed, nextTick, watch } from "vue";
|
|
98
|
+
import { getChatList, postChatMessage, getChat } from "../../../services/chatService";
|
|
99
|
+
import { serialize } from "../../../utils/serialize";
|
|
100
|
+
|
|
101
|
+
const chatStore = useChatStore();
|
|
102
|
+
const authStore = useAuthStore();
|
|
103
|
+
const { user } = storeToRefs(authStore);
|
|
104
|
+
|
|
105
|
+
const emit = defineEmits(["toggle-visible"]);
|
|
106
|
+
const modalRef = ref<HTMLElement | null>(null);
|
|
107
|
+
const activeTab = ref<"chats" | "requests">("chats");
|
|
108
|
+
const showChatMessage = ref(false);
|
|
109
|
+
const selectedChatId = ref<number | string>(0);
|
|
110
|
+
const searchTerm = ref("");
|
|
111
|
+
const chatList = ref<any[]>([]);
|
|
112
|
+
const chatLoading = ref(false);
|
|
113
|
+
const chatMessageInput = ref("");
|
|
114
|
+
const chatMessageLoading = ref(false);
|
|
115
|
+
const chatMessages = ref<any>({});
|
|
116
|
+
const chatContainer = ref<HTMLElement | null>(null);
|
|
117
|
+
const inputRef = ref<HTMLInputElement | null>(null);
|
|
118
|
+
|
|
119
|
+
const scrollToBottom = (smooth = true) => {
|
|
120
|
+
if (!chatContainer.value) return;
|
|
121
|
+
nextTick(() => {
|
|
122
|
+
const container = chatContainer.value!;
|
|
123
|
+
container.style.scrollBehavior = smooth ? "smooth" : "auto";
|
|
124
|
+
container.scrollTop = container.scrollHeight;
|
|
125
|
+
if (smooth) setTimeout(() => { container.style.scrollBehavior = "auto"; }, 300);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const fetchChatList = async (params: any = {}) => {
|
|
130
|
+
chatLoading.value = true;
|
|
131
|
+
try {
|
|
132
|
+
const config = useRuntimeConfig();
|
|
133
|
+
const systemId = config.public.mgSharedUi?.systemId || import.meta.env.VITE_SYSTEM_ID;
|
|
134
|
+
const response = await getChatList({ mg_network_system_id: systemId, ...params });
|
|
135
|
+
chatList.value = response.data.data || response.data;
|
|
136
|
+
} catch {
|
|
137
|
+
// silent fail
|
|
138
|
+
} finally {
|
|
139
|
+
chatLoading.value = false;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const handleSelectedChat = async (chatId: string | number) => {
|
|
144
|
+
selectedChatId.value = chatId;
|
|
145
|
+
showChatMessage.value = true;
|
|
146
|
+
chatMessageLoading.value = true;
|
|
147
|
+
try {
|
|
148
|
+
const response = await getChat({ chat_id: chatId });
|
|
149
|
+
chatMessages.value = response.data;
|
|
150
|
+
chatStore.setChatMessagesWidget(response.data, true);
|
|
151
|
+
nextTick(() => scrollToBottom(false));
|
|
152
|
+
} catch {
|
|
153
|
+
// silent fail
|
|
154
|
+
} finally {
|
|
155
|
+
chatMessageLoading.value = false;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const submitChatMessage = async () => {
|
|
160
|
+
if (!chatMessageInput.value.trim() || chatMessageLoading.value) return;
|
|
161
|
+
try {
|
|
162
|
+
chatMessageLoading.value = true;
|
|
163
|
+
await postChatMessage({
|
|
164
|
+
chat_id: selectedChatId.value,
|
|
165
|
+
message: chatMessageInput.value,
|
|
166
|
+
});
|
|
167
|
+
chatMessageInput.value = "";
|
|
168
|
+
scrollToBottom(true);
|
|
169
|
+
} catch {
|
|
170
|
+
// silent fail
|
|
171
|
+
} finally {
|
|
172
|
+
chatMessageLoading.value = false;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const messagesGroupedByDate = computed(() => {
|
|
177
|
+
const messages = chatMessages.value?.data?.chat_messages;
|
|
178
|
+
if (!messages || !Array.isArray(messages)) return [];
|
|
179
|
+
|
|
180
|
+
const grouped: Record<string, any[]> = {};
|
|
181
|
+
messages.forEach((chat: any) => {
|
|
182
|
+
const date = chat.created_at?.split("T")[0] || "unknown";
|
|
183
|
+
if (!grouped[date]) grouped[date] = [];
|
|
184
|
+
grouped[date].push(chat);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return Object.entries(grouped).map(([date, msgs]) => ({ date, messages: msgs }));
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const searchChat = () => {
|
|
191
|
+
if (searchTerm.value.length >= 3 || searchTerm.value.length === 0) {
|
|
192
|
+
fetchChatList(searchTerm.value ? { search: searchTerm.value } : {});
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
watch(
|
|
197
|
+
() => chatStore.currentMessageData,
|
|
198
|
+
(newMessage) => {
|
|
199
|
+
if (newMessage) {
|
|
200
|
+
const messages = chatMessages.value?.data?.chat_messages;
|
|
201
|
+
if (messages) {
|
|
202
|
+
messages.push(newMessage.message || newMessage.message_object);
|
|
203
|
+
nextTick(() => scrollToBottom(true));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{ deep: true },
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
onMounted(() => {
|
|
211
|
+
fetchChatList();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
215
|
+
if (modalRef.value && !modalRef.value.contains(event.target as Node)) {
|
|
216
|
+
emit("toggle-visible");
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
onMounted(() => document.addEventListener("click", handleClickOutside));
|
|
221
|
+
onUnmounted(() => document.removeEventListener("click", handleClickOutside));
|
|
222
|
+
</script>
|
|
223
|
+
|
|
224
|
+
<style lang="scss" scoped>
|
|
225
|
+
#mg-message-modal {
|
|
226
|
+
position: absolute;
|
|
227
|
+
width: 410px;
|
|
228
|
+
background-color: var(--chat-bg, var(--card-article-bg));
|
|
229
|
+
z-index: 30;
|
|
230
|
+
max-height: 750px;
|
|
231
|
+
top: 56px;
|
|
232
|
+
right: 80px;
|
|
233
|
+
overflow-y: auto;
|
|
234
|
+
border: 1px solid var(--text-secondary-color);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.search {
|
|
238
|
+
padding: 10px;
|
|
239
|
+
display: flex;
|
|
240
|
+
gap: 4px;
|
|
241
|
+
|
|
242
|
+
input {
|
|
243
|
+
width: 100%;
|
|
244
|
+
height: 32px;
|
|
245
|
+
padding-left: 10px;
|
|
246
|
+
margin-top: 20px;
|
|
247
|
+
border: none;
|
|
248
|
+
border-bottom: 2px solid var(--bt-active);
|
|
249
|
+
background-color: var(--header-ui-config-bg);
|
|
250
|
+
font-size: 16px;
|
|
251
|
+
color: var(--text-primary-color);
|
|
252
|
+
outline: none;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
i {
|
|
256
|
+
font-size: 30px;
|
|
257
|
+
margin-top: 20px;
|
|
258
|
+
color: var(--text-primary-color);
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.read-all--button-wrapper {
|
|
264
|
+
padding: 16px;
|
|
265
|
+
font-size: 16px;
|
|
266
|
+
display: flex;
|
|
267
|
+
justify-content: space-between;
|
|
268
|
+
|
|
269
|
+
.chats {
|
|
270
|
+
color: var(--text-primary-color);
|
|
271
|
+
cursor: pointer;
|
|
272
|
+
|
|
273
|
+
&.active {
|
|
274
|
+
font-weight: bold;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.cards .card-list {
|
|
280
|
+
overflow-y: auto;
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-direction: column;
|
|
283
|
+
max-height: 450px;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.no-content {
|
|
287
|
+
color: var(--text-secondary-color);
|
|
288
|
+
text-align: center;
|
|
289
|
+
padding: 32px;
|
|
290
|
+
|
|
291
|
+
i {
|
|
292
|
+
font-size: 56px;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.message-detail {
|
|
297
|
+
padding: 24px 16px 16px;
|
|
298
|
+
|
|
299
|
+
.infos {
|
|
300
|
+
display: flex;
|
|
301
|
+
gap: 8px;
|
|
302
|
+
align-items: center;
|
|
303
|
+
padding: 8px 0;
|
|
304
|
+
border-bottom: 1px solid var(--body-bg);
|
|
305
|
+
|
|
306
|
+
img {
|
|
307
|
+
max-width: 48px;
|
|
308
|
+
height: 48px;
|
|
309
|
+
object-fit: cover;
|
|
310
|
+
border-radius: 100%;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.title {
|
|
314
|
+
font-size: 14px;
|
|
315
|
+
color: var(--text-primary-color);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.back-button {
|
|
321
|
+
padding: 0 0 16px;
|
|
322
|
+
display: flex;
|
|
323
|
+
align-items: center;
|
|
324
|
+
gap: 8px;
|
|
325
|
+
font-size: 16px;
|
|
326
|
+
color: var(--text-primary-color);
|
|
327
|
+
background: transparent;
|
|
328
|
+
border: none;
|
|
329
|
+
font-weight: 600;
|
|
330
|
+
cursor: pointer;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.chat-container {
|
|
334
|
+
height: 450px;
|
|
335
|
+
overflow-y: auto;
|
|
336
|
+
padding-top: 20px;
|
|
337
|
+
|
|
338
|
+
.messages {
|
|
339
|
+
display: flex;
|
|
340
|
+
flex-direction: column;
|
|
341
|
+
gap: 8px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.message-group {
|
|
345
|
+
display: flex;
|
|
346
|
+
flex-direction: column;
|
|
347
|
+
gap: 18px;
|
|
348
|
+
padding: 0 16px;
|
|
349
|
+
width: 100%;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.message-me {
|
|
353
|
+
align-self: flex-end;
|
|
354
|
+
text-align: right;
|
|
355
|
+
background-color: var(--input-bg);
|
|
356
|
+
padding: 8px;
|
|
357
|
+
font-size: 14px;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.message-user {
|
|
361
|
+
align-self: flex-start;
|
|
362
|
+
text-align: left;
|
|
363
|
+
background: var(--body-bg-card);
|
|
364
|
+
padding: 8px;
|
|
365
|
+
font-size: 14px;
|
|
366
|
+
color: var(--text-primary-color);
|
|
367
|
+
|
|
368
|
+
.user-name {
|
|
369
|
+
color: var(--header-active-fg);
|
|
370
|
+
margin-bottom: 0;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.message-info {
|
|
375
|
+
font-size: 10px;
|
|
376
|
+
color: var(--search-context-section-title-fg);
|
|
377
|
+
text-align: right;
|
|
378
|
+
margin-top: 3px;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.input-me {
|
|
383
|
+
display: flex;
|
|
384
|
+
height: 72px;
|
|
385
|
+
padding: 8px 16px;
|
|
386
|
+
align-items: center;
|
|
387
|
+
gap: 16px;
|
|
388
|
+
background-color: var(--body-bg);
|
|
389
|
+
|
|
390
|
+
textarea {
|
|
391
|
+
display: flex;
|
|
392
|
+
height: 40px;
|
|
393
|
+
padding: 6px;
|
|
394
|
+
resize: none;
|
|
395
|
+
flex: 1 0 0;
|
|
396
|
+
|
|
397
|
+
&:focus {
|
|
398
|
+
outline: 1px solid var(--highlight-color);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.send {
|
|
403
|
+
cursor: pointer;
|
|
404
|
+
min-height: 40px;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
@media screen and (max-width: 576px) {
|
|
409
|
+
#mg-message-modal {
|
|
410
|
+
width: 100%;
|
|
411
|
+
right: 0;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
</style>
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<article class="notification-card" :class="{ read: notification.read_at }">
|
|
3
|
+
<div :class="['infos', { read: notification.read_at }]">
|
|
4
|
+
<img
|
|
5
|
+
:src="notification.image"
|
|
6
|
+
alt=""
|
|
7
|
+
@click="toNotificationUrl(notification.url, notification.id, notification.object)"
|
|
8
|
+
/>
|
|
9
|
+
<div
|
|
10
|
+
class="description"
|
|
11
|
+
@click="toNotificationUrl(notification.url, notification.id, notification.object)"
|
|
12
|
+
>
|
|
13
|
+
<div class="description-top">
|
|
14
|
+
<div class="title">{{ truncatedText(notification.title, 80) }}</div>
|
|
15
|
+
<p v-html="truncatedText(notification.message, 95)"></p>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="description-down">{{ notification.created_at }}</div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div class="action-bar">
|
|
21
|
+
<div ref="selectRef">
|
|
22
|
+
<div class="more" @click.prevent.stop="showMenu = !showMenu">
|
|
23
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
24
|
+
<path d="M11 15V17H13V15H11Z" fill="var(--text-primary-color)" />
|
|
25
|
+
<path d="M11 11V13H13V11H11Z" fill="var(--text-primary-color)" />
|
|
26
|
+
<path d="M11 7V9H13V7H11Z" fill="var(--text-primary-color)" />
|
|
27
|
+
</svg>
|
|
28
|
+
</div>
|
|
29
|
+
<div v-if="showMenu" class="notification-menu">
|
|
30
|
+
<button @click="handleMarkAsRead">{{ $t("notification_component.mark_read") }}</button>
|
|
31
|
+
<button @click="handleDelete">{{ $t("notification_component.delete") }}</button>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</article>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { ref } from "vue";
|
|
41
|
+
import type { MgNotification } from "../../../types";
|
|
42
|
+
|
|
43
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
44
|
+
const notificationsStore = useNotificationsStore();
|
|
45
|
+
|
|
46
|
+
const props = defineProps<{
|
|
47
|
+
notification: MgNotification;
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
const emit = defineEmits(["close"]);
|
|
51
|
+
const showMenu = ref(false);
|
|
52
|
+
const selectRef = ref<HTMLElement | null>(null);
|
|
53
|
+
|
|
54
|
+
const handleMarkAsRead = async () => {
|
|
55
|
+
if (props.notification.id) {
|
|
56
|
+
await notificationsStore.markAsRead(props.notification.id);
|
|
57
|
+
}
|
|
58
|
+
showMenu.value = false;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleDelete = async () => {
|
|
62
|
+
if (props.notification.id) {
|
|
63
|
+
await notificationsStore.removeNotification(props.notification.id);
|
|
64
|
+
}
|
|
65
|
+
showMenu.value = false;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const toNotificationUrl = async (url: string | null, id: string | null, object: string | null) => {
|
|
69
|
+
const router = useRouter();
|
|
70
|
+
if (!id) return;
|
|
71
|
+
|
|
72
|
+
await notificationsStore.markAsRead(id);
|
|
73
|
+
emit("close");
|
|
74
|
+
|
|
75
|
+
if (object === "invoice") {
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
router.push(`/${locale.value}/wallet`);
|
|
78
|
+
}, 500);
|
|
79
|
+
} else if (url) {
|
|
80
|
+
if (url.startsWith(window.location.origin)) {
|
|
81
|
+
router.push(url.replace(window.location.origin, ""));
|
|
82
|
+
} else {
|
|
83
|
+
window.open(url, "_blank");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const truncatedText = (text: string, size: number) => {
|
|
89
|
+
if (!text) return "";
|
|
90
|
+
return text.length > size ? text.substring(0, size) + "..." : text;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
94
|
+
if (selectRef.value && !selectRef.value.contains(event.target as Node)) {
|
|
95
|
+
showMenu.value = false;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
onMounted(() => document.addEventListener("click", handleClickOutside));
|
|
100
|
+
onBeforeUnmount(() => document.removeEventListener("click", handleClickOutside));
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<style lang="scss" scoped>
|
|
104
|
+
.notification-card {
|
|
105
|
+
display: flex;
|
|
106
|
+
height: 136px;
|
|
107
|
+
padding: 16px 8px;
|
|
108
|
+
align-items: center;
|
|
109
|
+
gap: 8px;
|
|
110
|
+
align-self: stretch;
|
|
111
|
+
border-bottom: 1px solid var(--body-bg);
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
background-color: var(--card-article-bg);
|
|
114
|
+
|
|
115
|
+
&.read {
|
|
116
|
+
background-color: var(--body-bg);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.infos {
|
|
120
|
+
display: flex;
|
|
121
|
+
height: 104px;
|
|
122
|
+
gap: 8px;
|
|
123
|
+
flex: 1 0 0;
|
|
124
|
+
|
|
125
|
+
img {
|
|
126
|
+
width: 104px;
|
|
127
|
+
height: 104px;
|
|
128
|
+
object-fit: cover;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&.read img {
|
|
132
|
+
filter: grayscale(1);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.description {
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
width: 100%;
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
justify-content: space-between;
|
|
141
|
+
|
|
142
|
+
.description-top {
|
|
143
|
+
.title {
|
|
144
|
+
font-size: 14px;
|
|
145
|
+
font-weight: 500;
|
|
146
|
+
line-height: 20px;
|
|
147
|
+
color: var(--active);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
p {
|
|
151
|
+
font-size: 12px;
|
|
152
|
+
font-weight: 400;
|
|
153
|
+
line-height: 16px;
|
|
154
|
+
color: var(--secondary-info-fg);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.description-down {
|
|
159
|
+
font-size: 12px;
|
|
160
|
+
color: var(--secondary-info-fg);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.action-bar {
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
align-items: center;
|
|
168
|
+
|
|
169
|
+
.more {
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.notification-menu {
|
|
174
|
+
position: absolute;
|
|
175
|
+
right: 0;
|
|
176
|
+
background: var(--header-ui-config-bg);
|
|
177
|
+
border: 1px solid var(--header-ui-config-border);
|
|
178
|
+
z-index: 10;
|
|
179
|
+
padding: 4px 0;
|
|
180
|
+
|
|
181
|
+
button {
|
|
182
|
+
display: block;
|
|
183
|
+
width: 100%;
|
|
184
|
+
padding: 8px 16px;
|
|
185
|
+
background: none;
|
|
186
|
+
border: none;
|
|
187
|
+
color: var(--active);
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
text-align: left;
|
|
191
|
+
|
|
192
|
+
&:hover {
|
|
193
|
+
background: var(--header-ui-config-hover);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
</style>
|