Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 10ba883

Browse files
committed
Merge branch 'frontend/refactor' into develop
2 parents c699c38 + 8c20f0f commit 10ba883

File tree

5 files changed

+16
-33
lines changed

5 files changed

+16
-33
lines changed

frontend/src/components/CarouselComponent.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<Carousel v-bind="settings" :breakpoints="breakpoints">
33
<Slide v-for="election in elections" :key="String(election.id)">
4-
<ElectionCard :election="election"/>
4+
<ElectionCard :election="election" :time="time"/>
55
</Slide>
66
<template #pagination="{ pagesCount, currentPage, setCurrentPage }">
77
<div class="pagination">
@@ -28,7 +28,8 @@ import 'vue3-carousel/dist/carousel.css'
2828
import type {Voting} from "@/stores/voting";
2929
3030
defineProps<{
31-
elections: Voting[]
31+
elections: Voting[],
32+
time: number,
3233
}>()
3334
3435
const settings = {

frontend/src/components/ElectionCardComponent.vue

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,12 @@ import type {Voting} from "@/stores/voting";
2525
import {ref} from "vue";
2626
import {formatDate, formatTime, getStatus} from "@/commons/utils";
2727
28-
defineProps<{
29-
election: Voting
28+
const props = defineProps<{
29+
election: Voting,
30+
time: number,
3031
}>()
3132
32-
const now = ref(new Date().getTime());
33-
34-
function scheduleUpdateNow() {
35-
setTimeout(updateNow, 1000);
36-
}
37-
38-
function updateNow() {
39-
now.value = new Date().getTime();
40-
scheduleUpdateNow();
41-
}
42-
43-
scheduleUpdateNow();
33+
const now = ref(props.time);
4434
4535
function isOpen(election: Voting): boolean {
4636
return getStatus(election, now.value) === 'open';

frontend/src/components/ElectionComponent.vue

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,15 @@ import type {Voting} from "@/stores/voting";
4343
import {capitalizeFirstLetter, formatDate, formatTime, getStatus} from "@/commons/utils";
4444
import {ref} from "vue";
4545
46-
const now = ref(new Date().getTime());
47-
48-
function scheduleUpdateNow() {
49-
setTimeout(updateNow, 1000);
50-
}
51-
52-
function updateNow() {
53-
now.value = new Date().getTime();
54-
scheduleUpdateNow();
55-
}
56-
57-
scheduleUpdateNow();
58-
5946
function isOpen(election: Voting): boolean {
6047
return getStatus(election, now.value) === 'open';
6148
}
62-
defineProps<{
63-
election: Voting
49+
const props = defineProps<{
50+
election: Voting,
51+
time: number,
6452
}>()
53+
54+
const now = ref(props.time);
6555
</script>
6656

6757
<style scoped>

frontend/src/views/DashboardView.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<div v-for="qualifier in qualifiers" :class="`elections col-10 center mx-auto election election-${qualifier} bg-light`" :key="`div-${qualifier}`">
55
<h2><a :href="`/elections?qualifier=${qualifier}`" class="election-link">{{ capitalizeFirstLetter(qualifier) }} Elections</a></h2>
66
<hr v-if="getData(qualifier).length > 0"/>
7-
<Carousel :elections="sortElectionsByDate(getData(qualifier))"/>
7+
<Carousel :elections="sortElectionsByDate(getData(qualifier))"
8+
:time="now"/>
89
</div>
910
</template>
1011

frontend/src/views/ElectionsView.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ function resetPage() {
147147
<div class="container-sm col-10 col-md-8 text-center">
148148
<div v-if="displayedElections.length > 0">
149149
<div v-for="election in displayedElections" :key="String(election.id)" class="row election">
150-
<ElectionComponent :election="election"/>
150+
<ElectionComponent :election="election"
151+
:time="now"/>
151152
</div>
152153
<div class="pagination-buttons" v-if="totalPages>2">
153154
<button @click="prevPage" class="btn btn-primary" :disabled="currentPage === 1">&lt;</button>

0 commit comments

Comments
 (0)