qpa-client/packages/qpa/Event/CreateEvent.tsx

43 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-08-16 10:30:29 +02:00
import * as React from "react"
2019-10-04 11:31:10 +02:00
import {useMessageCenter} from "qpa-message-center"
2019-10-06 17:08:47 +02:00
import {useAppContext} from "../App/Context/AppContext"
2019-08-16 10:30:29 +02:00
import CreateEventMutation from "./CreateEventMutation"
2019-05-25 10:36:18 +02:00
import EventForm, {EventFormData} from "./EventForm"
2019-05-24 19:59:54 +02:00
const CreateEvent = () => {
2019-08-16 10:30:29 +02:00
const { addMessage } = useMessageCenter()
2019-10-07 17:06:08 +02:00
const { supportedLocales } = useAppContext()
2019-08-16 10:30:29 +02:00
return <CreateEventMutation onCompleted={() => {
addMessage({
type: "success",
text: "Event was created successfully",
})
}}>
2019-05-24 19:59:54 +02:00
{
2019-06-04 14:07:04 +02:00
(createEvent, { loading }) => (
<EventForm
2019-10-07 17:06:08 +02:00
locales={supportedLocales}
2019-06-04 14:07:04 +02:00
loading={loading}
onSubmit={(values: EventFormData) => {
2019-05-25 10:36:18 +02:00
createEvent({
variables: {
input: {
2019-10-06 11:30:10 +02:00
infos: values.infos,
2019-06-04 14:03:51 +02:00
location: values.location,
2019-05-25 10:36:18 +02:00
time: {
2019-06-04 14:03:51 +02:00
...values.time,
2019-08-16 10:30:29 +02:00
timeZone: "Europe/Madrid",
2019-05-25 10:36:18 +02:00
},
2019-08-16 10:30:29 +02:00
status: "confirmed",
meta: values.meta,
},
},
2019-05-25 10:36:18 +02:00
})
}} />
)}
2019-05-24 19:59:54 +02:00
</CreateEventMutation>
}
2019-05-25 10:36:18 +02:00
export default CreateEvent