Skip to content

Commit 12081e0

Browse files
authored
events bug fixes (#100)
1 parent 0b13478 commit 12081e0

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/ui/pages/events/ManageEvent.page.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ export const ManageEventPage: React.FC = () => {
9292
getEvent();
9393
}, [eventId, isEditing]);
9494

95+
const startDate = new Date().setMinutes(0);
9596
const form = useForm<EventPostRequest>({
9697
validate: zodResolver(requestBodySchema),
9798
initialValues: {
9899
title: '',
99100
description: '',
100-
start: new Date(),
101-
end: new Date(new Date().valueOf() + 3.6e6), // 1 hr later
101+
start: new Date(startDate),
102+
end: new Date(startDate + 3.6e6), // 1 hr later
102103
location: 'ACM Room (Siebel CS 1104)',
103104
locationLink: 'https://maps.app.goo.gl/dwbBBBkfjkgj8gvA8',
104105
host: 'ACM',
@@ -108,21 +109,17 @@ export const ManageEventPage: React.FC = () => {
108109
paidEventId: undefined,
109110
},
110111
});
112+
useEffect(() => {
113+
if (form.values.end && form.values.end <= form.values.start) {
114+
form.setFieldValue('end', new Date(form.values.start.getTime() + 3.6e6)); // 1 hour after the start date
115+
}
116+
}, [form.values.start]);
111117

112-
const checkPaidEventId = async (paidEventId: string) => {
113-
try {
114-
const merchEndpoint = getRunEnvironmentConfig().ServiceConfiguration.merch.baseEndpoint;
115-
const ticketEndpoint = getRunEnvironmentConfig().ServiceConfiguration.tickets.baseEndpoint;
116-
const paidEventHref = paidEventId.startsWith('merch:')
117-
? `${merchEndpoint}/api/v1/merch/details?itemid=${paidEventId.slice(6)}`
118-
: `${ticketEndpoint}/api/v1/event/details?eventid=${paidEventId}`;
119-
const response = await api.get(paidEventHref);
120-
return Boolean(response.status < 299 && response.status >= 200);
121-
} catch (error) {
122-
console.error('Error validating paid event ID:', error);
123-
return false;
118+
useEffect(() => {
119+
if (form.values.locationLink === '') {
120+
form.setFieldValue('locationLink', undefined);
124121
}
125-
};
122+
}, [form.values.locationLink]);
126123

127124
const handleSubmit = async (values: EventPostRequest) => {
128125
try {

src/ui/pages/events/ViewEvents.page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export const ViewEventsPage: React.FC = () => {
7979
<Table.Td>
8080
{event.title} {event.featured ? <Badge color="green">Featured</Badge> : null}
8181
</Table.Td>
82-
<Table.Td>{dayjs(event.start).format('MMM D YYYY hh:mm')}</Table.Td>
83-
<Table.Td>{event.end ? dayjs(event.end).format('MMM D YYYY hh:mm') : 'N/A'}</Table.Td>
82+
<Table.Td>{dayjs(event.start).format('MMM D YYYY hh:mm A')}</Table.Td>
83+
<Table.Td>{event.end ? dayjs(event.end).format('MMM D YYYY hh:mm A') : 'N/A'}</Table.Td>
8484
<Table.Td>
8585
{event.locationLink ? (
8686
<Anchor target="_blank" size="sm" href={event.locationLink}>

0 commit comments

Comments
 (0)