summaryrefslogtreecommitdiff
path: root/lib/owner-companies/owner-company-list.tsx
blob: b78b193b0df60248debf7a29360e508ed52e483d (plain)
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
// app/(admin)/owner-companies/_components/owner-company-list.tsx
"use client";

import { Button } from "@/components/ui/button";
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table";
import Link from "next/link";
import { Building2, Users } from "lucide-react";

interface OwnerCompany {
  id: number;
  name: string;
  createdAt: Date;
}

interface OwnerCompanyListProps {
  companies: OwnerCompany[];
}

export function OwnerCompanyList({ companies }: OwnerCompanyListProps) {
  if (companies.length === 0) {
    return (
      <div className="text-center py-12">
        <Building2 className="mx-auto h-12 w-12 text-muted-foreground" />
        <h3 className="mt-4 text-lg font-semibold">등록된 회사가 없습니다</h3>
        <p className="mt-2 text-sm text-muted-foreground">
          첫 번째 발주처 회사를 등록해보세요.
        </p>
        <Button asChild className="mt-4">
          <Link href="/evcp/data-room/owner-companies/new">회사 등록</Link>
        </Button>
      </div>
    );
  }

  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>회사명</TableHead>
          <TableHead>등록일</TableHead>
          <TableHead className="text-right">작업</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {companies.map((company) => (
          <TableRow key={company.id}>
            <TableCell className="font-medium">
              <div className="flex items-center gap-2">
                <Building2 className="h-4 w-4 text-muted-foreground" />
                {company.name}
              </div>
            </TableCell>
            <TableCell>
              {new Date(company.createdAt).toLocaleDateString("ko-KR", {
                year: "numeric",
                month: "long",
                day: "numeric",
              })}
            </TableCell>
            <TableCell className="text-right">
              <div className="flex gap-2 justify-end">
                <Button variant="outline" size="sm" asChild>
                  <Link href={`/owner-companies/${company.id}`}>수정</Link>
                </Button>
                <Button variant="outline" size="sm" asChild>
                  <Link href={`/evcp/data-room/owner-companies/${company.id}/users`}>
                    <Users className="h-4 w-4 mr-1" />
                    사용자 관리
                  </Link>
                </Button>
              </div>
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}