Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop event editor from breaking in dev #3665

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions app/reducers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ export default createEntityReducer({
function transformEvent(event: EventType) {
return {
...event,
startTime: moment(event.startTime),
endTime: moment(event.endTime),
startTime: event.startTime && moment(event.startTime).toISOString(),
endTime: event.endTime && moment(event.endTime).toISOString(),
activationTime:
event.activationTime !== null ? moment(event.activationTime) : null,
mergeTime: event.mergeTime && moment(event.mergeTime),
event.activationTime && moment(event.activationTime).toISOString(),
mergeTime: event.mergeTime && moment(event.mergeTime).toISOString(),
useCaptcha: config.environment === 'ci' ? false : event.useCaptcha,
};
}
Expand Down Expand Up @@ -208,7 +208,9 @@ export const selectUpcomingEvents = createSelector(selectEvents, (events) =>
events.filter((event) => event.isUsersUpcoming)
);
export const selectSortedEvents = createSelector(selectEvents, (events) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be out of scope, but could it be possible to add some types to these functions, to make it easier to maintain in the future?

[...events].sort((a, b) => a.startTime.unix() - b.startTime.unix())
[...events].sort(
(a, b) => moment(a.startTime).unix() - moment(b.startTime).unix()
)
);
export const selectEventById = createSelector(
(state) => state.events.byId,
Expand Down
6 changes: 3 additions & 3 deletions app/routes/events/components/EventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const groupEvents = ({
}): GroupedEvents => {
const nextWeek = moment().add(1, 'week');
const groups = {
currentWeek: (event) => event[field].isSame(moment(), 'week'),
nextWeek: (event) => event[field].isSame(nextWeek, 'week'),
later: (event) => event[field].isAfter(nextWeek),
currentWeek: (event) => moment(event[field]).isSame(moment(), 'week'),
nextWeek: (event) => moment(event[field]).isSame(nextWeek, 'week'),
later: (event) => moment(event[field]).isAfter(nextWeek),
};
return events.reduce((result, event) => {
for (const groupName in groups) {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/events/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { pick, sumBy, find } from 'lodash';
import moment from 'moment-timezone';
import config from 'app/config';
import type {
TransformEvent,
Event,
Expand Down Expand Up @@ -236,8 +237,7 @@ export const transformEvent = (data: TransformEvent) => ({
unregistrationDeadline: calculateUnregistrationDeadline(data),
unregistrationDeadlineHours: calculateUnregistrationDeadlineHours(data),
pools: calculatePools(data),
useCaptcha: true,
// always use Captcha, this blocks the use of CLI
useCaptcha: config.environment === 'ci' ? false : data.useCaptcha,
ivarnakken marked this conversation as resolved.
Show resolved Hide resolved
youtubeUrl: data.youtubeUrl,
mazemapPoi: calculateMazemapPoi(data),
feedbackDescription:
Expand Down
4 changes: 3 additions & 1 deletion app/routes/overview/components/CompactEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import moment from 'moment-timezone';
import { Component } from 'react';
import { Link } from 'react-router-dom';
import { Flex } from 'app/components/Layout';
Expand All @@ -18,7 +19,8 @@ export default class CompactEvents extends Component<Props> {
return events
.filter(
(event) =>
event.endTime.isAfter() && eventTypes.includes(event.eventType)
moment(event.endTime).isAfter() &&
eventTypes.includes(event.eventType)
)
.slice(0, 5)
.map((event, key) => (
Expand Down
3 changes: 2 additions & 1 deletion app/routes/surveys/EditSurveyRoute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { push } from 'connected-react-router';
import moment from 'moment-timezone';
import qs from 'qs';
import { connect } from 'react-redux';
import { compose } from 'redux';
Expand Down Expand Up @@ -54,7 +55,7 @@ const mapStateToProps = (state, props) => {
...template,
title: survey.title || template.title,
event: initialEvent,
activeFrom: survey.event && survey.event.endTime,
activeFrom: moment(survey.event?.endTime),
};
} else {
initialValues = {
Expand Down
2 changes: 1 addition & 1 deletion app/utils/eventStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const eventStatus = (event: Event, loggedIn = false): string => {
case 'NORMAL':
case 'INFINITE':
// Check if event has been
if (event.startTime > moment()) {
if (moment(event.startTime) > moment()) {
return `${registrationCount}/${totalCapacity || '∞'} påmeldte`;
}

Expand Down