| @@ -15,27 +15,25 @@ import { ApiId } from "api"; | |||||
| import { | import { | ||||
| UseSummary, | UseSummary, | ||||
| getUseSummaries, | getUseSummaries, | ||||
| getUseSummaryYYYYMMs, | |||||
| } from "api/custom/hello-techno/use-summary"; | } from "api/custom/hello-techno/use-summary"; | ||||
| import { getFullUrl } from "api/url"; | import { getFullUrl } from "api/url"; | ||||
| import { PageID, TabID } from "codes/page"; | import { PageID, TabID } from "codes/page"; | ||||
| import { FormProvider } from "components/hook-form"; | import { FormProvider } from "components/hook-form"; | ||||
| import RHFDatePicker from "components/hook-form/RHFDatePicker"; | import RHFDatePicker from "components/hook-form/RHFDatePicker"; | ||||
| import RHFSelect, { SelectOptionProps } from "components/hook-form/RHFSelect"; | |||||
| import { TableHeadCustom } from "components/table"; | import { TableHeadCustom } from "components/table"; | ||||
| import { HeadLabelProps } from "components/table/TableHeadCustom"; | import { HeadLabelProps } from "components/table/TableHeadCustom"; | ||||
| import { SearchConditionContextProvider } from "contexts/SearchConditionContext"; | import { SearchConditionContextProvider } from "contexts/SearchConditionContext"; | ||||
| import { addMonths, endOfMonth, startOfMonth } from "date-fns"; | |||||
| import useAPICall from "hooks/useAPICall"; | import useAPICall from "hooks/useAPICall"; | ||||
| import useDashboard from "hooks/useDashBoard"; | import useDashboard from "hooks/useDashBoard"; | ||||
| import useNavigateCustom from "hooks/useNavigateCustom"; | import useNavigateCustom from "hooks/useNavigateCustom"; | ||||
| import useSearchConditionContext from "hooks/useSearchConditionContext"; | import useSearchConditionContext from "hooks/useSearchConditionContext"; | ||||
| import useTable, { UseTableReturn } from "hooks/useTable"; | import useTable, { UseTableReturn } from "hooks/useTable"; | ||||
| import { SearchParam } from "pages/dashboard/receipt-issuing-order/custom/hello-techno/list"; | import { SearchParam } from "pages/dashboard/receipt-issuing-order/custom/hello-techno/list"; | ||||
| import { useEffect, useMemo, useState } from "react"; | |||||
| import { useEffect, useMemo } from "react"; | |||||
| import { useForm } from "react-hook-form"; | import { useForm } from "react-hook-form"; | ||||
| import { getPath } from "routes/path"; | import { getPath } from "routes/path"; | ||||
| import { sprintf } from "sprintf-js"; | |||||
| import { dateParse, formatDateStr } from "utils/datetime"; | |||||
| import { dateParse, formatDateStr, now } from "utils/datetime"; | |||||
| export default function UseSummaryList() { | export default function UseSummaryList() { | ||||
| const { setHeaderTitle, setTabs } = useDashboard( | const { setHeaderTitle, setTabs } = useDashboard( | ||||
| @@ -127,8 +125,14 @@ function SearchBox({ table }: CommonProps) { | |||||
| // 初期値設定 | // 初期値設定 | ||||
| useEffect(() => { | useEffect(() => { | ||||
| if (initialized) { | if (initialized) { | ||||
| form.setValue("date_from", dateParse(get("date_from"))); | |||||
| form.setValue("date_to", dateParse(get("date_to"))); | |||||
| const lastMonth = addMonths(now(), -1); | |||||
| const defaultDateFrom = startOfMonth(lastMonth); | |||||
| const defaultDateTo = endOfMonth(lastMonth); | |||||
| form.setValue( | |||||
| "date_from", | |||||
| dateParse(get("date_from")) ?? defaultDateFrom | |||||
| ); | |||||
| form.setValue("date_to", dateParse(get("date_to")) ?? defaultDateTo); | |||||
| } | } | ||||
| }, [initialized]); | }, [initialized]); | ||||