Skip to content

Instantly share code, notes, and snippets.

View AndrejGajdos's full-sized avatar

Andrej Gajdos AndrejGajdos

View GitHub Profile
import { put, takeLatest } from 'redux-saga/effects';
import * as ActionTypes from 'constants/actionTypes';
function* toggleModal(action) {
const { newState } = action;
if (!newState) {
// if login modal is closed, reset error
yield put({ type: ActionTypes.LOGIN_FAILED, error: null });
}
yield put({ type: ActionTypes.TOGGLE_MODAL_SUCCEEDED, newState });
import access from 'state/access.reducers';
import toggleModal from 'state/modals.reducers';
export default {
access,
toggleModal,
};
import * as ActionTypes from '../constants/actionTypes';
export default function toggleModal(state = { login: false }, action) {
switch (action.type) {
case ActionTypes.TOGGLE_MODAL_SUCCEEDED:
return { login: action.newState };
default:
return state;
}
}
import Cookies from 'js-cookie';
import * as ActionTypes from '../constants/actionTypes';
const initialState = {
user: {
isAuthenticated: typeof Cookies.get('auth__flow__spa__loggedUserObj') !== 'undefined',
loggedUserObj: Cookies.getJSON('auth__flow__spa__loggedUserObj'),
},
error: null,
};
import axios from 'axios';
import { API_ADDRESS } from 'config';
export function get(path, params) {
const url = `${API_ADDRESS}${path}`;
return axios({
method: 'get',
url,
params,
import React from 'react';
import Loadable from 'react-loadable';
const Loading = () => (
<div />
);
export const AsyncAboutView = Loadable({
loader: () => import('about/AboutView'),
loading: () => <Loading />,
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import Cookies from 'js-cookie';
import { Redirect } from 'react-router';
import { AsyncHomeView, AsyncAboutView } from 'asyncViews';
export default function Routes() {
return (
<Switch>
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import { connect } from 'react-redux';
import { NavLink } from 'react-router-dom';
import get from 'lodash/get';
import ProfilePlaceholder from 'assets/img/profile_placeholder.png';
import { isValidURL } from 'utils/utils';
import { logout, getProfile } from 'actions/access.actions';
import toggleLogin from 'actions/modals.actions';
app.use(
session(
{
store: redisStore(),
},
app,
),
);
const passport = require('koa-passport');
app.use(passport.initialize());
app.use(passport.session());