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

Commit d151d88

Browse files
committed
fix: solve modal problem
1 parent 67be3f5 commit d151d88

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

frontend/src/components/ElectionComponent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const props = defineProps<{
5353
}>()
5454
5555
defineEmits<{
56-
openModal: [electionId: number, electionName: string]
56+
openModal: [electionId: string, electionName: string]
5757
}>();
5858
5959
const now = ref(props.time);

frontend/src/components/vote/RequestCodeModal.vue

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
import { ref, onBeforeMount } from 'vue'
3-
import { useAuthStore } from '@/stores/auth'
43
import axios from 'axios'
54
import { apiEndpoints } from "@/commons/globals";
65
@@ -14,18 +13,11 @@ const requestError = ref(false)
1413
const codeRequest = ref(false)
1514
const submit = ref(false)
1615
const code = ref("")
17-
let userInfo: any = {}
1816
19-
onBeforeMount(async () => {
20-
userInfo = await useAuthStore().getUserInfo();
21-
});
22-
23-
function sendCodeRequest() {
17+
function sendCodeRequest(id: string) {
2418
submit.value = true
25-
axios.post(`${apiEndpoints.API_SERVER}/code/generate`, {
26-
userId: userInfo.id,
27-
electionId: electionId
28-
}).then((response) => {
19+
axios.post(`${apiEndpoints.API_SERVER}/code/generate`, { electionId: id })
20+
.then((response) => {
2921
code.value = response.data.data
3022
codeRequest.value = true
3123
requestError.value = false
@@ -39,7 +31,6 @@ function sendCodeRequest() {
3931
});
4032
}
4133
42-
4334
</script>
4435

4536
<template>
@@ -63,7 +54,7 @@ function sendCodeRequest() {
6354
<p>Already have a code? <a href="#toElectionPage">Vote now</a></p>
6455
</div>
6556
<div class="row mb-2">
66-
<form @submit.prevent="sendCodeRequest">
57+
<form @submit.prevent="sendCodeRequest(electionId)">
6758
<div class="input-group mb-3 has-validation">
6859
<input type="text" class="form-control" aria-label="Code output" v-model="code" readonly>
6960
<div class="input-group-append">

frontend/src/views/ElectionsView.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const modalId = ref("modal_vote_view")
1818
const modal = ref()
1919
const electionName = ref("")
2020
const electionId = ref("")
21+
const refKey = ref(0)
2122
2223
onMounted(async () => {
2324
await getVotings();
@@ -26,9 +27,9 @@ onMounted(async () => {
2627
modal.value = new bootstrap.Modal(`#${modalId.value}`, {});
2728
})
2829
29-
function openModal(id: number, name: string) {
30+
function openModal(id: string, name: string) {
3031
electionName.value = name
31-
electionId.value = String(id)
32+
electionId.value = id
3233
if (modal.value) {
3334
modal.value.show()
3435
}
@@ -163,13 +164,11 @@ function resetPage() {
163164
<div class="container-sm col-12 col-md-8 text-center">
164165
<div v-if="displayedElections.length > 0">
165166
<div v-for="election in displayedElections" :key="String(election.id)" class="row election">
166-
<ElectionComponent :election="election"
167-
:time="now"
168-
@openModal="(id: number, name: string) => openModal(id, name)"
167+
<ElectionComponent :election="election" :time="now" @openModal="(id: string, name: string) => openModal(id, name)"
169168
/>
170-
<RequestCodeModal :electionName="electionName" :electionId="electionId" :id="modalId" />
169+
<RequestCodeModal :electionName="electionName" :electionId="electionId" :id="modalId"/>
171170
</div>
172-
<div class="pagination-buttons" v-if="totalPages>2">
171+
<div class="pagination-buttons" v-if="totalPages>1">
173172
<button @click="prevPage" class="btn btn-primary" :disabled="currentPage === 1">&lt;</button>
174173
<button @click="nextPage" class="btn btn-primary" :disabled="currentPage === totalPages">&gt;</button>
175174
<br/>

0 commit comments

Comments
 (0)