1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2025-01-10 15:59:44 +00:00
festa/components/events/actions/edit.tsx
2022-07-19 20:32:13 +02:00

45 lines
1.3 KiB
TypeScript

import { Event } from "@prisma/client"
import { useMemo } from "react"
import { KeyedMutator } from "swr"
import { ViewContent } from "../../generic/views/content"
export type EventsActionViewProps = {
data: Event,
mutate: KeyedMutator<Event>,
}
export const EventsActionEdit = ({ data, mutate }: EventsActionViewProps) => {
const name = data.name
const description = data.description
return (
<ViewContent
title={
useMemo(
() => (
<input
type="text"
value={name}
onChange={e => mutate({ ...data, name: e.target.value }, { revalidate: false })}
/>
),
[mutate, name]
)
}
content={<>
{useMemo(
() => (
<textarea
rows={12}
value={description}
onChange={e => mutate({ ...data, description: e.target.value }, { revalidate: false })}
/>
),
[mutate, description]
)}
</>}
/>
)
}