Merge commit '7c1cc6df65822576ae95cd3fd5839da8ba7a59ee' into iipbs/wr/form_fuction
This commit is contained in:
@@ -10,12 +10,23 @@ import { Button, Calendar, Popover, PopoverContent, PopoverTrigger } from "@comm
|
||||
import { cn } from "../../lib/utils";
|
||||
import { FormControl } from "../form";
|
||||
import { ko } from "date-fns/locale";
|
||||
import { useState } from "react";
|
||||
|
||||
type DatePickerProps = DayPickerSingleProps & { field: { value: Date; onChange: (date: Date | undefined) => void } ,selectClass:string|undefined };
|
||||
|
||||
|
||||
export function DatePicker({ field, selectClass }: DatePickerProps) {
|
||||
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const handleSelect = (date: Date | undefined) => {
|
||||
field.onChange(date); // React Hook Form 업데이트
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<FormControl>
|
||||
<Button
|
||||
@@ -28,7 +39,7 @@ export function DatePicker({ field, selectClass }: DatePickerProps) {
|
||||
):selectClass}
|
||||
>
|
||||
{field?.value ? (
|
||||
format(field?.value, "PPP")
|
||||
format(field?.value, "PPP", { locale: ko })
|
||||
) : (
|
||||
<span>Pick a date</span>
|
||||
)}
|
||||
@@ -40,7 +51,7 @@ export function DatePicker({ field, selectClass }: DatePickerProps) {
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={field?.value}
|
||||
onSelect={field?.onChange}
|
||||
onSelect={handleSelect}
|
||||
initialFocus
|
||||
locale={ko}
|
||||
/>
|
||||
|
||||
@@ -24,6 +24,8 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa
|
||||
setCur(page);
|
||||
onPageChange(page);
|
||||
}
|
||||
const style = cellClick ? 'cursor-pointer' : '';
|
||||
|
||||
return (
|
||||
<>
|
||||
{headName ? <div className="card-header">
|
||||
@@ -42,7 +44,7 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa
|
||||
{tableData?.map((el: { [key: string]: string | number | boolean | object}, index) => (
|
||||
<TableRow key={index + "row"} >
|
||||
{headlist?.map((head) => (
|
||||
<TableCell className="cursor-pointer" onClick={()=>cellClick && cellClick(index)} key={head.id + index}>{el[head.id]}</TableCell>
|
||||
<TableCell className={style} onClick={()=>cellClick && cellClick(index)} key={head.id + index}>{el[head.id]}</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user