Display election ID in the response and insert voters in a goroutine

This commit is contained in:
2025-01-13 20:41:33 +01:00
parent 7ab27a947e
commit 2f13d7a76a
3 changed files with 48 additions and 5 deletions

View File

@ -61,6 +61,17 @@
</div>
</form>
<div v-if="createdElectionId > 0" class="election-info">
<h2>Election Created Successfully</h2>
<div class="info-container">
<span class="info-label">Election ID:</span>
<span class="info-value">{{ createdElectionId }}</span>
<button @click="copyElectionId" class="copy-btn">
Copy
</button>
</div>
</div>
<div v-if="voterIdentities.length > 0" class="voter-codes">
<h2>Voter Access Codes</h2>
<div class="codes-container">
@ -95,6 +106,7 @@
expiresAt: "",
choices: ["", ""] // Start with two empty choices
},
createdElectionId: 0,
voterIdentities: []
};
},
@ -138,7 +150,12 @@
},
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(response => {
const locationHeader = response.headers.get('Location');
this.createdElectionId = locationHeader.replace('/election/', '');
return response.json();
})
.then(data => {
this.voterIdentities = data.voterIdentities;
})