LocationsView.tsx
11.6 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
import React, { useState } from 'react';
import {
Search,
Plus,
Download,
Upload,
Edit,
MapPin,
Phone,
Mail,
MoreHorizontal
} from 'lucide-react';
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "../ui/table";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "../ui/dialog";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "../ui/select";
import { Label } from "../ui/label";
import { Badge } from "../ui/badge";
import { Switch } from "../ui/switch";
// --- Mock Data ---
const MOCK_LOCATIONS = [
{
id: '12345',
name: 'Downtown Store',
street: '123 Main St',
city: 'New York',
state: 'NY',
country: 'USA',
zipCode: '10001',
phone: '+1 (555) 123-4567',
email: 'downtown@example.com',
gps: '40.7128° N, 74.0060° W',
status: 'active'
},
{
id: '12335',
name: 'Uptown Market',
street: '456 High St',
city: 'New York',
state: 'NY',
country: 'USA',
zipCode: '10002',
phone: '+1 (555) 987-6543',
email: 'uptown@example.com',
gps: '40.7580° N, 73.9855° W',
status: 'active'
},
{
id: '12445',
name: 'Airport Kiosk',
street: 'Terminal 4, JFK Airport',
city: 'Jamaica',
state: 'NY',
country: 'USA',
zipCode: '11430',
phone: '+1 (555) 555-5555',
email: 'jfk@example.com',
gps: '40.6413° N, 73.7781° W',
status: 'active'
},
{
id: '12555',
name: 'Suburban Outlet',
street: '789 Country Rd',
city: 'Long Island',
state: 'NY',
country: 'USA',
zipCode: '11901',
phone: '+1 (555) 111-2222',
email: 'suburb@example.com',
gps: '40.8500° N, 73.2000° W',
status: 'inactive'
},
];
export function LocationsView() {
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
const [locations, setLocations] = useState(MOCK_LOCATIONS);
return (
<div className="h-full flex flex-col">
{/* Toolbar - no white background; spacing matches Labels (main p-8 only) */}
<div className="pb-4">
<div className="flex flex-col gap-4">
{/* Toolbar: Search + Filters + Actions in one row, no "Search" label */}
<div className="flex flex-nowrap items-center gap-3">
<Input
placeholder="Search"
style={{ height: 40, boxSizing: 'border-box' }}
className="border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"
/>
<Select defaultValue="partner-a">
<SelectTrigger className="w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0" style={{ height: 40, boxSizing: 'border-box' }}>
<SelectValue placeholder="Partner" />
</SelectTrigger>
<SelectContent>
<SelectItem value="partner-a">Partner A</SelectItem>
</SelectContent>
</Select>
<Select defaultValue="group-b">
<SelectTrigger className="w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0" style={{ height: 40, boxSizing: 'border-box' }}>
<SelectValue placeholder="Group" />
</SelectTrigger>
<SelectContent>
<SelectItem value="group-b">Group B</SelectItem>
</SelectContent>
</Select>
<Select defaultValue="all">
<SelectTrigger className="w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0" style={{ height: 40, boxSizing: 'border-box' }}>
<SelectValue placeholder="Location" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All Locations</SelectItem>
<SelectItem value="loc-1">Location 1</SelectItem>
</SelectContent>
</Select>
<div className="flex-1" />
<Button variant="outline" className="h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0">
Bulk Import
</Button>
<Button variant="outline" className="h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0">
Bulk Export
</Button>
<Button variant="outline" className="h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0">
Bulk Edit
</Button>
<Button
className="h-10 bg-blue-600 hover:bg-blue-700 text-white rounded-md px-6 font-medium shrink-0"
onClick={() => setIsCreateDialogOpen(true)}
>
New+
</Button>
</div>
</div>
</div>
{/* Content Area - same padding as Labels (relies on main p-8) */}
<div className="flex-1 overflow-auto pt-6">
<div className="bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden">
<Table>
<TableHeader>
<TableRow className="bg-gray-100 hover:bg-gray-100">
<TableHead className="text-gray-900 font-bold border-r">Location ID</TableHead>
<TableHead className="text-gray-900 font-bold border-r">Location Name</TableHead>
<TableHead className="text-gray-900 font-bold border-r">Street</TableHead>
<TableHead className="text-gray-900 font-bold border-r">City</TableHead>
<TableHead className="text-gray-900 font-bold border-r">State</TableHead>
<TableHead className="text-gray-900 font-bold border-r">Country</TableHead>
<TableHead className="text-gray-900 font-bold border-r">Zip Code</TableHead>
<TableHead className="text-gray-900 font-bold border-r">Phone</TableHead>
<TableHead className="text-gray-900 font-bold border-r">Email</TableHead>
<TableHead className="text-gray-900 font-bold border-r">GPS</TableHead>
<TableHead className="text-gray-900 font-bold text-center">Actions</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{locations.map((loc) => (
<TableRow key={loc.id}>
<TableCell className="border-r font-numeric text-gray-600">{loc.id}</TableCell>
<TableCell className="border-r font-medium text-black">{loc.name}</TableCell>
<TableCell className="border-r text-gray-600 max-w-[140px] truncate">{loc.street}</TableCell>
<TableCell className="border-r text-gray-600">{loc.city}</TableCell>
<TableCell className="border-r text-gray-600">{loc.state}</TableCell>
<TableCell className="border-r text-gray-600">{loc.country}</TableCell>
<TableCell className="border-r text-gray-600 font-numeric">{loc.zipCode}</TableCell>
<TableCell className="border-r text-gray-600 whitespace-nowrap">{loc.phone}</TableCell>
<TableCell className="border-r text-gray-600 text-sm">{loc.email}</TableCell>
<TableCell className="border-r text-gray-500 font-numeric text-xs">{loc.gps}</TableCell>
<TableCell className="text-center">
<Button variant="ghost" size="icon" className="h-8 w-8">
<MoreHorizontal className="h-4 w-4 text-gray-500" />
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</div>
<CreateLocationDialog open={isCreateDialogOpen} onOpenChange={setIsCreateDialogOpen} />
</div>
);
}
// --- Sub-components ---
function CreateLocationDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[600px]">
<DialogHeader>
<DialogTitle>Add New Location</DialogTitle>
<DialogDescription>
Enter the details for the new store location.
</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label>Partner</Label>
<Select defaultValue="partner-a">
<SelectTrigger><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="partner-a">Partner A</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label>Group</Label>
<Select defaultValue="group-b">
<SelectTrigger><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="group-b">Group B</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<div className="grid grid-cols-3 gap-4">
<div className="space-y-2 col-span-1">
<Label>Location ID</Label>
<Input placeholder="e.g. 12345" />
</div>
<div className="space-y-2 col-span-2">
<Label>Location Name</Label>
<Input placeholder="e.g. Downtown Store" />
</div>
</div>
<div className="space-y-2">
<Label>Street</Label>
<Input placeholder="e.g. 123 Main St" />
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label>City</Label>
<Input placeholder="e.g. New York" />
</div>
<div className="space-y-2">
<Label>State</Label>
<Input placeholder="e.g. NY" />
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label>Country</Label>
<Input placeholder="e.g. USA" />
</div>
<div className="space-y-2">
<Label>Zip Code</Label>
<Input placeholder="e.g. 10001" />
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label>Phone Number</Label>
<Input placeholder="+1 (555) 000-0000" />
</div>
<div className="space-y-2">
<Label>Email</Label>
<Input placeholder="store@example.com" />
</div>
</div>
<div className="space-y-2">
<Label className="flex items-center gap-2">
<MapPin className="w-4 h-4" /> GPS Coordinates
</Label>
<div className="grid grid-cols-2 gap-4">
<Input placeholder="Latitude (e.g. 40.7128)" />
<Input placeholder="Longitude (e.g. -74.0060)" />
</div>
</div>
<div className="flex items-center gap-2 pt-2">
<Switch id="loc-status" defaultChecked />
<Label htmlFor="loc-status">Active Location</Label>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
<Button onClick={() => onOpenChange(false)} className="bg-blue-600 text-white hover:bg-blue-700">Create Location</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}