1
Fork 0
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:
Steffo 2022-06-03 04:10:51 +02:00
parent d431540e4d
commit 4f3de3d018
Signed by: steffo
GPG key ID: 6965406171929D01
5 changed files with 14 additions and 14 deletions

View file

@ -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,

View 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}`)
}

View 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")
}

View file

@ -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}`)
}

View file

@ -1,6 +0,0 @@
import { Event } from "@prisma/client";
import useSWR, { SWRResponse } from "swr";
export function useMyEvents(): SWRResponse<Event[]> {
return useSWR("/api/events/mine")
}