From 3877f4f7208bd38afd9b20625a066db77dddafa2 Mon Sep 17 00:00:00 2001 From: Thai <42761684+thaigillespie@users.noreply.github.com> Date: Wed, 16 Sep 2020 16:59:14 -0700 Subject: [PATCH] Create Event now works properly and as intended. (#165) * Tsconfig changes again : ( * Fixed merge issue * Create Event now works properly and as intended. After creating an event, the browser redirects to the newly created event's EventDetails page. Note that fbURL and canvaURL both have to either be empty or filled out with a proper URL string, otherwise a status code 400 will be sent from the backend server. * Added url validation to create event form's schema's fbURL + canvaURL. * Changed process.env in src/index.js to using config. --- .../components/EventCreationForm/schema.ts | 6 ++- src/pages/EventCreationPage/index.tsx | 11 +++- src/services/api/.openapi-generator/FILES | 52 +++++++++---------- src/services/api/.openapi-generator/VERSION | 2 +- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/pages/EventCreationPage/components/EventCreationForm/schema.ts b/src/pages/EventCreationPage/components/EventCreationForm/schema.ts index 899cc68b..1df403e4 100644 --- a/src/pages/EventCreationPage/components/EventCreationForm/schema.ts +++ b/src/pages/EventCreationPage/components/EventCreationForm/schema.ts @@ -8,8 +8,10 @@ const schema = Yup.object({ location: Yup.string().required('Required'), description: Yup.string().required('Required'), hosts: Yup.array().required('Required'), - fbURL: Yup.string(), - canvaURL: Yup.string(), + fbURL: Yup.string().url('Please either enter a valid URL or leave it blank'), + canvaURL: Yup.string().url( + 'Please either enter a valid URL or leave it blank' + ), }); export default schema; diff --git a/src/pages/EventCreationPage/index.tsx b/src/pages/EventCreationPage/index.tsx index b5b48ed4..dba47bdc 100644 --- a/src/pages/EventCreationPage/index.tsx +++ b/src/pages/EventCreationPage/index.tsx @@ -17,7 +17,16 @@ function EventCreationPage(): JSX.Element { values: EventRequest, setSubmitting: (_: boolean) => void ) => { - const createdEvent = await createEvent(values); + const submission = { + ...values, + hosts: values.hosts.map(host => { + return { id: host.id }; + }), + fbURL: values.fbURL === '' ? undefined : values.fbURL, + canvaURL: values.canvaURL === '' ? undefined : values.canvaURL, + }; + + const createdEvent = await createEvent(submission); const { id } = createdEvent; setSubmitting(false); diff --git a/src/services/api/.openapi-generator/FILES b/src/services/api/.openapi-generator/FILES index 426df699..dfb244f0 100644 --- a/src/services/api/.openapi-generator/FILES +++ b/src/services/api/.openapi-generator/FILES @@ -1,28 +1,28 @@ -apis/AuthApi.ts -apis/EventApi.ts -apis/UserApi.ts -apis/index.ts +apis\AuthApi.ts +apis\EventApi.ts +apis\UserApi.ts +apis\index.ts index.ts -models/AppUserEventRequest.ts -models/AppUserEventResponse.ts -models/AppUserInductionClass.ts -models/AppUserNameResponse.ts -models/AppUserPKPayload.ts -models/AppUserPostRequest.ts -models/AppUserProfileResponse.ts -models/AppUserResponse.ts -models/AppUserRolesResponse.ts -models/AppUserSignupRequest.ts -models/AttendanceResponse.ts -models/BaseEventPayload.ts -models/EventAttendanceResponse.ts -models/EventRSVPResponse.ts -models/EventRequest.ts -models/EventResponse.ts -models/MultipleAppUserResponse.ts -models/MultipleEventResponse.ts -models/MultipleUserNameResponse.ts -models/MultipleUserQuery.ts -models/RSVPResponse.ts -models/index.ts +models\AppUserEventRequest.ts +models\AppUserEventResponse.ts +models\AppUserInductionClass.ts +models\AppUserNameResponse.ts +models\AppUserPKPayload.ts +models\AppUserPostRequest.ts +models\AppUserProfileResponse.ts +models\AppUserResponse.ts +models\AppUserRolesResponse.ts +models\AppUserSignupRequest.ts +models\AttendanceResponse.ts +models\BaseEventPayload.ts +models\EventAttendanceResponse.ts +models\EventRSVPResponse.ts +models\EventRequest.ts +models\EventResponse.ts +models\MultipleAppUserResponse.ts +models\MultipleEventResponse.ts +models\MultipleUserNameResponse.ts +models\MultipleUserQuery.ts +models\RSVPResponse.ts +models\index.ts runtime.ts diff --git a/src/services/api/.openapi-generator/VERSION b/src/services/api/.openapi-generator/VERSION index 1a487e1a..8836c812 100644 --- a/src/services/api/.openapi-generator/VERSION +++ b/src/services/api/.openapi-generator/VERSION @@ -1 +1 @@ -5.0.0-beta2 \ No newline at end of file +5.0.0-beta \ No newline at end of file