AlertsView.tsx
9.26 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
import React, { useState } from 'react';
import {
ChevronLeft,
Menu,
User,
Plus,
Grid,
List,
ArrowDownAZ,
Pin,
X,
Coffee,
Tablet,
Trash2,
Utensils,
Syringe,
Timer
} from 'lucide-react';
import { Button } from "../ui/button";
import { cn } from "../ui/utils";
// Mock Data for Timers
const timersData = [
{
id: 1,
title: 'Coffee - 2 hrs',
subtitle: '1 min - Completes at 12:05 PM',
totalTime: 7200, // seconds
remainingTime: 0,
status: 'expired',
icon: Coffee,
},
{
id: 2,
title: 'Clean Tablet',
subtitle: '1 hrs - Completes at 12:37 PM',
totalTime: 3600,
remainingTime: 237, // 3:57
status: 'running',
icon: Tablet,
},
{
id: 3,
title: 'Replace Sanitizer Towels',
subtitle: '1 hrs - Completes at 12:37 PM',
totalTime: 3600,
remainingTime: 238, // 3:58
status: 'running',
icon: Trash2,
},
{
id: 4,
title: 'Take Out Trash',
subtitle: '1 hrs - Completes at 01:03 PM',
totalTime: 3600,
remainingTime: 58, // 00:58
status: 'running',
icon: Trash2,
},
{
id: 5,
title: 'Change Utensils',
subtitle: '1 hrs - Completes at 01:03 PM',
totalTime: 3600,
remainingTime: 58,
status: 'running',
icon: Utensils,
},
{
id: 6,
title: 'Sanitize Surfaces',
subtitle: '1 hrs - Completes at 02:00 PM',
totalTime: 3600,
remainingTime: 2157,
status: 'running',
icon: Syringe,
},
{
id: 7,
title: 'Check Temperatures',
subtitle: '1 hrs - Completes at 02:00 PM',
totalTime: 3600,
remainingTime: 2158,
status: 'running',
icon: Syringe,
},
{
id: 8,
title: 'Ranch 4 hrs',
subtitle: '4 hrs - Completes at 04:04 PM',
totalTime: 14400,
remainingTime: 2158,
status: 'running',
icon: Syringe,
},
];
function TimerCard({ timer }: { timer: typeof timersData[0] }) {
// Calculate progress percentage for circle
const progress = ((timer.totalTime - timer.remainingTime) / timer.totalTime) * 100;
const isExpired = timer.remainingTime === 0;
// Format remaining time MM:SS or similar
const formatTime = (seconds: number) => {
if (seconds <= 0) return "0s";
const m = Math.floor(seconds / 60);
const s = seconds % 60;
return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
};
return (
<div className="bg-gray-200 rounded-xl p-4 flex flex-col items-center relative shadow-sm h-[280px]">
<div className="text-center mb-2">
<h3 className="text-lg font-medium text-gray-800 leading-tight">{timer.title}</h3>
<p className="text-xs text-gray-500 mt-1">{timer.subtitle}</p>
</div>
{/* Timer Circle */}
<div className="relative w-32 h-32 my-auto flex items-center justify-center">
{/* Background Circle */}
<svg className="w-full h-full transform -rotate-90">
<circle
cx="64"
cy="64"
r="56"
stroke="white"
strokeWidth="12"
fill="transparent"
/>
{/* Progress Circle */}
<circle
cx="64"
cy="64"
r="56"
stroke={isExpired ? "#ef4444" : "#3b82f6"} // red-500 or blue-500
strokeWidth="12"
fill="transparent"
strokeDasharray={351.86} // 2 * pi * r
strokeDashoffset={isExpired ? 0 : 351.86 * (progress / 100)} // Inverse logic for countdown visual? Usually full then empty.
// Let's assume the blue part represents remaining time or elapsed?
// In screenshot, blue circle is mostly complete for 00:58 remaining?
// If it's a countdown, full circle = full time.
// Let's just make it look like the screenshot.
className="transition-all duration-1000 ease-linear"
/>
</svg>
<div className="absolute inset-0 flex flex-col items-center justify-center">
<span className={cn(
"text-3xl font-bold",
isExpired ? "text-red-500" : "text-gray-800"
)}>
{isExpired ? "0s" : formatTime(timer.remainingTime)}
</span>
<span className={cn(
"text-[10px] font-medium uppercase mt-1",
isExpired ? "text-red-400" : "text-gray-400"
)}>
Remaining
</span>
</div>
</div>
{/* Bottom Icons/Controls */}
<div className="w-full flex justify-between items-end mt-2">
<Pin className="w-5 h-5 text-blue-700 fill-current" />
<div className="flex flex-col items-center">
<div className="w-10 h-10 rounded-full border-2 border-gray-300 flex items-center justify-center text-gray-400 mb-1">
<timer.icon className="w-5 h-5" />
</div>
</div>
<div className="flex flex-col items-end">
<span className="text-xs text-blue-600 font-bold mb-2 cursor-pointer">EDIT</span>
</div>
</div>
{/* Floating X Button */}
<button className="absolute bottom-12 right-4 bg-blue-600 rounded-full p-1 text-white hover:bg-blue-700 shadow-md">
<X className="w-4 h-4" />
</button>
</div>
);
}
export function AlertsView() {
const [showModal, setShowModal] = useState(true);
return (
<div className="h-full flex flex-col bg-gray-50 relative">
{/* Top Header */}
<div className="bg-white border-b border-gray-200 px-4 py-3 flex items-center justify-between shadow-sm z-10">
<div className="flex items-center gap-4">
<button className="flex items-center text-blue-500 text-lg font-medium">
<ChevronLeft className="w-6 h-6" />
Back
</button>
<Menu className="w-6 h-6 text-gray-500" />
</div>
<div className="flex flex-col items-center">
<div className="flex items-center gap-2">
<div className="bg-blue-600 p-1.5 rounded-md">
<Timer className="w-5 h-5 text-white" />
</div>
<h1 className="text-xl font-bold text-blue-900">Timers</h1>
</div>
<div className="flex items-center gap-1 text-xs text-green-600 font-medium">
<span>86016</span>
<div className="w-2 h-2 bg-green-500 rounded-full" />
</div>
</div>
<div className="flex items-center gap-4 text-blue-500 font-medium">
<User className="w-6 h-6 text-gray-400" />
<button className="flex items-center gap-1">
<Plus className="w-5 h-5" />
Add Timer
</button>
</div>
</div>
{/* Sub Header */}
<div className="bg-gray-700 text-white px-6 py-2 flex items-center justify-between">
<div className="flex-1" /> {/* Spacer */}
<div className="font-medium">Today, December 15</div>
<div className="flex-1 flex justify-end items-center gap-4">
<div className="flex items-center gap-1">
<Grid className="w-5 h-5 text-gray-300" />
<List className="w-5 h-5 text-gray-500" />
</div>
<ArrowDownAZ className="w-5 h-5 text-blue-400" />
</div>
</div>
{/* Grid Content */}
<div className="flex-1 overflow-y-auto p-6">
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
{timersData.map(timer => (
<TimerCard key={timer.id} timer={timer} />
))}
</div>
</div>
{/* Alert Modal Overlay */}
{showModal && (
<div className="absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[1px]">
<div className="bg-black text-white rounded-xl shadow-2xl w-[600px] max-w-full overflow-hidden border border-gray-800">
<div className="p-8 text-center space-y-6">
<h2 className="text-3xl font-medium text-blue-500">Coffee - 2 hrs</h2>
<div className="space-y-4 py-4">
<p className="text-2xl font-light">Timer expired at 12:05 PM</p>
<p className="text-2xl font-light">Please discard the coffee</p>
</div>
{/* TACT Image Tag Mockup */}
<div className="flex justify-end">
<span className="bg-gray-200 text-black text-[10px] px-1 rounded-sm opacity-50">
TACT_Img_Timer-Notification@2x
</span>
</div>
<div className="grid grid-cols-3 gap-4 mt-8">
<Button
onClick={() => setShowModal(false)}
className="bg-blue-700 hover:bg-blue-600 text-white h-14 text-xl font-medium rounded-lg"
>
Mute
</Button>
<Button
onClick={() => setShowModal(false)}
className="bg-blue-600 hover:bg-blue-500 text-white h-14 text-xl font-medium rounded-lg"
>
Restart
</Button>
<Button
onClick={() => setShowModal(false)}
className="bg-blue-800 hover:bg-blue-700 text-white h-14 text-xl font-medium rounded-lg"
>
Acknowledge
</Button>
</div>
</div>
</div>
</div>
)}
</div>
);
}