Backend removed eventLocation, frontend fixes

This commit is contained in:
elweyn 2023-05-17 22:12:08 +02:00
parent df86812fc0
commit 5544f453a6
5 changed files with 15 additions and 18 deletions

View File

@ -9,23 +9,21 @@ export const validateEventParams = (params) => {
validateEventEnd(eventInput.eventStart, eventInput.eventEnd)
params.eventEnd = eventInput.eventEnd
}
if (eventInput.eventLocation && !eventInput.eventVenue) {
if (eventInput.eventLocationName && !eventInput.eventVenue) {
throw new UserInputError('Event venue must be present if event location is given!')
}
params.eventVenue = eventInput.eventVenue
params.eventLocation = eventInput.eventLocation
params.eventLocationName = eventInput.eventLocationName
params.eventIsOnline = !!eventInput.eventIsOnline
}
delete params.eventInput
let locationName
if (params.eventLocation) {
params.eventLocationName = params.eventLocation
locationName = params.eventLocation
if (params.eventLocationName) {
locationName = params.eventLocationName
} else {
params.eventLocationName = null
locationName = null
}
delete params.eventLocation
return locationName
}

View File

@ -505,7 +505,7 @@ describe('CreatePost', () => {
})
})
describe('event location is given but event venue is missing', () => {
describe('event location name is given but event venue is missing', () => {
it('throws an error', async () => {
const now = new Date()
await expect(
@ -516,7 +516,7 @@ describe('CreatePost', () => {
postType: 'Event',
eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
eventLocation: 'Berlin',
eventLocationName: 'Berlin',
},
},
}),
@ -557,7 +557,7 @@ describe('CreatePost', () => {
})
})
describe('valid event input with location', () => {
describe('valid event input with location name', () => {
it('has label "Event" set', async () => {
const now = new Date()
await expect(
@ -568,7 +568,7 @@ describe('CreatePost', () => {
postType: 'Event',
eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
eventLocation: 'Leipzig',
eventLocationName: 'Leipzig',
eventVenue: 'Connewitzer Kreuz',
},
},
@ -821,7 +821,7 @@ describe('UpdatePost', () => {
})
})
describe('event location is given but event venue is missing', () => {
describe('event location name is given but event venue is missing', () => {
it('throws an error', async () => {
const now = new Date()
await expect(
@ -832,7 +832,7 @@ describe('UpdatePost', () => {
postType: 'Event',
eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
eventLocation: 'Berlin',
eventLocationName: 'Berlin',
},
},
}),
@ -846,7 +846,7 @@ describe('UpdatePost', () => {
})
})
describe('valid event input without location', () => {
describe('valid event input without location name', () => {
it('has label "Event" set', async () => {
const now = new Date()
await expect(
@ -872,7 +872,7 @@ describe('UpdatePost', () => {
})
})
describe('valid event input with location', () => {
describe('valid event input with location name', () => {
it('has label "Event" set', async () => {
const now = new Date()
await expect(
@ -883,7 +883,7 @@ describe('UpdatePost', () => {
postType: 'Event',
eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
eventLocation: 'Leipzig',
eventLocationName: 'Leipzig',
eventVenue: 'Connewitzer Kreuz',
},
},

View File

@ -194,7 +194,6 @@ input _PostInput {
input _EventInput {
eventStart: String!
eventEnd: String
eventLocation: String
eventVenue: String
eventLocationName: String
eventIsOnline: Boolean

View File

@ -247,7 +247,7 @@ export default {
eventLocation: eventLocation || '',
eventLocationName: eventLocationName || '',
eventVenue: eventVenue || '',
eventIsOnline: eventIsOnline || true,
eventIsOnline: eventIsOnline || false,
},
formSchema: {
title: { required: true, min: 3, max: 100 },
@ -284,7 +284,6 @@ export default {
if (this.creatEvent) {
return {
eventStart: this.formData.eventStart,
eventLocation: this.formData.eventLocation,
eventVenue: this.formData.eventVenue,
eventEnd: this.formData.eventEnd,
eventIsOnline: this.formData.eventIsOnline,

View File

@ -46,6 +46,7 @@ export default () => {
}
eventStart
eventVenue
eventLocationName
eventLocation {
lng
lat