diff --git a/src/app.js b/src/app.js index 37becbf8..99cac405 100644 --- a/src/app.js +++ b/src/app.js @@ -12,7 +12,6 @@ import Index from './components/Index' import Admin from './admin' import Auth from './modules/auth' -import Cal from './modules/cal' import Varer from './modules/varer' import Voucher from './modules/voucher' import Z from './modules/z' @@ -35,7 +34,6 @@ const App = () => ( {Admin} {Auth} - {Cal} {Varer} {Voucher} {Z} diff --git a/src/components/Nav.js b/src/components/Nav.js index 334ae87b..5082ff01 100644 --- a/src/components/Nav.js +++ b/src/components/Nav.js @@ -72,9 +72,6 @@ class Nav extends React.Component { Modules Statistics - - Overview - Overview Use vouchers diff --git a/src/modules/cal/actionTypes.js b/src/modules/cal/actionTypes.js deleted file mode 100644 index c90fec42..00000000 --- a/src/modules/cal/actionTypes.js +++ /dev/null @@ -1,13 +0,0 @@ -import keyMirror from 'fbjs/lib/keyMirror' - -export default keyMirror({ - RECEIVE_LIST_START: null, - RECEIVE_LIST_SUCCESS: null, - RECEIVE_LIST_FAILURE: null, - RECEIVE_EVENT_START: null, - RECEIVE_EVENT_SUCCESS: null, - RECEIVE_EVENT_FAILURE: null, - RECEIVE_SEMESTERS_START: null, - RECEIVE_SEMESTERS_SUCCESS: null, - RECEIVE_SEMESTERS_FAILURE: null, -}) diff --git a/src/modules/cal/actions.js b/src/modules/cal/actions.js deleted file mode 100644 index fefe1899..00000000 --- a/src/modules/cal/actions.js +++ /dev/null @@ -1,30 +0,0 @@ -import reactor from './../../reactor' -import {dispatchAsync} from '../../utils/FluxUtils' - -import CalendarService from './services/CalendarService' - -import actionTypes from './actionTypes' - -export function fetchList(year, semester) { - dispatchAsync(CalendarService.getEventList(year, semester), { - request: actionTypes.RECEIVE_LIST_START, - success: actionTypes.RECEIVE_LIST_SUCCESS, - failure: actionTypes.RECEIVE_LIST_FAILURE - }, {year, semester}) -} - -export function fetchEvent(eventId) { - dispatchAsync(CalendarService.getEvent(eventId), { - request: actionTypes.RECEIVE_EVENT_START, - success: actionTypes.RECEIVE_EVENT_SUCCESS, - failure: actionTypes.RECEIVE_EVENT_FAILURE - }, {eventId}) -} - -export function fetchSemesters() { - dispatchAsync(CalendarService.getSemesters(), { - request: actionTypes.RECEIVE_SEMESTERS_START, - success: actionTypes.RECEIVE_SEMESTERS_SUCCESS, - failure: actionTypes.RECEIVE_SEMESTERS_FAILURE - }) -} diff --git a/src/modules/cal/components/Event.js b/src/modules/cal/components/Event.js deleted file mode 100644 index 8cc038c1..00000000 --- a/src/modules/cal/components/Event.js +++ /dev/null @@ -1,80 +0,0 @@ -import moment from '../../../moment' -import React from 'react' -import { Link } from 'react-router-dom' -import { connect } from 'nuclear-js-react-addons-chefsplate' - -import {api} from '../../../api' - -import * as actions from '../actions' -import * as getters from '../getters' - -import PageLoader from '../../../components/PageLoader' - -export default -@connect(props => ({ - event: getters.event -})) -class Event extends React.Component { - componentDidMount() { - actions.fetchEvent(this.props.match.params.eventId) - } - - renderIncomplete() { - return ( - - ) - } - - render() { - let event = this.props.event.get('data') - if (event === null) { - return this.renderIncomplete() - } - - event = event.toJS() - - let start, end - if (event.is_allday) { - start = moment.utc(event.start).format('dddd DD. MMM YYYY') - end = moment.utc(event.end).format('dddd DD. MMM YYYY') - } else { - start = moment(event.start).format('dddd DD. MMM YYYY HH:mm') - end = moment(event.end).format('dddd DD. MMM YYYY HH:mm') - } - - return ( -
-

Arrangement: {event.title}

- -

Tilbake

- -

{start === end ? start : `${start} til ${end}`}

- - {event.description !== '' ? ( -

Beskrivelse: {event.description}

- ) : ''} - -
-
In Escape?
-
{event.in_escape ? 'Yes' : 'No'}
-
Cancelled?
-
{event.is_cancelled ? 'Yes' : 'No'}
-
External event?
-
{event.is_external ? 'Yes' : 'No'}
-
Public?
-
{event.is_published ? 'Yes' : 'No'}
-
Link
-
{event.link !== '' ? event.link : 'ingen'}
-
Organizer
-
{event.organizer ? event.organizer.realname : 'ingen'}
-
- -

.ics

-
- ) - } -} diff --git a/src/modules/cal/components/List.js b/src/modules/cal/components/List.js deleted file mode 100644 index 0dc00cb0..00000000 --- a/src/modules/cal/components/List.js +++ /dev/null @@ -1,116 +0,0 @@ -import moment from '../../../moment' -import React from 'react' -import { Link } from 'react-router-dom' -import { connect } from 'nuclear-js-react-addons-chefsplate' - -import {api} from '../../../api' -import * as getters from '../getters' -import * as actions from '../actions' - -import Loader from '../../../components/Loader' -import Tag from './Tag' - -export default -@connect(props => ({ - list: getters.list, - semesters: getters.semesters, -})) -class List extends React.Component { - componentDidMount() { - actions.fetchList(this.props.list.get('year'), this.props.list.get('semester')) - actions.fetchSemesters() - } - - handleSemester(semester, event) { - event.preventDefault() - actions.fetchList(semester.year, parseInt(semester.semester.substring(0, 1))) - } - - renderSemesters() { - if (this.props.semesters.get('items').isEmpty()) { - return - } - - return ( - - ) - } - - renderList() { - if (this.props.list.get('items').isEmpty()) { - return - } - - return ( - - - - - - - - - {this.props.list.get('items').toList().toJS().map((event) => { - let start, end - if (event.is_allday) { - start = moment.utc(event.start).format('ddd D. MMM YYYY') - end = moment.utc(event.end).format('ddd D. MMM YYYY') - } else { - start = moment(event.start).format('ddd D. MMM YYYY HH:mm') - end = moment(event.end).format('ddd D. MMM YYYY HH:mm') - } - - let duration = start === end ? start : `${start} - ${end}` - - return ( - - - - - ) - })} - -
TitleDuration
- {event.title} - {event.is_external ? (event.is_public ? : ) : ''} - {!event.in_escape ? : ''} - {!event.is_public && !event.is_external ? : ''} - {duration}
- ) - } - - render() { - let calUrl = api('cal/events.ics') - - return ( -
-

Calendar

-

Calendar-file: {calUrl}

- - No semesters have event information. - - {this.renderSemesters()} - - No events exists for selected semester. - - {this.renderList()} -
- ) - } -} diff --git a/src/modules/cal/components/Tag.js b/src/modules/cal/components/Tag.js deleted file mode 100644 index 778476bd..00000000 --- a/src/modules/cal/components/Tag.js +++ /dev/null @@ -1,19 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react' -import './Tag.scss' - -export default class extends React.Component { - - static propTypes = { - text: PropTypes.string.isRequired - } - - static defaultProps = { - type: 'normal', - text: 'unknown', - } - - render() { - return {this.props.text} - } -} diff --git a/src/modules/cal/components/Tag.scss b/src/modules/cal/components/Tag.scss deleted file mode 100644 index c5c344b6..00000000 --- a/src/modules/cal/components/Tag.scss +++ /dev/null @@ -1,26 +0,0 @@ -.eventlist-tag { - padding: 1px; - border-radius: 3px; - margin: 5px; - - background-color: #00b0ff; - border: 1px solid #555; - - opacity: 0.7; - - &.is-external { - background-color: #54c7e6; - } - - &.is-not-escape { - background-color: #4de561; - } - - &.is-not-public { - background-color: #e5b95f; - } - - &:hover { - opacity: 1; - } -} \ No newline at end of file diff --git a/src/modules/cal/getters.js b/src/modules/cal/getters.js deleted file mode 100644 index 785dfe4c..00000000 --- a/src/modules/cal/getters.js +++ /dev/null @@ -1,3 +0,0 @@ -export const list = ['calList'] -export const event = ['calEvent'] -export const semesters = ['calSemesters'] diff --git a/src/modules/cal/index.js b/src/modules/cal/index.js deleted file mode 100644 index aa3a80d0..00000000 --- a/src/modules/cal/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react' -import { Route } from 'react-router' -import { provideReactor } from 'nuclear-js-react-addons-chefsplate' - -import reactor from '../../reactor' - -import Event from './components/Event' -import List from './components/List' - -import EventStore from './stores/EventStore' -import ListStore from './stores/ListStore' -import SemestersStore from './stores/SemestersStore' - -reactor.registerStores({ - calList: ListStore, - calEvent: EventStore, - calSemesters: SemestersStore, -}) - -export default ( - - - - -) diff --git a/src/modules/cal/services/CalendarService.js b/src/modules/cal/services/CalendarService.js deleted file mode 100644 index dacc309b..00000000 --- a/src/modules/cal/services/CalendarService.js +++ /dev/null @@ -1,33 +0,0 @@ -import reqwest from '../../../utils/reqwest' -import {api} from '../../../api' - -class CalendarService { - - getEventList(year, semester) { - let semesterOffset = semester == 1 ? 1 : 7 - let toDay = semester == 1 ? 30 : 31 - let from = `${year}-${semesterOffset}-01` - let to = `${year}-${semesterOffset+5}-${toDay}` - - return reqwest({ - url: api(`cal/events?f=${from}&t=${to}`), - type: 'json' - }) - } - - getEvent(eventId) { - return reqwest({ - url: api('cal/events/' + eventId), - type: 'json' - }) - } - - getSemesters() { - return reqwest({ - url: api('cal/semesters'), - type: 'json' - }) - } -} - -export default new CalendarService() diff --git a/src/modules/cal/stores/EventStore.js b/src/modules/cal/stores/EventStore.js deleted file mode 100644 index a893a793..00000000 --- a/src/modules/cal/stores/EventStore.js +++ /dev/null @@ -1,43 +0,0 @@ -import { Store, toImmutable } from 'nuclear-js' -import actionTypes from '../actionTypes' - -export default Store({ - getInitialState() { - return toImmutable({ - data: null, - error: null, - isLoading: true - }) - }, - - initialize() { - this.on(actionTypes.RECEIVE_EVENT_START, receiveEventStart) - this.on(actionTypes.RECEIVE_EVENT_SUCCESS, receiveEventSuccess) - this.on(actionTypes.RECEIVE_EVENT_FAILURE, receiveEventFailure) - } -}) - -function receiveEventStart(state) { - return state - .set('data', null) - .set('error', null) - .set('isLoading', true) -} - -function receiveEventSuccess(state, {response}) { - return state - .set('data', toImmutable(response)) - .set('isLoading', false) -} - -function receiveEventFailure(state, {error}) { - let msg = error.statusText - if (error.status === 404) { - msg = 'Data not found' - } - - console.log('Receiving list failed', msg) - return state - .set('error', toImmutable(msg)) - .set('isLoading', false) -} diff --git a/src/modules/cal/stores/ListStore.js b/src/modules/cal/stores/ListStore.js deleted file mode 100644 index 6995a40e..00000000 --- a/src/modules/cal/stores/ListStore.js +++ /dev/null @@ -1,45 +0,0 @@ -import moment from 'moment' -import { Store, toImmutable } from 'nuclear-js' -import actionTypes from '../actionTypes' - -export default Store({ - getInitialState() { - return toImmutable({ - error: null, - items: [], - isLoading: true, - semester: moment().month() < 7 ? 1 : 2, - year: moment().year(), - }) - }, - - initialize() { - this.on(actionTypes.RECEIVE_LIST_START, receiveListStart) - this.on(actionTypes.RECEIVE_LIST_SUCCESS, receiveListSuccess) - this.on(actionTypes.RECEIVE_LIST_FAILURE, receiveListFailure) - } -}) - -function receiveListStart(state, {year, semester}) { - return state - .set('error', null) - .set('items', toImmutable({})) - .set('isLoading', true) - .set('year', year) - .set('semester', semester) -} - -function receiveListSuccess(state, {response}) { - return state - .set('items', toImmutable(response) - .toOrderedMap() - .mapKeys((k, v) => v.get('id'))) - .set('isLoading', false) -} - -function receiveListFailure(state, {error}) { - console.log('Receiving list failed', error) - return state - .set('error', toImmutable(error)) - .set('isLoading', false) -} diff --git a/src/modules/cal/stores/SemestersStore.js b/src/modules/cal/stores/SemestersStore.js deleted file mode 100644 index 7c1eb31c..00000000 --- a/src/modules/cal/stores/SemestersStore.js +++ /dev/null @@ -1,38 +0,0 @@ -import { Store, toImmutable } from 'nuclear-js' -import actionTypes from '../actionTypes' - -export default Store({ - getInitialState() { - return toImmutable({ - error: null, - items: [], - isLoading: true - }) - }, - - initialize() { - this.on(actionTypes.RECEIVE_SEMESTERS_START, receiveSemestersStart) - this.on(actionTypes.RECEIVE_SEMESTERS_SUCCESS, receiveSemestersSuccess) - this.on(actionTypes.RECEIVE_SEMESTERS_FAILURE, receiveSemestersFailure) - } -}) - -function receiveSemestersStart(state) { - return state - .set('error', null) - .set('items', toImmutable([])) - .set('isLoading', true) -} - -function receiveSemestersSuccess(state, {response}) { - return state - .set('items', toImmutable(response)) - .set('isLoading', false) -} - -function receiveSemestersFailure(state, {error}) { - console.log('Receiving list failed', error) - return state - .set('error', toImmutable(error)) - .set('isLoading', false) -}