mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 22:54:22 +00:00
Move SWR hooks to their own directory
This commit is contained in:
parent
d431540e4d
commit
4f3de3d018
5 changed files with 14 additions and 14 deletions
|
@ -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<HTMLFormElement>) {
|
||||
const { t } = useTranslation()
|
||||
const { data, error } = useMyEvents()
|
||||
const { data, error } = useMyEventsSWR()
|
||||
|
||||
const newClassName = classNames(props.className, {
|
||||
"negative": error,
|
||||
|
|
6
hooks/swr/useEventDetailsSWR.ts
Normal file
6
hooks/swr/useEventDetailsSWR.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { Event } from "@prisma/client";
|
||||
import { default as useSWR } from "swr";
|
||||
|
||||
export function useEventDetailsSWR(slug: string) {
|
||||
return useSWR<Event>(`/api/events/${slug}`)
|
||||
}
|
6
hooks/swr/useMyEventsSWR.ts
Normal file
6
hooks/swr/useMyEventsSWR.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { Event } from "@prisma/client";
|
||||
import { default as useSWR } from "swr";
|
||||
|
||||
export function useMyEventsSWR() {
|
||||
return useSWR<Event[]>("/api/events/mine")
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import { Event } from "@prisma/client";
|
||||
import useSWR, { SWRResponse } from "swr";
|
||||
|
||||
export function useEventDetail(slug: string): SWRResponse<Event> {
|
||||
return useSWR(`/api/events/${slug}`)
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import { Event } from "@prisma/client";
|
||||
import useSWR, { SWRResponse } from "swr";
|
||||
|
||||
export function useMyEvents(): SWRResponse<Event[]> {
|
||||
return useSWR("/api/events/mine")
|
||||
}
|
Loading…
Reference in a new issue