From 19aa06123022ac39112435f05517030b82ccf1c9 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 14 Jan 2025 10:25:19 +0300 Subject: [PATCH] fix --- src/front/src/components/vote/VoteCard.vue | 4 +-- src/front/src/utils/axios-api.js | 28 +++++++++---------- src/front/src/views/VoteHomePage.vue | 31 ++++++++++------------ 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/front/src/components/vote/VoteCard.vue b/src/front/src/components/vote/VoteCard.vue index b4978341e..0bc3f945c 100644 --- a/src/front/src/components/vote/VoteCard.vue +++ b/src/front/src/components/vote/VoteCard.vue @@ -7,7 +7,7 @@ {{ voteCard.subtitle }} - + { - console.log('Завершённые голосования:', data); - }) - .catch(err => { - console.error('Ошибка:', err); - }); +// getVotes('completed') +// .then(data => { +// console.log('Завершённые голосования:', data); +// }) +// .catch(err => { +// console.error('Ошибка:', err); +// }); -getVotes('active') - .then(data => { - console.log('Активные голосования:', data); - }) - .catch(err => { - console.error('Ошибка:', err); - }); +// getVotes('active') +// .then(data => { +// console.log('Активные голосования:', data); +// }) +// .catch(err => { +// console.error('Ошибка:', err); +// }); async function createVote(voteData, files) { try { diff --git a/src/front/src/views/VoteHomePage.vue b/src/front/src/views/VoteHomePage.vue index 2a8160870..14b4f48cd 100644 --- a/src/front/src/views/VoteHomePage.vue +++ b/src/front/src/views/VoteHomePage.vue @@ -22,7 +22,8 @@ :key="voting.id" cols="12" lg="3" md="4" > - + + @@ -143,34 +144,30 @@ import {computed, ref} from "vue"; import VoteConstructor from "@/components/vote/VoteConstructor.vue"; import CurrentVote from "@/components/vote/CurrentVote.vue"; +import VoteCardVue from "@/components/vote/VoteCard.vue"; import {votingData} from '@/test/testDataForVote' export default { - computed: { - votingData() { - return votingData - } - }, - components: {CurrentVote, VoteConstructor}, + components: {CurrentVote, VoteConstructor, VoteCardVue}, setup() { const currentTab = ref("current"); const votes = ref([ { id: 1, title: "Голосование 1", - endDate: new Date(new Date().getTime() + 600000), // 10 минут + dateend: new Date(new Date().getTime() + 600000), // 10 минут voted: false, }, { id: 2, title: "Голосование 2", - endDate: new Date(new Date().getTime() - 600000), // Уже завершено + dateend: new Date(new Date().getTime() - 600000), // Уже завершено voted: true, }, { id: 3, title: "Голосование 3", - endDate: new Date(new Date().getTime() + 3600000), // 1 час + dateend: new Date(new Date().getTime() + 3600000), // 1 час voted: true, }, ]); @@ -182,19 +179,19 @@ export default { const sortedCurrentVotes = computed(() => { return votes.value - .filter((v) => new Date(v.endDate) > new Date()) - .sort((a, b) => new Date(a.endDate) - new Date(b.endDate)); + .filter((v) => new Date(v.dateend) > new Date()) + .sort((a, b) => new Date(a.dateend) - new Date(b.dateend)); }); const sortedCompletedVotes = computed(() => { return votes.value - .filter((v) => new Date(v.endDate) <= new Date()) - .sort((a, b) => new Date(b.endDate) - new Date(a.endDate)); + .filter((v) => new Date(v.dateend) <= new Date()) + .sort((a, b) => new Date(b.dateend) - new Date(a.dateend)); }); - const timeRemaining = (endDate) => { + const timeRemaining = (dateend) => { const now = new Date(); - const diff = new Date(endDate) - now; + const diff = new Date(dateend) - now; return diff > 0 ? `${Math.floor(diff / 60000)} минут` : "Завершено"; };