Skip to content

Commit f56ea23

Browse files
committed
feat(vote): restrict candidate selection to voting period and update UI message
1 parent f99796e commit f56ea23

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

apps/web/src/pages/democracy/vote.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
q-icon(name='mdi-information-outline' size='66px' color='grey-4')
2929
small.text-grey Sélectionne un candidat pour voir son programme
3030
q-separator.q-my-md
31-
.fit.flex(v-if="candidature.candidatures")
31+
.fit.flex(v-if="candidature.candidatures && isToVote")
3232
.flex.justify-center.items-center.column(:style='{flex: 1}')
3333
h3.text-center.q-mb-md.q-mt-none Urne de vote
3434
.slot.middle.cursor-pointer.flex.column(@click="toVoteCandidature")
@@ -48,6 +48,7 @@
4848
option-value="proposedBy"
4949
option-label="proposedBy"
5050
)
51+
div.text-center(v-else) C'est pas encore le moment de voter, reviens plus tard !
5152
div(v-else-if='hasLaw')
5253
div(v-else)
5354
q-card-section.text-center
@@ -112,7 +113,22 @@ export default {
112113
const hours = currentDate.getHours()
113114
114115
// Vendredi à partir de 18h
115-
if (day === 5 && hours >= 18) return true
116+
if (day === 5) return true
117+
118+
// Samedi (toute la journée)
119+
if (day === 6) return true
120+
121+
// Dimanche avant 20h
122+
if (day === 0 && hours < 20) return true
123+
124+
return false
125+
},
126+
isToVote() {
127+
// les elections se déroulent tout les vendredi de 18h à dimanche 20h
128+
const currentDate = new Date()
129+
130+
const day = currentDate.getDay() // 0 = dimanche, 5 = vendredi, 6 = samedi
131+
const hours = currentDate.getHours()
116132
117133
// Samedi (toute la journée)
118134
if (day === 6) return true

0 commit comments

Comments
 (0)