diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go
index 8c250a6..627277e 100644
--- a/cmd/web/handlers.go
+++ b/cmd/web/handlers.go
@@ -92,10 +92,7 @@ func (app *application) CreateElection(w http.ResponseWriter, r *http.Request) {
randomIdentity := randomVoterIdentity()
voterIdentities = append(voterIdentities, randomIdentity)
}
- _, err := app.voters.InsertMultiple(voterIdentities, electionId)
- if err != nil {
- app.serverError(w, r, err)
- }
+ go app.voters.InsertMultiple(voterIdentities, electionId)
res, err = json.Marshal(api.CreateElectionResponse{VoterIdentities: &voterIdentities})
if err != nil {
diff --git a/ui/create-election.html b/ui/create-election.html
index 2b7bcda..463db5b 100644
--- a/ui/create-election.html
+++ b/ui/create-election.html
@@ -61,6 +61,17 @@
+
+
Election Created Successfully
+
+ Election ID:
+ {{ createdElectionId }}
+
+
+
+
Voter Access Codes
@@ -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;
})
diff --git a/ui/static/css/styles.css b/ui/static/css/styles.css
index 0afaff5..90e3e8a 100644
--- a/ui/static/css/styles.css
+++ b/ui/static/css/styles.css
@@ -147,6 +147,35 @@ button:hover {
margin-top: 1rem;
}
+.election-info {
+ margin-top: 2rem;
+}
+
+.election-info h2 {
+ margin-bottom: 1.5rem;
+ color: var(--text-color);
+ font-size: 1.5rem;
+}
+
+.info-container {
+ display: flex;
+ align-items: center;
+ padding: 0.75rem;
+ background: var(--background-color);
+ border: 1px solid var(--border-color);
+ border-radius: 4px;
+}
+
+.info-label {
+ font-weight: 500;
+ margin-right: 1rem;
+}
+
+.info-value {
+ font-family: monospace;
+ flex: 1;
+}
+
@media (max-width: 640px) {
.container {
padding: 0;