import { Button, Card, Group, Loader, Modal, Stack, Text, Tooltip, UnstyledButton, } from "@mantine/core"; import { IconPencil, IconX } from "@tabler/icons-react"; import { useState } from "react"; import TimeInput from "@/ui/input/time-input"; import { useDisclosure } from "@mantine/hooks"; import dayjs from "dayjs"; import { usePatchFlight } from "@/util/hooks"; import utc from "dayjs/plugin/utc.js"; dayjs.extend(utc); export function TimeLogItem({ label, content, date, id = "", field = "", }: { label: string; content: string | null; date: dayjs.Dayjs | string; id?: string; field?: string; }) { if (date instanceof String) date = dayjs(date); const time = (content as string).split("T")[1].split(":"); const [editValue, setEditValue] = useState( Number(`${time[0]}${time[1]}`) ); const [editError, setEditError] = useState(""); const [editOpened, { open: openEdit, close: closeEdit }] = useDisclosure(false); const updateValue = usePatchFlight(id, field, closeEdit); content = `${time[0]}:${time[1]}`; const editForm = ( ); return ( <> {editForm} {updateValue.isPending ? : null} {updateValue.isError ? ( {updateValue.error?.message} ) : null} {label} {content === null ? : content} ); }