mirror of
https://github.com/quepasaevents/qpa-client.git
synced 2023-12-14 05:33:02 +01:00
Updating event works
This commit is contained in:
parent
93531421fa
commit
33fbe6acf8
6 changed files with 27 additions and 10 deletions
|
@ -23,6 +23,7 @@ const graphqlClient = new ApolloClient({
|
|||
connectToDevTools: true,
|
||||
link: httpLink,
|
||||
cache: new InMemoryCache({
|
||||
addTypename: false,
|
||||
dataIdFromObject: (o: IdGetterObj) => {
|
||||
if (o.id && o.__typename) {
|
||||
return `${o.__typename}_${o.id}`
|
||||
|
|
|
@ -10,8 +10,8 @@ interface Props {
|
|||
const EditEvent = (props: Props) => (
|
||||
<EditEventMutation>
|
||||
{
|
||||
(editEvent, { loading }) => (
|
||||
<GetEventQuery skip={!props.eventId}>
|
||||
(editEvent, { loading: editLoading }) => (
|
||||
<GetEventQuery skip={!props.eventId} variables={{id: props.eventId}}>
|
||||
{
|
||||
({data, error, loading}) => {
|
||||
if (loading) {
|
||||
|
@ -34,7 +34,7 @@ const EditEvent = (props: Props) => (
|
|||
})
|
||||
}}
|
||||
values={{
|
||||
contact: data.event.contact,
|
||||
meta: data.event.meta,
|
||||
time: data.event.time,
|
||||
location: data.event.location,
|
||||
info: data.event.info,
|
||||
|
|
|
@ -21,6 +21,9 @@ export const EventFragment = gql`
|
|||
recurrence
|
||||
}
|
||||
status
|
||||
meta {
|
||||
tags
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
|
@ -45,6 +48,9 @@ export interface ContactData {
|
|||
languages: string[]
|
||||
name: string
|
||||
}
|
||||
export interface EventMetaData {
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
export interface EventData {
|
||||
id: string
|
||||
|
@ -56,6 +62,7 @@ export interface EventData {
|
|||
}
|
||||
time: EventTimeData
|
||||
status: EventStatus
|
||||
meta: EventMetaData
|
||||
}
|
||||
|
||||
interface Data {
|
||||
|
@ -72,7 +79,7 @@ const query = gql`
|
|||
`
|
||||
|
||||
interface Variables {
|
||||
id: number
|
||||
id: string
|
||||
}
|
||||
|
||||
export default class GetEventQuery extends Query<Data, Variables> {
|
||||
|
|
|
@ -39,7 +39,8 @@ const config: webpack.Configuration = {
|
|||
devtool: '@source-map',
|
||||
output: {
|
||||
path: path.resolve(__dirname, './dist'),
|
||||
filename: 'bundle.js'
|
||||
filename: 'bundle.js',
|
||||
publicPath: '/'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
title: "blabla",
|
||||
|
|
|
@ -41,6 +41,11 @@ type CalendarEvent {
|
|||
status: EventStatus!
|
||||
location: Location!
|
||||
occurrences: [EventOccurrence]
|
||||
meta: EventMeta
|
||||
}
|
||||
|
||||
type EventMeta {
|
||||
tags: [String]!
|
||||
}
|
||||
|
||||
type EventOccurrence {
|
||||
|
|
|
@ -87,7 +87,6 @@ const resolvers: ResolverMap = {
|
|||
_,
|
||||
{ input }: GQL.IUpdateEventOnMutationArguments,
|
||||
context: Context,
|
||||
info
|
||||
) => {
|
||||
const {id, ...fields} = input
|
||||
|
||||
|
@ -116,12 +115,16 @@ const resolvers: ResolverMap = {
|
|||
})
|
||||
)
|
||||
}
|
||||
if (info.location) {
|
||||
event.location = info.location
|
||||
if (input.location) {
|
||||
event.location = input.location
|
||||
}
|
||||
if (info.meta) {
|
||||
event.meta = info.meta
|
||||
if (input.meta) {
|
||||
event.meta = input.meta
|
||||
}
|
||||
if (input.location) {
|
||||
event.location = input.location
|
||||
}
|
||||
return event.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue