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) validateEventEnd(eventInput.eventStart, eventInput.eventEnd)
params.eventEnd = 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!') throw new UserInputError('Event venue must be present if event location is given!')
} }
params.eventVenue = eventInput.eventVenue params.eventVenue = eventInput.eventVenue
params.eventLocation = eventInput.eventLocation params.eventLocationName = eventInput.eventLocationName
params.eventIsOnline = !!eventInput.eventIsOnline params.eventIsOnline = !!eventInput.eventIsOnline
} }
delete params.eventInput delete params.eventInput
let locationName let locationName
if (params.eventLocation) { if (params.eventLocationName) {
params.eventLocationName = params.eventLocation locationName = params.eventLocationName
locationName = params.eventLocation
} else { } else {
params.eventLocationName = null params.eventLocationName = null
locationName = null locationName = null
} }
delete params.eventLocation
return locationName 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 () => { it('throws an error', async () => {
const now = new Date() const now = new Date()
await expect( await expect(
@ -516,7 +516,7 @@ describe('CreatePost', () => {
postType: 'Event', postType: 'Event',
eventInput: { eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), 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 () => { it('has label "Event" set', async () => {
const now = new Date() const now = new Date()
await expect( await expect(
@ -568,7 +568,7 @@ describe('CreatePost', () => {
postType: 'Event', postType: 'Event',
eventInput: { eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
eventLocation: 'Leipzig', eventLocationName: 'Leipzig',
eventVenue: 'Connewitzer Kreuz', 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 () => { it('throws an error', async () => {
const now = new Date() const now = new Date()
await expect( await expect(
@ -832,7 +832,7 @@ describe('UpdatePost', () => {
postType: 'Event', postType: 'Event',
eventInput: { eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), 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 () => { it('has label "Event" set', async () => {
const now = new Date() const now = new Date()
await expect( 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 () => { it('has label "Event" set', async () => {
const now = new Date() const now = new Date()
await expect( await expect(
@ -883,7 +883,7 @@ describe('UpdatePost', () => {
postType: 'Event', postType: 'Event',
eventInput: { eventInput: {
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
eventLocation: 'Leipzig', eventLocationName: 'Leipzig',
eventVenue: 'Connewitzer Kreuz', eventVenue: 'Connewitzer Kreuz',
}, },
}, },

View File

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

View File

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

View File

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