-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubmit-Form.html
More file actions
220 lines (214 loc) · 13.1 KB
/
Copy pathSubmit-Form.html
File metadata and controls
220 lines (214 loc) · 13.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SmartOps — Submit a Task</title>
<link href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #f0f2f7; --white: #ffffff; --navy: #0f1f3d; --blue: #2563eb;
--blue-light: #eff6ff; --border: #e2e8f0; --text: #0f172a;
--text2: #475569; --text3: #94a3b8; --red: #ef4444; --green-light: #f0fdf4;
--shadow-lg: 0 4px 6px rgba(0,0,0,0.05), 0 20px 40px rgba(0,0,0,0.1);
--radius: 14px; --mono: 'JetBrains Mono', monospace; --sans: 'Figtree', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); font-family: var(--sans); min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 16px 48px; }
.header { width: 100%; max-width: 600px; margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 38px; height: 38px; background: var(--navy); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.brand-name { font-size: 18px; font-weight: 800; color: var(--navy); }
.brand-sub { font-family: var(--mono); font-size: 9px; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; }
.secure-badge { font-family: var(--mono); font-size: 10px; color: var(--text3); background: var(--white); border: 1px solid var(--border); border-radius: 20px; padding: 5px 10px; }
.card { width: 100%; max-width: 600px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.card-header { background: var(--navy); padding: 28px 32px; }
.card-tag { display: inline-flex; background: rgba(37,99,235,0.3); border: 1px solid rgba(37,99,235,0.5); border-radius: 20px; padding: 4px 12px; font-family: var(--mono); font-size: 10px; color: #93c5fd; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px; }
.card-title { font-size: 26px; font-weight: 800; color: white; margin-bottom: 6px; }
.card-desc { font-size: 14px; color: rgba(255,255,255,0.6); line-height: 1.5; }
.form-body { padding: 32px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 20px; }
label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
label .required { color: var(--red); }
label .hint { font-weight: 400; color: var(--text3); font-size: 12px; margin-left: auto; }
input, select, textarea { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-family: var(--sans); font-size: 14px; color: var(--text); background: white; outline: none; appearance: none; transition: all 0.15s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
input::placeholder, textarea::placeholder { color: var(--text3); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.section-label { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 16px; }
.priority-hint { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.p-hint { font-size: 11px; color: var(--text3); font-family: var(--mono); }
.submit-btn { width: 100%; padding: 14px; background: var(--blue); color: white; border: none; border-radius: 10px; font-family: var(--sans); font-size: 15px; font-weight: 700; cursor: pointer; transition: all 0.2s; }
.submit-btn:hover { background: #1d4ed8; transform: translateY(-1px); }
.submit-btn:disabled { background: #93c5fd; cursor: not-allowed; transform: none; }
.field-error { font-size: 12px; color: var(--red); margin-top: 5px; display: none; }
input.error, select.error, textarea.error { border-color: var(--red); }
.success-screen { display: none; padding: 48px 32px; text-align: center; }
.success-icon { width: 72px; height: 72px; background: var(--green-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; margin: 0 auto 20px; }
.success-title { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.success-desc { font-size: 14px; color: var(--text2); line-height: 1.6; margin-bottom: 24px; }
.task-ref { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 20px; font-family: var(--mono); font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.task-ref span { color: var(--blue); font-weight: 700; }
.new-task-btn { padding: 11px 28px; background: var(--navy); color: white; border: none; border-radius: 10px; font-family: var(--sans); font-size: 14px; font-weight: 600; cursor: pointer; }
.footer { margin-top: 20px; font-family: var(--mono); font-size: 10px; color: var(--text3); text-align: center; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } .card-header { padding: 22px; } .form-body { padding: 22px; } }
</style>
</head>
<body>
<div class="header">
<div class="brand">
<div class="brand-icon">⚙️</div>
<div>
<div class="brand-name">SmartOps</div>
<div class="brand-sub">Task Intelligence Platform</div>
</div>
</div>
<div class="secure-badge">🔒 Secure · Internal Use</div>
</div>
<div class="card">
<div class="card-header">
<div class="card-tag">📋 All Departments</div>
<div class="card-title">Submit a Task</div>
<div class="card-desc">Report an issue or request. Your task will be automatically prioritised and assigned.</div>
</div>
<div class="form-body" id="formBody">
<div class="section-label">Your Details</div>
<div class="form-row">
<div class="form-group">
<label>Full Name <span class="required">*</span></label>
<input type="text" id="name" placeholder="e.g. Sarah Jones">
<div class="field-error" id="nameErr">Please enter your name</div>
</div>
<div class="form-group">
<label>Work Email <span class="required">*</span></label>
<input type="email" id="email" placeholder="you@company.com">
<div class="field-error" id="emailErr">Please enter a valid email</div>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>Department <span class="required">*</span></label>
<select id="dept">
<option value="">Select department...</option>
<option>Admin</option><option>Operations</option><option>Sales</option>
<option>Revenue</option><option>Facilities</option><option>IT</option><option>HR</option>
</select>
<div class="field-error" id="deptErr">Please select your department</div>
</div>
<div class="form-group">
<label>Site / Location <span class="required">*</span></label>
<select id="site">
<option value="">Select site...</option>
<option>Site A - Manchester</option><option>Site B - Birmingham</option>
<option>Site C - Leeds</option><option>Head Office</option><option>Remote</option>
</select>
<div class="field-error" id="siteErr">Please select your site</div>
</div>
</div>
<div class="form-group">
<label>Shift Manager <span class="required">*</span> <span class="hint">Who is your manager today?</span></label>
<input type="text" id="manager" placeholder="e.g. Dave Wilson">
<div class="field-error" id="managerErr">Please enter your shift manager</div>
</div>
<div class="divider"></div>
<div class="section-label">Task Details</div>
<div class="form-group">
<label>Problem Description <span class="required">*</span> <span class="hint">Be specific — affects priority score</span></label>
<textarea id="problem" placeholder="Describe the issue clearly, e.g. 'Broken toilet on 2nd floor, out of order since 9am'"></textarea>
<div class="field-error" id="problemErr">Please describe the problem</div>
<div class="priority-hint">
<span class="p-hint">🔴 Critical: fire, gas leak, injury</span>
<span class="p-hint">🟠 High: broken toilet, heating, lock</span>
<span class="p-hint">🟡 Medium: wifi, lighting, printer</span>
<span class="p-hint">🟢 Low: parking, chair, desk</span>
</div>
</div>
<div class="form-group">
<label>Action Needed <span class="required">*</span></label>
<textarea id="action" placeholder="What action do you need taken?" style="min-height:80px"></textarea>
<div class="field-error" id="actionErr">Please describe the action needed</div>
</div>
<button class="submit-btn" id="submitBtn" onclick="submitForm()">Submit Task →</button>
</div>
<div class="success-screen" id="successScreen">
<div class="success-icon">✅</div>
<div class="success-title">Task Submitted!</div>
<div class="success-desc">Your task has been received and will be automatically prioritised. You'll receive an email confirmation once it's resolved.</div>
<div class="task-ref">Reference: <span id="taskRef">—</span> · Submitted <span id="taskTime">—</span></div>
<button class="new-task-btn" onclick="resetForm()">Submit Another Task</button>
</div>
</div>
<div class="footer">SmartOps Task Intelligence Platform · Internal Use Only · All submissions are monitored</div>
<script>
function validate() {
let valid = true;
const fields = [
{ id: "name", errId: "nameErr", check: v => v.trim().length > 1 },
{ id: "email", errId: "emailErr", check: v => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v) },
{ id: "dept", errId: "deptErr", check: v => v !== "" },
{ id: "site", errId: "siteErr", check: v => v !== "" },
{ id: "manager", errId: "managerErr", check: v => v.trim().length > 1 },
{ id: "problem", errId: "problemErr", check: v => v.trim().length > 10 },
{ id: "action", errId: "actionErr", check: v => v.trim().length > 5 },
];
fields.forEach(f => {
const el = document.getElementById(f.id);
const err = document.getElementById(f.errId);
if (!f.check(el.value)) { el.classList.add("error"); err.style.display = "block"; valid = false; }
else { el.classList.remove("error"); err.style.display = "none"; }
});
return valid;
}
function submitForm() {
if (!validate()) return;
const btn = document.getElementById("submitBtn");
btn.disabled = true;
btn.textContent = "Submitting...";
const now = new Date();
const data = {
timestamp: now.toISOString().slice(0,16).replace("T", " "),
name: document.getElementById("name").value,
email: document.getElementById("email").value,
site: document.getElementById("site").value,
department:document.getElementById("dept").value,
manager: document.getElementById("manager").value,
problem: document.getElementById("problem").value,
action: document.getElementById("action").value,
};
// This calls the Apps Script function directly — no CORS issue
google.script.run
.withSuccessHandler(function() {
const ref = "TASK-" + Math.random().toString(36).substr(2, 8).toUpperCase();
document.getElementById("taskRef").textContent = ref;
document.getElementById("taskTime").textContent = now.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' });
document.getElementById("formBody").style.display = "none";
document.getElementById("successScreen").style.display = "block";
})
.withFailureHandler(function(err) {
btn.disabled = false;
btn.textContent = "Submit Task →";
alert("Something went wrong. Please try again.");
})
.submitTask(data);
}
function resetForm() {
document.getElementById("formBody").style.display = "block";
document.getElementById("successScreen").style.display = "none";
document.getElementById("submitBtn").disabled = false;
document.getElementById("submitBtn").textContent = "Submit Task →";
["name","email","dept","site","manager","problem","action"].forEach(id => {
document.getElementById(id).value = "";
document.getElementById(id).classList.remove("error");
});
}
["name","email","dept","site","manager","problem","action"].forEach(id => {
document.getElementById(id).addEventListener("input", () => {
document.getElementById(id).classList.remove("error");
});
});
</script>
</body>
</html>