-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
312 lines (278 loc) · 13.4 KB
/
Copy pathindex.html
File metadata and controls
312 lines (278 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!DOCTYPE html>
<html lang="en" class="govuk-template">
<head>
<meta charset="utf-8">
<title>GOV.UK Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link rel="icon" sizes="48x48" href="/favicon.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/govuk-frontend@5.0.0/dist/govuk/govuk-frontend.min.css">
<style>
.loading-spinner {
display: none;
text-align: center;
margin: 30px 0;
}
.loading-spinner.active {
display: block;
}
.spinner {
border: 4px solid #dee0e2;
border-top: 4px solid #005ea5;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto 15px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.info-icon {
display: inline-block;
width: 20px;
height: 20px;
background-color: #1d70b8;
color: white;
border-radius: 50%;
text-align: center;
line-height: 20px;
font-size: 14px;
font-weight: bold;
cursor: pointer;
margin-left: 8px;
position: relative;
}
.info-tooltip {
display: none;
position: absolute;
background-color: #0b0c0c;
color: white;
padding: 10px;
border-radius: 4px;
width: 250px;
left: 30px;
top: -10px;
z-index: 1000;
font-size: 14px;
line-height: 1.4;
}
.info-icon:hover .info-tooltip {
display: block;
}
</style>
</head>
<body class="govuk-template__body">
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
<header class="govuk-header" role="banner" data-module="govuk-header">
<div class="govuk-header__container govuk-width-container">
<div class="govuk-header__logo">
<a href="/" class="govuk-header__link govuk-header__link--homepage">
<span class="govuk-header__logotype">
<svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 132 97" height="30" width="36">
<path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8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4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
</svg>
<span class="govuk-header__logotype-text">GOV.UK</span>
</span>
</a>
</div>
</div>
</header>
<div class="govuk-width-container">
<main class="govuk-main-wrapper">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<!-- Logo -->
<div style="margin-bottom: 30px;">
<img src="logo.png" alt="Logo" style="max-width: 150px; height: auto;">
</div>
<div id="formContainer">
<h1 class="govuk-heading-xl">Tell us about your problem</h1>
<!-- Homelessness banner -->
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Important
</h2>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-notification-banner__heading">
If you are currently experiencing homelessness please <a class="govuk-notification-banner__link" href="#">follow this link to get help</a>
</p>
</div>
</div>
<form id="submissionForm" novalidate>
<!-- Name field -->
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="name">
Name
</label>
<input class="govuk-input" id="name" name="name" type="text">
</div>
<!-- Age field -->
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="age-group">
Age
</label>
<input class="govuk-input govuk-input--width-5" id="age-group" name="ageGroup" type="number" min="0">
</div>
<!-- Gender dropdown -->
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="gender">
Gender
</label>
<select class="govuk-select" id="gender" name="gender">
<option value="">Select an option</option>
<option value="female">Female</option>
<option value="male">Male</option>
<option value="non-binary">Non-binary</option>
<option value="prefer-not-to-say">Prefer not to say</option>
</select>
</div>
<!-- Issue field (large text area) -->
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="issue">
Issue
</label>
<textarea class="govuk-textarea" id="issue" name="issue" rows="8"></textarea>
</div>
<!-- Postcode field -->
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="postcode">
Postcode
</label>
<input class="govuk-input govuk-input--width-10" id="postcode" name="postcode" type="text" autocomplete="postal-code">
</div>
<!-- Household composition field -->
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="household-composition">
Household composition
</label>
<div class="govuk-hint">
For example, ages of group members and relationship status
</div>
<textarea class="govuk-textarea" id="household-composition" name="householdComposition" rows="5"></textarea>
</div>
<!-- Consent checkbox -->
<div class="govuk-form-group">
<div class="govuk-checkboxes" data-module="govuk-checkboxes">
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="consent" name="consent" type="checkbox" value="yes">
<label class="govuk-label govuk-checkboxes__label" for="consent">
I'm happy for this information to be used by my local council, and linked with existing information, to provide me with tailored help.
<span class="info-icon">i
<span class="info-tooltip">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
</span>
</label>
</div>
</div>
</div>
<!-- Submit button -->
<button type="submit" class="govuk-button" data-module="govuk-button" id="submitBtn">
Submit
</button>
</form>
</div>
<!-- Loading spinner -->
<div id="loadingSpinner" class="loading-spinner">
<div class="spinner"></div>
<p class="govuk-body">Processing your submission...</p>
</div>
<!-- Response area -->
<div id="responseArea" style="display: none; margin-top: 30px;">
<div class="govuk-panel govuk-panel--confirmation">
<h2 class="govuk-panel__title">Form submitted successfully</h2>
</div>
<div class="govuk-inset-text" id="agentResponse"></div>
</div>
<!-- Error area -->
<div id="errorArea" style="display: none; margin-top: 30px;">
<div class="govuk-error-summary">
<h2 class="govuk-error-summary__title">There was a problem</h2>
<div class="govuk-error-summary__body">
<p id="errorMessage"></p>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<script src="https://cdn.jsdelivr.net/npm/govuk-frontend@5.0.0/dist/govuk/govuk-frontend.min.js"></script>
<script>
if (window.GOVUKFrontend) {
window.GOVUKFrontend.initAll();
}
// Replace with your API Gateway endpoint URL
const API_ENDPOINT = 'https://mofcej4j9h.execute-api.us-east-1.amazonaws.com/stage_1/submit';
document.getElementById('submissionForm').addEventListener('submit', async (e) => {
e.preventDefault();
const submitBtn = document.getElementById('submitBtn');
const responseArea = document.getElementById('responseArea');
const errorArea = document.getElementById('errorArea');
const loadingSpinner = document.getElementById('loadingSpinner');
// Hide previous responses
responseArea.style.display = 'none';
errorArea.style.display = 'none';
// Show loading spinner
loadingSpinner.classList.add('active');
// Disable submit button
submitBtn.disabled = true;
submitBtn.textContent = 'Submitting...';
// Collect form data
const formData = {
name: document.getElementById('name').value,
ageGroup: document.getElementById('age-group').value,
gender: document.getElementById('gender').value,
issue: document.getElementById('issue').value,
postcode: document.getElementById('postcode').value,
householdComposition: document.getElementById('household-composition').value,
consent: document.getElementById('consent').checked
};
try {
console.log('Sending request to:', API_ENDPOINT);
console.log('Form data:', formData);
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
});
console.log('Response status:', response.status);
console.log('Response headers:', response.headers);
let result = await response.json();
console.log('Result:', result);
// Handle Lambda proxy integration response format
if (result.body && typeof result.body === 'string') {
result = JSON.parse(result.body);
}
if (result.success) {
// Hide the form and spinner
document.getElementById('formContainer').style.display = 'none';
loadingSpinner.classList.remove('active');
// Show success message and agent response
document.getElementById('agentResponse').innerHTML =
'<h3 class="govuk-heading-m">Response:</h3>' +
'<p>' + result.agentResponse.replace(/\n/g, '<br>') + '</p>';
responseArea.style.display = 'block';
// Scroll to top
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
throw new Error(result.error || 'Unknown error occurred');
}
} catch (error) {
console.error('Error:', error);
loadingSpinner.classList.remove('active');
document.getElementById('errorMessage').textContent = error.message;
errorArea.style.display = 'block';
} finally {
// Re-enable submit button
loadingSpinner.classList.remove('active');
submitBtn.disabled = false;
submitBtn.textContent = 'Submit';
}
});
</script>
</body>
</html>