import { Event } from "@prisma/client" import { useTranslation } from "next-i18next" import { Dispatch, useMemo } from "react" import { KeyedMutator } from "swr" import { UsePromise } from "../../generic/loading/promise" import { ViewContent } from "../../generic/views/content" export type EventsActionViewProps = { data: Event, mutate: KeyedMutator, save: UsePromise, setEditing: Dispatch, } export const EventsActionEdit = ({ data, mutate, save, setEditing }: EventsActionViewProps) => { const { t } = useTranslation() const name = data.name const description = data.description const postcard = data.postcard return (
{ e.preventDefault() save.run() setEditing(false) }}> ( mutate((prev) => ({ ...prev!, name: e.target.value }), { revalidate: false })} placeholder={t("eventNamePlaceholder")} /> ), [mutate, name] ) } content={<> {useMemo( () => (