Commit f3fbd498 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg Committed by Gijs Hendriksen
Browse files

Get rid of status property of events

parent 729c974a
...@@ -10,14 +10,6 @@ import MemberView from './MemberView'; ...@@ -10,14 +10,6 @@ import MemberView from './MemberView';
import LoadingScreen from './LoadingScreen'; import LoadingScreen from './LoadingScreen';
import { colors } from '../style'; import { colors } from '../style';
const REGISTRATION_NOT_NEEDED = -1;
const REGISTRATION_NOT_YET_OPEN = 0;
// eslint-disable-next-line no-unused-vars
const REGISTRATION_OPEN = 1;
const REGISTRATION_OPEN_NO_CANCEL = 2;
const REGISTRATION_CLOSED = 3;
const REGISTRATION_CLOSED_CANCEL_ONLY = 4;
class Event extends Component { class Event extends Component {
eventDesc = (data) => { eventDesc = (data) => {
const startDate = Moment(data.start).format('D MMM YYYY, HH:mm'); const startDate = Moment(data.start).format('D MMM YYYY, HH:mm');
...@@ -50,7 +42,7 @@ class Event extends Component { ...@@ -50,7 +42,7 @@ class Event extends Component {
</View>, </View>,
); );
if (data.status > REGISTRATION_NOT_NEEDED) { if (event.registration_start !== null || event.registration_end !== null) {
const registrationDeadline = Moment(data.registration_end).format('D MMM YYYY, HH:mm'); const registrationDeadline = Moment(data.registration_end).format('D MMM YYYY, HH:mm');
const cancelDeadline = Moment(data.cancel_deadline).format('D MMM YYYY, HH:mm'); const cancelDeadline = Moment(data.cancel_deadline).format('D MMM YYYY, HH:mm');
...@@ -110,23 +102,33 @@ class Event extends Component { ...@@ -110,23 +102,33 @@ class Event extends Component {
eventInfo = (event) => { eventInfo = (event) => {
let text = ''; let text = '';
if (event.status === REGISTRATION_NOT_YET_OPEN) {
const registrationStart = Moment(event.registration_start).format('D MMM YYYY, HH:m'); const nowDate = new Date();
text = `Aanmelden opent ${registrationStart}`; const startRegDate = new Date(event.registration_start);
} else if (event.status === REGISTRATION_CLOSED || const endRegDate = new Date(event.registration_end);
event.status === REGISTRATION_CLOSED_CANCEL_ONLY) { const cancelDeadlineDate = new Date(event.cancel_deadline);
text = 'Aanmelden is niet meer mogelijk';
} else if (event.status === REGISTRATION_NOT_NEEDED) { const regRequired = event.registration_start !== null || event.registration_end !== null;
text = 'Geen aanmelding vereist'; const regStarted = startRegDate <= nowDate;
const regAllowed = regRequired && endRegDate > nowDate && regStarted;
const afterCancelDeadline = event.cancel_deadline !== null && cancelDeadlineDate <= nowDate;
if (!regRequired) {
text = 'Geen aanmelding vereist.';
if (event.no_registration_message) { if (event.no_registration_message) {
text = event.no_registration_message; text = event.no_registration_message;
} }
} else if (!regStarted) {
const registrationStart = Moment(event.registration_start).format('D MMM YYYY, HH:m');
text = `Aanmelden opent ${registrationStart}.`;
} else if (!regAllowed) {
text = 'Aanmelden is niet meer mogelijk.';
} }
if ((event.status === REGISTRATION_OPEN_NO_CANCEL || event.status === REGISTRATION_CLOSED) && if (afterCancelDeadline) {
event.user_registration !== null && if (text.length > 0) {
!event.user_registration.is_cancelled && event.fine > 0 && text += ' ';
event.user_registration.queue_position === null) { }
text += `Afmelden is niet meer mogelijk zonder de volledige kosten van €${event.fine} te ` + text += `Afmelden is niet meer mogelijk zonder de volledige kosten van €${event.fine} te ` +
'betalen. Let op: je kunt je hierna niet meer aanmelden.'; 'betalen. Let op: je kunt je hierna niet meer aanmelden.';
} }
...@@ -267,7 +269,6 @@ Event.propTypes = { ...@@ -267,7 +269,6 @@ Event.propTypes = {
organiser: PropTypes.number.isRequired, organiser: PropTypes.number.isRequired,
location: PropTypes.string.isRequired, location: PropTypes.string.isRequired,
map_location: PropTypes.string.isRequired, map_location: PropTypes.string.isRequired,
status: PropTypes.number.isRequired,
registration_allowed: PropTypes.bool.isRequired, registration_allowed: PropTypes.bool.isRequired,
has_fields: PropTypes.bool.isRequired, has_fields: PropTypes.bool.isRequired,
registration_start: PropTypes.string, registration_start: PropTypes.string,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment