From d40d001147dbacc3299778be4ea31a79511babfc Mon Sep 17 00:00:00 2001 From: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com> Date: Sat, 4 Mar 2023 08:57:18 +0530 Subject: [PATCH] Fix create event mutation [Fixes part of #1101 in Talawa-API] (#523) * Add format fix * Fix updation of posts --- src/components/EventListCard/EventListCard.tsx | 12 ++++++------ .../OrganizationEvents/OrganizationEvents.tsx | 17 +++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/components/EventListCard/EventListCard.tsx b/src/components/EventListCard/EventListCard.tsx index 18acc6758f..11c378679f 100644 --- a/src/components/EventListCard/EventListCard.tsx +++ b/src/components/EventListCard/EventListCard.tsx @@ -37,8 +37,8 @@ function EventListCard(props: EventListCardProps): JSX.Element { title: '', eventdescrip: '', location: '', - startTime: '', - endTime: '', + startTime: '08:00:00', + endTime: '18:00:00', }); useEffect(() => { @@ -46,8 +46,8 @@ function EventListCard(props: EventListCardProps): JSX.Element { title: props.eventName, eventdescrip: props.eventDescription, location: props.eventLocation, - startTime: props.startTime, - endTime: props.endTime, + startTime: props.startTime?.split('.')[0] || '08:00:00', + endTime: props.endTime?.split('.')[0] || '18:00:00', }); setAllDayChecked(props.allDay); @@ -92,8 +92,8 @@ function EventListCard(props: EventListCardProps): JSX.Element { isRegisterable: registrablechecked, allDay: alldaychecked, location: formState.location, - startTime: formState.startTime, - endTime: formState.endTime, + startTime: !alldaychecked ? formState.startTime + 'Z' : null, + endTime: !alldaychecked ? formState.endTime + 'Z' : null, }, }); diff --git a/src/screens/OrganizationEvents/OrganizationEvents.tsx b/src/screens/OrganizationEvents/OrganizationEvents.tsx index 982224c4c6..833431f0b7 100644 --- a/src/screens/OrganizationEvents/OrganizationEvents.tsx +++ b/src/screens/OrganizationEvents/OrganizationEvents.tsx @@ -18,6 +18,7 @@ import { CREATE_EVENT_MUTATION } from 'GraphQl/Mutations/mutations'; import { RootState } from 'state/reducers'; import PaginationList from 'components/PaginationList/PaginationList'; import debounce from 'utils/debounce'; +import dayjs from 'dayjs'; function OrganizationEvents(): JSX.Element { const { t } = useTranslation('translation', { @@ -43,8 +44,8 @@ function OrganizationEvents(): JSX.Element { eventdescrip: '', date: '', location: '', - startTime: '', - endTime: '', + startTime: '08:00:00', + endTime: '18:00:00', }); const currentUrl = window.location.href.split('=')[1]; @@ -83,12 +84,12 @@ function OrganizationEvents(): JSX.Element { recurring: recurringchecked, isRegisterable: registrablechecked, organizationId: currentUrl, - startDate: startDate?.toDateString(), - endDate: endDate?.toDateString(), + startDate: dayjs(startDate).format('YYYY-MM-DD'), + endDate: dayjs(endDate).format('YYYY-MM-DD'), allDay: alldaychecked, location: formState.location, - startTime: formState.startTime, - endTime: formState.endTime, + startTime: !alldaychecked ? formState.startTime + 'Z' : null, + endTime: !alldaychecked ? formState.endTime + 'Z' : null, }, }); @@ -101,8 +102,8 @@ function OrganizationEvents(): JSX.Element { eventdescrip: '', date: '', location: '', - startTime: '', - endTime: '', + startTime: '08:00:00', + endTime: '18:00:00', }); } } catch (error: any) {