diff --git a/web/src/components/entry-dialog/EntryDialog.tsx b/web/src/components/entry-dialog/EntryDialog.tsx index 38620f38..18e5c823 100644 --- a/web/src/components/entry-dialog/EntryDialog.tsx +++ b/web/src/components/entry-dialog/EntryDialog.tsx @@ -29,24 +29,24 @@ export type EntryFormSchema = { type EntryDialogProps = DialogProps & { editEntry?: Entry; + date?: Dayjs; }; -const EntryDialog = ({ editEntry, ...props }: EntryDialogProps) => { - console.log("edit entry", editEntry); +const EntryDialog = ({ editEntry, date, ...props }: EntryDialogProps) => { const theme = useTheme(); const fullScreen = useMediaQuery(theme.breakpoints.down("md")); const [addWorkdayEntryMutation] = useMutation(AddWorkdayEntryDocument); - const { handleSubmit, control, reset } = useForm({ - defaultValues: { - date: dayjs(), - duration: "", - product: "", - activity: "", - issue: "", - client: "", - }, - }); + const defaultValues: EntryFormSchema = { + date: date ? dayjs(date) : dayjs(), + duration: editEntry?.duration.toString() || "", + product: editEntry?.product || "", + activity: editEntry?.activity || "", + issue: editEntry?.issue || "", + client: editEntry?.client || "", + }; + + const { handleSubmit, control, reset } = useForm({ defaultValues }); const onSubmit: SubmitHandler = async (formValues) => { const { date, duration, product, activity, issue, client } = formValues; diff --git a/web/src/components/workday-accordion/EditEntryButton.tsx b/web/src/components/workday-accordion/EditEntryButton.tsx index bfd267b0..5848edf4 100644 --- a/web/src/components/workday-accordion/EditEntryButton.tsx +++ b/web/src/components/workday-accordion/EditEntryButton.tsx @@ -1,14 +1,33 @@ import EditIcon from "@mui/icons-material/Edit"; import { IconButton } from "@mui/material"; +import { Dayjs } from "dayjs"; +import { useState } from "react"; import { useTranslation } from "react-i18next"; +import { Entry } from "../../graphql/generated/graphql"; +import EntryDialog from "../entry-dialog/EntryDialog"; -const EditEntryButton = () => { +type EditEntryButtonProps = { + entry: Entry; + date: Dayjs; +}; + +const EditEntryButton = ({ entry, date }: EditEntryButtonProps) => { const { t } = useTranslation(); + const [open, setOpen] = useState(false); + const toggleOpen = () => setOpen((prev) => !prev); return ( - - - + <> + + + + + ); }; diff --git a/web/src/components/workday-accordion/EntryTable.tsx b/web/src/components/workday-accordion/EntryTable.tsx index 105ee4a3..1c6610ef 100644 --- a/web/src/components/workday-accordion/EntryTable.tsx +++ b/web/src/components/workday-accordion/EntryTable.tsx @@ -36,7 +36,7 @@ const EntryTable = ({ workday }: EntryTableProps) => { {entry.issue} {entry.client} - +