mirror of
https://github.com/quepasaevents/qpa-client.git
synced 2023-12-14 05:33:02 +01:00
Show messages on editing an event
This commit is contained in:
parent
1da166f60f
commit
6126469e4e
2 changed files with 21 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
|||
import { Spinner } from "qpa-components"
|
||||
import { useMessageCenter } from "qpa-message-center"
|
||||
import * as React from "react"
|
||||
import intl from "react-intl-universal"
|
||||
import { useAppContext } from "../App/Context/AppContext"
|
||||
import removeTypename from "../App/remove-typename"
|
||||
import useEditEventMutation from "./useEditEventMutation"
|
||||
|
@ -13,13 +15,23 @@ interface Props {
|
|||
|
||||
const EditEvent = (props: Props) => {
|
||||
const { supportedLocales } = useAppContext()
|
||||
const { addMessage } = useMessageCenter()
|
||||
|
||||
const [
|
||||
deleteEvent,
|
||||
{ loading: deleteEventLoading },
|
||||
] = useDeleteEventMutation()
|
||||
const [editEvent, { loading: editLoading }] = useEditEventMutation({
|
||||
onCompleted: () => {
|
||||
alert("Event edited successfully")
|
||||
onCompleted: () =>
|
||||
addMessage({
|
||||
type: "success",
|
||||
text: intl.get("event-edit-success"),
|
||||
}),
|
||||
onError: error => {
|
||||
addMessage({
|
||||
type: "error",
|
||||
text: intl.get("event-edit-error", { message: error.message }),
|
||||
})
|
||||
},
|
||||
})
|
||||
const { data, loading, error } = useGetEventQuery({
|
||||
|
@ -30,7 +42,7 @@ const EditEvent = (props: Props) => {
|
|||
return <Spinner />
|
||||
}
|
||||
if (error) {
|
||||
return <p>{ error.message }</p>
|
||||
return <p>{error.message}</p>
|
||||
}
|
||||
const event = removeTypename(data.event)
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
"must-provide-location-address": "Please provide name of the venue",
|
||||
"must-provide-location-name": "Please provide address of the venue",
|
||||
"event-create-success": "Event created successfully",
|
||||
"event-create-error": "There was an error: {message}"
|
||||
"event-create-error": "There was an error: {message}",
|
||||
"event-edit-success": "Event was changed successfully",
|
||||
"event-edit-error": "Error on chaging event {error}"
|
||||
},
|
||||
"es": {
|
||||
"EVENT_CREATED_SUCCESSFULLY": "Evento ha sido creado correctamente",
|
||||
|
@ -51,6 +53,8 @@
|
|||
"must-provide-location-address": "Escribe el nombre del lugar",
|
||||
"must-provide-location-name": "Escribe la dirección del lugar",
|
||||
"event-create-success": "Evento creado correctamente",
|
||||
"event-create-error": "Habido un error: {message}"
|
||||
"event-create-error": "Habido un error: {message}",
|
||||
"event-edit-success": "Evento correctamente modificado",
|
||||
"event-edit-error": "Error al modificar el evento {error}"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue