From b549efc71fd83494074216aca5d99ce91706e04a Mon Sep 17 00:00:00 2001 From: bangdk Date: Wed, 27 Nov 2024 12:40:07 +0900 Subject: [PATCH] auto commit --- .../branches/components/ApiKeyDialog.tsx | 1 + .../branches/components/ApiKeySection.tsx | 46 +- .../branches/components/BranchCard.tsx | 109 + .../branches/components/BranchFormDialog.tsx | 16 +- .../branches/components/BranchTable.tsx | 115 - .../src/app/(admin)/company/branches/page.tsx | 50 +- fems-app/src/types/company.ts | 22 +- fems-mqtt/data/mosquitto.db | Bin 47 -> 47 bytes fems-mqtt/data/passwd | 4 +- fems-mqtt/log/mosquitto.log | 2105 +++++++++++++++++ ...c9b956018e7ebc08dc33061795e3736-audit.json | 5 + ...d3be0bd8551fdd86d0d3cca3a97cd90-audit.json | 5 + .../logs/info/info-2024-11-26.log | 171 -- ...363f7141809635bfe8d8a1642abfc24-audit.json | 5 + .../logs/system/system-2024-11-26.log | 171 -- 15 files changed, 2307 insertions(+), 518 deletions(-) create mode 100644 fems-app/src/app/(admin)/company/branches/components/BranchCard.tsx delete mode 100644 fems-app/src/app/(admin)/company/branches/components/BranchTable.tsx delete mode 100644 fems-realtime-api/logs/info/info-2024-11-26.log delete mode 100644 fems-realtime-api/logs/system/system-2024-11-26.log diff --git a/fems-app/src/app/(admin)/company/branches/components/ApiKeyDialog.tsx b/fems-app/src/app/(admin)/company/branches/components/ApiKeyDialog.tsx index 030b752..fde1f7b 100644 --- a/fems-app/src/app/(admin)/company/branches/components/ApiKeyDialog.tsx +++ b/fems-app/src/app/(admin)/company/branches/components/ApiKeyDialog.tsx @@ -58,6 +58,7 @@ export function ApiKeyDialog({ branch, isOpen, onClose }: ApiKeyDialogProps) { `/api/v1/admin/api-keys/${branch.id}/api-keys`, data ); + console.log("createApiKeyMutation", response.data); return response.data; }, onSuccess: () => { diff --git a/fems-app/src/app/(admin)/company/branches/components/ApiKeySection.tsx b/fems-app/src/app/(admin)/company/branches/components/ApiKeySection.tsx index 8e57e61..fae2a6f 100644 --- a/fems-app/src/app/(admin)/company/branches/components/ApiKeySection.tsx +++ b/fems-app/src/app/(admin)/company/branches/components/ApiKeySection.tsx @@ -2,7 +2,7 @@ import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { useToast } from "@/hooks/use-toast"; -import { Key, Copy } from "lucide-react"; +import { Key, Copy, Power, Trash2 } from "lucide-react"; import type { Branch } from "@/types/company"; import { format } from "date-fns"; import { ko } from "date-fns/locale"; @@ -26,7 +26,7 @@ export function ApiKeySection({ const queryClient = useQueryClient(); // API 키 상태 토글 mutation - const toggleApiKeytatusMutation = useMutation({ + const toggleApiKeyStatusMutation = useMutation({ mutationFn: async ({ apiKeyId, isActive, @@ -64,15 +64,16 @@ export function ApiKeySection({ return (
-
+
+
API 키
- {branch.ApiKey && branch.ApiKey.length > 0 ? ( + {branch.ApiKeys && branch.ApiKeys.length > 0 ? (
- {branch.ApiKey.map((apiKey) => ( + {branch.ApiKeys.map((apiKey) => (
handleCopyApiKey(apiKey.apiKey)} + title="API 키 복사" > - + - + {(user?.role === "super_admin" || + user?.role === "company_admin") && ( + + )}
))} diff --git a/fems-app/src/app/(admin)/company/branches/components/BranchCard.tsx b/fems-app/src/app/(admin)/company/branches/components/BranchCard.tsx new file mode 100644 index 0000000..5a24d61 --- /dev/null +++ b/fems-app/src/app/(admin)/company/branches/components/BranchCard.tsx @@ -0,0 +1,109 @@ +// src/app/(admin)/company/branches/components/BranchCard.tsx +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import type { Branch, BranchCardProps } from "@/types/company"; +import { useAuthStore } from "@/stores/auth"; +import { useState } from "react"; +import { ApiKeySection } from "./ApiKeySection"; +import { ApiKeyDialog } from "./ApiKeyDialog"; +import { DeleteApiKeyDialog } from "./DeleteApiKeyDialog"; +import { Edit, Trash2 } from "lucide-react"; + +export function BranchCard({ branches, onEdit, onDelete }: BranchCardProps) { + const { user } = useAuthStore(); + const [selectedBranch, setSelectedBranch] = useState(null); + const [isApiKeyDialogOpen, setIsApiKeyDialogOpen] = useState(false); + const [deleteApiKeyInfo, setDeleteApiKeyInfo] = useState<{ + id: string; + name: string; + branchId: string; + } | null>(null); + + return ( + <> +
+ {branches.map((branch) => ( + + +
+
+ {branch.name} + + {branch.isActive ? "활성" : "비활성"} + +
+
+ + {(user?.role === "super_admin" || + user?.role === "company_admin") && ( + + )} +
+
+
+ +
+
+
주소
+
{branch.address}
+
+
+
연락처
+
{branch.tel}
+
+
+ { + setSelectedBranch(branch); + setIsApiKeyDialogOpen(true); + }} + onDeleteClick={(apiKeyId, keyName) => { + setDeleteApiKeyInfo({ + id: apiKeyId, + name: keyName, + branchId: branch.id, + }); + }} + /> +
+
+
+
+ ))} +
+ + {selectedBranch && ( + { + setIsApiKeyDialogOpen(false); + setSelectedBranch(null); + }} + /> + )} + + setDeleteApiKeyInfo(null)} + /> + + ); +} diff --git a/fems-app/src/app/(admin)/company/branches/components/BranchFormDialog.tsx b/fems-app/src/app/(admin)/company/branches/components/BranchFormDialog.tsx index f7db863..6239579 100644 --- a/fems-app/src/app/(admin)/company/branches/components/BranchFormDialog.tsx +++ b/fems-app/src/app/(admin)/company/branches/components/BranchFormDialog.tsx @@ -14,21 +14,7 @@ import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Switch } from "@/components/ui/switch"; -import type { Branch } from "@/types/company"; - -interface BranchFormDialogProps { - mode: "add" | "edit" | null; - branch: Branch | null; - isOpen: boolean; - onClose: () => void; -} - -interface BranchFormData { - name: string; - address: string; - tel: string; - isActive: boolean; -} +import type { BranchFormData, BranchFormDialogProps } from "@/types/company"; export function BranchFormDialog({ mode, diff --git a/fems-app/src/app/(admin)/company/branches/components/BranchTable.tsx b/fems-app/src/app/(admin)/company/branches/components/BranchTable.tsx deleted file mode 100644 index 8fcdb13..0000000 --- a/fems-app/src/app/(admin)/company/branches/components/BranchTable.tsx +++ /dev/null @@ -1,115 +0,0 @@ -// src/app/(admin)/company/branches/components/BranchTable.tsx -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Button } from "@/components/ui/button"; -import { Badge } from "@/components/ui/badge"; -import type { Branch } from "@/types/company"; -import { ApiKeySection } from "./ApiKeySection"; -import { useAuthStore } from "@/stores/auth"; -import { useState } from "react"; -import { ApiKeyDialog } from "./ApiKeyDialog"; -import { DeleteApiKeyDialog } from "./DeleteApiKeyDialog"; - -interface BranchTableProps { - branches: Branch[]; - onEdit: (branch: Branch) => void; - onDelete: (branchId: string) => void; -} - -export function BranchTable({ branches, onEdit, onDelete }: BranchTableProps) { - const { user } = useAuthStore(); - const [selectedBranch, setSelectedBranch] = useState(null); - const [isApiKeyDialogOpen, setIsApiKeyDialogOpen] = useState(false); - const [deleteApiKeyInfo, setDeleteApiKeyInfo] = useState<{ - id: string; - name: string; - branchId: string; - } | null>(null); - - return ( - <> - - - - 지점명 - 주소 - 연락처 - 상태 - API 키 - 관리 - - - - {branches.map((branch) => ( - - {branch.name} - {branch.address} - {branch.tel} - - - {branch.isActive ? "활성" : "비활성"} - - - - { - setSelectedBranch(branch); - setIsApiKeyDialogOpen(true); - }} - onDeleteClick={(apiKeyId, keyName) => { - setDeleteApiKeyInfo({ - id: apiKeyId, - name: keyName, - branchId: branch.id, - }); - }} - /> - - - - {user?.role === "super_admin" && ( - - )} - - - ))} - -
- - {selectedBranch && ( - { - setIsApiKeyDialogOpen(false); - setSelectedBranch(null); - }} - /> - )} - - setDeleteApiKeyInfo(null)} - /> - - ); -} diff --git a/fems-app/src/app/(admin)/company/branches/page.tsx b/fems-app/src/app/(admin)/company/branches/page.tsx index b6de11e..73abcd6 100644 --- a/fems-app/src/app/(admin)/company/branches/page.tsx +++ b/fems-app/src/app/(admin)/company/branches/page.tsx @@ -4,13 +4,14 @@ import { useQuery } from "@tanstack/react-query"; import { useAuthStore } from "@/stores/auth"; import { api } from "@/lib/api"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +// import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { useState } from "react"; -import { BranchTable } from "./components/BranchTable"; +import { BranchCard } from "./components/BranchCard"; import { BranchFormDialog } from "./components/BranchFormDialog"; import { DeleteBranchDialog } from "./components/DeleteBranchDialog"; import type { Company, Branch } from "@/types/company"; +import { Plus } from "lucide-react"; export default function CompanyBranchesPage() { const { token, user } = useAuthStore(); @@ -30,7 +31,7 @@ export default function CompanyBranchesPage() { const { data } = await api.get( `/api/v1/admin/companies/${user?.companyId}?include=branches.apiKey` ); - console.log(data); + // console.log("branches.apiKey", data); return data; }, enabled: !!token && !!user?.companyId, @@ -57,30 +58,25 @@ export default function CompanyBranchesPage() { if (!company) return
회사 정보를 찾을 수 없습니다.
; return ( -
- - -
- 지점 목록 - -
-
- - - -
+
+
+

지점/공장 목록

+ +
+ {/* Dialogs */} void; +} + +export interface BranchCardProps { + branches: Branch[]; + onEdit: (branch: Branch) => void; + onDelete: (branchId: string) => void; +} diff --git a/fems-mqtt/data/mosquitto.db b/fems-mqtt/data/mosquitto.db index 568efefcc1f5eaeae138a611cbc9f7ad174778a3..bf895f880a7265ced4a72f0ed22f81e21851f354 100644 GIT binary patch delta 21 UcmdPbpCB)wxsaIw3^*VZ03quE^8f$< delta 21 WcmdPbpCB)w_lAi91Q