|
| 1 | +<template> |
| 2 | + <div class="flex flex-row gap-2 items-start"> |
| 3 | + <div class="mt-2.5"> |
| 4 | + <UAvatar :src="user?.avatarUrl ?? undefined" /> |
| 5 | + </div> |
| 6 | + <div class="w-full flex flex-col gap-1.5"> |
| 7 | + <UDropdownMenu |
| 8 | + :items="items" |
| 9 | + :ui="{ |
| 10 | + content: 'w-56', |
| 11 | + item: 'p-2 motion-preset-slide-left motion-duration-200', |
| 12 | + }" |
| 13 | + :content="{ |
| 14 | + sideOffset: -32, |
| 15 | + }" |
| 16 | + > |
| 17 | + <ActiveCard> |
| 18 | + <div class="w-full relative flex flex-col justify-between gap-2"> |
| 19 | + <div class="flex flex-col gap-1"> |
| 20 | + <div class="text-base/5 whitespace-break-spaces text-default font-medium"> |
| 21 | + {{ comment?.text }} |
| 22 | + </div> |
| 23 | + |
| 24 | + <div v-if="comment?.createdAt" class="mt-1 flex justify-end text-xs text-muted"> |
| 25 | + {{ format(new Date(comment.createdAt), 'dd MMMM в HH:mm', { locale: ru }) }} |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + </div> |
| 29 | + </ActiveCard> |
| 30 | + </UDropdownMenu> |
| 31 | + |
| 32 | + <!-- <div v-if="comment?.notifications?.length" class="-mt-4 ml-4 flex flex-row flex-wrap gap-1"> |
| 33 | + <UserBeacon |
| 34 | + v-for="notification in comment.notifications" |
| 35 | + :key="notification.id" |
| 36 | + :notification="notification" |
| 37 | + /> |
| 38 | + </div> --> |
| 39 | + </div> |
| 40 | + </div> |
| 41 | +</template> |
| 42 | + |
| 43 | +<script setup lang="ts"> |
| 44 | +import type { DropdownMenuItem } from '@nuxt/ui' |
| 45 | +import { format } from 'date-fns' |
| 46 | +import { ru } from 'date-fns/locale/ru' |
| 47 | +
|
| 48 | +const { itemId, commentId } = defineProps<{ |
| 49 | + itemId: string |
| 50 | + commentId: string |
| 51 | +}>() |
| 52 | +
|
| 53 | +const flowStore = useFlowStore() |
| 54 | +const userStore = useUserStore() |
| 55 | +
|
| 56 | +const item = computed(() => flowStore.items.find((i) => i.id === itemId)) |
| 57 | +const comment = computed(() => item.value?.comments.find((comment) => comment.id === commentId)) |
| 58 | +const user = computed(() => userStore.find(comment.value?.userId ?? '')) |
| 59 | +
|
| 60 | +const items = computed<DropdownMenuItem[]>(() => { |
| 61 | + const menuItems: DropdownMenuItem[] = [ |
| 62 | + { |
| 63 | + label: 'Скопировать сообщение', |
| 64 | + icon: 'i-lucide-copy', |
| 65 | + color: 'neutral', |
| 66 | + disabled: false, |
| 67 | + onSelect: () => navigator.clipboard.writeText(comment.value?.text ?? ''), |
| 68 | + condition: true, |
| 69 | + }, |
| 70 | + // { |
| 71 | + // label: 'Маякнуть (будет позже)', |
| 72 | + // icon: 'i-lucide-users-round', |
| 73 | + // color: 'neutral', |
| 74 | + // disabled: true, |
| 75 | + // onSelect: () => modalCreateEpicCommentBeacon.open({ commentId }), |
| 76 | + // condition: true, |
| 77 | + // }, |
| 78 | + { |
| 79 | + label: 'Лайкнуть (будет позже)', |
| 80 | + icon: 'i-lucide-thumbs-up', |
| 81 | + color: 'neutral', |
| 82 | + disabled: true, |
| 83 | + onSelect: () => {}, |
| 84 | + condition: user.value?.id !== userStore.id, |
| 85 | + }, |
| 86 | + { |
| 87 | + label: 'Редактировать', |
| 88 | + icon: 'i-lucide-edit', |
| 89 | + disabled: true, |
| 90 | + onSelect: () => {}, |
| 91 | + condition: user.value?.id === userStore.id, |
| 92 | + }, |
| 93 | + { |
| 94 | + label: 'Удалить', |
| 95 | + icon: 'i-lucide-trash-2', |
| 96 | + disabled: true, |
| 97 | + onSelect: () => {}, |
| 98 | + condition: user.value?.id === userStore.id, |
| 99 | + }, |
| 100 | + ] |
| 101 | +
|
| 102 | + return menuItems.filter((item) => item.condition) |
| 103 | +}) |
| 104 | +</script> |
0 commit comments