"use client"

import { type Table } from "@tanstack/react-table"
import { Download, RotateCcw, Shield } from "lucide-react"

import { Button } from "@/components/ui/button"
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"

import { ExtendedLoginSession } from "../validation"
import { exportTableToExcel } from "@/lib/export_all"

interface LoginSessionsTableToolbarActionsProps {
  table: Table<ExtendedLoginSession>
}

export function LoginSessionsTableToolbarActions({
  table,
}: LoginSessionsTableToolbarActionsProps) {
  return (
    <div className="flex items-center gap-2">
      <Tooltip>
        <TooltipTrigger asChild>
          <Button
            variant="outline"
            size="sm"
            onClick={() =>
              exportTableToExcel(table, {
                filename: "login-sessions",
                excludeColumns: ["select", "actions"],
              })
            }
          >
            <Download className="mr-2 size-4" aria-hidden="true" />
            Export
          </Button>
        </TooltipTrigger>
        <TooltipContent>
          <p>로그인 세션 데이터를 엑셀로 내보내기</p>
        </TooltipContent>
      </Tooltip>

      <Tooltip>
        <TooltipTrigger asChild>
          <Button
            variant="outline"
            size="sm"
            onClick={() => window.location.reload()}
          >
            <RotateCcw className="mr-2 size-4" aria-hidden="true" />
            새로고침
          </Button>
        </TooltipTrigger>
        <TooltipContent>
          <p>데이터 새로고침</p>
        </TooltipContent>
      </Tooltip>

      <Tooltip>
        <TooltipTrigger asChild>
          <Button
            variant="outline"
            size="sm"
            onClick={() => {
              // 보안 리포트 생성 기능
              console.log("Generate security report")
            }}
          >
            <Shield className="mr-2 size-4" aria-hidden="true" />
            보안 리포트
          </Button>
        </TooltipTrigger>
        <TooltipContent>
          <p>보안 분석 리포트 생성</p>
        </TooltipContent>
      </Tooltip>
    </div>
  )
}