260617_01_ENH: 배정 테스트를 위해 개발 중도 커밋
This commit is contained in:
66
src/components/common/DatePicker.tsx
Normal file
66
src/components/common/DatePicker.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
"use client";
|
||||
|
||||
import {format} from "date-fns";
|
||||
import {CalendarIcon, X} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Calendar} from "@/components/ui/calendar";
|
||||
import {Popover, PopoverContent, PopoverTrigger} from "@/components/ui/popover";
|
||||
import {cn} from "@/lib/utils";
|
||||
|
||||
const parseDate = (value: string) => {
|
||||
if (!value) return undefined;
|
||||
const [year, month, day] = value.split("-").map(Number);
|
||||
if (!year || !month || !day) return undefined;
|
||||
return new Date(year, month - 1, day);
|
||||
};
|
||||
|
||||
export function DatePicker({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = "날짜 선택",
|
||||
className,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
const selected = parseDate(value);
|
||||
|
||||
return (
|
||||
<div className={cn("relative", className)}>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className={cn("h-9 w-full justify-start bg-white pr-8 text-left font-normal", !value && "text-muted-foreground")}
|
||||
>
|
||||
<CalendarIcon className="h-4 w-4" />
|
||||
{selected ? format(selected, "yyyy-MM-dd") : placeholder}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0" align="start">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={selected}
|
||||
onSelect={(date) => onChange(date ? format(date, "yyyy-MM-dd") : "")}
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
{value && (
|
||||
<button
|
||||
type="button"
|
||||
className="absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onChange("");
|
||||
}}
|
||||
aria-label="날짜 초기화"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export function LoadingOverlay({ force = false }: { force?: boolean }) {
|
||||
if (!force && !isLoading) return null;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-[9999] bg-black-600/70 flex items-center justify-center">
|
||||
<div className="fixed inset-0 z-[9999] bg-black/60 flex items-center justify-center">
|
||||
{/* 심플 로딩 인디케이터 */}
|
||||
<div className="h-12 w-12 rounded-full border-4 border-gray-400 border-t-white animate-spin" />
|
||||
</div>
|
||||
|
||||
@@ -47,6 +47,7 @@ export function DataTable<TData>({
|
||||
onRowSelectionChange,
|
||||
defaultPageSize = 10,
|
||||
pageSizeOptions = [5, 10, 25, 50],
|
||||
showPagination = true,
|
||||
paginationItemsToDisplay = 5
|
||||
}: Readonly<DataTableProps<TData>>) {
|
||||
// Pagination state
|
||||
@@ -240,7 +241,7 @@ export function DataTable<TData>({
|
||||
onClick={drag.wrapClick(() => handleRowClick(row))}
|
||||
className={cn(
|
||||
'content-text-base',
|
||||
'[&>td]:py-0 [&>td]:px-2',
|
||||
'[&>td]:py-3 [&>td]:px-3',
|
||||
selectMode !== 'none' && 'cursor-pointer',
|
||||
'data-[state=selected]:bg-slate-100 data-[state=selected]:font-semibold',
|
||||
shouldHighlight && 'bg-emerald-50',
|
||||
@@ -264,6 +265,7 @@ export function DataTable<TData>({
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
{showPagination && (
|
||||
<div className='flex items-center justify-between gap-3 max-sm:flex-col p-2 pt-0'>
|
||||
<p className='text-muted-foreground flex-1 text-sm whitespace-nowrap' aria-live='polite'>
|
||||
Page <span className='text-foreground'>{table.getState().pagination.pageIndex + 1}</span> of{' '}
|
||||
@@ -380,6 +382,7 @@ export function DataTable<TData>({
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,41 @@
|
||||
import { ColumnDef, PaginationState, SortingState } from '@tanstack/react-table'
|
||||
import {ColumnDef, PaginationState, SortingState} from "@tanstack/react-table";
|
||||
|
||||
export type SelectMode = 'none' | 'click-event' | 'single' | 'multi'
|
||||
export type SelectMode = "none" | "click-event" | "single" | "multi";
|
||||
|
||||
export type DataTableColumn<TData, TValue = unknown> = ColumnDef<TData, TValue> & {
|
||||
enableSorting?: boolean // 정렬 가능 여부 (기본값: false)
|
||||
}
|
||||
enableSorting?: boolean;
|
||||
};
|
||||
|
||||
export interface ServerPaginationParams {
|
||||
pageIndex: number
|
||||
pageSize: number
|
||||
sorting?: SortingState
|
||||
pageIndex: number;
|
||||
pageSize: number;
|
||||
sorting?: SortingState;
|
||||
}
|
||||
|
||||
export interface ServerPaginationResponse<TData> {
|
||||
data: TData[]
|
||||
totalCount: number
|
||||
pageCount: number
|
||||
data: TData[];
|
||||
totalCount: number;
|
||||
pageCount: number;
|
||||
}
|
||||
|
||||
export interface DataTableProps<TData> {
|
||||
// 필수 props
|
||||
columns: DataTableColumn<TData, any>[]
|
||||
data: TData[]
|
||||
getRowId?: (row: TData, index: number) => string //id 지정
|
||||
highlightRowIds?: string[]
|
||||
// 페이지네이션 모드
|
||||
isClient?: boolean // true: 클라이언트, false: 서버 (기본값: true)
|
||||
columns: DataTableColumn<TData, any>[];
|
||||
data: TData[];
|
||||
getRowId?: (row: TData, index: number) => string;
|
||||
highlightRowIds?: string[];
|
||||
|
||||
// 서버 페이지네이션 (isClient=false일 때 필요)
|
||||
pageCount?: number
|
||||
totalCount?: number
|
||||
onPaginationChange?: (pagination: PaginationState) => void
|
||||
onSortingChange?: (sorting: SortingState) => void
|
||||
isClient?: boolean;
|
||||
pageCount?: number;
|
||||
totalCount?: number;
|
||||
onPaginationChange?: (pagination: PaginationState) => void;
|
||||
onSortingChange?: (sorting: SortingState) => void;
|
||||
|
||||
// 선택 모드
|
||||
selectMode?: SelectMode // 'none' | 'click-event' | 'single' | 'multi' (기본값: 'none')
|
||||
onRowClick?: (selectedRows: TData) => void
|
||||
onRowSelectionChange?: (selectedRows: TData[]) => void
|
||||
selectMode?: SelectMode;
|
||||
onRowClick?: (selectedRows: TData) => void;
|
||||
onRowSelectionChange?: (selectedRows: TData[]) => void;
|
||||
|
||||
// 페이지네이션 설정
|
||||
defaultPageSize?: number
|
||||
pageSizeOptions?: number[]
|
||||
|
||||
// 기타 설정
|
||||
paginationItemsToDisplay?: number
|
||||
}
|
||||
defaultPageSize?: number;
|
||||
pageSizeOptions?: number[];
|
||||
showPagination?: boolean;
|
||||
paginationItemsToDisplay?: number;
|
||||
}
|
||||
|
||||
218
src/components/dialog/AssignMonitoringDialog.tsx
Normal file
218
src/components/dialog/AssignMonitoringDialog.tsx
Normal file
@@ -0,0 +1,218 @@
|
||||
"use client";
|
||||
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {Send} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Checkbox} from "@/components/ui/checkbox";
|
||||
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||
import {DataTable} from "@/components/data-table/DataTable";
|
||||
import {DataTableColumn} from "@/components/data-table/DataTable.type";
|
||||
import {StatusPill} from "@/components/gwcf/StatusPill";
|
||||
import {Code, MonitoringApplyUser, PerformanceFull} from "@/types/gwcf";
|
||||
import {CodeGroup} from "@/query/code";
|
||||
import {getCodeLabel, getDetailValue} from "@/lib/gwcf/view";
|
||||
import {getAssignStatusDisplay, MONITORING_ASSIGN_TYPE} from "@/lib/gwcf/performance-status";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
|
||||
export function AssignMonitoringDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
selected,
|
||||
codes,
|
||||
applyUsers,
|
||||
isSavingAssign,
|
||||
onSaveAssign,
|
||||
onOpenSms,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
selected: PerformanceFull | null;
|
||||
codes: CodeMap;
|
||||
applyUsers: MonitoringApplyUser[];
|
||||
isSavingAssign?: boolean;
|
||||
onSaveAssign: (performanceId: number, userIds: string[]) => void;
|
||||
onOpenSms: (userIds: string[]) => void;
|
||||
}>) {
|
||||
const monitoringAssigns = useMemo(
|
||||
() => (selected?.performanceAssignList ?? []).filter((item) => item.assignType === MONITORING_ASSIGN_TYPE),
|
||||
[selected]
|
||||
);
|
||||
const [checkedIds, setCheckedIds] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
setCheckedIds([]);
|
||||
return;
|
||||
}
|
||||
|
||||
setCheckedIds(monitoringAssigns.map((item) => item.assignUser));
|
||||
}, [monitoringAssigns, open, selected?.id]);
|
||||
|
||||
const confirmRequestCount = monitoringAssigns.length;
|
||||
const confirmedCount = monitoringAssigns.filter((item) => item.assignConfirm).length;
|
||||
const smsTargetIds = checkedIds.filter(
|
||||
(userId) => !monitoringAssigns.some((assign) => assign.assignUser === userId && assign.assignConfirm)
|
||||
);
|
||||
|
||||
const updateChecked = (applyUser: MonitoringApplyUser, checked: boolean) => {
|
||||
if (!selected || isSavingAssign) return;
|
||||
|
||||
const currentAssign = monitoringAssigns.find((assign) => assign.assignUser === applyUser.userId);
|
||||
|
||||
if (checked) {
|
||||
if (!checkedIds.includes(applyUser.userId) && checkedIds.length >= 2) {
|
||||
alert("모니터링 배정은 최대 2명까지 선택할 수 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
const next = Array.from(new Set([...checkedIds, applyUser.userId]));
|
||||
setCheckedIds(next);
|
||||
onSaveAssign(selected.id, next);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAssign?.assignConfirm) {
|
||||
if (!confirm("이미 승인된 상태입니다. 정말로 취소 하시 겠습니까?")) return;
|
||||
} else if (currentAssign) {
|
||||
if (!confirm("이미 문자 발송된 상태입니다. 정말로 취소 하시 겠습니까?")) return;
|
||||
}
|
||||
|
||||
const next = checkedIds.filter((userId) => userId !== applyUser.userId);
|
||||
setCheckedIds(next);
|
||||
onSaveAssign(selected.id, next);
|
||||
};
|
||||
|
||||
const toggleApplyUser = (applyUser: MonitoringApplyUser) => {
|
||||
updateChecked(applyUser, !checkedIds.includes(applyUser.userId));
|
||||
};
|
||||
|
||||
const columns = useMemo<DataTableColumn<MonitoringApplyUser>[]>(() => [
|
||||
{
|
||||
id: "select",
|
||||
header: "선택",
|
||||
cell: ({row}) => {
|
||||
const applyUser = row.original;
|
||||
const checked = checkedIds.includes(applyUser.userId);
|
||||
const disabled = (!checked && checkedIds.length >= 2) || isSavingAssign;
|
||||
|
||||
return (
|
||||
<Checkbox
|
||||
checked={checked}
|
||||
tabIndex={-1}
|
||||
aria-label="배정 선택 상태"
|
||||
aria-disabled={disabled}
|
||||
className={disabled ? "pointer-events-none opacity-50" : "pointer-events-none"}
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "user",
|
||||
header: "신청자",
|
||||
cell: ({row}) => (
|
||||
<div>
|
||||
<div className="font-semibold">{row.original.user?.userName || row.original.userId}</div>
|
||||
<div className="text-xs text-muted-foreground">{row.original.userId}</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "area",
|
||||
header: "지역",
|
||||
cell: ({row}) =>
|
||||
getCodeLabel(codes, "area", getDetailValue(row.original.user?.userDetail, ["area", "userArea", "region"])) || "-",
|
||||
},
|
||||
{
|
||||
id: "tel",
|
||||
header: "연락처",
|
||||
cell: ({row}) => getDetailValue(row.original.user?.userDetail, ["tel", "phone", "userTel"], "-"),
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
header: "상태",
|
||||
cell: ({row}) => {
|
||||
const assigned = monitoringAssigns.find((item) => item.assignUser === row.original.userId);
|
||||
if (!assigned) return null;
|
||||
|
||||
const display = getAssignStatusDisplay(assigned.assignConfirm);
|
||||
return <StatusPill variant={display.variant}>{display.label}</StatusPill>;
|
||||
},
|
||||
},
|
||||
], [checkedIds, codes, isSavingAssign, monitoringAssigns]);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-h-[90vh] overflow-y-auto sm:max-w-5xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>모니터링 요원 배정</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-[1fr_1.2fr]">
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 font-semibold">공연 기본 정보</div>
|
||||
<table className="w-full border-collapse text-sm">
|
||||
<tbody>
|
||||
{[
|
||||
["연번", selected?.id],
|
||||
["사업유형", getCodeLabel(codes, "business_type", selected?.businessType)],
|
||||
["분야(장르)", getCodeLabel(codes, "genre", selected?.performanceGenre)],
|
||||
["지역", getCodeLabel(codes, "area", selected?.performanceArea)],
|
||||
["단체(팀)명", selected?.artistName],
|
||||
["사업명", selected?.performanceName],
|
||||
["사업 일정", selected?.performanceDtInfo],
|
||||
["운영 시간", selected?.performanceTimeInfo],
|
||||
["모니터링 일정", selected?.performanceMonitoringSchedule?.monitoringDate],
|
||||
["모니터링 시간", selected?.performanceMonitoringSchedule?.monitoringTimeInfo],
|
||||
["방문 장소", selected?.performanceMonitoringSchedule?.monitoringAddress],
|
||||
["예매 예약", getCodeLabel(codes, "ticket_reservation_status", selected?.ticketReservationStatus)],
|
||||
["예매 비고", selected?.ticketReservationMemo],
|
||||
].map(([label, value]) => (
|
||||
<tr key={String(label)}>
|
||||
<th className="w-32 border bg-muted p-2 text-left">{label}</th>
|
||||
<td className="border p-2">{value || "-"}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section className="space-y-3 rounded-md border p-3">
|
||||
<div className="grid grid-cols-3 rounded-md border text-center text-sm">
|
||||
<div className="p-2">
|
||||
<div className="text-muted-foreground">신청자</div>
|
||||
<div className="font-semibold">{applyUsers.length}</div>
|
||||
</div>
|
||||
<div className="border-x p-2">
|
||||
<div className="text-muted-foreground">확정요청</div>
|
||||
<div className="font-semibold">{confirmRequestCount}</div>
|
||||
</div>
|
||||
<div className="p-2">
|
||||
<div className="text-muted-foreground">확정</div>
|
||||
<div className="font-semibold">{confirmedCount}</div>
|
||||
</div>
|
||||
</div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={applyUsers}
|
||||
getRowId={(row) => row.userId}
|
||||
defaultPageSize={applyUsers.length || 10}
|
||||
pageSizeOptions={[applyUsers.length || 10]}
|
||||
showPagination={false}
|
||||
selectMode="click-event"
|
||||
onRowClick={toggleApplyUser}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" disabled={smsTargetIds.length === 0} onClick={() => onOpenSms(smsTargetIds)}>
|
||||
<Send className="h-4 w-4" />
|
||||
확정 문자 발송
|
||||
</Button>
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>닫기</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
102
src/components/dialog/ExcelRegisterDialog.tsx
Normal file
102
src/components/dialog/ExcelRegisterDialog.tsx
Normal file
@@ -0,0 +1,102 @@
|
||||
"use client";
|
||||
|
||||
import {useEffect, useState} from "react";
|
||||
import {Download, FileUp} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import {ExcelUploadResult} from "@/types/common";
|
||||
import {downloadBase64File} from "@/lib/utils";
|
||||
|
||||
export function ExcelRegisterDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
onDownloadTemplate,
|
||||
onUpload,
|
||||
isUploading,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title: string;
|
||||
onDownloadTemplate: () => void;
|
||||
onUpload: (file: File) => Promise<ExcelUploadResult>;
|
||||
isUploading?: boolean;
|
||||
}>) {
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [uploadResult, setUploadResult] = useState<ExcelUploadResult | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
setFile(null);
|
||||
setUploadResult(null);
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const upload = async () => {
|
||||
if (!file) return;
|
||||
const result = await onUpload(file);
|
||||
setUploadResult(result);
|
||||
};
|
||||
|
||||
const downloadErrorFile = () => {
|
||||
if (!uploadResult?.errorFileBase64) return;
|
||||
downloadBase64File(uploadResult.errorFileBase64, uploadResult.errorFileName || "excel_upload_error.xlsx");
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-3">
|
||||
<Button type="button" variant="outline" className="w-full" onClick={onDownloadTemplate}>
|
||||
<Download className="h-4 w-4" />
|
||||
양식 다운로드
|
||||
</Button>
|
||||
<label className="flex h-11 cursor-pointer items-center justify-center gap-2 rounded-md border bg-muted text-sm font-medium">
|
||||
<FileUp className="h-4 w-4" />
|
||||
{file ? file.name : "파일 업로드"}
|
||||
<input
|
||||
type="file"
|
||||
accept=".xlsx,.xls"
|
||||
className="hidden"
|
||||
onChange={(event) => {
|
||||
setFile(event.target.files?.[0] ?? null);
|
||||
setUploadResult(null);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
{uploadResult && (
|
||||
<div className="rounded-md border bg-muted/40 p-3 text-sm">
|
||||
<div>전체: {uploadResult.totalCount}</div>
|
||||
<div>성공: {uploadResult.successCount}</div>
|
||||
<div>실패: {uploadResult.failCount}</div>
|
||||
{uploadResult.hasErrorFile && (
|
||||
<Button type="button" variant="outline" size="sm" className="mt-2 w-full" onClick={downloadErrorFile}>
|
||||
<Download className="h-4 w-4" />
|
||||
오류 파일 다운로드
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!file || isUploading}
|
||||
onClick={upload}
|
||||
>
|
||||
등록
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
81
src/components/dialog/MonitoringVisitDialog.tsx
Normal file
81
src/components/dialog/MonitoringVisitDialog.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
"use client";
|
||||
|
||||
import {ReactNode, useEffect, useMemo, useState} from "react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import {PerformanceCompact} from "@/types/gwcf";
|
||||
|
||||
function DetailRow({label, children}: {label: string; children: ReactNode}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[130px_1fr] border-b last:border-b-0">
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">{label}</div>
|
||||
<div className="min-h-9 px-3 py-2 text-sm">{children || "-"}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function MonitoringVisitDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
performance,
|
||||
mode,
|
||||
onSubmit,
|
||||
isSubmitting,
|
||||
}: {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
performance: PerformanceCompact | null;
|
||||
mode: "departure" | "arrival";
|
||||
onSubmit?: (files?: File[]) => void | Promise<void>;
|
||||
isSubmitting?: boolean;
|
||||
}) {
|
||||
const nowText = useMemo(() => new Date().toLocaleString("ko-KR"), [open]);
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) setFiles([]);
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>모니터링 {mode === "departure" ? "출발" : "도착"}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="rounded-md border">
|
||||
<DetailRow label="현재 시간">{nowText}</DetailRow>
|
||||
<DetailRow label="모니터링 일정">
|
||||
{performance?.performanceMonitoringSchedule?.monitoringDate} {performance?.performanceMonitoringSchedule?.monitoringTimeInfo}
|
||||
</DetailRow>
|
||||
<DetailRow label="사업명">{performance?.performanceName}</DetailRow>
|
||||
<DetailRow label="장소">{performance?.performanceMonitoringSchedule?.monitoringAddress}</DetailRow>
|
||||
{mode === "arrival" && (
|
||||
<DetailRow label="증빙사진">
|
||||
<label className="flex min-h-11 cursor-pointer items-center justify-center rounded-md border bg-muted px-3 py-2 text-sm font-medium">
|
||||
{files.length > 0 ? `${files.length}개 파일 선택됨` : "증빙 사진 선택"}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
className="hidden"
|
||||
onChange={(event) => setFiles(Array.from(event.target.files ?? []))}
|
||||
/>
|
||||
</label>
|
||||
</DetailRow>
|
||||
)}
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button type="button" disabled={!performance || isSubmitting} onClick={() => onSubmit?.(files)}>
|
||||
{mode === "departure" ? "출발 저장" : "도착 저장"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
471
src/components/dialog/PerformanceDetailDialog.tsx
Normal file
471
src/components/dialog/PerformanceDetailDialog.tsx
Normal file
@@ -0,0 +1,471 @@
|
||||
"use client";
|
||||
|
||||
import {ReactNode, useEffect, useMemo, useState} from "react";
|
||||
import {Download, ImageIcon, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||
import {DatePicker} from "@/components/common/DatePicker";
|
||||
import {FilterSelect} from "@/components/gwcf/FilterSelect";
|
||||
import {StatusPill} from "@/components/gwcf/StatusPill";
|
||||
import {Code, PerformanceCompact, PerformanceFull, PerformanceMonitoringSchedule, PerformanceStaff, UserFull} from "@/types/gwcf";
|
||||
import {CodeGroup} from "@/query/code";
|
||||
import {getCodeLabel, getDetailValue, ROLE} from "@/lib/gwcf/view";
|
||||
import {
|
||||
getMonitoringRecordedAt,
|
||||
getMonitoringRecordedUser,
|
||||
getMonitoringSlots,
|
||||
getMonitoringStatusDisplay,
|
||||
getReviewStatusDisplay,
|
||||
getWrittenReviewRows,
|
||||
isReviewComplete,
|
||||
LOCAL_GOVERNMENT_REVIEW_TYPE,
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {buildWrittenReviewLink} from "@/config/gwcf.config";
|
||||
import {
|
||||
useDownloadReviewOriginalMutation,
|
||||
useDownloadReviewPdfMutation,
|
||||
useEndWrittenReviewMutation,
|
||||
useReviewFileQuery,
|
||||
useStartWrittenReviewMutation,
|
||||
useUploadReviewFileMutation,
|
||||
} from "@/query/review";
|
||||
import {useDownloadEvidenceZipMutation} from "@/query/monitoring";
|
||||
import {downloadFile} from "@/lib/utils";
|
||||
import {useUsersQuery} from "@/query/user";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
|
||||
function DetailRow({label, children}: {label: string; children: ReactNode}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[130px_1fr] border-b last:border-b-0">
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">{label}</div>
|
||||
<div className="min-h-9 px-3 py-2 text-sm">{children || "-"}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function FileActionButton({
|
||||
children,
|
||||
icon = "download",
|
||||
disabled = false,
|
||||
onClick,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
icon?: "download" | "upload" | "image";
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
}) {
|
||||
const Icon = icon === "upload" ? Upload : icon === "image" ? ImageIcon : Download;
|
||||
return (
|
||||
<Button type="button" size="xs" variant="outline" disabled={disabled} onClick={onClick}>
|
||||
<Icon className="h-3 w-3" />
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
function AssignedUserInfo({
|
||||
userId,
|
||||
user,
|
||||
codes,
|
||||
type,
|
||||
}: {
|
||||
userId?: string;
|
||||
user?: UserFull;
|
||||
codes: CodeMap;
|
||||
type: "monitoring" | "written";
|
||||
}) {
|
||||
const detail = user?.userDetail;
|
||||
const tel = getDetailValue(detail, ["tel", "phone", "userTel"], "-");
|
||||
const email = getDetailValue(detail, ["email", "userEmail"], "-");
|
||||
const metaValue = type === "monitoring"
|
||||
? getCodeLabel(codes, "area", getDetailValue(detail, ["area", "userArea", "region"]))
|
||||
: getCodeLabel(codes, "genre", getDetailValue(detail, ["userGenre", "genre", "reviewGenre"]));
|
||||
const metaLabel = type === "monitoring" ? "지역" : "장르";
|
||||
const hasCar = getCodeLabel(codes, "has_car", getDetailValue(detail, ["userHasCar", "has_car", "hasCar"])) || "-";
|
||||
|
||||
return (
|
||||
<div className="rounded-md border bg-muted/30 p-2 text-sm">
|
||||
<div className="grid gap-1 text-xs text-muted-foreground sm:grid-cols-2">
|
||||
<span>ID: {userId || "-"}</span>
|
||||
<span>{metaLabel}: {metaValue || "-"}</span>
|
||||
<span>연락처: {tel}</span>
|
||||
<span>이메일: {email}</span>
|
||||
{type === "monitoring" && <span>자차유무: {hasCar}</span>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const downloadBlob = (buffer: ArrayBuffer, fileName: string, type = "application/octet-stream") => {
|
||||
const blob = new Blob([buffer], {type});
|
||||
downloadFile(blob, fileName);
|
||||
};
|
||||
|
||||
function ReviewFileActions({
|
||||
performanceId,
|
||||
reviewType,
|
||||
uploadFileName,
|
||||
pdfFileName,
|
||||
}: {
|
||||
performanceId: number;
|
||||
reviewType: number;
|
||||
uploadFileName?: string;
|
||||
pdfFileName?: string;
|
||||
}) {
|
||||
const uploadMutation = useUploadReviewFileMutation();
|
||||
const originalMutation = useDownloadReviewOriginalMutation();
|
||||
const pdfMutation = useDownloadReviewPdfMutation();
|
||||
|
||||
const upload = (file?: File) => {
|
||||
if (!file) return;
|
||||
uploadMutation.mutate({performanceId, reviewType, file});
|
||||
};
|
||||
|
||||
const downloadOriginal = async () => {
|
||||
const buffer = await originalMutation.mutateAsync({performanceId, reviewType});
|
||||
downloadBlob(buffer, uploadFileName || `review-original-${performanceId}-${reviewType}`);
|
||||
};
|
||||
|
||||
const downloadPdf = async () => {
|
||||
const buffer = await pdfMutation.mutateAsync({performanceId, reviewType});
|
||||
downloadBlob(buffer, pdfFileName || `review-pdf-${performanceId}-${reviewType}.pdf`, "application/pdf");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-1">
|
||||
<label>
|
||||
<input type="file" className="hidden" onChange={(event) => upload(event.target.files?.[0])} />
|
||||
<FileActionButton icon="upload" disabled={uploadMutation.isPending}>파일 업로드</FileActionButton>
|
||||
</label>
|
||||
<FileActionButton icon="download" disabled={!uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</FileActionButton>
|
||||
<FileActionButton icon="download" disabled={!pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</FileActionButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EvidenceZipButton({performanceId, userId}: {performanceId: number; userId: string}) {
|
||||
const zipMutation = useDownloadEvidenceZipMutation();
|
||||
const download = async () => {
|
||||
const buffer = await zipMutation.mutateAsync({performanceId, userId});
|
||||
downloadBlob(buffer, `monitoring-evidence-${performanceId}-${userId}.zip`, "application/zip");
|
||||
};
|
||||
|
||||
return <FileActionButton icon="image" disabled={zipMutation.isPending} onClick={download}>증빙사진</FileActionButton>;
|
||||
}
|
||||
|
||||
function LocalGovernmentReviewRow({performanceId, codes}: {performanceId: number; codes: CodeMap}) {
|
||||
const reviewType = LOCAL_GOVERNMENT_REVIEW_TYPE;
|
||||
const {data: review} = useReviewFileQuery(performanceId, reviewType, performanceId > 0);
|
||||
const label = getCodeLabel(codes, "review_status", review?.reviewStatus);
|
||||
const display = getReviewStatusDisplay(label, review, true);
|
||||
|
||||
return (
|
||||
<div className="space-y-2 border-b p-3">
|
||||
<div className="font-semibold">지자체</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<StatusPill variant={display.variant}>{display.label}</StatusPill>
|
||||
<ReviewFileActions performanceId={performanceId} reviewType={reviewType} uploadFileName={review?.uploadFileName} pdfFileName={review?.pdfFileName} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MonitoringStatusRow({
|
||||
performance,
|
||||
index,
|
||||
codes,
|
||||
userMap,
|
||||
}: {
|
||||
performance: PerformanceFull | PerformanceCompact;
|
||||
index: 0 | 1;
|
||||
codes: CodeMap;
|
||||
userMap: Map<string, UserFull>;
|
||||
}) {
|
||||
const slot = getMonitoringSlots(performance as PerformanceFull)[index];
|
||||
const user = slot.assign?.assignUser ? userMap.get(slot.assign.assignUser) : undefined;
|
||||
const reviewType = index + 1;
|
||||
const {data: review} = useReviewFileQuery(performance.id, reviewType, performance.id > 0);
|
||||
const label = getCodeLabel(codes, "monitoring_visit_status", slot.visit?.monitoringVisitStatus);
|
||||
const display = getMonitoringStatusDisplay(label, slot);
|
||||
|
||||
return (
|
||||
<div className="space-y-2 border-b p-3">
|
||||
<div className="font-semibold">모니터링 {index + 1}</div>
|
||||
<div className="grid gap-1 text-sm">
|
||||
<AssignedUserInfo userId={slot.assign?.assignUser} user={user} codes={codes} type="monitoring" />
|
||||
<div>기록 사용자: {getMonitoringRecordedUser(slot.visit)}</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<StatusPill variant={display.variant}>{display.label}</StatusPill>
|
||||
<ReviewFileActions performanceId={performance.id} reviewType={reviewType} uploadFileName={review?.uploadFileName} pdfFileName={review?.pdfFileName} />
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<span>모니터링 출발/도착 기록: {getMonitoringRecordedAt(slot.visit)}</span>
|
||||
{slot.assign?.assignUser ? (
|
||||
<EvidenceZipButton performanceId={performance.id} userId={slot.assign.assignUser} />
|
||||
) : (
|
||||
<FileActionButton icon="image" disabled>증빙사진</FileActionButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function WrittenReviewRows({
|
||||
performance,
|
||||
codes,
|
||||
isWrittenReviewer,
|
||||
userMap,
|
||||
}: {
|
||||
performance: PerformanceFull | PerformanceCompact;
|
||||
codes: CodeMap;
|
||||
isWrittenReviewer: boolean;
|
||||
userMap: Map<string, UserFull>;
|
||||
}) {
|
||||
const startMutation = useStartWrittenReviewMutation();
|
||||
const endMutation = useEndWrittenReviewMutation();
|
||||
const rows = getWrittenReviewRows(performance as PerformanceFull);
|
||||
|
||||
if(rows.length === 0){
|
||||
rows.push({userId: "", assign: undefined, review: undefined});
|
||||
}
|
||||
|
||||
const openWrittenReviewLink = (userId: string, complete: boolean) => {
|
||||
window.open(buildWrittenReviewLink({performanceId: performance.id, userId, complete}), "_blank", "noopener,noreferrer");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2 border-b p-3">
|
||||
<div className="font-semibold">서면평가</div>
|
||||
<div className="grid gap-1 text-sm">
|
||||
{rows.map(({userId, assign, review}) => {
|
||||
const user = userMap.get(userId);
|
||||
const complete = isReviewComplete(review);
|
||||
const reviewType = review?.reviewType ?? assign?.assignType ?? 2;
|
||||
const label = getCodeLabel(codes, "review_status", review?.reviewStatus);
|
||||
const display = getReviewStatusDisplay(label, review, Boolean(assign));
|
||||
return (
|
||||
<div key={`${userId}-${reviewType}`} className="space-y-2 border-b p-3 last:border-b-0">
|
||||
<AssignedUserInfo userId={userId} user={user} codes={codes} type="written" />
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<StatusPill variant={display.variant} onClick={isWrittenReviewer ? () => openWrittenReviewLink(userId, complete) : undefined}>
|
||||
{display.label}
|
||||
</StatusPill>
|
||||
{isWrittenReviewer && (
|
||||
<Button type="button" size="xs" variant="outline" onClick={() => openWrittenReviewLink(userId, complete)}>
|
||||
평가 링크
|
||||
</Button>
|
||||
)}
|
||||
<Button type="button" size="xs" variant="outline" onClick={() => startMutation.mutate(performance.id)}>
|
||||
평가진행
|
||||
</Button>
|
||||
{complete && (
|
||||
<Button type="button" size="xs" variant="outline" onClick={() => endMutation.mutate({performanceId: performance.id, userId})}>
|
||||
평가완료
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function PerformanceDetailDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
performance,
|
||||
codes,
|
||||
canEdit,
|
||||
isWrittenReviewer = false,
|
||||
onSave,
|
||||
}: {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
performance: PerformanceFull | PerformanceCompact | null;
|
||||
codes: CodeMap;
|
||||
canEdit: boolean;
|
||||
isWrittenReviewer?: boolean;
|
||||
onSave?: (performance: PerformanceCompact) => void;
|
||||
}) {
|
||||
const [draft, setDraft] = useState<PerformanceCompact | null>(null);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const {data: monitoringUsers = []} = useUsersQuery(ROLE.MONITORING, open);
|
||||
const {data: writtenUsers = []} = useUsersQuery(ROLE.WRITTEN_REVIEWER, open);
|
||||
const monitoringUserMap = useMemo(
|
||||
() => new Map(monitoringUsers.map((user) => [user.userId, user])),
|
||||
[monitoringUsers]
|
||||
);
|
||||
const writtenUserMap = useMemo(
|
||||
() => new Map(writtenUsers.map((user) => [user.userId, user])),
|
||||
[writtenUsers]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!performance) {
|
||||
setDraft(null);
|
||||
setIsEditing(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setDraft({
|
||||
id: performance.id,
|
||||
businessType: performance.businessType,
|
||||
performanceGenre: performance.performanceGenre,
|
||||
performanceArea: performance.performanceArea,
|
||||
artistName: performance.artistName,
|
||||
performanceName: performance.performanceName,
|
||||
performanceStartMonth: performance.performanceStartMonth,
|
||||
performanceDtInfo: performance.performanceDtInfo,
|
||||
performanceTimeInfo: performance.performanceTimeInfo,
|
||||
ticketReservationStatus: performance.ticketReservationStatus,
|
||||
ticketReservationMemo: performance.ticketReservationMemo,
|
||||
performanceMemo: performance.performanceMemo,
|
||||
performanceDetail: performance.performanceDetail,
|
||||
performanceStaff: performance.performanceStaff,
|
||||
performanceMonitoringSchedule: performance.performanceMonitoringSchedule,
|
||||
});
|
||||
setIsEditing(false);
|
||||
}, [performance]);
|
||||
|
||||
const updateDraft = <K extends keyof PerformanceCompact>(key: K, value: PerformanceCompact[K]) => {
|
||||
setDraft((prev) => prev ? {...prev, [key]: value} : prev);
|
||||
};
|
||||
|
||||
const updateSchedule = <K extends keyof PerformanceMonitoringSchedule>(key: K, value: PerformanceMonitoringSchedule[K]) => {
|
||||
setDraft((prev) => prev ? {
|
||||
...prev,
|
||||
performanceMonitoringSchedule: {
|
||||
...prev.performanceMonitoringSchedule,
|
||||
[key]: value,
|
||||
},
|
||||
} : prev);
|
||||
};
|
||||
|
||||
const updateStaff = (index: number, key: keyof PerformanceStaff, value: string | number) => {
|
||||
setDraft((prev) => {
|
||||
if (!prev) return prev;
|
||||
const next = [...(prev.performanceStaff ?? [])];
|
||||
next[index] = {...next[index], [key]: value};
|
||||
return {...prev, performanceStaff: next};
|
||||
});
|
||||
};
|
||||
|
||||
const resetDraft = () => {
|
||||
if (!performance) return;
|
||||
setDraft({
|
||||
id: performance.id,
|
||||
businessType: performance.businessType,
|
||||
performanceGenre: performance.performanceGenre,
|
||||
performanceArea: performance.performanceArea,
|
||||
artistName: performance.artistName,
|
||||
performanceName: performance.performanceName,
|
||||
performanceStartMonth: performance.performanceStartMonth,
|
||||
performanceDtInfo: performance.performanceDtInfo,
|
||||
performanceTimeInfo: performance.performanceTimeInfo,
|
||||
ticketReservationStatus: performance.ticketReservationStatus,
|
||||
ticketReservationMemo: performance.ticketReservationMemo,
|
||||
performanceMemo: performance.performanceMemo,
|
||||
performanceDetail: performance.performanceDetail,
|
||||
performanceStaff: performance.performanceStaff,
|
||||
performanceMonitoringSchedule: performance.performanceMonitoringSchedule,
|
||||
});
|
||||
};
|
||||
|
||||
const save = () => {
|
||||
if (!draft) return;
|
||||
onSave?.(draft);
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[90vh] flex-col overflow-hidden sm:max-w-6xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>사업 상세 정보</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="min-h-0 flex-1 overflow-y-auto pr-1">
|
||||
{draft && (
|
||||
<div className="grid gap-4 lg:grid-cols-[1.1fr_0.9fr]">
|
||||
<div className="space-y-4">
|
||||
<section className="rounded-md border">
|
||||
<DetailRow label="연번">{draft.id}</DetailRow>
|
||||
<DetailRow label="사업유형">{getCodeLabel(codes, "business_type", draft.businessType)}</DetailRow>
|
||||
<DetailRow label="분야(장르)">{getCodeLabel(codes, "genre", draft.performanceGenre)}</DetailRow>
|
||||
<DetailRow label="지역">{getCodeLabel(codes, "area", draft.performanceArea)}</DetailRow>
|
||||
<DetailRow label="단체(인)명">{draft.artistName}</DetailRow>
|
||||
<DetailRow label="사업명">{isEditing ? <Input value={draft.performanceName} onChange={(event) => updateDraft("performanceName", event.target.value)} /> : draft.performanceName}</DetailRow>
|
||||
<DetailRow label="사업 수행 월">{isEditing ? <Input type="number" value={draft.performanceStartMonth} onChange={(event) => updateDraft("performanceStartMonth", Number(event.target.value))} /> : `${draft.performanceStartMonth}월`}</DetailRow>
|
||||
<DetailRow label="사업 일정">{isEditing ? <Input value={draft.performanceDtInfo} onChange={(event) => updateDraft("performanceDtInfo", event.target.value)} /> : draft.performanceDtInfo}</DetailRow>
|
||||
<DetailRow label="운영 시간">{isEditing ? <Input value={draft.performanceTimeInfo} onChange={(event) => updateDraft("performanceTimeInfo", event.target.value)} /> : draft.performanceTimeInfo}</DetailRow>
|
||||
<DetailRow label="예매 예약">
|
||||
{isEditing ? (
|
||||
<FilterSelect value={String(draft.ticketReservationStatus ?? "")} onChange={(value) => updateDraft("ticketReservationStatus", Number(value))} options={codes.ticket_reservation_status ?? []} placeholder="예매 예약" />
|
||||
) : getCodeLabel(codes, "ticket_reservation_status", draft.ticketReservationStatus)}
|
||||
</DetailRow>
|
||||
<DetailRow label="예매 비고">{isEditing ? <Input value={draft.ticketReservationMemo} onChange={(event) => updateDraft("ticketReservationMemo", event.target.value)} /> : draft.ticketReservationMemo}</DetailRow>
|
||||
<DetailRow label="모니터링 일정">{isEditing ? <DatePicker value={draft.performanceMonitoringSchedule?.monitoringDate ?? ""} onChange={(value) => updateSchedule("monitoringDate", value)} /> : draft.performanceMonitoringSchedule?.monitoringDate}</DetailRow>
|
||||
<DetailRow label="모니터링 시간">{isEditing ? <Input value={draft.performanceMonitoringSchedule?.monitoringTimeInfo ?? ""} onChange={(event) => updateSchedule("monitoringTimeInfo", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringTimeInfo}</DetailRow>
|
||||
<DetailRow label="방문 장소">{isEditing ? <Input value={draft.performanceMonitoringSchedule?.monitoringAddress ?? ""} onChange={(event) => updateSchedule("monitoringAddress", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringAddress}</DetailRow>
|
||||
<DetailRow label="메모">{isEditing ? <Input value={draft.performanceMemo} onChange={(event) => updateDraft("performanceMemo", event.target.value)} /> : draft.performanceMemo}</DetailRow>
|
||||
</section>
|
||||
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 font-semibold">관계자 정보</div>
|
||||
<div className="overflow-auto">
|
||||
<table className="w-full min-w-[620px] border-collapse text-sm">
|
||||
<thead>
|
||||
<tr className="bg-muted">
|
||||
<th className="border p-2">유형</th>
|
||||
<th className="border p-2">이름</th>
|
||||
<th className="border p-2">연락처1</th>
|
||||
<th className="border p-2">연락처2</th>
|
||||
<th className="border p-2">이메일</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{draft.performanceStaff?.map((staff, index) => (
|
||||
<tr key={staff.id}>
|
||||
<td className="border p-2">{getCodeLabel(codes, "staff_type", staff.staffType)}</td>
|
||||
<td className="border p-2">{isEditing ? <Input value={staff.staffName} onChange={(event) => updateStaff(index, "staffName", event.target.value)} /> : staff.staffName}</td>
|
||||
<td className="border p-2">{isEditing ? <Input value={staff.staffTel1} onChange={(event) => updateStaff(index, "staffTel1", event.target.value)} /> : staff.staffTel1}</td>
|
||||
<td className="border p-2">{isEditing ? <Input value={staff.staffTel2} onChange={(event) => updateStaff(index, "staffTel2", event.target.value)} /> : staff.staffTel2}</td>
|
||||
<td className="border p-2">{isEditing ? <Input value={staff.staffEmail} onChange={(event) => updateStaff(index, "staffEmail", event.target.value)} /> : staff.staffEmail}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 font-semibold">평가 및 모니터링 현황</div>
|
||||
<LocalGovernmentReviewRow performanceId={draft.id} codes={codes} />
|
||||
<MonitoringStatusRow performance={performance ?? draft} index={0} codes={codes} userMap={monitoringUserMap} />
|
||||
<MonitoringStatusRow performance={performance ?? draft} index={1} codes={codes} userMap={monitoringUserMap} />
|
||||
<WrittenReviewRows performance={performance ?? draft} codes={codes} isWrittenReviewer={isWrittenReviewer} userMap={writtenUserMap} />
|
||||
</section>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DialogFooter className="shrink-0 border-t pt-4">
|
||||
{canEdit && draft && !isEditing && <Button type="button" onClick={() => setIsEditing(true)}>수정</Button>}
|
||||
{canEdit && draft && isEditing && (
|
||||
<>
|
||||
<Button type="button" onClick={save}>저장</Button>
|
||||
<Button type="button" variant="outline" onClick={() => { resetDraft(); setIsEditing(false); }}>취소</Button>
|
||||
</>
|
||||
)}
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>닫기</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
271
src/components/dialog/SmsSendDialog.tsx
Normal file
271
src/components/dialog/SmsSendDialog.tsx
Normal file
@@ -0,0 +1,271 @@
|
||||
"use client";
|
||||
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {Edit, RotateCcw, Save, Send} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
NOTIFICATION_REQUEST_SERVICE,
|
||||
useNotificationTemplateQuery,
|
||||
useSaveNotificationTemplateMutation,
|
||||
useSendSmsBulkMutation,
|
||||
} from "@/query/notification";
|
||||
import {SaveTemplateRequest, Template} from "@/types/notification";
|
||||
import {UserCompact} from "@/types/gwcf";
|
||||
import {getDetailValue} from "@/lib/gwcf/view";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
|
||||
type TemplateDraft = Pick<Template, "tmplatIdx" | "tmplatNm" | "tmplatTitle" | "tmplatBody" | "sendTel">;
|
||||
|
||||
const toText = (value: string | null | undefined) => value ?? "";
|
||||
|
||||
const toDraft = (template: Template, emptyBody = false): TemplateDraft => ({
|
||||
tmplatIdx: template.tmplatIdx,
|
||||
tmplatNm: toText(template.tmplatNm),
|
||||
tmplatTitle: toText(template.tmplatTitle),
|
||||
tmplatBody: emptyBody ? "" : toText(template.tmplatBody),
|
||||
sendTel: toText(template.sendTel),
|
||||
});
|
||||
|
||||
const toParamValue = (value: unknown) => value == null ? "" : String(value);
|
||||
|
||||
const buildUserMsgParam = (user: UserCompact): Record<string, string> => ({
|
||||
...Object.fromEntries(
|
||||
Object.entries(user.userDetail ?? {}).map(([key, value]) => [key, toParamValue(value)])
|
||||
),
|
||||
userId: toParamValue(user.userId),
|
||||
userCmpn: toParamValue(user.userCmpn),
|
||||
userTeam: toParamValue(user.userTeam),
|
||||
userName: toParamValue(user.userName),
|
||||
userRole: toParamValue(user.userRole),
|
||||
});
|
||||
|
||||
export function SmsSendDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title = "문자 발송",
|
||||
templateIdx,
|
||||
newMessageTemplateIdx,
|
||||
selectedUsers,
|
||||
addParams = {},
|
||||
onSent,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title?: string;
|
||||
templateIdx: number;
|
||||
newMessageTemplateIdx?: number;
|
||||
selectedUsers: UserCompact[];
|
||||
addParams?: Record<string, string>;
|
||||
onSent?: () => void;
|
||||
}>) {
|
||||
const {auth} = useAuth();
|
||||
const [activeTemplateIdx, setActiveTemplateIdx] = useState(templateIdx);
|
||||
const [isNewMessage, setIsNewMessage] = useState(false);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [draft, setDraft] = useState<TemplateDraft | null>(null);
|
||||
|
||||
const templateQuery = useNotificationTemplateQuery(activeTemplateIdx, open);
|
||||
const saveTemplateMutation = useSaveNotificationTemplateMutation();
|
||||
const sendSmsMutation = useSendSmsBulkMutation();
|
||||
|
||||
const isBusy = templateQuery.isLoading || saveTemplateMutation.isPending || sendSmsMutation.isPending;
|
||||
const canEdit = isNewMessage || isEditing;
|
||||
|
||||
const destinations = useMemo(() => {
|
||||
return selectedUsers
|
||||
.map((user) => ({
|
||||
sid: user.userId,
|
||||
destTel: getDetailValue(user.userDetail, ["userTel"]),
|
||||
destNm: user.userName || user.userId,
|
||||
msgParam: {
|
||||
...buildUserMsgParam(user),
|
||||
...addParams,
|
||||
},
|
||||
}))
|
||||
.filter((item) => item.destTel);
|
||||
}, [selectedUsers, addParams]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
||||
setActiveTemplateIdx(templateIdx);
|
||||
setIsNewMessage(false);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
}, [open, templateIdx]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !templateQuery.data) return;
|
||||
|
||||
setDraft(toDraft(templateQuery.data, isNewMessage));
|
||||
setIsEditing(false);
|
||||
}, [isNewMessage, open, templateQuery.data]);
|
||||
|
||||
const updateDraft = <K extends keyof TemplateDraft>(key: K, value: TemplateDraft[K]) => {
|
||||
setDraft((prev) => prev ? {...prev, [key]: value} : prev);
|
||||
};
|
||||
|
||||
const saveTemplate = async () => {
|
||||
if (!draft) return null;
|
||||
|
||||
const payload: SaveTemplateRequest = {
|
||||
tmplatIdx: draft.tmplatIdx,
|
||||
tmplatNm: draft.tmplatNm,
|
||||
tmplatTitle: draft.tmplatTitle,
|
||||
tmplatBody: draft.tmplatBody,
|
||||
sendTel: draft.sendTel,
|
||||
};
|
||||
|
||||
const saved = await saveTemplateMutation.mutateAsync(payload);
|
||||
setDraft(toDraft(saved));
|
||||
setIsEditing(false);
|
||||
return saved;
|
||||
};
|
||||
|
||||
const switchToNewMessage = () => {
|
||||
if (!newMessageTemplateIdx) return;
|
||||
|
||||
setActiveTemplateIdx(newMessageTemplateIdx);
|
||||
setIsNewMessage(true);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
};
|
||||
|
||||
const restoreTemplate = () => {
|
||||
setActiveTemplateIdx(templateIdx);
|
||||
setIsNewMessage(false);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
};
|
||||
|
||||
const send = async () => {
|
||||
if (!draft) return;
|
||||
|
||||
if (!auth.user?.userCmpn || !auth.user?.userId) {
|
||||
alert("로그인 사용자 정보를 확인할 수 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedUsers.length === 0) {
|
||||
alert("문자를 발송할 사용자를 선택해 주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (destinations.length === 0) {
|
||||
alert("발송 가능한 연락처가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (destinations.length !== selectedUsers.length) {
|
||||
if (!confirm("연락처가 없는 사용자는 제외하고 발송합니다. 계속하시겠습니까?")) return;
|
||||
}
|
||||
|
||||
if (isNewMessage) {
|
||||
await saveTemplate();
|
||||
}
|
||||
|
||||
const result = await sendSmsMutation.mutateAsync({
|
||||
templateIdx: draft.tmplatIdx,
|
||||
reqstCmpn: auth.user.userCmpn,
|
||||
reqstUser: auth.user.userId,
|
||||
reqstSvc: NOTIFICATION_REQUEST_SERVICE,
|
||||
destinations,
|
||||
});
|
||||
|
||||
alert(`문자 발송 요청이 ${result.requestCount}건 완료되었습니다.`);
|
||||
onSent?.();
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[90vh] flex-col overflow-hidden sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="min-h-0 flex-1 space-y-4 overflow-y-auto pr-1">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 p-3">
|
||||
<div className="text-sm text-muted-foreground">
|
||||
선택 인원: <span className="font-semibold text-foreground">{selectedUsers.length}</span>명
|
||||
{destinations.length !== selectedUsers.length && (
|
||||
<span className="ml-2 text-destructive">발송 가능 {destinations.length}명</span>
|
||||
)}
|
||||
</div>
|
||||
{newMessageTemplateIdx && (
|
||||
isNewMessage ? (
|
||||
<Button type="button" size="sm" variant="outline" onClick={restoreTemplate} disabled={isBusy}>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
기본 템플릿
|
||||
</Button>
|
||||
) : (
|
||||
<Button type="button" size="sm" variant="outline" onClick={switchToNewMessage} disabled={isBusy}>
|
||||
새문자 보내기
|
||||
</Button>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
|
||||
{templateQuery.isLoading && (
|
||||
<div className="rounded-md border p-4 text-sm text-muted-foreground">템플릿 정보를 불러오는 중입니다.</div>
|
||||
)}
|
||||
|
||||
{draft && (
|
||||
<div className="space-y-3">
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">템플릿명</span>
|
||||
<Input value={draft.tmplatNm} disabled />
|
||||
</label>
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">발신번호</span>
|
||||
<Input value={draft.sendTel ?? ""} disabled={!canEdit || isBusy} onChange={(event) => updateDraft("sendTel", event.target.value)} />
|
||||
</label>
|
||||
</div>
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">제목</span>
|
||||
<Input value={draft.tmplatTitle} disabled={!canEdit || isBusy} onChange={(event) => updateDraft("tmplatTitle", event.target.value)} />
|
||||
</label>
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">내용</span>
|
||||
<textarea
|
||||
value={draft.tmplatBody}
|
||||
disabled={!canEdit || isBusy}
|
||||
onChange={(event) => updateDraft("tmplatBody", event.target.value)}
|
||||
className="min-h-56 w-full rounded-md border border-input bg-background p-3 text-sm disabled:cursor-not-allowed disabled:opacity-70"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DialogFooter className="shrink-0 border-t pt-4">
|
||||
{!isNewMessage && draft && !isEditing && (
|
||||
<Button type="button" variant="outline" onClick={() => setIsEditing(true)} disabled={isBusy}>
|
||||
<Edit className="h-4 w-4" />
|
||||
수정
|
||||
</Button>
|
||||
)}
|
||||
{!isNewMessage && draft && isEditing && (
|
||||
<Button type="button" variant="outline" onClick={saveTemplate} disabled={isBusy}>
|
||||
<Save className="h-4 w-4" />
|
||||
저장
|
||||
</Button>
|
||||
)}
|
||||
<Button type="button" disabled={!draft || isBusy || isEditing || selectedUsers.length === 0} onClick={send}>
|
||||
<Send className="h-4 w-4" />
|
||||
발송
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
11
src/components/gwcf/EmptyRow.tsx
Normal file
11
src/components/gwcf/EmptyRow.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
"use client";
|
||||
|
||||
export function EmptyRow({colSpan}: {colSpan: number}) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={colSpan} className="h-28 border p-4 text-center text-sm text-muted-foreground">
|
||||
조회된 데이터가 없습니다.
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
25
src/components/gwcf/FilePendingButton.tsx
Normal file
25
src/components/gwcf/FilePendingButton.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import {ReactNode} from "react";
|
||||
import {Download, ImageIcon, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
|
||||
export function FilePendingButton({
|
||||
children,
|
||||
icon = "download",
|
||||
disabled = true,
|
||||
onClick,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
icon?: "download" | "upload" | "image";
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
}) {
|
||||
const Icon = icon === "upload" ? Upload : icon === "image" ? ImageIcon : Download;
|
||||
return (
|
||||
<Button type="button" size="xs" variant="outline" disabled={disabled} onClick={onClick}>
|
||||
<Icon className="h-3 w-3" />
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
37
src/components/gwcf/FilterSelect.tsx
Normal file
37
src/components/gwcf/FilterSelect.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
"use client";
|
||||
|
||||
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
|
||||
import {Code} from "@/types/gwcf";
|
||||
|
||||
export function FilterSelect({
|
||||
value,
|
||||
onChange,
|
||||
options,
|
||||
placeholder,
|
||||
className,
|
||||
useClear = true,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
options: Code[];
|
||||
placeholder: string;
|
||||
className?: string;
|
||||
useClear?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<KriSingleSelect
|
||||
items={options}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
getValue={(item) => String(item.codeValue)}
|
||||
getLabel={(item) => item.codeLabel}
|
||||
useClear={useClear}
|
||||
clearLabel="전체"
|
||||
widthClassName={className}
|
||||
spanClassName="text-sm"
|
||||
badgeClassName="text-sm"
|
||||
className="h-9"
|
||||
/>
|
||||
);
|
||||
}
|
||||
34
src/components/gwcf/MultiFilterSelect.tsx
Normal file
34
src/components/gwcf/MultiFilterSelect.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import {KriMultiSelect} from "@/components/common/KriAutoComplete";
|
||||
import {Code} from "@/types/gwcf";
|
||||
|
||||
export function MultiFilterSelect({
|
||||
value,
|
||||
onChange,
|
||||
options,
|
||||
placeholder,
|
||||
className,
|
||||
}: {
|
||||
value: string[];
|
||||
onChange: (value: string[]) => void;
|
||||
options: Code[];
|
||||
placeholder: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<KriMultiSelect
|
||||
items={options}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
getValue={(item) => String(item.codeValue)}
|
||||
getLabel={(item) => item.codeLabel}
|
||||
widthClassName={className}
|
||||
maxCount={1}
|
||||
spanClassName="text-sm"
|
||||
badgeClassName="text-sm"
|
||||
className="h-9"
|
||||
/>
|
||||
);
|
||||
}
|
||||
12
src/components/gwcf/PagePanel.tsx
Normal file
12
src/components/gwcf/PagePanel.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import {ReactNode} from "react";
|
||||
import {cn} from "@/lib/utils";
|
||||
|
||||
export function PagePanel({children, className}: {children: ReactNode; className?: string}) {
|
||||
return (
|
||||
<section className={cn("rounded-md border border-gray-300 bg-white p-4 shadow-sm", className)}>
|
||||
{children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
62
src/components/gwcf/StatusPill.tsx
Normal file
62
src/components/gwcf/StatusPill.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
"use client";
|
||||
|
||||
import {MouseEvent, ReactNode} from "react";
|
||||
import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip";
|
||||
import {cn} from "@/lib/utils";
|
||||
|
||||
export type StatusPillVariant = "default" | "danger" | "pending" | "inprogress" | "departed" | "arrived" | "done";
|
||||
|
||||
const variantClassName: Record<StatusPillVariant, string> = {
|
||||
default: "border-primary/30 bg-primary/10 text-primary",
|
||||
danger: "gwcf-status-badge--danger",
|
||||
pending: "gwcf-status-badge--pending",
|
||||
inprogress: "gwcf-status-badge--inprogress",
|
||||
departed: "gwcf-status-badge--departed",
|
||||
arrived: "gwcf-status-badge--arrived",
|
||||
done: "gwcf-status-badge--done",
|
||||
};
|
||||
|
||||
export function StatusPill({
|
||||
children,
|
||||
onClick,
|
||||
variant = "default",
|
||||
tooltip,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
onClick?: () => void;
|
||||
variant?: StatusPillVariant;
|
||||
tooltip?: ReactNode;
|
||||
}) {
|
||||
const className = cn(
|
||||
"inline-flex min-w-14 items-center justify-center rounded-full border px-2 py-1 text-xs font-semibold",
|
||||
variant !== "default" && "gwcf-status-badge",
|
||||
variantClassName[variant],
|
||||
onClick && "cursor-pointer hover:opacity-80"
|
||||
);
|
||||
|
||||
const handleClick = (event: MouseEvent<HTMLButtonElement>) => {
|
||||
event.stopPropagation();
|
||||
onClick?.();
|
||||
};
|
||||
|
||||
const pill = onClick ? (
|
||||
<button type="button" className={className} onClick={handleClick}>
|
||||
{children || "-"}
|
||||
</button>
|
||||
) : (
|
||||
<span className={className}>
|
||||
{children || "-"}
|
||||
</span>
|
||||
);
|
||||
|
||||
if (!tooltip) return pill;
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{pill}</TooltipTrigger>
|
||||
<TooltipContent sideOffset={6}>{tooltip}</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import Image from "next/image";
|
||||
import {TOP_MENUS} from "@/config/menu.data";
|
||||
import type {LoginUser} from "@/types/auth";
|
||||
import {SITE_TITLE} from "@/config/gwcf.config";
|
||||
import {useLogoutMutation} from "@/query/auth";
|
||||
import {isFoundationRole, isInternalRole} from "@/lib/gwcf/view";
|
||||
|
||||
interface HeaderProps {
|
||||
userInfo: LoginUser | undefined;
|
||||
@@ -20,6 +22,14 @@ export const Header = ({
|
||||
activeTopId,
|
||||
onNavigate,
|
||||
}: HeaderProps) => {
|
||||
const logoutMutation = useLogoutMutation();
|
||||
const menus = TOP_MENUS.filter((menu) => {
|
||||
if (!isInternalRole(userInfo?.userRole)) {
|
||||
return !["user-list", "assign"].includes(menu.id);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return (
|
||||
<header className="bg-white border-b border-gray-200 sticky top-0 z-40">
|
||||
<div className="relative flex items-center justify-between px-4 h-16">
|
||||
@@ -52,7 +62,7 @@ export const Header = ({
|
||||
{
|
||||
!isMonitoring && (
|
||||
<nav className="flex items-center gap-1">
|
||||
{TOP_MENUS.map((m) => (
|
||||
{menus.map((m) => (
|
||||
<Button
|
||||
key={m.id}
|
||||
variant={activeTopId === m.id ? "default" : "ghost"}
|
||||
@@ -73,12 +83,13 @@ export const Header = ({
|
||||
<div className="relative z-10 flex items-center gap-4">
|
||||
<span
|
||||
className="content-text-base text-header-color font-bold">
|
||||
{userInfo?.userName || "박준성7957"}
|
||||
{userInfo?.userName || ""}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="gap-2 sm:bg-primary sm:text-primary-foreground sm:hover:bg-primary/90"
|
||||
onClick={() => onNavigate("/logout")}
|
||||
>
|
||||
<LogOut className="w-4 h-4"/>
|
||||
<span className="hidden sm:inline">로그아웃</span>
|
||||
|
||||
@@ -27,7 +27,7 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
setUserInfo(auth.user);
|
||||
}
|
||||
else{
|
||||
//router.replace("/logout");
|
||||
router.replace("/logout");
|
||||
}
|
||||
}, [auth.user, mounted, router])
|
||||
|
||||
@@ -39,9 +39,9 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
<div
|
||||
className="bg-gray-50 flex flex-col min-h-screen"
|
||||
>
|
||||
{/* 헤더 - 고정 폰트 크기 */}
|
||||
{/* 헤더 - 고정 높이 */}
|
||||
<Header
|
||||
isMonitoring={isMonitoring}
|
||||
isMonitoring={mounted ? isMonitoring : false}
|
||||
userInfo={userInfo}
|
||||
activeTopId={activeTop.id}
|
||||
onNavigate={movePage}
|
||||
@@ -49,7 +49,7 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
|
||||
{/* 본문 */}
|
||||
<div className="flex flex-1 min-h-0">
|
||||
{/* 메인 콘텐츠만 가변 폰트 크기 적용 */}
|
||||
{/* 메인 콘텐츠만 가변 높이 적용 */}
|
||||
<main className="flex-1 p-4">
|
||||
{children}
|
||||
</main>
|
||||
@@ -59,3 +59,4 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
};
|
||||
|
||||
export default MainLayout;
|
||||
|
||||
|
||||
220
src/components/ui/calendar.tsx
Normal file
220
src/components/ui/calendar.tsx
Normal file
@@ -0,0 +1,220 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from "lucide-react"
|
||||
import {
|
||||
DayPicker,
|
||||
getDefaultClassNames,
|
||||
type DayButton,
|
||||
} from "react-day-picker"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button, buttonVariants } from "@/components/ui/button"
|
||||
|
||||
function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
showOutsideDays = true,
|
||||
captionLayout = "label",
|
||||
buttonVariant = "ghost",
|
||||
formatters,
|
||||
components,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayPicker> & {
|
||||
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
||||
}) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn(
|
||||
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
||||
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
||||
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
||||
className
|
||||
)}
|
||||
captionLayout={captionLayout}
|
||||
formatters={{
|
||||
formatMonthDropdown: (date) =>
|
||||
date.toLocaleString("default", { month: "short" }),
|
||||
...formatters,
|
||||
}}
|
||||
classNames={{
|
||||
root: cn("w-fit", defaultClassNames.root),
|
||||
months: cn(
|
||||
"relative flex flex-col gap-4 md:flex-row",
|
||||
defaultClassNames.months
|
||||
),
|
||||
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
||||
nav: cn(
|
||||
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
||||
defaultClassNames.nav
|
||||
),
|
||||
button_previous: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
||||
defaultClassNames.button_previous
|
||||
),
|
||||
button_next: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
||||
defaultClassNames.button_next
|
||||
),
|
||||
month_caption: cn(
|
||||
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
||||
defaultClassNames.month_caption
|
||||
),
|
||||
dropdowns: cn(
|
||||
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
||||
defaultClassNames.dropdowns
|
||||
),
|
||||
dropdown_root: cn(
|
||||
"relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
|
||||
defaultClassNames.dropdown_root
|
||||
),
|
||||
dropdown: cn(
|
||||
"absolute inset-0 bg-popover opacity-0",
|
||||
defaultClassNames.dropdown
|
||||
),
|
||||
caption_label: cn(
|
||||
"font-medium select-none",
|
||||
captionLayout === "label"
|
||||
? "text-sm"
|
||||
: "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
||||
defaultClassNames.caption_label
|
||||
),
|
||||
table: "w-full border-collapse",
|
||||
weekdays: cn("flex", defaultClassNames.weekdays),
|
||||
weekday: cn(
|
||||
"flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
|
||||
defaultClassNames.weekday
|
||||
),
|
||||
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
||||
week_number_header: cn(
|
||||
"w-(--cell-size) select-none",
|
||||
defaultClassNames.week_number_header
|
||||
),
|
||||
week_number: cn(
|
||||
"text-[0.8rem] text-muted-foreground select-none",
|
||||
defaultClassNames.week_number
|
||||
),
|
||||
day: cn(
|
||||
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
|
||||
props.showWeekNumber
|
||||
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md"
|
||||
: "[&:first-child[data-selected=true]_button]:rounded-l-md",
|
||||
defaultClassNames.day
|
||||
),
|
||||
range_start: cn(
|
||||
"rounded-l-md bg-accent",
|
||||
defaultClassNames.range_start
|
||||
),
|
||||
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
||||
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
||||
today: cn(
|
||||
"rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
|
||||
defaultClassNames.today
|
||||
),
|
||||
outside: cn(
|
||||
"text-muted-foreground aria-selected:text-muted-foreground",
|
||||
defaultClassNames.outside
|
||||
),
|
||||
disabled: cn(
|
||||
"text-muted-foreground opacity-50",
|
||||
defaultClassNames.disabled
|
||||
),
|
||||
hidden: cn("invisible", defaultClassNames.hidden),
|
||||
...classNames,
|
||||
} as React.ComponentProps<typeof DayPicker>["classNames"]}
|
||||
components={{
|
||||
Root: ({ className, rootRef, ...props }) => {
|
||||
return (
|
||||
<div
|
||||
data-slot="calendar"
|
||||
ref={rootRef}
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
},
|
||||
Chevron: ({ className, orientation, ...props }) => {
|
||||
if (orientation === "left") {
|
||||
return (
|
||||
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
if (orientation === "right") {
|
||||
return (
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
},
|
||||
DayButton: CalendarDayButton,
|
||||
WeekNumber: ({ children, ...props }) => {
|
||||
return (
|
||||
<td {...props}>
|
||||
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
||||
{children}
|
||||
</div>
|
||||
</td>
|
||||
)
|
||||
},
|
||||
...components,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CalendarDayButton({
|
||||
className,
|
||||
day,
|
||||
modifiers,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayButton>) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
const ref = React.useRef<HTMLButtonElement>(null)
|
||||
React.useEffect(() => {
|
||||
if (modifiers.focused) ref.current?.focus()
|
||||
}, [modifiers.focused])
|
||||
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
data-day={day.date.toLocaleDateString()}
|
||||
data-selected-single={
|
||||
modifiers.selected &&
|
||||
!modifiers.range_start &&
|
||||
!modifiers.range_end &&
|
||||
!modifiers.range_middle
|
||||
}
|
||||
data-range-start={modifiers.range_start}
|
||||
data-range-end={modifiers.range_end}
|
||||
data-range-middle={modifiers.range_middle}
|
||||
className={cn(
|
||||
"flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
|
||||
defaultClassNames.day,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Calendar, CalendarDayButton }
|
||||
@@ -11,6 +11,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
"h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
|
||||
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
||||
"aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
|
||||
"bg-white",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -1136,171 +1136,150 @@ function MultiSelectInner(
|
||||
responsiveSettings.compactMode && "gap-0.5"
|
||||
)}
|
||||
>
|
||||
{selectedValues
|
||||
.slice(0, responsiveSettings.maxCount)
|
||||
.map((value) => {
|
||||
const option =
|
||||
getOptionByValue(value) ??
|
||||
({ value, label: value } as MultiSelectOption<any>);
|
||||
const IconComponent = option.icon;
|
||||
const customStyle = option.style;
|
||||
const badgeStyle: React.CSSProperties = {
|
||||
animationDuration: `${animation}s`,
|
||||
...(customStyle?.badgeColor && {
|
||||
backgroundColor: customStyle.badgeColor,
|
||||
}),
|
||||
...(customStyle?.gradient && {
|
||||
background: customStyle.gradient,
|
||||
color: "white",
|
||||
}),
|
||||
};
|
||||
return (
|
||||
<Badge
|
||||
key={value}
|
||||
className={cn(
|
||||
getBadgeAnimationClass(),
|
||||
multiSelectVariants({ variant }),
|
||||
customStyle?.gradient &&
|
||||
"text-white border-transparent",
|
||||
responsiveSettings.compactMode &&
|
||||
"px-1.5 py-0.5",
|
||||
screenSize === "mobile" &&
|
||||
"max-w-[120px] truncate",
|
||||
singleLine &&
|
||||
"flex-shrink-0 whitespace-nowrap",
|
||||
"[&>svg]:pointer-events-auto",
|
||||
badgeClassName
|
||||
)}
|
||||
style={{
|
||||
...badgeStyle,
|
||||
animationDuration: `${
|
||||
animationConfig?.duration || animation
|
||||
}s`,
|
||||
animationDelay: `${
|
||||
animationConfig?.delay || 0
|
||||
}s`,
|
||||
}}
|
||||
>
|
||||
{IconComponent &&
|
||||
!responsiveSettings.hideIcons && (
|
||||
<IconComponent
|
||||
className={cn(
|
||||
"h-4 w-4 mr-2",
|
||||
responsiveSettings.compactMode &&
|
||||
"h-3 w-3 mr-1",
|
||||
customStyle?.iconColor &&
|
||||
"text-current"
|
||||
)}
|
||||
{...(customStyle?.iconColor && {
|
||||
style: { color: customStyle.iconColor },
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<span
|
||||
{
|
||||
selectedValues.length <= responsiveSettings.maxCount?
|
||||
selectedValues
|
||||
.slice(0, responsiveSettings.maxCount)
|
||||
.map((value) => {
|
||||
const option =
|
||||
getOptionByValue(value) ??
|
||||
({ value, label: value } as MultiSelectOption<any>);
|
||||
const IconComponent = option.icon;
|
||||
const customStyle = option.style;
|
||||
const badgeStyle: React.CSSProperties = {
|
||||
animationDuration: `${animation}s`,
|
||||
...(customStyle?.badgeColor && {
|
||||
backgroundColor: customStyle.badgeColor,
|
||||
}),
|
||||
...(customStyle?.gradient && {
|
||||
background: customStyle.gradient,
|
||||
color: "white",
|
||||
}),
|
||||
};
|
||||
return (
|
||||
<Badge
|
||||
key={value}
|
||||
className={cn(
|
||||
screenSize === "mobile" && "truncate"
|
||||
getBadgeAnimationClass(),
|
||||
multiSelectVariants({ variant }),
|
||||
customStyle?.gradient &&
|
||||
"text-white border-transparent",
|
||||
responsiveSettings.compactMode &&
|
||||
"px-1.5 py-0.5",
|
||||
screenSize === "mobile" &&
|
||||
"max-w-[120px] truncate",
|
||||
singleLine &&
|
||||
"flex-shrink-0 whitespace-nowrap",
|
||||
"[&>svg]:pointer-events-auto",
|
||||
badgeClassName
|
||||
)}
|
||||
style={{
|
||||
...badgeStyle,
|
||||
animationDuration: `${
|
||||
animationConfig?.duration || animation
|
||||
}s`,
|
||||
animationDelay: `${
|
||||
animationConfig?.delay || 0
|
||||
}s`,
|
||||
}}
|
||||
>
|
||||
{IconComponent &&
|
||||
!responsiveSettings.hideIcons && (
|
||||
<IconComponent
|
||||
className={cn(
|
||||
"h-4 w-4 mr-2",
|
||||
responsiveSettings.compactMode &&
|
||||
"h-3 w-3 mr-1",
|
||||
customStyle?.iconColor &&
|
||||
"text-current"
|
||||
)}
|
||||
{...(customStyle?.iconColor && {
|
||||
style: { color: customStyle.iconColor },
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<span
|
||||
className={cn(
|
||||
screenSize === "mobile" && "truncate"
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</span>
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleOption(value);
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (
|
||||
event.key === "Enter" ||
|
||||
event.key === " "
|
||||
) {
|
||||
event.preventDefault();
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleOption(value);
|
||||
}
|
||||
}}
|
||||
aria-label={`Remove ${option.label} from selection`}
|
||||
className="ml-2 h-4.5 w-4.5 cursor-pointer hover:bg-white/20 rounded-sm p-0.5 -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50"
|
||||
>
|
||||
{!preventDeselect &&
|
||||
<XCircle
|
||||
className={cn(
|
||||
"h-3 w-3",
|
||||
responsiveSettings.compactMode &&
|
||||
"h-2.5 w-2.5"
|
||||
)}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
</Badge>
|
||||
);
|
||||
})
|
||||
.filter(Boolean)}
|
||||
{selectedValues.length >
|
||||
responsiveSettings.maxCount && (
|
||||
<Badge
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (
|
||||
event.key === "Enter" ||
|
||||
event.key === " "
|
||||
) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
toggleOption(value);
|
||||
}
|
||||
}}
|
||||
aria-label={`Remove ${option.label} from selection`}
|
||||
className="ml-2 h-4.5 w-4.5 cursor-pointer hover:bg-white/20 rounded-sm p-0.5 -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50"
|
||||
>
|
||||
{!preventDeselect &&
|
||||
<XCircle
|
||||
className={cn(
|
||||
"h-3 w-3",
|
||||
responsiveSettings.compactMode &&
|
||||
"h-2.5 w-2.5"
|
||||
)}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
</Badge>
|
||||
);
|
||||
})
|
||||
.filter(Boolean)
|
||||
:
|
||||
<Badge
|
||||
className={cn(
|
||||
"bg-transparent text-foreground border-foreground/1 hover:bg-transparent",
|
||||
getBadgeAnimationClass(),
|
||||
multiSelectVariants({ variant }),
|
||||
responsiveSettings.compactMode &&
|
||||
"px-1.5 py-0.5",
|
||||
singleLine &&
|
||||
"flex-shrink-0 whitespace-nowrap",
|
||||
"[&>svg]:pointer-events-auto",
|
||||
badgeClassName
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${
|
||||
animationConfig?.duration || animation
|
||||
}s`,
|
||||
animationDelay: `${
|
||||
animationConfig?.delay || 0
|
||||
}s`,
|
||||
}}
|
||||
>
|
||||
{`+ ${
|
||||
selectedValues.length
|
||||
}`}
|
||||
<XCircle
|
||||
className={cn(
|
||||
"bg-transparent text-foreground border-foreground/1 hover:bg-transparent",
|
||||
getBadgeAnimationClass(),
|
||||
multiSelectVariants({ variant }),
|
||||
"ml-2 h-4 w-4 mt-0.5 cursor-pointer",
|
||||
responsiveSettings.compactMode &&
|
||||
"px-1.5 py-0.5",
|
||||
singleLine &&
|
||||
"flex-shrink-0 whitespace-nowrap",
|
||||
"[&>svg]:pointer-events-auto",
|
||||
badgeClassName
|
||||
"ml-1 h-3 w-3"
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${
|
||||
animationConfig?.duration || animation
|
||||
}s`,
|
||||
animationDelay: `${
|
||||
animationConfig?.delay || 0
|
||||
}s`,
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
handleClear();
|
||||
}}
|
||||
>
|
||||
{`+${
|
||||
selectedValues.length -
|
||||
responsiveSettings.maxCount
|
||||
} more`}
|
||||
<XCircle
|
||||
className={cn(
|
||||
"ml-2 h-4 w-4 mt-0.5 cursor-pointer",
|
||||
responsiveSettings.compactMode &&
|
||||
"ml-1 h-3 w-3"
|
||||
)}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
clearExtraOptions();
|
||||
}}
|
||||
/>
|
||||
</Badge>
|
||||
)}
|
||||
/>
|
||||
</Badge>
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center justify-between">
|
||||
{!preventDeselect &&
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
handleClear();
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
handleClear();
|
||||
}
|
||||
}}
|
||||
aria-label={`Clear all ${selectedValues.length} selected options`}
|
||||
className="flex items-center justify-center h-4 w-4 mx-2 cursor-pointer text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 rounded-sm"
|
||||
>
|
||||
<XIcon className="h-4 w-4" />
|
||||
</div>
|
||||
}
|
||||
<Separator
|
||||
orientation="vertical"
|
||||
className="flex min-h-6 h-full"
|
||||
|
||||
57
src/components/ui/tooltip.tsx
Normal file
57
src/components/ui/tooltip.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function TooltipProvider({
|
||||
delayDuration = 0,
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
||||
return (
|
||||
<TooltipPrimitive.Provider
|
||||
data-slot="tooltip-provider"
|
||||
delayDuration={delayDuration}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Tooltip({
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
||||
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
||||
}
|
||||
|
||||
function TooltipTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
||||
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
||||
}
|
||||
|
||||
function TooltipContent({
|
||||
className,
|
||||
sideOffset = 0,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
||||
return (
|
||||
<TooltipPrimitive.Portal>
|
||||
<TooltipPrimitive.Content
|
||||
data-slot="tooltip-content"
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
|
||||
</TooltipPrimitive.Content>
|
||||
</TooltipPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
||||
Reference in New Issue
Block a user