|
1 | 1 | <template> |
2 | | - <div class="flex w-full justify-start"> |
3 | | - <div class="w-10 h-10 rounded-full pt-1.5"> |
| 2 | + <div :class="['flex w-full', isProcessor ? 'justify-end' : 'justify-start']"> |
| 3 | + <div :class="['w-10 h-10 rounded-full pt-1.5', isProcessor ? 'order-3' : 'order-1']"> |
4 | 4 | <img |
5 | | - src="/images/mockProfile.jpg" |
| 5 | + :src="history.details.commentDetails?.profileImageUrl || '/images/mockProfile.jpg'" |
6 | 6 | class="rounded-full" /> |
7 | 7 | </div> |
8 | | - <div class="flex max-w-[400px] flex-wrap px-6 py-4 bg-background-2 ml-4 text-black rounded-lg"> |
9 | | - 네네... 부탁드릴게요 가능하시다면 오늘 오후 6시까지 되었으면 좋겠습니다! 감사합니다. |
| 8 | + <div |
| 9 | + :class="[ |
| 10 | + 'flex flex-col gap-2 order-2', |
| 11 | + isProcessor ? 'items-end pr-4 pl-1' : 'items-start pl-4 pr-1' |
| 12 | + ]"> |
| 13 | + <p>{{ history.details.commentDetails?.nickName }}</p> |
| 14 | + <p |
| 15 | + :class="[ |
| 16 | + 'flex max-w-[400px] flex-wrap px-6 py-4 text-black rounded-lg', |
| 17 | + isProcessor ? 'bg-primary2' : 'bg-background-2' |
| 18 | + ]"> |
| 19 | + {{ history.details.commentDetails?.comment }} |
| 20 | + </p> |
| 21 | + </div> |
| 22 | + <div |
| 23 | + :class="[ |
| 24 | + 'flex flex-col h-full justify-end text-xs font-bold text-body gap-1 relative', |
| 25 | + isProcessor ? 'order-1 items-end' : 'order-3 items-start' |
| 26 | + ]"> |
| 27 | + <div |
| 28 | + v-if="history.details.commentDetails?.nickName === info.nickname" |
| 29 | + class="relative cursor-pointer"> |
| 30 | + <CommonIcons |
| 31 | + :name="menuDotIcon" |
| 32 | + @click="clickMenuDot" /> |
| 33 | + <div |
| 34 | + v-if="isClicked" |
| 35 | + @click="deleteCommentText" |
| 36 | + :class="[ |
| 37 | + 'absolute shadow-custom bottom-0 w-20 h-7 flex items-center justify-center text-xs text-red-1 bg-white hover:bg-background-1', |
| 38 | + isProcessor ? 'right-6' : 'left-6' |
| 39 | + ]"> |
| 40 | + 삭제 |
| 41 | + </div> |
| 42 | + </div> |
| 43 | + <div class="flex flex-col gap-1"> |
| 44 | + {{ history.details.commentDetails?.isModified ? '(수정됨)' : '' }} |
| 45 | + {{ formatTodayOrNot(history.date, history.time) }} |
| 46 | + </div> |
10 | 47 | </div> |
11 | | - <div class="flex h-full items-end text-xs font-bold text-body ml-2">오후 2:18</div> |
12 | 48 | </div> |
13 | 49 | </template> |
14 | 50 |
|
15 | | -<script setup lang="ts"></script> |
| 51 | +<script setup lang="ts"> |
| 52 | +import { deleteComment } from '@/api/user' |
| 53 | +import { menuDotIcon } from '@/constants/iconPath' |
| 54 | +import { useMemberStore } from '@/stores/member' |
| 55 | +import type { TaskDetailHistoryChatProps } from '@/types/common' |
| 56 | +import { formatTodayOrNot } from '@/utils/date' |
| 57 | +import { useQueryClient } from '@tanstack/vue-query' |
| 58 | +import { storeToRefs } from 'pinia' |
| 59 | +import { computed, defineProps, ref } from 'vue' |
| 60 | +import CommonIcons from '../common/CommonIcons.vue' |
| 61 | +
|
| 62 | +const memberStore = useMemberStore() |
| 63 | +const { info } = storeToRefs(memberStore) |
| 64 | +const isClicked = ref(false) |
| 65 | +const isProcessor = computed(() => history.details.commentDetails?.nickName !== requestorName) |
| 66 | +const queryClient = useQueryClient() |
| 67 | +
|
| 68 | +const { taskId, history, requestorName } = defineProps<TaskDetailHistoryChatProps>() |
| 69 | +
|
| 70 | +const clickMenuDot = async () => { |
| 71 | + isClicked.value = !isClicked.value |
| 72 | +} |
| 73 | +
|
| 74 | +const deleteCommentText = async () => { |
| 75 | + isClicked.value = !isClicked.value |
| 76 | + await deleteComment(history.historyId) |
| 77 | + queryClient.invalidateQueries({ queryKey: ['historyData', taskId] }) |
| 78 | +} |
| 79 | +</script> |
0 commit comments