Blame view

美国版/Food Labeling Management Platform/src/components/locations/LocationsView.tsx 57.7 KB
de8956f8   杨鑫   平台端 门店,菜单,角色
1
  import React, { useEffect, useMemo, useRef, useState } from "react";
3af4878d   杨鑫   产品 标签 关联
2
  import { Edit, MapPin, MoreHorizontal, Trash2 } from "lucide-react";
884054fb   “wangming”   项目初始化
3
  import { Button } from "../ui/button";
63289723   杨鑫   提交
4
  import { Checkbox } from "../ui/checkbox";
884054fb   “wangming”   项目初始化
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
  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";
ef6b3255   杨鑫   修改BUG
31
  import { cn } from "../ui/utils";
884054fb   “wangming”   项目初始化
32
  import { Switch } from "../ui/switch";
de8956f8   杨鑫   平台端 门店,菜单,角色
33
  import { toast } from "sonner";
143afd59   杨鑫   打印,标签
34
  import { skipCountForPage } from "../../lib/paginationQuery";
540ac0e3   杨鑫   前端修改bug
35
  import { useCategoryScopeAuth } from "../../hooks/useCategoryScopeAuth";
de8956f8   杨鑫   平台端 门店,菜单,角色
36
37
38
39
40
41
42
43
44
  import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
  import {
    Pagination,
    PaginationContent,
    PaginationItem,
    PaginationLink,
    PaginationNext,
    PaginationPrevious,
  } from "../ui/pagination";
63289723   杨鑫   提交
45
46
47
48
49
50
51
52
53
  import {
    createLocation,
    deleteLocation,
    downloadLocationImportTemplate,
    exportLocationsExcel,
    getLocations,
    importLocationsBatch,
    updateLocation,
  } from "../../services/locationService";
699ea6e8   杨鑫   完善打印逻辑
54
55
  import { getPartners } from "../../services/partnerService";
  import { getGroups } from "../../services/groupService";
de8956f8   杨鑫   平台端 门店,菜单,角色
56
  import type { LocationCreateInput, LocationDto } from "../../types/location";
699ea6e8   杨鑫   完善打印逻辑
57
58
  import type { GroupListItem } from "../../types/group";
  import type { PartnerListItem } from "../../types/partner";
63289723   杨鑫   提交
59
  import { BatchImportDialog } from "../bulk/batch-import-dialog";
6ce07406   杨鑫   提交
60
  import { LocationBulkEditPage } from "./location-bulk-edit-page";
699ea6e8   杨鑫   完善打印逻辑
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
  
  const LOCATION_PG_NONE = "__none__";
  
  async function loadActivePartnerOptions(signal: AbortSignal): Promise<PartnerListItem[]> {
    const out: PartnerListItem[] = [];
    let page = 1;
    const size = 100;
    for (;;) {
      const res = await getPartners({ skipCount: page, maxResultCount: size, state: true }, signal);
      out.push(...(res.items ?? []));
      if (!res.items || res.items.length < size) break;
      page += 1;
      if (page > 200) break;
    }
    const m = new Map<string, PartnerListItem>();
    for (const p of out) if (p.id && !m.has(p.id)) m.set(p.id, p);
    return Array.from(m.values());
  }
  
  async function loadActiveGroupsForPartner(partnerId: string, signal: AbortSignal): Promise<GroupListItem[]> {
    const out: GroupListItem[] = [];
    let page = 1;
    const size = 100;
    for (;;) {
      const res = await getGroups(
        { skipCount: page, maxResultCount: size, partnerId, state: true },
        signal,
      );
      out.push(...(res.items ?? []));
      if (!res.items || res.items.length < size) break;
      page += 1;
      if (page > 200) break;
    }
    const m = new Map<string, GroupListItem>();
    for (const g of out) if (g.id && !m.has(g.id)) m.set(g.id, g);
    return Array.from(m.values());
  }
884054fb   “wangming”   项目初始化
98
  
de8956f8   杨鑫   平台端 门店,菜单,角色
99
100
101
102
103
104
105
106
107
108
  function toDisplay(v: string | null | undefined): string {
    const s = (v ?? "").trim();
    return s ? s : "N/A";
  }
  
  function formatGps(lat: number | null | undefined, lng: number | null | undefined): string {
    if (lat === null || lat === undefined || lng === null || lng === undefined) return "N/A";
    if (!Number.isFinite(lat) || !Number.isFinite(lng)) return "N/A";
    return `${lat}, ${lng}`;
  }
884054fb   “wangming”   项目初始化
109
  
3d4c10ac   杨鑫   对接,标签产品
110
  /**
ef6b3255   杨鑫   修改BUG
111
   * 门店表单红框区域:Location ID / Name、地址、联系方式(Company、Region、Active、GPS 不要求)
3d4c10ac   杨鑫   对接,标签产品
112
113
114
115
116
117
118
119
120
121
122
123
124
   * 仅校验是否填写,不校验邮箱/电话格式。
   */
  function getLocationRedBoxValidationErrors(form: LocationCreateInput): string[] {
    const errs: string[] = [];
    if (!form.locationCode.trim()) errs.push("Location ID");
    if (!form.locationName.trim()) errs.push("Location Name");
    if (!(form.street ?? "").trim()) errs.push("Street");
    if (!(form.city ?? "").trim()) errs.push("City");
    if (!(form.stateCode ?? "").trim()) errs.push("State");
    if (!(form.country ?? "").trim()) errs.push("Country");
    if (!(form.zipCode ?? "").trim()) errs.push("Zip Code");
    if (!(form.phone ?? "").trim()) errs.push("Phone Number");
    if (!(form.email ?? "").trim()) errs.push("Email");
3d4c10ac   杨鑫   对接,标签产品
125
126
127
    return errs;
  }
  
699ea6e8   杨鑫   完善打印逻辑
128
129
130
131
132
133
  export type LocationsViewProps = {
    /**
     * 嵌入 Account Management 时:将「搜索/筛选/操作」条交给父组件排版(例如放在 Tab 上方)。
     * 传入的 `toolbar` 为门店管理原有工具栏节点,父组件应将其与 Tab 等一并渲染。
     */
    renderBeforeTabs?: (toolbar: React.ReactNode) => React.ReactNode;
ef6b3255   杨鑫   修改BUG
134
135
136
137
138
    /**
     * 为 false 时隐藏新建、批量导入/批量编辑、行勾选及编辑/删除(非平台管理员)。
     * @default true
     */
    canMutateLocations?: boolean;
699ea6e8   杨鑫   完善打印逻辑
139
140
  };
  
ef6b3255   杨鑫   修改BUG
141
  export function LocationsView({ renderBeforeTabs, canMutateLocations = true }: LocationsViewProps = {}) {
884054fb   “wangming”   项目初始化
142
    const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
de8956f8   杨鑫   平台端 门店,菜单,角色
143
144
145
146
147
148
149
150
151
    const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
    const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
    const [editingLocation, setEditingLocation] = useState<LocationDto | null>(null);
    const [deletingLocation, setDeletingLocation] = useState<LocationDto | null>(null);
    const [locations, setLocations] = useState<LocationDto[]>([]);
    const [loading, setLoading] = useState(false);
    const [total, setTotal] = useState(0);
    const [refreshSeq, setRefreshSeq] = useState(0);
    const [actionsOpenForId, setActionsOpenForId] = useState<string | null>(null);
63289723   杨鑫   提交
152
153
    const [selectedIds, setSelectedIds] = useState<Set<string>>(() => new Set());
    const [bulkImportOpen, setBulkImportOpen] = useState(false);
6ce07406   杨鑫   提交
154
    const [locationBulkEditPage, setLocationBulkEditPage] = useState(false);
63289723   杨鑫   提交
155
156
157
    const [bulkEditSeed, setBulkEditSeed] = useState<LocationDto[]>([]);
    const [tmplDownloading, setTmplDownloading] = useState(false);
    const [excelExporting, setExcelExporting] = useState(false);
de8956f8   杨鑫   平台端 门店,菜单,角色
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  
    const [keyword, setKeyword] = useState("");
    const [partner, setPartner] = useState<string>("all");
    const [groupName, setGroupName] = useState<string>("all");
    const [locationPick, setLocationPick] = useState<string>("all");
  
    const [pageIndex, setPageIndex] = useState(1);
    const [pageSize, setPageSize] = useState(10);
  
    const abortRef = useRef<AbortController | null>(null);
    const keywordTimerRef = useRef<number | null>(null);
    const [debouncedKeyword, setDebouncedKeyword] = useState("");
  
    useEffect(() => {
      if (keywordTimerRef.current) window.clearTimeout(keywordTimerRef.current);
      keywordTimerRef.current = window.setTimeout(() => setDebouncedKeyword(keyword.trim()), 300);
      return () => {
        if (keywordTimerRef.current) window.clearTimeout(keywordTimerRef.current);
      };
    }, [keyword]);
  
63289723   杨鑫   提交
179
180
181
182
183
    const listKeyword = useMemo(
      () => (locationPick !== "all" ? locationPick : debouncedKeyword.trim()),
      [locationPick, debouncedKeyword],
    );
  
de8956f8   杨鑫   平台端 门店,菜单,角色
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
    // Options derived from current result set (no dedicated endpoints provided in doc).
    const partnerOptions = useMemo(() => {
      const s = new Set<string>();
      for (const x of locations) {
        const v = (x.partner ?? "").trim();
        if (v) s.add(v);
      }
      return ["all", ...Array.from(s).sort((a, b) => a.localeCompare(b))];
    }, [locations]);
  
    const groupOptions = useMemo(() => {
      const s = new Set<string>();
      for (const x of locations) {
        const v = (x.groupName ?? "").trim();
        if (v) s.add(v);
      }
      return ["all", ...Array.from(s).sort((a, b) => a.localeCompare(b))];
    }, [locations]);
  
    const locationOptions = useMemo(() => {
      const s = new Set<string>();
      for (const x of locations) {
        const v = (x.locationCode ?? "").trim();
        if (v) s.add(v);
      }
      return ["all", ...Array.from(s).sort((a, b) => a.localeCompare(b))];
    }, [locations]);
  
    const totalPages = Math.max(1, Math.ceil(total / pageSize));
  
    useEffect(() => {
      // When filter changes, reset to first page.
      setPageIndex(1);
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [debouncedKeyword, partner, groupName, locationPick, pageSize]);
  
    useEffect(() => {
      const run = async () => {
        abortRef.current?.abort();
        const ac = new AbortController();
        abortRef.current = ac;
  
        setLoading(true);
        try {
143afd59   杨鑫   打印,标签
228
          const skipCount = skipCountForPage(pageIndex);
de8956f8   杨鑫   平台端 门店,菜单,角色
229
230
231
232
          const res = await getLocations(
            {
              skipCount,
              maxResultCount: pageSize,
63289723   杨鑫   提交
233
              keyword: listKeyword || undefined,
de8956f8   杨鑫   平台端 门店,菜单,角色
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
              partner: partner !== "all" ? partner : undefined,
              groupName: groupName !== "all" ? groupName : undefined,
            },
            ac.signal,
          );
  
          setLocations(res.items ?? []);
          setTotal(res.totalCount ?? 0);
        } catch (e: any) {
          if (e?.name === "AbortError") return;
          toast.error("Failed to load locations.", {
            description: e?.message ? String(e.message) : "Please try again.",
          });
          setLocations([]);
          setTotal(0);
        } finally {
          setLoading(false);
        }
      };
  
      run();
      return () => abortRef.current?.abort();
63289723   杨鑫   提交
256
257
258
259
260
    }, [listKeyword, partner, groupName, locationPick, pageIndex, pageSize, refreshSeq]);
  
    useEffect(() => {
      setSelectedIds(new Set());
    }, [debouncedKeyword, partner, groupName, locationPick, pageIndex]);
de8956f8   杨鑫   平台端 门店,菜单,角色
261
  
ef6b3255   杨鑫   修改BUG
262
263
264
265
266
267
268
269
    useEffect(() => {
      if (!canMutateLocations) {
        setLocationBulkEditPage(false);
        setBulkEditSeed([]);
        setSelectedIds(new Set());
      }
    }, [canMutateLocations]);
  
de8956f8   杨鑫   平台端 门店,菜单,角色
270
271
272
273
274
275
276
277
278
279
280
281
282
    const refreshList = () => setRefreshSeq((x) => x + 1);
  
    const openEdit = (loc: LocationDto) => {
      setActionsOpenForId(null);
      setEditingLocation(loc);
      setIsEditDialogOpen(true);
    };
  
    const openDelete = (loc: LocationDto) => {
      setActionsOpenForId(null);
      setDeletingLocation(loc);
      setIsDeleteDialogOpen(true);
    };
884054fb   “wangming”   项目初始化
283
  
699ea6e8   杨鑫   完善打印逻辑
284
    const toolbarSection = (
6ce07406   杨鑫   提交
285
      <div className={cn(!locationBulkEditPage && "pb-4", locationBulkEditPage && "hidden")}>
699ea6e8   杨鑫   完善打印逻辑
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
        <div className="flex flex-col gap-4">
          <div className="flex flex-nowrap items-center gap-3">
            <Input
              placeholder="Search"
              value={keyword}
              onChange={(e) => setKeyword(e.target.value)}
              style={{ height: 40, boxSizing: "border-box" }}
              className="border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"
            />
            <Select value={partner} onValueChange={setPartner}>
              <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="Company" />
              </SelectTrigger>
              <SelectContent>
                {partnerOptions.map((p) => (
                  <SelectItem key={p} value={p}>
                    {p === "all" ? "Company (All)" : p}
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
            <Select value={groupName} onValueChange={setGroupName}>
              <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="Region" />
              </SelectTrigger>
              <SelectContent>
                {groupOptions.map((g) => (
                  <SelectItem key={g} value={g}>
                    {g === "all" ? "Region (All)" : g}
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
            <Select value={locationPick} onValueChange={setLocationPick}>
              <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>
                {locationOptions.map((x) => (
                  <SelectItem key={x} value={x}>
                    {x === "all" ? "All Locations" : x}
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
            <div className="flex-1" />
ef6b3255   杨鑫   修改BUG
332
333
334
335
336
337
338
339
340
341
342
343
            {canMutateLocations && (
              <>
                <Button
                  type="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"
                  onClick={() => setBulkImportOpen(true)}
                >
                  Bulk Import
                </Button>
              </>
            )}
63289723   杨鑫   提交
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
            <Button
              type="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"
              disabled={excelExporting}
              onClick={async () => {
                setExcelExporting(true);
                try {
                  await exportLocationsExcel({
                    keyword: listKeyword || undefined,
                    partner: partner !== "all" ? partner : undefined,
                    groupName: groupName !== "all" ? groupName : undefined,
                  });
                  toast.success("Export started", { description: "Your browser should download the Excel file." });
                } catch (e: unknown) {
                  const msg = e instanceof Error ? e.message : "Please try again.";
                  toast.error("Export failed", { description: msg });
                } finally {
                  setExcelExporting(false);
                }
              }}
            >
              {excelExporting ? "Exporting…" : "Bulk Export"}
            </Button>
ef6b3255   杨鑫   修改BUG
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
            {canMutateLocations && (
              <>
                <Button
                  type="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"
                  onClick={() => {
                    const seed = locations.filter((l) => selectedIds.has(l.id));
                    if (seed.length === 0) {
                      toast.error("No rows selected", { description: "Use the checkboxes on the left, then open Bulk Edit." });
                      return;
                    }
                    setBulkEditSeed(seed);
                    setLocationBulkEditPage(true);
                  }}
                >
                  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>
              </>
            )}
884054fb   “wangming”   项目初始化
394
395
          </div>
        </div>
699ea6e8   杨鑫   完善打印逻辑
396
397
      </div>
    );
884054fb   “wangming”   项目初始化
398
  
ef6b3255   杨鑫   修改BUG
399
400
    const locationTableColSpan = canMutateLocations ? 15 : 14;
  
699ea6e8   杨鑫   完善打印逻辑
401
402
403
    const tableAndPagination = (
      <>
        <div className="flex-1 overflow-auto pt-6 min-h-0">
884054fb   “wangming”   项目初始化
404
405
406
          <div className="bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden">
            <Table>
              <TableHeader>
ef6b3255   杨鑫   修改BUG
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
                  <TableRow className="bg-gray-100 hover:bg-gray-100">
                    {canMutateLocations ? (
                      <TableHead className="border-r text-sm font-semibold text-gray-900 w-12 shrink-0 text-center px-3">
                        <Checkbox
                          checked={locations.length > 0 && locations.every((l) => selectedIds.has(l.id))}
                          onCheckedChange={(c) => {
                            if (c === true) setSelectedIds(new Set(locations.map((l) => l.id)));
                            else setSelectedIds(new Set());
                          }}
                          aria-label="Select all on page"
                        />
                      </TableHead>
                    ) : null}
                    <TableHead className="border-r text-sm font-semibold text-gray-900">Company</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Region</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Location ID</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Location Name</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Street</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">City</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">State</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Country</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Zip Code</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Phone</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Email</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">GPS</TableHead>
                  <TableHead className="border-r text-sm font-semibold text-gray-900">Active</TableHead>
                  <TableHead className="text-sm font-semibold text-gray-900 text-center">Actions</TableHead>
884054fb   “wangming”   项目初始化
434
435
436
                </TableRow>
              </TableHeader>
              <TableBody>
de8956f8   杨鑫   平台端 门店,菜单,角色
437
438
                {loading ? (
                  <TableRow>
ef6b3255   杨鑫   修改BUG
439
                    <TableCell colSpan={locationTableColSpan} className="text-center text-sm font-normal text-gray-900 py-10">
de8956f8   杨鑫   平台端 门店,菜单,角色
440
441
442
443
444
                      Loading...
                    </TableCell>
                  </TableRow>
                ) : locations.length === 0 ? (
                  <TableRow>
ef6b3255   杨鑫   修改BUG
445
                    <TableCell colSpan={locationTableColSpan} className="text-center text-sm font-normal text-gray-900 py-10">
de8956f8   杨鑫   平台端 门店,菜单,角色
446
                      No results.
884054fb   “wangming”   项目初始化
447
448
                    </TableCell>
                  </TableRow>
de8956f8   杨鑫   平台端 门店,菜单,角色
449
450
451
                ) : (
                  locations.map((loc) => (
                    <TableRow key={loc.id}>
ef6b3255   杨鑫   修改BUG
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
                      {canMutateLocations ? (
                        <TableCell className="border-r w-12 shrink-0 text-center px-3">
                          <Checkbox
                            checked={selectedIds.has(loc.id)}
                            onCheckedChange={(c) => {
                              setSelectedIds((prev) => {
                                const n = new Set(prev);
                                if (c === true) n.add(loc.id);
                                else n.delete(loc.id);
                                return n;
                              });
                            }}
                            aria-label="Select row"
                          />
                        </TableCell>
                      ) : null}
                      <TableCell className="border-r text-sm font-normal text-gray-900 max-w-[140px] truncate">
                        {toDisplay(loc.partner)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 max-w-[140px] truncate">
                        {toDisplay(loc.groupName)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 font-numeric">
                        {toDisplay(loc.locationCode ?? loc.id)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900">{toDisplay(loc.locationName)}</TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 max-w-[140px] truncate">
                        {toDisplay(loc.street)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900">{toDisplay(loc.city)}</TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900">{toDisplay(loc.stateCode)}</TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900">{toDisplay(loc.country)}</TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 font-numeric">
                        {toDisplay(loc.zipCode)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 whitespace-nowrap">
                        {toDisplay(loc.phone)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 max-w-[180px] truncate">
                        {toDisplay(loc.email)}
                      </TableCell>
                      <TableCell className="border-r text-sm font-normal text-gray-900 font-numeric">
                        {formatGps(loc.latitude, loc.longitude)}
63289723   杨鑫   提交
495
                      </TableCell>
de8956f8   杨鑫   平台端 门店,菜单,角色
496
                      <TableCell className="border-r">
ef6b3255   杨鑫   修改BUG
497
498
499
500
501
502
                        <Badge
                          className={cn(
                            "text-sm font-normal",
                            loc.state ? "bg-green-600" : "bg-gray-400",
                          )}
                        >
de8956f8   杨鑫   平台端 门店,菜单,角色
503
504
505
                          {loc.state ? "Yes" : "No"}
                        </Badge>
                      </TableCell>
ef6b3255   杨鑫   修改BUG
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
                      <TableCell className="text-center text-sm font-normal text-gray-900">
                        {canMutateLocations ? (
                          <Popover
                            open={actionsOpenForId === loc.id}
                            onOpenChange={(open) => setActionsOpenForId(open ? loc.id : null)}
                          >
                            <PopoverTrigger asChild>
                              <Button
                                type="button"
                                variant="ghost"
                                size="icon"
                                className="h-8 w-8"
                                aria-label="Row actions"
                              >
                                <MoreHorizontal className="h-4 w-4 text-gray-500" />
                              </Button>
                            </PopoverTrigger>
                            <PopoverContent align="end" className="w-40 p-1">
                              <Button
                                type="button"
                                variant="ghost"
                                className="w-full justify-start gap-2 h-9 px-2 font-normal"
                                onClick={() => openEdit(loc)}
                              >
                                <Edit className="w-4 h-4" />
                                Edit
                              </Button>
                              <Button
                                type="button"
                                variant="ghost"
                                className="w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50"
                                onClick={() => openDelete(loc)}
                              >
                                <Trash2 className="w-4 h-4 shrink-0" />
                                Delete
                              </Button>
                            </PopoverContent>
                          </Popover>
                        ) : (
                          "—"
                        )}
de8956f8   杨鑫   平台端 门店,菜单,角色
547
548
549
550
                      </TableCell>
                    </TableRow>
                  ))
                )}
884054fb   “wangming”   项目初始化
551
552
553
554
555
              </TableBody>
            </Table>
          </div>
        </div>
  
699ea6e8   杨鑫   完善打印逻辑
556
        <div className="pt-4 shrink-0">
ef6b3255   杨鑫   修改BUG
557
          <div className="flex items-center justify-between text-sm font-normal text-gray-900">
de8956f8   杨鑫   平台端 门店,菜单,角色
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
            <div>
              Showing {total === 0 ? 0 : (pageIndex - 1) * pageSize + 1}-
              {Math.min(pageIndex * pageSize, total)} of {total}
            </div>
            <div className="flex items-center gap-3">
              <Select value={String(pageSize)} onValueChange={(v) => setPageSize(Number(v))}>
                <SelectTrigger className="w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900">
                  <SelectValue />
                </SelectTrigger>
                <SelectContent>
                  {[10, 20, 50].map((n) => (
                    <SelectItem key={n} value={String(n)}>
                      {n} / page
                    </SelectItem>
                  ))}
                </SelectContent>
              </Select>
              <Pagination className="mx-0 w-auto justify-end">
                <PaginationContent>
                  <PaginationItem>
                    <PaginationPrevious
                      href="#"
                      size="default"
                      onClick={(e) => {
                        e.preventDefault();
                        setPageIndex((p) => Math.max(1, p - 1));
                      }}
                      aria-disabled={pageIndex <= 1}
                      className={pageIndex <= 1 ? "pointer-events-none opacity-50" : ""}
                    />
                  </PaginationItem>
                  <PaginationItem>
                    <PaginationLink
                      href="#"
                      isActive
                      size="default"
                      onClick={(e) => e.preventDefault()}
                    >
                      Page {pageIndex} / {totalPages}
                    </PaginationLink>
                  </PaginationItem>
                  <PaginationItem>
                    <PaginationNext
                      href="#"
                      size="default"
                      onClick={(e) => {
                        e.preventDefault();
                        setPageIndex((p) => Math.min(totalPages, p + 1));
                      }}
                      aria-disabled={pageIndex >= totalPages}
                      className={pageIndex >= totalPages ? "pointer-events-none opacity-50" : ""}
                    />
                  </PaginationItem>
                </PaginationContent>
              </Pagination>
            </div>
          </div>
        </div>
699ea6e8   杨鑫   完善打印逻辑
616
617
      </>
    );
de8956f8   杨鑫   平台端 门店,菜单,角色
618
  
6ce07406   杨鑫   提交
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
    const listOrBulkMain = locationBulkEditPage ? (
      <div className="flex-1 overflow-auto pt-6 min-h-0">
        <div className="bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden flex flex-col min-h-0 h-full max-h-full">
          <LocationBulkEditPage
            seed={bulkEditSeed}
            onBack={() => {
              setLocationBulkEditPage(false);
              setBulkEditSeed([]);
            }}
            onSaved={() => {
              setSelectedIds(new Set());
              refreshList();
            }}
          />
        </div>
      </div>
    ) : (
      tableAndPagination
    );
  
699ea6e8   杨鑫   完善打印逻辑
639
640
    const dialogs = (
      <>
de8956f8   杨鑫   平台端 门店,菜单,角色
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
        <CreateLocationDialog
          open={isCreateDialogOpen}
          onOpenChange={setIsCreateDialogOpen}
          onCreated={() => {
            // 新增后强制刷新一次列表;如果当前已在第一页也能刷新。
            setPageIndex(1);
            refreshList();
          }}
        />
  
        <EditLocationDialog
          open={isEditDialogOpen}
          location={editingLocation}
          onOpenChange={(open) => {
            setIsEditDialogOpen(open);
            if (!open) setEditingLocation(null);
          }}
          onUpdated={() => {
            // 编辑后强制刷新一次列表
            refreshList();
          }}
        />
  
        <DeleteLocationDialog
          open={isDeleteDialogOpen}
          location={deletingLocation}
          onOpenChange={(open) => {
            setIsDeleteDialogOpen(open);
            if (!open) setDeletingLocation(null);
          }}
          onDeleted={() => {
            refreshList();
63289723   杨鑫   提交
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
          }}
        />
  
        <BatchImportDialog
          open={bulkImportOpen}
          onOpenChange={setBulkImportOpen}
          title="Bulk import locations"
          description="Upload an .xlsx file. Use the official template for correct column headers."
          downloadingTemplate={tmplDownloading}
          onDownloadTemplate={async () => {
            setTmplDownloading(true);
            try {
              await downloadLocationImportTemplate();
              toast.success("Template downloaded.");
            } catch (e: unknown) {
              const msg = e instanceof Error ? e.message : "Download failed.";
              toast.error("Template download failed", { description: msg });
            } finally {
              setTmplDownloading(false);
            }
          }}
          onImportFile={async (file) => {
            const r = await importLocationsBatch(file);
            refreshList();
            return { successCount: r.successCount, failCount: r.failCount };
          }}
        />
  
699ea6e8   杨鑫   完善打印逻辑
701
702
703
704
705
706
707
      </>
    );
  
    if (renderBeforeTabs) {
      return (
        <div className="h-full flex flex-col min-h-0">
          {renderBeforeTabs(toolbarSection)}
6ce07406   杨鑫   提交
708
          <div className="flex-1 min-h-0 flex flex-col overflow-hidden">{listOrBulkMain}</div>
699ea6e8   杨鑫   完善打印逻辑
709
710
711
712
713
714
715
716
          {dialogs}
        </div>
      );
    }
  
    return (
      <div className="h-full flex flex-col min-h-0">
        {toolbarSection}
6ce07406   杨鑫   提交
717
        <div className="flex-1 min-h-0 flex flex-col overflow-hidden">{listOrBulkMain}</div>
699ea6e8   杨鑫   完善打印逻辑
718
        {dialogs}
884054fb   “wangming”   项目初始化
719
720
721
722
723
724
      </div>
    );
  }
  
  // --- Sub-components ---
  
de8956f8   杨鑫   平台端 门店,菜单,角色
725
726
727
728
729
730
731
732
733
  function CreateLocationDialog({
    open,
    onOpenChange,
    onCreated,
  }: {
    open: boolean;
    onOpenChange: (open: boolean) => void;
    onCreated: () => void;
  }) {
540ac0e3   杨鑫   前端修改bug
734
    const scopeAuth = useCategoryScopeAuth();
de8956f8   杨鑫   平台端 门店,菜单,角色
735
736
737
738
739
740
741
742
743
744
745
746
747
    const [submitting, setSubmitting] = useState(false);
    const [form, setForm] = useState<LocationCreateInput>({
      partner: "",
      groupName: "",
      locationCode: "",
      locationName: "",
      street: "",
      city: "",
      stateCode: "",
      country: "",
      zipCode: "",
      phone: "",
      email: "",
ef6b3255   杨鑫   修改BUG
748
      operatingHours: "",
de8956f8   杨鑫   平台端 门店,菜单,角色
749
750
751
752
      latitude: null,
      longitude: null,
      state: true,
    });
699ea6e8   杨鑫   完善打印逻辑
753
754
755
756
757
758
759
    const [partnerPickId, setPartnerPickId] = useState(LOCATION_PG_NONE);
    const [groupPickId, setGroupPickId] = useState(LOCATION_PG_NONE);
    const [partnerOptions, setPartnerOptions] = useState<PartnerListItem[]>([]);
    const [groupOptions, setGroupOptions] = useState<GroupListItem[]>([]);
    const [loadingPartners, setLoadingPartners] = useState(false);
    const [loadingGroups, setLoadingGroups] = useState(false);
    const createAbortRef = useRef<AbortController | null>(null);
de8956f8   杨鑫   平台端 门店,菜单,角色
760
761
762
763
764
765
766
767
768
769
770
771
772
773
  
    const resetForm = () => {
      setForm({
        partner: "",
        groupName: "",
        locationCode: "",
        locationName: "",
        street: "",
        city: "",
        stateCode: "",
        country: "",
        zipCode: "",
        phone: "",
        email: "",
ef6b3255   杨鑫   修改BUG
774
        operatingHours: "",
de8956f8   杨鑫   平台端 门店,菜单,角色
775
776
777
778
        latitude: null,
        longitude: null,
        state: true,
      });
699ea6e8   杨鑫   完善打印逻辑
779
780
781
782
      setPartnerPickId(LOCATION_PG_NONE);
      setGroupPickId(LOCATION_PG_NONE);
      setPartnerOptions([]);
      setGroupOptions([]);
de8956f8   杨鑫   平台端 门店,菜单,角色
783
784
785
786
    };
  
    useEffect(() => {
      if (!open) {
699ea6e8   杨鑫   完善打印逻辑
787
        createAbortRef.current?.abort();
de8956f8   杨鑫   平台端 门店,菜单,角色
788
789
790
791
792
        resetForm();
        setSubmitting(false);
      }
    }, [open]);
  
699ea6e8   杨鑫   完善打印逻辑
793
794
795
796
797
798
799
800
801
802
    useEffect(() => {
      if (!open) return;
      createAbortRef.current?.abort();
      const ac = new AbortController();
      createAbortRef.current = ac;
      setLoadingPartners(true);
      (async () => {
        try {
          const list = await loadActivePartnerOptions(ac.signal);
          setPartnerOptions(list);
540ac0e3   杨鑫   前端修改bug
803
804
805
806
807
808
          if (!scopeAuth.requireCompanySelection) {
            const pid = scopeAuth.fixedPartnerId.trim();
            if (pid && list.some((p) => p.id === pid)) {
              setPartnerPickId(pid);
            }
          }
699ea6e8   杨鑫   完善打印逻辑
809
810
811
812
813
814
815
816
817
818
819
        } catch (e: any) {
          if (e?.name === "AbortError") return;
          toast.error("Failed to load companies.", {
            description: e?.message ? String(e.message) : "Please try again.",
          });
          setPartnerOptions([]);
        } finally {
          setLoadingPartners(false);
        }
      })();
      return () => ac.abort();
540ac0e3   杨鑫   前端修改bug
820
821
822
823
824
825
826
827
828
    }, [open, scopeAuth.requireCompanySelection, scopeAuth.fixedPartnerId]);
  
    useEffect(() => {
      if (!open || scopeAuth.requireCompanySelection || scopeAuth.loadingPartner) return;
      const pid = scopeAuth.fixedPartnerId.trim();
      if (pid && partnerOptions.some((p) => p.id === pid)) {
        setPartnerPickId(pid);
      }
    }, [open, scopeAuth.requireCompanySelection, scopeAuth.fixedPartnerId, scopeAuth.loadingPartner, partnerOptions]);
699ea6e8   杨鑫   完善打印逻辑
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
  
    useEffect(() => {
      if (!open || partnerPickId === LOCATION_PG_NONE) {
        setGroupOptions([]);
        setGroupPickId(LOCATION_PG_NONE);
        setLoadingGroups(false);
        return;
      }
      const ac = new AbortController();
      setLoadingGroups(true);
      (async () => {
        try {
          const list = await loadActiveGroupsForPartner(partnerPickId, ac.signal);
          setGroupOptions(list);
          setGroupPickId(LOCATION_PG_NONE);
        } catch (e: any) {
          if (e?.name === "AbortError") return;
          toast.error("Failed to load regions.", {
            description: e?.message ? String(e.message) : "Please try again.",
          });
          setGroupOptions([]);
        } finally {
          setLoadingGroups(false);
        }
      })();
      return () => ac.abort();
    }, [open, partnerPickId]);
  
de8956f8   杨鑫   平台端 门店,菜单,角色
857
    const submit = async () => {
3d4c10ac   杨鑫   对接,标签产品
858
859
      const errs = getLocationRedBoxValidationErrors(form);
      if (errs.length) {
de8956f8   杨鑫   平台端 门店,菜单,角色
860
        toast.error("Please fill in required fields.", {
3d4c10ac   杨鑫   对接,标签产品
861
          description: `Missing: ${errs.join(", ")}.`,
de8956f8   杨鑫   平台端 门店,菜单,角色
862
863
864
        });
        return;
      }
540ac0e3   杨鑫   前端修改bug
865
866
867
868
869
870
871
872
873
      const resolvedPartnerPickId =
        partnerPickId !== LOCATION_PG_NONE
          ? partnerPickId
          : !scopeAuth.requireCompanySelection
            ? scopeAuth.fixedPartnerId.trim()
            : "";
      const p = resolvedPartnerPickId
        ? partnerOptions.find((x) => x.id === resolvedPartnerPickId)
        : undefined;
699ea6e8   杨鑫   完善打印逻辑
874
      const g = groupPickId !== LOCATION_PG_NONE ? groupOptions.find((x) => x.id === groupPickId) : undefined;
de8956f8   杨鑫   平台端 门店,菜单,角色
875
876
877
878
879
880
      setSubmitting(true);
      try {
        await createLocation({
          ...form,
          locationCode: form.locationCode.trim(),
          locationName: form.locationName.trim(),
699ea6e8   杨鑫   完善打印逻辑
881
882
          partner: p?.partnerName?.trim() ? p.partnerName.trim() : null,
          groupName: g?.groupName?.trim() ? g.groupName.trim() : null,
3d4c10ac   杨鑫   对接,标签产品
883
884
885
886
887
888
889
          street: (form.street ?? "").trim(),
          city: (form.city ?? "").trim(),
          stateCode: (form.stateCode ?? "").trim(),
          country: (form.country ?? "").trim(),
          zipCode: (form.zipCode ?? "").trim(),
          phone: (form.phone ?? "").trim(),
          email: (form.email ?? "").trim(),
ef6b3255   杨鑫   修改BUG
890
891
892
          operatingHours: (form.operatingHours ?? "").trim() || null,
          latitude: form.latitude ?? null,
          longitude: form.longitude ?? null,
de8956f8   杨鑫   平台端 门店,菜单,角色
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
        });
        toast.success("Location created.", {
          description: "The location has been added successfully.",
        });
        onOpenChange(false);
        onCreated();
      } catch (e: any) {
        toast.error("Failed to create location.", {
          description: e?.message ? String(e.message) : "Please try again.",
        });
      } finally {
        setSubmitting(false);
      }
    };
  
884054fb   “wangming”   项目初始化
908
909
910
911
912
913
914
915
916
917
918
919
920
    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">
699ea6e8   杨鑫   完善打印逻辑
921
922
923
924
925
926
927
                <Label>Company</Label>
                <Select
                  value={partnerPickId}
                  onValueChange={(v) => {
                    setPartnerPickId(v);
                    setGroupPickId(LOCATION_PG_NONE);
                  }}
540ac0e3   杨鑫   前端修改bug
928
                  disabled={loadingPartners || scopeAuth.loadingPartner || !scopeAuth.requireCompanySelection}
699ea6e8   杨鑫   完善打印逻辑
929
930
931
932
933
                >
                  <SelectTrigger className="h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500">
                    <SelectValue placeholder={loadingPartners ? "Loading..." : "e.g. Global Foods Inc."} />
                  </SelectTrigger>
                  <SelectContent>
540ac0e3   杨鑫   前端修改bug
934
935
936
                    {scopeAuth.requireCompanySelection ? (
                      <SelectItem value={LOCATION_PG_NONE}>None</SelectItem>
                    ) : null}
699ea6e8   杨鑫   完善打印逻辑
937
938
939
940
941
942
943
                    {partnerOptions.map((p) => (
                      <SelectItem key={p.id} value={p.id}>
                        {p.partnerName ?? p.id}
                      </SelectItem>
                    ))}
                  </SelectContent>
                </Select>
884054fb   “wangming”   项目初始化
944
945
              </div>
              <div className="space-y-2">
699ea6e8   杨鑫   完善打印逻辑
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
                <Label>Region</Label>
                <Select
                  value={groupPickId}
                  onValueChange={setGroupPickId}
                  disabled={loadingGroups || partnerPickId === LOCATION_PG_NONE}
                >
                  <SelectTrigger className="h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500">
                    <SelectValue
                      placeholder={
                        partnerPickId === LOCATION_PG_NONE
                          ? "Select a company first"
                          : loadingGroups
                            ? "Loading..."
                            : "e.g. East Coast Region"
                      }
                    />
                  </SelectTrigger>
                  <SelectContent>
                    <SelectItem value={LOCATION_PG_NONE}>None</SelectItem>
                    {groupOptions.map((g) => (
                      <SelectItem key={g.id} value={g.id}>
                        {g.groupName ?? g.id}
                      </SelectItem>
                    ))}
                  </SelectContent>
                </Select>
884054fb   “wangming”   项目初始化
972
973
974
975
976
              </div>
            </div>
  
            <div className="grid grid-cols-3 gap-4">
               <div className="space-y-2 col-span-1">
3d4c10ac   杨鑫   对接,标签产品
977
                <Label>Location ID *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
978
979
980
981
982
                <Input
                  placeholder="e.g. 12345"
                  value={form.locationCode}
                  onChange={(e) => setForm((p) => ({ ...p, locationCode: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
983
984
              </div>
              <div className="space-y-2 col-span-2">
3d4c10ac   杨鑫   对接,标签产品
985
                <Label>Location Name *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
986
987
988
989
990
                <Input
                  placeholder="e.g. Downtown Store"
                  value={form.locationName}
                  onChange={(e) => setForm((p) => ({ ...p, locationName: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
991
992
993
994
              </div>
            </div>
  
            <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
995
              <Label>Street *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
996
997
998
999
1000
              <Input
                placeholder="e.g. 123 Main St"
                value={form.street ?? ""}
                onChange={(e) => setForm((p) => ({ ...p, street: e.target.value }))}
              />
884054fb   “wangming”   项目初始化
1001
1002
1003
1004
            </div>
  
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1005
                <Label>City *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1006
1007
1008
1009
1010
                <Input
                  placeholder="e.g. New York"
                  value={form.city ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, city: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
1011
1012
              </div>
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1013
                <Label>State *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1014
1015
1016
1017
1018
                <Input
                  placeholder="e.g. NY"
                  value={form.stateCode ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, stateCode: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
1019
1020
1021
1022
1023
              </div>
            </div>
  
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1024
                <Label>Country *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1025
1026
1027
1028
1029
                <Input
                  placeholder="e.g. USA"
                  value={form.country ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, country: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
1030
1031
              </div>
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1032
                <Label>Zip Code *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1033
1034
1035
1036
1037
                <Input
                  placeholder="e.g. 10001"
                  value={form.zipCode ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, zipCode: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
1038
1039
1040
1041
1042
              </div>
            </div>
  
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1043
                <Label>Phone Number *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1044
1045
1046
1047
1048
                <Input
                  placeholder="+1 (555) 000-0000"
                  value={form.phone ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, phone: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
1049
1050
              </div>
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1051
                <Label>Email *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1052
1053
1054
1055
1056
                <Input
                  placeholder="store@example.com"
                  value={form.email ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, email: e.target.value }))}
                />
884054fb   “wangming”   项目初始化
1057
1058
1059
1060
              </div>
            </div>
  
            <div className="space-y-2">
ef6b3255   杨鑫   修改BUG
1061
1062
1063
1064
1065
1066
1067
1068
1069
              <Label>Business hours</Label>
              <Input
                placeholder="e.g. Mon–Fri 9:00 AM – 6:00 PM"
                value={form.operatingHours ?? ""}
                onChange={(e) => setForm((p) => ({ ...p, operatingHours: e.target.value }))}
              />
            </div>
  
            <div className="space-y-2">
884054fb   “wangming”   项目初始化
1070
              <Label className="flex items-center gap-2">
ef6b3255   杨鑫   修改BUG
1071
                <MapPin className="w-4 h-4" /> GPS Coordinates
884054fb   “wangming”   项目初始化
1072
1073
              </Label>
              <div className="grid grid-cols-2 gap-4">
de8956f8   杨鑫   平台端 门店,菜单,角色
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
                <Input
                  placeholder="Latitude (e.g. 40.7128)"
                  value={form.latitude === null || form.latitude === undefined ? "" : String(form.latitude)}
                  onChange={(e) => {
                    const raw = e.target.value.trim();
                    setForm((p) => ({ ...p, latitude: raw ? Number(raw) : null }));
                  }}
                />
                <Input
                  placeholder="Longitude (e.g. -74.0060)"
                  value={form.longitude === null || form.longitude === undefined ? "" : String(form.longitude)}
                  onChange={(e) => {
                    const raw = e.target.value.trim();
                    setForm((p) => ({ ...p, longitude: raw ? Number(raw) : null }));
                  }}
                />
884054fb   “wangming”   项目初始化
1090
1091
1092
1093
              </div>
            </div>
  
             <div className="flex items-center gap-2 pt-2">
de8956f8   杨鑫   平台端 门店,菜单,角色
1094
1095
1096
1097
1098
              <Switch
                id="loc-status"
                checked={!!form.state}
                onCheckedChange={(v) => setForm((p) => ({ ...p, state: v }))}
              />
884054fb   “wangming”   项目初始化
1099
1100
1101
1102
1103
1104
1105
              <Label htmlFor="loc-status">Active Location</Label>
            </div>
  
          </div>
  
          <DialogFooter>
            <Button variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
de8956f8   杨鑫   平台端 门店,菜单,角色
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
            <Button
              disabled={submitting}
              onClick={submit}
              className="bg-blue-600 text-white hover:bg-blue-700"
            >
              {submitting ? "Creating..." : "Create Location"}
            </Button>
          </DialogFooter>
        </DialogContent>
      </Dialog>
    );
  }
  
  function fromDtoToForm(loc: LocationDto): LocationCreateInput {
    return {
      partner: loc.partner ?? "",
      groupName: loc.groupName ?? "",
      locationCode: loc.locationCode ?? "",
      locationName: loc.locationName ?? "",
      street: loc.street ?? "",
      city: loc.city ?? "",
      stateCode: loc.stateCode ?? "",
      country: loc.country ?? "",
      zipCode: loc.zipCode ?? "",
      phone: loc.phone ?? "",
      email: loc.email ?? "",
ef6b3255   杨鑫   修改BUG
1132
      operatingHours: loc.operatingHours ?? "",
de8956f8   杨鑫   平台端 门店,菜单,角色
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
      latitude: loc.latitude ?? null,
      longitude: loc.longitude ?? null,
      state: !!loc.state,
    };
  }
  
  function EditLocationDialog({
    open,
    location,
    onOpenChange,
    onUpdated,
  }: {
    open: boolean;
    location: LocationDto | null;
    onOpenChange: (open: boolean) => void;
    onUpdated: () => void;
  }) {
    const [submitting, setSubmitting] = useState(false);
    const [form, setForm] = useState<LocationCreateInput>({
      partner: "",
      groupName: "",
      locationCode: "",
      locationName: "",
      street: "",
      city: "",
      stateCode: "",
      country: "",
      zipCode: "",
      phone: "",
      email: "",
ef6b3255   杨鑫   修改BUG
1163
      operatingHours: "",
de8956f8   杨鑫   平台端 门店,菜单,角色
1164
1165
1166
1167
      latitude: null,
      longitude: null,
      state: true,
    });
699ea6e8   杨鑫   完善打印逻辑
1168
1169
1170
1171
1172
1173
1174
    const [partnerPickId, setPartnerPickId] = useState(LOCATION_PG_NONE);
    const [groupPickId, setGroupPickId] = useState(LOCATION_PG_NONE);
    const [partnerOptions, setPartnerOptions] = useState<PartnerListItem[]>([]);
    const [groupOptions, setGroupOptions] = useState<GroupListItem[]>([]);
    const [loadingPartners, setLoadingPartners] = useState(false);
    const [loadingGroups, setLoadingGroups] = useState(false);
    const initialPartnerIdRef = useRef<string | typeof LOCATION_PG_NONE | "__user__">(LOCATION_PG_NONE);
de8956f8   杨鑫   平台端 门店,菜单,角色
1175
1176
  
    useEffect(() => {
699ea6e8   杨鑫   完善打印逻辑
1177
      if (!open) {
de8956f8   杨鑫   平台端 门店,菜单,角色
1178
        setSubmitting(false);
699ea6e8   杨鑫   完善打印逻辑
1179
1180
1181
1182
1183
1184
        setPartnerPickId(LOCATION_PG_NONE);
        setGroupPickId(LOCATION_PG_NONE);
        setPartnerOptions([]);
        setGroupOptions([]);
        initialPartnerIdRef.current = LOCATION_PG_NONE;
        return;
de8956f8   杨鑫   平台端 门店,菜单,角色
1185
      }
699ea6e8   杨鑫   完善打印逻辑
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
      if (!location) return;
      setForm(fromDtoToForm(location));
      setSubmitting(false);
      initialPartnerIdRef.current = LOCATION_PG_NONE;
      setPartnerPickId(LOCATION_PG_NONE);
      setGroupPickId(LOCATION_PG_NONE);
  
      const ac = new AbortController();
      setLoadingPartners(true);
      (async () => {
        try {
          const plist = await loadActivePartnerOptions(ac.signal);
          setPartnerOptions(plist);
          const pname = (location.partner ?? "").trim().toLowerCase();
          let pid: string | typeof LOCATION_PG_NONE = LOCATION_PG_NONE;
          if (pname) {
            const hit = plist.find((p) => (p.partnerName ?? "").trim().toLowerCase() === pname);
            if (hit) pid = hit.id;
          }
          initialPartnerIdRef.current = pid;
          setPartnerPickId(pid);
        } catch (e: any) {
          if (e?.name === "AbortError") return;
          toast.error("Failed to load companies.", {
            description: e?.message ? String(e.message) : "Please try again.",
          });
          setPartnerOptions([]);
        } finally {
          setLoadingPartners(false);
        }
      })();
      return () => ac.abort();
    }, [open, location?.id]);
  
    useEffect(() => {
      if (!open || partnerPickId === LOCATION_PG_NONE) {
        setGroupOptions([]);
        setGroupPickId(LOCATION_PG_NONE);
        setLoadingGroups(false);
        return;
      }
      const ac = new AbortController();
      setLoadingGroups(true);
      (async () => {
        try {
          const list = await loadActiveGroupsForPartner(partnerPickId, ac.signal);
          setGroupOptions(list);
          let nextG = LOCATION_PG_NONE;
          const refPid = initialPartnerIdRef.current;
          const canAuto =
            !!location &&
            refPid !== "__user__" &&
            refPid !== LOCATION_PG_NONE &&
            partnerPickId === refPid;
          if (canAuto) {
            const gname = (location!.groupName ?? "").trim().toLowerCase();
            if (gname) {
              const hit = list.find((g) => (g.groupName ?? "").trim().toLowerCase() === gname);
              if (hit) nextG = hit.id;
            }
          }
          setGroupPickId(nextG);
        } catch (e: any) {
          if (e?.name === "AbortError") return;
          toast.error("Failed to load regions.", {
            description: e?.message ? String(e.message) : "Please try again.",
          });
          setGroupOptions([]);
        } finally {
          setLoadingGroups(false);
        }
      })();
      return () => ac.abort();
    }, [open, partnerPickId, location?.groupName, location?.id]);
de8956f8   杨鑫   平台端 门店,菜单,角色
1260
  
de8956f8   杨鑫   平台端 门店,菜单,角色
1261
1262
    const submit = async () => {
      if (!location?.id) return;
3d4c10ac   杨鑫   对接,标签产品
1263
1264
      const errs = getLocationRedBoxValidationErrors(form);
      if (errs.length) {
de8956f8   杨鑫   平台端 门店,菜单,角色
1265
        toast.error("Please fill in required fields.", {
3d4c10ac   杨鑫   对接,标签产品
1266
          description: `Missing: ${errs.join(", ")}.`,
de8956f8   杨鑫   平台端 门店,菜单,角色
1267
1268
1269
1270
        });
        return;
      }
  
699ea6e8   杨鑫   完善打印逻辑
1271
1272
1273
1274
      const p =
        partnerPickId !== LOCATION_PG_NONE ? partnerOptions.find((x) => x.id === partnerPickId) : undefined;
      const g = groupPickId !== LOCATION_PG_NONE ? groupOptions.find((x) => x.id === groupPickId) : undefined;
  
de8956f8   杨鑫   平台端 门店,菜单,角色
1275
1276
1277
1278
1279
1280
      setSubmitting(true);
      try {
        await updateLocation(location.id, {
          ...form,
          locationCode: form.locationCode.trim(),
          locationName: form.locationName.trim(),
699ea6e8   杨鑫   完善打印逻辑
1281
1282
          partner: p?.partnerName?.trim() ? p.partnerName.trim() : null,
          groupName: g?.groupName?.trim() ? g.groupName.trim() : null,
3d4c10ac   杨鑫   对接,标签产品
1283
1284
1285
1286
1287
1288
1289
          street: (form.street ?? "").trim(),
          city: (form.city ?? "").trim(),
          stateCode: (form.stateCode ?? "").trim(),
          country: (form.country ?? "").trim(),
          zipCode: (form.zipCode ?? "").trim(),
          phone: (form.phone ?? "").trim(),
          email: (form.email ?? "").trim(),
ef6b3255   杨鑫   修改BUG
1290
1291
1292
          operatingHours: (form.operatingHours ?? "").trim() || null,
          latitude: form.latitude ?? null,
          longitude: form.longitude ?? null,
de8956f8   杨鑫   平台端 门店,菜单,角色
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
        });
  
        toast.success("Location updated.", {
          description: "The changes have been saved successfully.",
        });
        onOpenChange(false);
        onUpdated();
      } catch (e: any) {
        toast.error("Failed to update location.", {
          description: e?.message ? String(e.message) : "Please try again.",
        });
      } finally {
        setSubmitting(false);
      }
    };
  
    return (
      <Dialog open={open} onOpenChange={onOpenChange}>
        <DialogContent className="sm:max-w-[600px]">
          <DialogHeader>
            <DialogTitle>Edit Location</DialogTitle>
            <DialogDescription>
              Update the details for this store location.
            </DialogDescription>
          </DialogHeader>
  
          <div className="grid gap-4 py-4">
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
699ea6e8   杨鑫   完善打印逻辑
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
                <Label>Company</Label>
                <Select
                  value={partnerPickId}
                  onValueChange={(v) => {
                    initialPartnerIdRef.current = "__user__";
                    setPartnerPickId(v);
                    setGroupPickId(LOCATION_PG_NONE);
                  }}
                  disabled={loadingPartners}
                >
                  <SelectTrigger className="h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500">
                    <SelectValue placeholder={loadingPartners ? "Loading..." : "e.g. Global Foods Inc."} />
                  </SelectTrigger>
                  <SelectContent>
                    <SelectItem value={LOCATION_PG_NONE}>None</SelectItem>
                    {partnerOptions.map((p) => (
                      <SelectItem key={p.id} value={p.id}>
                        {p.partnerName ?? p.id}
                      </SelectItem>
                    ))}
                  </SelectContent>
                </Select>
de8956f8   杨鑫   平台端 门店,菜单,角色
1344
1345
              </div>
              <div className="space-y-2">
699ea6e8   杨鑫   完善打印逻辑
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
                <Label>Region</Label>
                <Select
                  value={groupPickId}
                  onValueChange={setGroupPickId}
                  disabled={loadingGroups || partnerPickId === LOCATION_PG_NONE}
                >
                  <SelectTrigger className="h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500">
                    <SelectValue
                      placeholder={
                        partnerPickId === LOCATION_PG_NONE
                          ? "Select a company first"
                          : loadingGroups
                            ? "Loading..."
                            : "e.g. East Coast Region"
                      }
                    />
                  </SelectTrigger>
                  <SelectContent>
                    <SelectItem value={LOCATION_PG_NONE}>None</SelectItem>
                    {groupOptions.map((g) => (
                      <SelectItem key={g.id} value={g.id}>
                        {g.groupName ?? g.id}
                      </SelectItem>
                    ))}
                  </SelectContent>
                </Select>
de8956f8   杨鑫   平台端 门店,菜单,角色
1372
1373
1374
1375
1376
              </div>
            </div>
  
            <div className="grid grid-cols-3 gap-4">
              <div className="space-y-2 col-span-1">
3d4c10ac   杨鑫   对接,标签产品
1377
                <Label>Location ID *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1378
1379
1380
1381
1382
1383
1384
                <Input
                  placeholder="e.g. 12345"
                  value={form.locationCode}
                  onChange={(e) => setForm((p) => ({ ...p, locationCode: e.target.value }))}
                />
              </div>
              <div className="space-y-2 col-span-2">
3d4c10ac   杨鑫   对接,标签产品
1385
                <Label>Location Name *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1386
1387
1388
1389
1390
1391
1392
1393
1394
                <Input
                  placeholder="e.g. Downtown Store"
                  value={form.locationName}
                  onChange={(e) => setForm((p) => ({ ...p, locationName: e.target.value }))}
                />
              </div>
            </div>
  
            <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1395
              <Label>Street *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1396
1397
1398
1399
1400
1401
1402
1403
1404
              <Input
                placeholder="e.g. 123 Main St"
                value={form.street ?? ""}
                onChange={(e) => setForm((p) => ({ ...p, street: e.target.value }))}
              />
            </div>
  
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1405
                <Label>City *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1406
1407
1408
1409
1410
1411
1412
                <Input
                  placeholder="e.g. New York"
                  value={form.city ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, city: e.target.value }))}
                />
              </div>
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1413
                <Label>State *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
                <Input
                  placeholder="e.g. NY"
                  value={form.stateCode ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, stateCode: e.target.value }))}
                />
              </div>
            </div>
  
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1424
                <Label>Country *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1425
1426
1427
1428
1429
1430
1431
                <Input
                  placeholder="e.g. USA"
                  value={form.country ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, country: e.target.value }))}
                />
              </div>
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1432
                <Label>Zip Code *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
                <Input
                  placeholder="e.g. 10001"
                  value={form.zipCode ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, zipCode: e.target.value }))}
                />
              </div>
            </div>
  
            <div className="grid grid-cols-2 gap-4">
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1443
                <Label>Phone Number *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1444
1445
1446
1447
1448
1449
1450
                <Input
                  placeholder="+1 (555) 000-0000"
                  value={form.phone ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, phone: e.target.value }))}
                />
              </div>
              <div className="space-y-2">
3d4c10ac   杨鑫   对接,标签产品
1451
                <Label>Email *</Label>
de8956f8   杨鑫   平台端 门店,菜单,角色
1452
1453
1454
1455
1456
1457
1458
1459
1460
                <Input
                  placeholder="store@example.com"
                  value={form.email ?? ""}
                  onChange={(e) => setForm((p) => ({ ...p, email: e.target.value }))}
                />
              </div>
            </div>
  
            <div className="space-y-2">
ef6b3255   杨鑫   修改BUG
1461
1462
1463
1464
1465
1466
1467
1468
1469
              <Label>Business hours</Label>
              <Input
                placeholder="e.g. Mon–Fri 9:00 AM – 6:00 PM"
                value={form.operatingHours ?? ""}
                onChange={(e) => setForm((p) => ({ ...p, operatingHours: e.target.value }))}
              />
            </div>
  
            <div className="space-y-2">
de8956f8   杨鑫   平台端 门店,菜单,角色
1470
              <Label className="flex items-center gap-2">
ef6b3255   杨鑫   修改BUG
1471
                <MapPin className="w-4 h-4" /> GPS Coordinates
de8956f8   杨鑫   平台端 门店,菜单,角色
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
              </Label>
              <div className="grid grid-cols-2 gap-4">
                <Input
                  placeholder="Latitude (e.g. 40.7128)"
                  value={form.latitude === null || form.latitude === undefined ? "" : String(form.latitude)}
                  onChange={(e) => {
                    const raw = e.target.value.trim();
                    setForm((p) => ({ ...p, latitude: raw ? Number(raw) : null }));
                  }}
                />
                <Input
                  placeholder="Longitude (e.g. -74.0060)"
                  value={form.longitude === null || form.longitude === undefined ? "" : String(form.longitude)}
                  onChange={(e) => {
                    const raw = e.target.value.trim();
                    setForm((p) => ({ ...p, longitude: raw ? Number(raw) : null }));
                  }}
                />
              </div>
            </div>
  
            <div className="flex items-center gap-2 pt-2">
              <Switch
                id="loc-status-edit"
                checked={!!form.state}
                onCheckedChange={(v) => setForm((p) => ({ ...p, state: v }))}
              />
              <Label htmlFor="loc-status-edit">Active Location</Label>
            </div>
          </div>
  
          <DialogFooter>
            <Button variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
            <Button
              disabled={submitting}
              onClick={submit}
              className="bg-blue-600 text-white hover:bg-blue-700"
            >
              {submitting ? "Saving..." : "Save Changes"}
            </Button>
          </DialogFooter>
        </DialogContent>
      </Dialog>
    );
  }
  
  function DeleteLocationDialog({
    open,
    location,
    onOpenChange,
    onDeleted,
  }: {
    open: boolean;
    location: LocationDto | null;
    onOpenChange: (open: boolean) => void;
    onDeleted: () => void;
  }) {
    const [submitting, setSubmitting] = useState(false);
  
    const name = useMemo(() => {
      const code = (location?.locationCode ?? "").trim();
      const n = (location?.locationName ?? "").trim();
      if (code && n) return `${code} - ${n}`;
      return code || n || "this location";
    }, [location?.locationCode, location?.locationName]);
  
    const submit = async () => {
      if (!location?.id) return;
      setSubmitting(true);
      try {
        await deleteLocation(location.id);
        toast.success("Location deleted.", {
          description: "The location has been removed successfully.",
        });
        onOpenChange(false);
        onDeleted();
      } catch (e: any) {
        toast.error("Failed to delete location.", {
          description: e?.message ? String(e.message) : "Please try again.",
        });
      } finally {
        setSubmitting(false);
      }
    };
  
    return (
      <Dialog open={open} onOpenChange={onOpenChange}>
        <DialogContent className="sm:max-w-none" style={{ width: "30%" }}>
          <DialogHeader>
            <DialogTitle>Delete Location</DialogTitle>
            <DialogDescription>
              This action cannot be undone.
            </DialogDescription>
          </DialogHeader>
  
          <div className="text-sm text-gray-700">
            Are you sure you want to delete <span className="font-medium">{name}</span>?
          </div>
  
          <DialogFooter className="flex-row flex-wrap justify-end">
            <Button className="min-w-24" variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
            <Button
3af4878d   杨鑫   产品 标签 关联
1574
              className="min-w-24 gap-2"
de8956f8   杨鑫   平台端 门店,菜单,角色
1575
1576
1577
1578
              variant="destructive"
              disabled={submitting}
              onClick={submit}
            >
3af4878d   杨鑫   产品 标签 关联
1579
              <Trash2 className="h-4 w-4 shrink-0" />
de8956f8   杨鑫   平台端 门店,菜单,角色
1580
1581
              {submitting ? "Deleting..." : "Delete"}
            </Button>
884054fb   “wangming”   项目初始化
1582
1583
1584
1585
1586
          </DialogFooter>
        </DialogContent>
      </Dialog>
    );
  }