✨ feat(src/components/feed/FeedCard.vue): добавляет обработку события клика для кнопок лайка и дизлайка
✨ feat(src/views/matches/MatchesView.vue): обновляет отображение аватара и возраста партнера в карточке совпадений
This commit is contained in:
@@ -65,12 +65,12 @@
|
||||
|
||||
<!-- Action buttons (visible on non-drag mode) -->
|
||||
<div v-if="isTop" class="feed-card__actions" @click.stop>
|
||||
<button class="feed-card__btn feed-card__btn--dislike" aria-label="Пропустить" @click="handleDislike">
|
||||
<button class="feed-card__btn feed-card__btn--dislike" aria-label="Пропустить" @click.stop="handleDislike">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" width="24" height="24">
|
||||
<path d="M18 6L6 18M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
<button class="feed-card__btn feed-card__btn--like" aria-label="Лайк" @click="handleLike">
|
||||
<button class="feed-card__btn feed-card__btn--like" aria-label="Лайк" @click.stop="handleLike">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" width="24" height="24">
|
||||
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />
|
||||
</svg>
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
>
|
||||
<RouterLink :to="`/profile/${match.partnerProfile.id}`" class="match-card__avatar-wrap">
|
||||
<img
|
||||
v-if="match.partnerProfile.avatarUrl"
|
||||
:src="match.partnerProfile.avatarUrl"
|
||||
v-if="match.partnerProfile.media[0]?.path"
|
||||
:src="match.partnerProfile.media[0].path"
|
||||
:alt="match.partnerProfile.name"
|
||||
class="match-card__avatar"
|
||||
>
|
||||
@@ -41,10 +41,10 @@
|
||||
<div class="match-card__info">
|
||||
<RouterLink :to="`/profile/${match.partnerProfile.id}`" class="match-card__name">
|
||||
{{ match.partnerProfile.name }}
|
||||
<span v-if="match.partnerProfile.age" class="match-card__age">, {{ match.partnerProfile.age }}</span>
|
||||
<span v-if="match.partnerProfile.birthDate" class="match-card__age">, {{ calcAge(match.partnerProfile.birthDate) }}</span>
|
||||
</RouterLink>
|
||||
<span v-if="match.partnerProfile.cityName" class="meta match-card__city">
|
||||
{{ match.partnerProfile.cityName }}
|
||||
<span v-if="match.partnerProfile.city?.name" class="meta match-card__city">
|
||||
{{ match.partnerProfile.city.name }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import type { MatchDto, ProfileResponseDto } from '@/api/api'
|
||||
import { apiClient } from '@/api/client'
|
||||
import AppButton from '@/components/common/AppButton.vue'
|
||||
import EmptyState from '@/components/common/EmptyState.vue'
|
||||
@@ -71,36 +72,41 @@ import { useAuth } from '@/composables/useAuth'
|
||||
import { useChat } from '@/composables/useChat'
|
||||
import { useUi } from '@/composables/useUi'
|
||||
|
||||
interface Match {
|
||||
id: string
|
||||
profileId: string
|
||||
partnerProfile: {
|
||||
id: string
|
||||
name: string
|
||||
avatarUrl?: string
|
||||
cityName?: string
|
||||
age?: number
|
||||
}
|
||||
createdAt: string
|
||||
hasChat: boolean
|
||||
}
|
||||
type EnrichedMatch = MatchDto & { partnerProfile: ProfileResponseDto }
|
||||
|
||||
const authStore = useAuth()
|
||||
const chatStore = useChat()
|
||||
const uiStore = useUi()
|
||||
const router = useRouter()
|
||||
|
||||
const matches = ref<Match[]>([])
|
||||
const matches = ref<EnrichedMatch[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
function calcAge(birthDate: string): number | undefined {
|
||||
const birth = new Date(birthDate)
|
||||
if (Number.isNaN(birth.getTime()))
|
||||
return undefined
|
||||
const today = new Date()
|
||||
let age = today.getFullYear() - birth.getFullYear()
|
||||
if (today.getMonth() < birth.getMonth() || (today.getMonth() === birth.getMonth() && today.getDate() < birth.getDate()))
|
||||
age--
|
||||
return age
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const profileId = authStore.activeProfile?.id
|
||||
if (!profileId)
|
||||
return
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await apiClient.api.likesControllerGetMyMatches({ profileId }) as unknown as Match[]
|
||||
matches.value = res
|
||||
const matchDtos = await apiClient.api.likesControllerGetMyMatches({ profileId })
|
||||
matches.value = await Promise.all(
|
||||
matchDtos.map(async (m) => {
|
||||
const partnerProfileId = m.profile1Id === profileId ? m.profile2Id : m.profile1Id
|
||||
const partnerProfile = await apiClient.api.profilesControllerFindOne(partnerProfileId)
|
||||
return { ...m, partnerProfile }
|
||||
}),
|
||||
)
|
||||
}
|
||||
catch {
|
||||
uiStore.addToast('Не удалось загрузить совпадения', 'error')
|
||||
@@ -110,7 +116,7 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
|
||||
async function openChat(match: Match) {
|
||||
async function openChat(match: EnrichedMatch) {
|
||||
const profileId = authStore.activeProfile?.id
|
||||
if (!profileId)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user