LocationsView.tsx
9.58 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
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',
address: '123 Main St, New York, NY',
phone: '+1 (555) 123-4567',
email: 'downtown@example.com',
gps: '40.7128° N, 74.0060° W',
status: 'active'
},
{
id: '12335',
name: 'Uptown Market',
address: '456 High St, New York, NY',
phone: '+1 (555) 987-6543',
email: 'uptown@example.com',
gps: '40.7580° N, 73.9855° W',
status: 'active'
},
{
id: '12445',
name: 'Airport Kiosk',
address: 'Terminal 4, JFK Airport',
phone: '+1 (555) 555-5555',
email: 'jfk@example.com',
gps: '40.6413° N, 73.7781° W',
status: 'active'
},
{
id: '12555',
name: 'Suburban Outlet',
address: '789 Country Rd, Long Island',
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 bg-white">
{/* Header / Top Bar:无白色背景,与 Labels 一致仅依赖 Layout p-8 外边距 */}
<div className="border-b border-gray-200 py-4 bg-gray-50">
<div className="flex flex-nowrap items-center gap-2 overflow-x-auto min-w-0">
<Input
placeholder="Search"
className="border border-black rounded-lg h-9 w-32 shrink-0 bg-white text-black"
/>
<Select defaultValue="partner-a">
<SelectTrigger className="w-[140px] h-9 rounded-lg border border-black bg-white font-medium text-black shrink-0">
<SelectValue placeholder="Partner" />
</SelectTrigger>
<SelectContent>
<SelectItem value="partner-a">Partner A</SelectItem>
</SelectContent>
</Select>
<Select defaultValue="group-b">
<SelectTrigger className="w-[140px] h-9 rounded-lg border border-black bg-white font-medium text-black shrink-0">
<SelectValue placeholder="Group" />
</SelectTrigger>
<SelectContent>
<SelectItem value="group-b">Group B</SelectItem>
</SelectContent>
</Select>
<Select defaultValue="all">
<SelectTrigger className="w-[140px] h-9 rounded-lg border border-black bg-white font-medium text-black shrink-0">
<SelectValue placeholder="Location" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All Locations</SelectItem>
<SelectItem value="loc-1">Location 1</SelectItem>
</SelectContent>
</Select>
<div className="flex-1 min-w-0" />
<Button variant="outline" className="h-9 border border-black rounded-lg text-black px-4 bg-white hover:bg-gray-50 shrink-0">
Bulk Import
</Button>
<Button variant="outline" className="h-9 border border-black rounded-lg text-black px-4 bg-white hover:bg-gray-50 shrink-0">
Bulk Export
</Button>
<Button variant="outline" className="h-9 border border-black rounded-lg text-black px-4 bg-white hover:bg-gray-50 shrink-0">
Bulk Edit
</Button>
<Button
className="h-9 bg-blue-600 hover:bg-blue-700 text-white rounded-lg px-6 font-medium border-0 shrink-0"
onClick={() => setIsCreateDialogOpen(true)}
>
New+
</Button>
</div>
</div>
{/* Content Area:上下左右间距与 Labels 一致(由 Layout main p-8 控制) */}
<div className="flex-1 overflow-auto bg-gray-50">
<div className="bg-white border border-gray-200 shadow-sm rounded-sm 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">Address</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-mono text-gray-600">{loc.id}</TableCell>
<TableCell className="border-r font-medium text-black">{loc.name}</TableCell>
<TableCell className="border-r text-gray-600 truncate max-w-[200px]">{loc.address}</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-mono 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>Address</Label>
<Input placeholder="Full street address" />
</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>
);
}