From 4f3de3d018b25589e3730c97cfbd5acf3c8519ee Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 3 Jun 2022 04:10:51 +0200 Subject: [PATCH] Move SWR hooks to their own directory --- components/ActionEventList.tsx | 4 ++-- hooks/swr/useEventDetailsSWR.ts | 6 ++++++ hooks/swr/useMyEventsSWR.ts | 6 ++++++ hooks/useEventDetail.ts | 6 ------ hooks/useMyEvents.ts | 6 ------ 5 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 hooks/swr/useEventDetailsSWR.ts create mode 100644 hooks/swr/useMyEventsSWR.ts delete mode 100644 hooks/useEventDetail.ts delete mode 100644 hooks/useMyEvents.ts diff --git a/components/ActionEventList.tsx b/components/ActionEventList.tsx index 35827a8..be47f66 100644 --- a/components/ActionEventList.tsx +++ b/components/ActionEventList.tsx @@ -1,7 +1,7 @@ import { default as classNames } from "classnames"; import { useTranslation } from "next-i18next"; import { HTMLProps } from "react"; -import { useMyEvents } from "../hooks/useMyEvents"; +import { useMyEventsSWR } from "../hooks/swr/useMyEventsSWR"; import { Loading } from "./Loading"; import { EventList } from "./EventList"; import { EventCreate } from "./EventCreate"; @@ -9,7 +9,7 @@ import { EventCreate } from "./EventCreate"; export function ActionEventList(props: HTMLProps) { const { t } = useTranslation() - const { data, error } = useMyEvents() + const { data, error } = useMyEventsSWR() const newClassName = classNames(props.className, { "negative": error, diff --git a/hooks/swr/useEventDetailsSWR.ts b/hooks/swr/useEventDetailsSWR.ts new file mode 100644 index 0000000..ca55001 --- /dev/null +++ b/hooks/swr/useEventDetailsSWR.ts @@ -0,0 +1,6 @@ +import { Event } from "@prisma/client"; +import { default as useSWR } from "swr"; + +export function useEventDetailsSWR(slug: string) { + return useSWR(`/api/events/${slug}`) +} diff --git a/hooks/swr/useMyEventsSWR.ts b/hooks/swr/useMyEventsSWR.ts new file mode 100644 index 0000000..8dbd4f3 --- /dev/null +++ b/hooks/swr/useMyEventsSWR.ts @@ -0,0 +1,6 @@ +import { Event } from "@prisma/client"; +import { default as useSWR } from "swr"; + +export function useMyEventsSWR() { + return useSWR("/api/events/mine") +} diff --git a/hooks/useEventDetail.ts b/hooks/useEventDetail.ts deleted file mode 100644 index 45f9e84..0000000 --- a/hooks/useEventDetail.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Event } from "@prisma/client"; -import useSWR, { SWRResponse } from "swr"; - -export function useEventDetail(slug: string): SWRResponse { - return useSWR(`/api/events/${slug}`) -} diff --git a/hooks/useMyEvents.ts b/hooks/useMyEvents.ts deleted file mode 100644 index a8d96f5..0000000 --- a/hooks/useMyEvents.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Event } from "@prisma/client"; -import useSWR, { SWRResponse } from "swr"; - -export function useMyEvents(): SWRResponse { - return useSWR("/api/events/mine") -}