-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
630 lines (574 loc) · 56.5 KB
/
test.html
File metadata and controls
630 lines (574 loc) · 56.5 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Skedaddle Technician Portal</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- React and ReactDOM -->
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- Babel for JSX -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Google Identity Services -->
<script src="https://accounts.google.com/gsi/client" async defer></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
body {
font-family: 'Inter', sans-serif;
margin: 0;
overflow-x: hidden;
min-height: 100vh;
background-color: #f8fafc;
color: #1e293b;
touch-action: manipulation;
-webkit-tap-highlight-color: transparent;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.calendar-grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 8px;
}
@media (max-width: 768px) { .calendar-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 480px) { .calendar-grid { grid-template-columns: repeat(3, 1fr); } }
.google-btn {
background: #4285F4;
color: white;
padding: 16px 24px;
border-radius: 12px;
font-weight: 700;
display: flex;
align-items: center;
gap: 12px;
transition: all 0.2s;
width: 100%;
justify-content: center;
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}
.google-btn:active { background: #357abd; transform: scale(0.98); }
.animate-slide-up {
animation: slideUp 0.3s ease-out forwards;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.supply-item { transition: all 0.3s ease; }
input, select, textarea { font-size: 16px !important; }
.stock-btn {
flex: 1;
padding: 8px 4px;
font-size: 9px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.05em;
border-radius: 8px;
transition: all 0.2s;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect, useMemo, useRef } = React;
const CLIENT_ID = "826145031424-e5rd2jbbnreu8am7re4m6qpc6m9aqpgl.apps.googleusercontent.com";
const APPS_SCRIPT_URL = "https://script.google.com/macros/s/AKfycbw-DhbESKUSJrOfYooCTZqXO5vySlaDVaoLQCHTT2AlI5zTv7i6tdzzX1f6xwzdHK4e4A/exec";
const LOGO_URL = "https://www.skedaddlewildlife.com/wp-content/themes/salcode-bootstrap-genesis/images/logo_r.png";
const MANUAL_FULL_URL = "https://drive.google.com/file/d/1iSar6lHhH5gNLbNj2RctD05ODisbSqE3/view?usp=sharing";
const Icons = {
LogOut: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>,
LogIn: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 5 12 10 7"/><line x1="15" y1="12" x2="5" y2="12"/></svg>,
UserCheck: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><polyline points="16 11 18 13 22 9"/></svg>,
Alert: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>,
Calendar: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>,
Loader: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" className={`animate-spin ${p.className}`}><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>,
FileText: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14.5 2 14.5 7 20 7"/></svg>,
ExternalLink: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>,
Plus: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>,
Trash: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>,
Search: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>,
Package: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.27 6.96 8.73 5.05 8.73-5.05"/><path d="M12 22.08V12"/></svg>,
ChevronDown: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><polyline points="6 9 12 15 18 9"/></svg>,
Copy: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>,
RefreshCcw: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg>,
Mail: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg>,
Settings: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>,
Truck: (p) => <svg {...p} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><rect x="1" y="3" width="15" height="13"/><polygon points="16 8 20 8 23 11 23 16 16 16 16 8"/><circle cx="5.5" cy="18.5" r="2.5"/><circle cx="18.5" cy="18.5" r="2.5"/></svg>
};
const SPECIES_DATA = {
'Raccoons': { icon: '🦝', bio: 'Intelligent/Strong. Maternal cycle begins late winter.', signs: 'Hand-prints, thumping, tubular scat (seeds).', method: 'OWDs or Physical Removal.' },
'Squirrels': { icon: '🐿️', bio: 'Persistent chewers. Diurnal activity.', signs: 'Scratching, 2" holes, nut shells.', method: 'Seal secondary + OWD primary.' },
'Bats': { icon: '🦇', bio: 'Protected. Vital role. Blackout June-Aug.', signs: 'Entry stains, guano (soil-like).', method: 'Check valves / Netting.' },
'Birds': { icon: '🐦', bio: 'Vent nesters. Fire hazard. Carry mites.', signs: 'Straw, chirping, mites, ammonia.', method: 'Nest removal + Sanitation + Guards.' },
'Skunks': { icon: '🦨', bio: 'Ground burrowers. Defensive spray 15ft.', signs: 'Musk, cone holes, 6" burrows.', method: 'Trenching + OWD.' },
'Mice': { icon: '🐭', bio: 'Small. Enter dime-sized gaps.', signs: 'Rice droppings, nested insulation.', method: 'Search & Seal foundation/roofline.' },
'Rats': { icon: '🐀', bio: 'Aggressive chewers. Neophobic.', signs: 'Grease marks, gnawed wood/PVC.', method: 'Steel mesh + Trapping.' }
};
const BIRTHING_CALENDAR = [
{ name: 'Raccoons', months: [2, 3, 4], color: 'bg-orange-400' },
{ name: 'Squirrels', months: [1, 2, 3, 6, 7, 8], color: 'bg-blue-400' },
{ name: 'Bats', months: [5, 6, 7], color: 'bg-slate-500' },
{ name: 'Birds', months: [3, 4, 5], color: 'bg-red-400' },
{ name: 'Skunks', months: [3, 4, 5], color: 'bg-gray-400' }
];
const DEFAULT_SUPPLIES = [
{ id: '1', name: '1 inch screen', category: 'Screens', checked: false, note: '' },
{ id: '2', name: '1/4 inch screen', category: 'Screens', checked: false, note: '' },
{ id: '3', name: 'deoderizer', category: 'Chemicals', checked: false, note: '' },
{ id: '4', name: 'bacterial digester', category: 'Chemicals', checked: false, note: '' },
{ id: '5', name: 'D/E', category: 'Chemicals', checked: false, note: '' },
{ id: '6', name: 'Roof vents (Top vented)', category: 'Vents', checked: false, note: '' },
{ id: '7', name: 'Roof vents (Bottom Vented)', category: 'Vents', checked: false, note: '' },
{ id: '8', name: 'Wall vents', category: 'Vents', checked: false, note: '' },
{ id: '9', name: 'Sealant', category: 'Fasteners & Sealants', checked: false, note: '' },
{ id: '10', name: 'Kopr-Lastic', category: 'Fasteners & Sealants', checked: false, note: '' },
{ id: '11', name: 'Washer screws', category: 'Fasteners & Sealants', checked: false, note: '' },
{ id: '12', name: 'Anchor screws', category: 'Fasteners & Sealants', checked: false, note: '' },
{ id: '13', name: 'DSS screws', category: 'Fasteners & Sealants', checked: false, note: '' },
{ id: '14', name: 'Foot Covers', category: 'PPE & Safety', checked: false, note: '' },
{ id: '15', name: 'Drop sheets', category: 'PPE & Safety', checked: false, note: '' },
{ id: '16', name: 'latex gloves', category: 'PPE & Safety', checked: false, note: '' },
{ id: '17', name: 'garbage bags', category: 'PPE & Safety', checked: false, note: '' },
{ id: '18', name: 'Respirator Filters', category: 'PPE & Safety', checked: false, note: '' }
];
const TRUCK_STOCK_ITEMS = [
{ id: 'ts1', name: '1" Screen Rolls', category: 'Hardware' },
{ id: 'ts2', name: '1/4" Screen Rolls', category: 'Hardware' },
{ id: 'ts3', name: 'Sealant Tubes', category: 'Hardware' },
{ id: 'ts4', name: 'Kopr-Lastic', category: 'Hardware' },
{ id: 'ts5', name: 'Raccoon OWD', category: 'Doors' },
{ id: 'ts6', name: 'Squirrel OWD', category: 'Doors' },
{ id: 'ts7', name: 'Bat Valves', category: 'Doors' },
{ id: 'ts8', name: 'Traps (Raccoon)', category: 'Equipment' },
{ id: 'ts9', name: 'Traps (Squirrel)', category: 'Equipment' },
{ id: 'ts10', name: 'Respirator Filters', category: 'Safety' },
{ id: 'ts11', name: 'Gloves (Latex)', category: 'Safety' },
{ id: 'ts12', name: 'Cleaning Sprays', category: 'Sanitation' }
];
const getRoundedTime = () => {
const now = new Date();
const minutes = now.getMinutes();
let roundedMinutes;
let hourAdjustment = 0;
if (minutes >= 53) { roundedMinutes = 0; hourAdjustment = 1; }
else if (minutes >= 38) { roundedMinutes = 45; }
else if (minutes >= 23) { roundedMinutes = 30; }
else if (minutes >= 8) { roundedMinutes = 15; }
else { roundedMinutes = 0; }
const h = (now.getHours() + hourAdjustment) % 24;
return { hours: h, minutes: roundedMinutes };
};
const App = () => {
const [user, setUser] = useState(() => {
const saved = localStorage.getItem('skedaddle_user');
return saved ? JSON.parse(saved) : null;
});
const [recipientEmails, setRecipientEmails] = useState(() => {
if (!user) return [];
const saved = localStorage.getItem(`emails_${user.email}`);
return saved ? JSON.parse(saved) : [];
});
const [activeTab, setActiveTab] = useState('clock');
const [selectedSpecies, setSelectedSpecies] = useState(null);
const [status, setStatus] = useState('idle');
const [logs, setLogs] = useState([]);
const [isInitializing, setIsInitializing] = useState(true);
const [isSyncing, setIsSyncing] = useState(false);
const [accessToken, setAccessToken] = useState(null);
const [tokenClient, setTokenClient] = useState(null);
const [supplies, setSupplies] = useState([]);
const [truckStock, setTruckStock] = useState([]);
const [supplySearch, setSupplySearch] = useState('');
const [newItemName, setNewItemName] = useState('');
const [expandedCategories, setExpandedCategories] = useState(['Screens', 'Fasteners & Sealants', 'PPE & Safety', 'Custom']);
const [showTimePicker, setShowTimePicker] = useState(false);
const [showEmailSettings, setShowEmailSettings] = useState(false);
const [isSetupConfirmed, setIsSetupConfirmed] = useState(false);
const [pendingAction, setPendingAction] = useState(null);
const [selHour, setSelHour] = useState(0);
const [selMin, setSelMin] = useState(0);
const [actionNote, setActionNote] = useState("");
const [newEmailInput, setNewEmailInput] = useState("");
const checkUserStatus = async (userObj) => {
if (!userObj) return;
setIsSyncing(true);
try {
const response = await fetch(`${APPS_SCRIPT_URL}?name=${encodeURIComponent(userObj.name)}`, { cache: 'no-store' });
const data = await response.json();
if (data.status) setStatus(data.status);
if (data.logs) setLogs(data.logs);
} catch (err) { console.error("Status error:", err); }
setIsSyncing(false);
};
const initializeGsi = () => {
if (!window.google) {
setTimeout(initializeGsi, 500);
return;
}
const client = window.google.accounts.oauth2.initTokenClient({
client_id: CLIENT_ID,
scope: 'openid email profile https://www.googleapis.com/auth/gmail.send',
callback: async (tokenResponse) => {
if (tokenResponse.error) return;
setAccessToken(tokenResponse.access_token);
try {
const userInfoRes = await fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
headers: { 'Authorization': `Bearer ${tokenResponse.access_token}` }
});
const profile = await userInfoRes.json();
const newUser = { email: profile.email, name: profile.name, picture: profile.picture };
setUser(newUser);
localStorage.setItem('skedaddle_user', JSON.stringify(newUser));
checkUserStatus(newUser);
} catch (e) { console.error("Profile fetch error", e); }
},
});
setTokenClient(client);
setIsInitializing(false);
if (user) checkUserStatus(user);
};
useEffect(() => {
if (user) {
const savedEmails = localStorage.getItem(`emails_${user.email}`);
const parsedEmails = savedEmails ? JSON.parse(savedEmails) : [];
setRecipientEmails(parsedEmails);
setIsSetupConfirmed(parsedEmails.length > 0);
const savedSupplies = localStorage.getItem(`supplies_${user.email}`);
setSupplies(savedSupplies ? JSON.parse(savedSupplies) : DEFAULT_SUPPLIES);
const savedStock = localStorage.getItem(`truck_${user.email}`);
setTruckStock(savedStock ? JSON.parse(savedStock) : TRUCK_STOCK_ITEMS.map(i => ({...i, level: 'High'})));
}
}, [user]);
useEffect(() => {
if (user) localStorage.setItem(`emails_${user.email}`, JSON.stringify(recipientEmails));
}, [recipientEmails, user]);
useEffect(() => {
if (user && supplies.length > 0) localStorage.setItem(`supplies_${user.email}`, JSON.stringify(supplies));
}, [supplies, user]);
useEffect(() => {
if (user && truckStock.length > 0) localStorage.setItem(`truck_${user.email}`, JSON.stringify(truckStock));
}, [truckStock, user]);
useEffect(() => { initializeGsi(); }, []);
const addRecipient = () => {
if (newEmailInput.includes('@')) {
setRecipientEmails([...recipientEmails, newEmailInput.trim()]);
setNewEmailInput("");
}
};
const sendEmailAsUser = async (action, time, note) => {
const dateStr = new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
const subject = `${user.name} - ${action === "IN" ? "Start Time" : "End Time"} - ${dateStr}`;
const message = `To: ${recipientEmails.join(', ')}\nSubject: ${subject}\n\n${action === "IN" ? "CLOCK IN" : "CLOCK OUT"}\nTime - ${time}\nNotes - ${note || "None"}\n\nSent via Timeclock App`;
const encodedEmail = btoa(unescape(encodeURIComponent(message))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
try {
const res = await fetch('https://gmail.googleapis.com/gmail/v1/users/me/messages/send', {
method: 'POST',
headers: { 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ raw: encodedEmail })
});
return res.ok;
} catch (err) { return false; }
};
const confirmClockAction = async () => {
const decimalTime = (selHour + (selMin / 60)).toFixed(2).padStart(5, '0');
setShowTimePicker(false);
setIsSyncing(true);
await sendEmailAsUser(pendingAction, decimalTime, actionNote);
try {
await fetch(APPS_SCRIPT_URL, {
method: 'POST',
mode: 'no-cors',
headers: { 'Content-Type': 'text/plain' },
body: JSON.stringify({ email: user.email, name: user.name, type: pendingAction, decimalTime, note: actionNote })
});
setTimeout(() => { setActionNote(""); checkUserStatus(user); }, 2500);
} catch (err) { setIsSyncing(false); }
};
const handleClockTrigger = (action) => {
const rounded = getRoundedTime();
setSelHour(rounded.hours);
setSelMin(rounded.minutes);
setPendingAction(action);
setShowTimePicker(true);
};
const toggleSupply = (id) => setSupplies(prev => prev.map(s => s.id === id ? { ...s, checked: !s.checked } : s));
const updateSupplyNote = (id, note) => setSupplies(prev => prev.map(s => s.id === id ? { ...s, note } : s));
const addSupply = () => {
if (!newItemName.trim()) return;
const newItem = { id: Date.now().toString(), name: newItemName, category: 'Custom', checked: true, note: '' };
setSupplies([newItem, ...supplies]);
setNewItemName('');
};
const deleteSupply = (id) => setSupplies(prev => prev.filter(s => s.id !== id));
const deselectAllSupplies = () => setSupplies(prev => prev.map(s => ({ ...s, checked: false, note: '' })));
const toggleCategory = (cat) => setExpandedCategories(prev => prev.includes(cat) ? prev.filter(c => c !== cat) : [...prev, cat]);
const updateTruckStock = (id, level) => {
setTruckStock(prev => prev.map(item => item.id === id ? {...item, level} : item));
};
const copySuppliesList = () => {
const checkedItems = supplies.filter(s => s.checked);
if (checkedItems.length === 0) return;
let text = `SUPPLIES NEEDED (${new Date().toLocaleDateString()}):\n`;
checkedItems.forEach(item => { text += `- ${item.name}${item.note ? ` (${item.note})` : ''}\n`; });
if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text);
};
const categorizedSupplies = useMemo(() => {
const filtered = supplies.filter(s => s.name.toLowerCase().includes(supplySearch.toLowerCase()));
const groups = {};
filtered.forEach(s => { if (!groups[s.category]) groups[s.category] = []; groups[s.category].push(s); });
Object.keys(groups).forEach(cat => groups[cat].sort((a, b) => a.name.localeCompare(b.name)));
return groups;
}, [supplies, supplySearch]);
const sortedCategoryNames = useMemo(() => Object.keys(categorizedSupplies).sort((a, b) => {
if (a === 'Custom') return 1; if (b === 'Custom') return -1;
return a.localeCompare(b);
}), [categorizedSupplies]);
if (isInitializing) return <div className="min-h-screen flex items-center justify-center bg-white"><Icons.Loader className="w-10 h-10 text-orange-500" /></div>;
return (
<div className="min-h-screen max-w-4xl mx-auto px-4 py-8">
{!user ? (
<div className="max-w-md mx-auto bg-white rounded-[2.5rem] shadow-xl p-10 text-center border border-slate-100 mt-10">
<img src={LOGO_URL} className="h-24 mx-auto mb-8 object-contain" />
<h1 className="text-3xl font-extrabold text-slate-800 mb-8 uppercase tracking-tight leading-none text-center">Technician Portal</h1>
<button onClick={() => tokenClient.requestAccessToken({ prompt: 'consent' })} className="google-btn mb-6 font-bold uppercase tracking-widest text-xs">Sign in with Google</button>
</div>
) : (
<div className="space-y-6">
{/* Full-Screen Settings Modal */}
{showEmailSettings && (
<div className="fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/90 backdrop-blur-md p-4">
<div className="bg-white rounded-[2.5rem] p-8 w-full max-w-sm shadow-2xl animate-slide-up">
<div className="text-center mb-6">
<div className="p-4 bg-orange-50 text-orange-600 rounded-full w-fit mx-auto mb-4"><Icons.Mail className="w-8 h-8"/></div>
<h2 className="text-2xl font-black uppercase tracking-tight">Supervisor Emails</h2>
<p className="text-slate-500 text-[10px] mt-1 font-medium uppercase tracking-widest">Recipients for your time logs</p>
</div>
<div className="space-y-3 mb-6 max-h-[200px] overflow-y-auto pr-1 no-scrollbar">
{recipientEmails.map((email, i) => (
<div key={i} className="flex items-center justify-between p-3 bg-slate-50 rounded-xl border border-slate-100">
<span className="text-[10px] font-bold text-slate-700 truncate mr-2">{email}</span>
<button onClick={() => setRecipientEmails(recipientEmails.filter((_, idx) => idx !== i))} className="text-red-400"><Icons.Trash className="w-4 h-4"/></button>
</div>
))}
</div>
<div className="flex gap-2 mb-8">
<input type="email" placeholder="email@skedaddle.com" className="flex-1 bg-slate-100 rounded-xl px-4 py-3 text-xs font-bold outline-none" value={newEmailInput} onChange={e => setNewEmailInput(e.target.value)} onKeyPress={e => e.key === 'Enter' && addRecipient()} />
<button onClick={addRecipient} className="bg-slate-900 text-white p-3 rounded-xl"><Icons.Plus className="w-5 h-5"/></button>
</div>
<button onClick={() => { if(recipientEmails.length > 0) { setIsSetupConfirmed(true); setShowEmailSettings(false); } }} className="w-full py-4 bg-slate-900 text-white font-black rounded-xl shadow-lg uppercase tracking-widest text-[10px]">Close & Save</button>
</div>
</div>
)}
{/* Time Picker Modal */}
{showTimePicker && (
<div className="fixed inset-0 z-[60] flex items-center justify-center bg-slate-900/80 backdrop-blur-sm p-4">
<div className="bg-white rounded-[2rem] p-8 w-full max-w-sm shadow-2xl animate-slide-up">
<h2 className="text-2xl font-black mb-6 text-center uppercase tracking-tight">Confirm {pendingAction}</h2>
<div className="flex justify-center gap-4 mb-6">
<select value={selHour} onChange={e => setSelHour(Number(e.target.value))} className="p-4 bg-slate-50 rounded-xl text-xl font-bold border-2 border-slate-100 outline-none">
{[...Array(24).keys()].map(h => <option key={h} value={h}>{h.toString().padStart(2, '0')}</option>)}
</select>
<select value={selMin} onChange={e => setSelMin(Number(e.target.value))} className="p-4 bg-slate-50 rounded-xl text-xl font-bold border-2 border-slate-100 outline-none">
{[0, 15, 30, 45].map(m => <option key={m} value={m}>{m.toString().padStart(2, '0')}</option>)}
</select>
</div>
<textarea value={actionNote} onChange={e => setActionNote(e.target.value)} placeholder="Enter details..." className="w-full p-4 bg-slate-50 rounded-xl mb-6 text-sm outline-none border-2 border-slate-100" rows="3" />
<button onClick={confirmClockAction} className="w-full py-4 bg-orange-600 text-white font-black rounded-xl shadow-lg uppercase tracking-widest text-xs">Confirm Entry</button>
<button onClick={() => setShowTimePicker(false)} className="w-full py-4 text-slate-400 font-bold text-sm uppercase tracking-widest text-[10px]">Cancel</button>
</div>
</div>
)}
{/* User Bar */}
<div className="bg-white rounded-[2rem] p-4 md:p-6 shadow-md flex items-center justify-between border border-slate-100">
<div className="flex items-center gap-4">
<img src={user.picture} className="w-12 h-12 rounded-xl border-2 border-slate-50" referrerPolicy="no-referrer" />
<div>
<p className="font-extrabold text-slate-800 leading-none uppercase tracking-tight text-sm md:text-base">{user.name}</p>
<div className="flex items-center gap-2 mt-1">
<div className={`w-1.5 h-1.5 rounded-full ${accessToken ? 'bg-green-500' : 'bg-red-500'}`}></div>
<p className={`text-[9px] font-black uppercase tracking-widest ${accessToken ? 'text-green-600' : 'text-red-500'}`}>Gmail {accessToken ? 'Synced' : 'Offline'}</p>
</div>
</div>
</div>
<div className="flex items-center gap-2">
{!accessToken && (
<button onClick={() => tokenClient.requestAccessToken({ prompt: 'consent' })} className="p-2.5 bg-red-50 text-red-600 rounded-xl shadow-sm border border-red-100 active:scale-95 transition-transform flex items-center gap-2">
<Icons.Mail className="w-4 h-4" />
<span className="text-[9px] font-black uppercase tracking-widest">Reconnect</span>
</button>
)}
<button onClick={() => { setUser(null); setAccessToken(null); localStorage.removeItem('skedaddle_user'); setActiveTab('clock'); }} className="p-3 text-slate-300 hover:text-red-500 transition-colors"><Icons.LogOut className="w-5 h-5"/></button>
</div>
</div>
<div className="flex bg-slate-900 rounded-full p-1.5 shadow-lg border border-slate-800 max-w-[400px] mx-auto overflow-x-auto no-scrollbar">
<button onClick={() => setActiveTab('clock')} className={`flex-1 py-3 px-4 rounded-full text-[9px] font-black uppercase tracking-widest transition-all shrink-0 ${activeTab === 'clock' ? 'bg-orange-500 text-white shadow-md' : 'text-slate-500 hover:text-white'}`}>Clock</button>
<button onClick={() => setActiveTab('hub')} className={`flex-1 py-3 px-4 rounded-full text-[9px] font-black uppercase tracking-widest transition-all shrink-0 ${activeTab === 'hub' ? 'bg-blue-600 text-white shadow-md' : 'text-slate-500 hover:text-white'}`}>Hub</button>
<button onClick={() => setActiveTab('truck')} className={`flex-1 py-3 px-4 rounded-full text-[9px] font-black uppercase tracking-widest transition-all shrink-0 ${activeTab === 'truck' ? 'bg-green-600 text-white shadow-md' : 'text-slate-500 hover:text-white'}`}>Truck Stock</button>
</div>
{activeTab === 'clock' && (
<div className="max-w-2xl mx-auto space-y-6">
<div className="bg-white rounded-[2rem] overflow-hidden shadow-xl border border-slate-100">
<div className="p-6 md:p-8 bg-slate-900 text-white flex justify-between items-center relative">
<div className="flex items-center gap-4">
<div className="p-3 bg-slate-800 rounded-xl text-orange-500"><Icons.UserCheck className="w-6 h-6" /></div>
<div><p className="text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-1">Status</p><p className="text-xl font-black">{status === 'clocked_in' ? 'SHIFT ACTIVE' : 'OFF DUTY'}</p></div>
</div>
<button onClick={() => setShowEmailSettings(true)} className="absolute top-4 right-4 p-2 text-slate-500 hover:text-white transition-colors"><Icons.Settings className="w-4 h-4" /></button>
<div className={`px-4 py-1.5 rounded-full text-[10px] font-black tracking-widest ${status === 'clocked_in' ? 'bg-green-500/10 text-green-500' : 'bg-slate-800 text-slate-500'}`}>{status === 'clocked_in' ? 'ONLINE' : 'OFFLINE'}</div>
</div>
<div className="p-6 md:p-8">
{isSyncing && <div className="flex items-center justify-center gap-2 text-orange-500 text-[10px] font-black uppercase mb-6 tracking-widest"><Icons.Loader className="w-4 h-4"/>Syncing...</div>}
{!accessToken && (
<div className="p-6 bg-red-50 border-4 border-dashed border-red-200 rounded-[3rem] text-center animate-slide-up mb-6">
<Icons.Alert className="text-red-500 w-8 h-8 mx-auto mb-4" />
<h3 className="text-red-900 font-black uppercase text-xs mb-2 tracking-tight">Gmail Offline</h3>
<p className="text-red-700 font-medium leading-relaxed text-[10px] uppercase tracking-widest font-bold">Reconnect Gmail in the header to unlock clock buttons.</p>
</div>
)}
{!isSetupConfirmed ? (
<div className="p-8 bg-orange-50 border-4 border-dashed border-orange-200 rounded-[3rem] text-center animate-slide-up mb-6">
<div className="p-4 bg-orange-100 text-orange-600 rounded-full w-fit mx-auto mb-4"><Icons.Mail className="w-8 h-8"/></div>
<h3 className="text-orange-900 font-black uppercase text-lg mb-2 tracking-tight">Supervisor Emails</h3>
<p className="text-orange-700 font-medium leading-relaxed text-[10px] mb-6 uppercase tracking-widest">Add emails to unlock clock in/out</p>
<div className="space-y-3 mb-4">
{recipientEmails.map((email, i) => (
<div key={i} className="flex items-center justify-between p-3 bg-white rounded-xl border border-orange-100">
<span className="text-[10px] font-bold text-slate-700">{email}</span>
<button onClick={() => setRecipientEmails(recipientEmails.filter((_, idx) => idx !== i))} className="text-red-400"><Icons.Trash className="w-4 h-4"/></button>
</div>
))}
</div>
<div className="flex gap-2 mb-6">
<input type="email" placeholder="Add Email..." className="flex-1 bg-white rounded-xl px-4 py-3 text-xs font-bold outline-none border border-orange-100" value={newEmailInput} onChange={e => setNewEmailInput(e.target.value)} onKeyPress={e => e.key === 'Enter' && addRecipient()} />
<button onClick={addRecipient} className="bg-orange-600 text-white p-3 rounded-xl"><Icons.Plus className="w-5 h-5"/></button>
</div>
{recipientEmails.length > 0 && (
<button onClick={() => setIsSetupConfirmed(true)} className="w-full py-4 bg-green-600 text-white font-black rounded-xl shadow-lg uppercase tracking-widest text-xs">Confirm & Unlock</button>
)}
</div>
) : status === 'clocked_out' ? (
<div className="p-8 bg-red-50 border-4 border-dashed border-red-200 rounded-[3rem] text-center animate-slide-up mb-6">
<Icons.Alert className="text-red-500 w-12 h-12 mx-auto mb-4" />
<h3 className="text-red-900 font-black uppercase text-lg mb-2 tracking-tight">Shift Recorded</h3>
<p className="text-red-700 font-medium leading-relaxed text-[10px] uppercase tracking-widest font-bold">Shift entries for today are complete.<br/>Contact supervisor for adjustments.</p>
</div>
) : (
<div className="grid grid-cols-2 gap-4">
<button disabled={status !== 'idle' || isSyncing || !accessToken} onClick={() => handleClockTrigger('IN')} className="p-6 rounded-2xl border-2 border-slate-50 bg-slate-50 active:bg-green-50 active:border-green-200 transition-all disabled:opacity-20 group">
<Icons.LogIn className="w-8 h-8 text-green-600 mb-2 mx-auto" />
<span className="block font-black text-[10px] uppercase text-slate-600 group-hover:text-green-700 tracking-widest">Clock In</span>
</button>
<button disabled={status === 'idle' || isSyncing || !accessToken} onClick={() => handleClockTrigger('OUT')} className="p-6 rounded-2xl border-2 border-slate-50 bg-slate-50 active:bg-red-50 active:border-red-200 transition-all disabled:opacity-20 group">
<Icons.LogOut className="w-8 h-8 text-red-600 mb-2 mx-auto" />
<span className="block font-black text-[10px] uppercase text-slate-600 group-hover:text-red-700 tracking-widest">Clock Out</span>
</button>
</div>
)}
</div>
</div>
<div className="bg-white rounded-[2rem] shadow-md overflow-hidden border border-slate-100">
<div className="p-6 border-b border-slate-50 flex items-center gap-3 font-black text-xs uppercase tracking-widest text-slate-500"><Icons.Calendar className="w-4 h-4 text-orange-500"/> Activity Log</div>
<div className="p-4 calendar-grid">
{logs.map((day, idx) => (
<div key={idx} className={`p-3 rounded-2xl border flex flex-col items-center transition-all ${day.start || day.end ? 'bg-orange-50/50 border-orange-100' : 'bg-slate-50 border-slate-50 opacity-40'}`}>
<span className="text-[9px] font-bold text-slate-400 uppercase">{day.weekday}</span>
<span className="text-xs font-black text-slate-700">{day.date}</span>
<span className="text-[10px] font-extrabold mt-1 text-orange-600">{day.total}h</span>
</div>
))}
</div>
</div>
</div>
)}
{activeTab === 'hub' && (
<div className="space-y-6 animate-slide-up">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 items-start">
<div className="bg-white rounded-[2.5rem] p-6 md:p-8 shadow-md border border-slate-100 flex flex-col h-full overflow-hidden">
<div className="flex items-center justify-between mb-6">
<div className="flex items-center gap-3"><div className="p-3 bg-orange-50 text-orange-600 rounded-2xl"><Icons.Package className="w-5 h-5"/></div><h3 className="font-black uppercase text-xs tracking-widest text-slate-800">Needed Supplies</h3></div>
<div className="flex gap-2">
<button onClick={deselectAllSupplies} className="p-2.5 bg-slate-100 text-slate-400 rounded-xl active:bg-red-50 transition-colors"><Icons.RefreshCcw className="w-4 h-4" /></button>
<button onClick={copySuppliesList} className="p-2.5 bg-slate-900 text-white rounded-xl active:bg-orange-600 transition-colors"><Icons.Copy className="w-4 h-4" /></button>
</div>
</div>
<div className="space-y-4 mb-6">
<div className="relative"><Icons.Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" /><input type="text" placeholder="Search..." className="w-full pl-10 pr-4 py-3 bg-slate-50 rounded-xl text-xs font-bold border-2 border-slate-100 outline-none focus:border-orange-500" value={supplySearch} onChange={e => setSupplySearch(e.target.value)} /></div>
<div className="flex gap-2"><input type="text" placeholder="Add Custom..." className="flex-1 px-4 py-3 bg-slate-50 rounded-xl text-xs font-bold border-2 border-slate-100 outline-none" value={newItemName} onChange={e => setNewItemName(e.target.value)} onKeyPress={e => e.key === 'Enter' && addSupply()} /><button onClick={addSupply} className="p-3 bg-orange-600 text-white rounded-xl"><Icons.Plus className="w-5 h-5" /></button></div>
</div>
<div className="flex-1 overflow-y-auto max-h-[500px] no-scrollbar space-y-4">
{sortedCategoryNames.map(category => {
const categoryItems = categorizedSupplies[category];
const selectedInCat = categoryItems.filter(i => i.checked).length;
return (
<div key={category} className="space-y-2">
<button onClick={() => toggleCategory(category)} className={`w-full flex items-center justify-between py-3 px-3 rounded-lg transition-colors ${selectedInCat > 0 ? 'bg-orange-100' : 'bg-slate-100 hover:bg-slate-200'}`}>
<div className="flex items-center gap-2"><span className={`text-[10px] font-black uppercase tracking-widest ${selectedInCat > 0 ? 'text-orange-700' : 'text-slate-500'}`}>{category}</span>{selectedInCat > 0 && <span className="bg-orange-500 text-white text-[9px] font-black px-1.5 py-0.5 rounded-full">+ {selectedInCat}</span>}</div>
<Icons.ChevronDown className={`w-4 h-4 transition-transform ${expandedCategories.includes(category) ? 'rotate-180' : ''}`} />
</button>
{expandedCategories.includes(category) && (<div className="space-y-3 animate-slide-up px-1">{categoryItems.map(item => (<div key={item.id} className={`p-4 rounded-2xl border-2 supply-item ${item.checked ? 'bg-orange-50 border-orange-200' : 'bg-white border-slate-50 shadow-sm'}`}><div className="flex items-center gap-3"><div onClick={() => toggleSupply(item.id)} className={`w-7 h-7 rounded-lg border-2 flex items-center justify-center cursor-pointer transition-colors ${item.checked ? 'bg-orange-600 border-orange-600' : 'border-slate-200'}`}>{item.checked && <div className="w-2.5 h-2.5 bg-white rounded-full"></div>}</div><div className="flex-1"><p className={`text-xs font-black uppercase tracking-tight ${item.checked ? 'text-orange-900' : 'text-slate-700'}`}>{item.name}</p></div>{item.category === 'Custom' && <button onClick={() => deleteSupply(item.id)} className="p-2 text-slate-300 active:text-red-500"><Icons.Trash className="w-4 h-4"/></button>}</div>{item.checked && <input type="text" placeholder="Add a note..." className="w-full mt-3 px-3 py-3 bg-white rounded-lg text-xs font-bold border border-orange-100 outline-none" value={item.note} onChange={e => updateSupplyNote(item.id, e.target.value)} />}</div>))}</div>)}
</div>
);
})}
</div>
</div>
<div className="space-y-6 h-full mt-6 md:mt-0">
<div className="bg-white rounded-[2.5rem] p-8 shadow-md border border-slate-100"><div className="flex items-center gap-3 mb-6"><div className="p-3 bg-slate-900 text-white rounded-2xl"><Icons.FileText className="w-5 h-5"/></div><h3 className="font-black uppercase text-xs tracking-widest text-slate-800">Manuals</h3></div><div className="p-6 bg-slate-50 rounded-3xl border border-slate-100 text-center"><Icons.FileText className="w-10 h-10 text-orange-500 mx-auto mb-4" /><h4 className="font-black text-slate-800 text-sm mb-4">Technical Manual</h4><a href={MANUAL_FULL_URL} target="_blank" className="w-full flex items-center justify-center gap-2 py-4 bg-slate-900 text-white rounded-xl font-black text-[10px] uppercase active:bg-orange-600 transition-all shadow-lg">Open <Icons.ExternalLink className="w-4 h-4"/></a></div></div>
<div className="bg-white rounded-[2.5rem] p-6 md:p-8 shadow-md border border-slate-100"><div className="flex items-center gap-3 mb-6"><div className="p-3 bg-blue-50 text-blue-600 rounded-2xl"><Icons.Search className="w-5 h-5"/></div><h3 className="font-black uppercase text-xs tracking-widest text-slate-800">Diagnostics</h3></div><div className="grid grid-cols-2 gap-2 mb-4">{Object.keys(SPECIES_DATA).map(s => (<button key={s} onClick={() => setSelectedSpecies(s === selectedSpecies ? null : s)} className={`p-4 rounded-2xl transition-all text-left border-2 ${selectedSpecies === s ? 'bg-blue-600 border-blue-600 text-white shadow-lg' : 'bg-slate-50 border-slate-100 active:border-blue-200'}`}><span className="text-xl block mb-1">{SPECIES_DATA[s].icon}</span><span className="font-black text-[9px] uppercase tracking-tighter leading-tight">{s}</span></button>))}</div>{selectedSpecies && (<div className="space-y-3 animate-slide-up"><div className="p-4 bg-blue-50 rounded-2xl border border-blue-100 text-xs"><p className="font-black text-blue-600 uppercase mb-1">Signs</p><p className="font-medium text-slate-700 leading-relaxed">{SPECIES_DATA[selectedSpecies].signs}</p></div><div className="p-4 bg-slate-900 rounded-2xl text-white text-xs"><p className="font-black text-slate-400 uppercase mb-1">Method</p><p className="font-medium italic leading-relaxed">"{SPECIES_DATA[selectedSpecies].method}"</p></div></div>)}</div>
</div>
</div>
<div className="bg-white rounded-[2.5rem] p-6 md:p-8 shadow-md border border-slate-100"><div className="flex items-center gap-3 mb-6"><div className="p-3 bg-red-50 text-red-600 rounded-2xl"><Icons.Calendar className="w-5 h-5"/></div><h3 className="font-black uppercase text-xs tracking-widest text-slate-800">Birthing Calendar</h3></div><div className="space-y-4 overflow-x-auto no-scrollbar"><div className="min-w-[400px]"><div className="flex mb-2 text-[8px] font-black uppercase text-slate-300 tracking-widest border-b border-slate-50 pb-1"><div className="w-20 shrink-0">Species</div>{['J','F','M','A','M','J','J','A','S','O','N','D'].map((m, i) => (<div key={i} className="flex-1 text-center">{m}</div>))}</div>{BIRTHING_CALENDAR.map(species => (<div key={species.name} className="flex items-center h-8 group active:bg-slate-50 rounded-lg transition-colors"><div className="w-20 shrink-0 text-[10px] font-black text-slate-600">{species.name}</div>{Array.from({length: 12}).map((_, i) => (<div key={i} className="flex-1 h-full px-0.5 py-2"><div className={`h-full w-full rounded-sm ${species.months.includes(i) ? species.color : 'bg-slate-100 opacity-20'}`}></div></div>))}</div>))}</div></div></div>
</div>
)}
{activeTab === 'truck' && (
<div className="space-y-6 animate-slide-up max-w-2xl mx-auto">
<div className="bg-white rounded-[2.5rem] p-6 md:p-8 shadow-md border border-slate-100">
<div className="flex items-center gap-3 mb-8">
<div className="p-3 bg-green-50 text-green-600 rounded-2xl"><Icons.Truck className="w-6 h-6"/></div>
<div>
<h3 className="font-black uppercase text-xs tracking-widest text-slate-800 leading-none mb-1">Truck Inventory</h3>
<p className="text-[9px] font-bold text-slate-400 uppercase tracking-widest">Track your stock levels</p>
</div>
</div>
<div className="space-y-4">
{truckStock.map((item) => (
<div key={item.id} className="p-4 bg-white border border-slate-100 rounded-2xl shadow-sm flex flex-col gap-3">
<div className="flex justify-between items-center">
<span className="text-[10px] font-black uppercase text-slate-800 tracking-tight">{item.name}</span>
<span className={`text-[8px] font-black px-2 py-0.5 rounded-full uppercase ${
item.level === 'Low' ? 'bg-red-100 text-red-600' :
item.level === 'Med' ? 'bg-orange-100 text-orange-600' : 'bg-green-100 text-green-600'
}`}>{item.level} Stock</span>
</div>
<div className="flex gap-1 bg-slate-50 p-1 rounded-xl">
<button
onClick={() => updateTruckStock(item.id, 'Low')}
className={`stock-btn ${item.level === 'Low' ? 'bg-red-500 text-white shadow-sm' : 'text-slate-400'}`}
>Low</button>
<button
onClick={() => updateTruckStock(item.id, 'Med')}
className={`stock-btn ${item.level === 'Med' ? 'bg-orange-500 text-white shadow-sm' : 'text-slate-400'}`}
>Med</button>
<button
onClick={() => updateTruckStock(item.id, 'High')}
className={`stock-btn ${item.level === 'High' ? 'bg-green-500 text-white shadow-sm' : 'text-slate-400'}`}
>High</button>
</div>
</div>
))}
</div>
</div>
</div>
)}
<div className="text-center pt-8 opacity-20"><p className="font-black uppercase tracking-[0.5em] text-[8px] text-slate-800">Skedaddle Wildlife Control</p></div>
</div>
)}
</div>
);
};
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
</script>
</body>
</html>