Resolve broken prod css

This commit is contained in:
Daniel Ternyak 2017-04-24 18:36:59 -05:00
parent 5652c56995
commit a12d720c8a
18 changed files with 4 additions and 472 deletions

View File

@ -1,27 +0,0 @@
import {
login_API,
setLocalToken,
resetLocalToken
} from 'api/AuthSvc';
import {resultOK} from 'api/utils';
export const LOGIN_AUTH_SUCCESS = 'LOGIN_AUTH_SUCCESS'
export const LOGIN_AUTH_FAIL = 'LOGIN_AUTH_FAIL'
export const LOGOUT_AUTH_SUCCESS = 'LOGOUT_AUTH_SUCCESS'
export function LOGIN_AUTH(data) {
return async () => {
let result = await login_API(data)
if (!resultOK(result)) {
return {type: LOGIN_AUTH_FAIL, error: result.data}
}
setLocalToken(result.token)
return {type: LOGIN_AUTH_SUCCESS, result: result.data}
}
}
export function LOGOUT_AUTH() {
resetLocalToken()
return {type: LOGOUT_AUTH_SUCCESS}
}

View File

@ -1,16 +0,0 @@
//import api service
import {getStatistics_API} from 'api/StatisticsSvc'
//import request management utils
import {resultOK} from 'api/utils'
//define action types
export const GET_STATISTICS_SUCCESS = 'GET_STATISTICS_SUCCESS'
export const GET_STATISTICS_FAIL = 'GET_STATISTICS_FAIL'
export const GET_STATISTICS = async () => {
let result = await getStatistics_API()
if (!resultOK(result)) {
return {type: GET_STATISTICS_FAIL, error: result.data}
}
return {type: GET_STATISTICS_SUCCESS, result: result.data}
}

View File

@ -1,13 +0,0 @@
import {resultOK} from 'api/utils'
import {getInbox_API} from 'api/InboxSvc'
export const GET_INBOX_SUCCESS = 'GET_INBOX_SUCCESS'
export const GET_INBOX_FAIL = 'GET_INBOX_FAIL'
export const GET_INBOX = async () => {
let result = await getInbox_API()
if (!resultOK(result)) {
return {type: GET_INBOX_FAIL, error: result.data}
}
return {type: GET_INBOX_SUCCESS, result: result.data}
}

View File

@ -1,25 +0,0 @@
export const UI_OPEN_SIDEBAR = 'UI_OPEN_SIDEBAR';
export const UI_CLOSE_SIDEBAR = 'UI_CLOSE_SIDEBAR';
export const UI_ACTIVATE_OBFUSCATOR = 'UI_ACTIVATE_OBFUSCATOR';
export const UI_DEACTIVATE_OBFUSCATOR = 'UI_DEACTIVATE_OBFUSCATOR';
export const UI_WINDOW_RESIZE = 'UI_WINDOW_RESIZE';
export const CLOSE_SIDEBAR = () => ({
type: UI_CLOSE_SIDEBAR
})
export const OPEN_SIDEBAR = () => ({
type: UI_OPEN_SIDEBAR
})
export const ACTIVATE_OBFUSCATOR = () => ({
type: UI_ACTIVATE_OBFUSCATOR
})
export const DEACTIVATE_OBFUSCATOR = () => ({
type: UI_DEACTIVATE_OBFUSCATOR
})
export const WINDOW_RESIZE = () => ({
type: UI_WINDOW_RESIZE
})

View File

@ -1,29 +0,0 @@
import {post} from './utils';
import * as store from 'store2'
export function getLocalToken() {
return store.get('auth_token')
}
export function resetLocalToken() {
// console.log('remove local token')
store.remove('auth_token')
}
export function setLocalToken(token) {
// console.log('set new local token')
store.set('auth_token', token)
}
export function isLoggedIn() {
return getLocalToken() === null ? false : true
}
export async function login_API(data) {
if (process.env.BUILD_GH_PAGES) {
return {
ok: true,
token: 'Just_for_demo'
}
}
return await post('/auth', data)
}

View File

@ -1,5 +0,0 @@
import {get} from './utils';
export async function getInbox_API() {
return await get('https://jsonplaceholder.typicode.com/users')
}

View File

@ -1,5 +0,0 @@
import {get} from './utils'
export async function getStatistics_API() {
return await get('https://jsonplaceholder.typicode.com/posts?userId=1&userId=2')
}

View File

@ -1,61 +0,0 @@
// Functions for <InputComponent /> validation,
// FEEL FREE TO REMOVE THIS FILE AND components/InputComponent.jsx,
export function maxSize(num, error = 'Value is too long') {
return function (value) {
if (value) {
return value.length > num ? error : true
}
}
}
export function noSpace(str) {
// trully can't get why do we need this check,
// but without it on /profile/settings page we get error
if (str !== undefined) {
return true;
}
return str.match(/[^-\s]/g) ? true : false
}
export function isRequired(str, field) {
if (str && str.length === 0) {
return `Please, enter your ${field}`
}
return true
}
export function latin(str) {
return str.match(/[a-zA-Z0-9]+/g) ? true : false
}
export function number(str) {
return str.match(/\d+/g) ? true : false
}
export function email() {
}
export function phone() {
}
export function composition(array) {
return function (value, field) {
for (let i = 0; i < array.length; i++) {
if (array[i](value, field) !== true) {
return array[i](value, field)
}
}
return false
}
}
export default {
isRequired,
phone,
email,
noSpace,
number,
latin,
maxSize,
composition
}

View File

@ -1,118 +0,0 @@
import React, {Component} from 'react';
import {Input, Form, Label} from 'semantic-ui-react';
import {omit} from 'lodash';
import PropTypes from 'prop-types';
//
export default class InputComponent extends Component {
constructor(props) {
super(props)
this.state = {
value: this.props.value
}
}
static propTypes = {
validate: PropTypes.func,
connectToParent: PropTypes.func,
value: PropTypes.any,
error: PropTypes.string,
labelText: PropTypes.string,
label: PropTypes.string,
placeholder: PropTypes.string,
name: PropTypes.string,
type: PropTypes.string,
as: PropTypes.node,
action: PropTypes.any
}
handleChange(event) {
let state = {
value: event.target.value
}
let {validate, name} = this.props;
if (validate) {
state.error = validate(state.value, name) // if valid, then false!
this.props.connectToParent({name, ...state})
}
this.setState(state)
}
// We have similar code in `handleChange()`
componentWillMount() {
let {validate, value, name} = this.props
let error;
if (validate) {
error = validate(value, name)
}
this.setState({...this.state, error, value})
}
componentWillReceiveProps() {
// PROPS ERROR TO STATE ERROR
let {error} = this.props;
if (error && error[0]) {
this.setState({
error: error || null
})
}
}
render() {
// STATE ERROR
let {error, value} = this.state
let {as} = this.props
// prop `as`
let propsToOmit = ['validate', 'error', 'connectToParent', 'as']
let propsForInput = {
...this.props,
onChange: this.handleChange.bind(this),
value
}
let RenderComponentAsProp
let propAsElemExists = false
if (as) {
propAsElemExists = true
RenderComponentAsProp = as
}
let propsForField
if (error) {
propsForField = {error: true}
}
propsForInput = omit(propsForInput, propsToOmit)
// labelText(custom) - is a TEXT label
// label - is a BUTTON label
// check semantic-react docs
let labelTextComponent = null
if (propsForInput.labelText) {
labelTextComponent = (<label>{propsForInput.labelText}</label>)
delete propsForInput.labelText
}
return (
// in semantic if input is a part of form, we can make it error-visible
// only throught the Form.Field error
<Form.Field {...propsForField}>
{labelTextComponent}
{propAsElemExists ?
<RenderComponentAsProp {...propsForInput} /> :
<Input {...propsForInput} />
}
{/* display tooltip with error */}
{error && <Label basic color='red' pointing>{error}</Label>}
</Form.Field>
)
}
}

View File

@ -1,36 +0,0 @@
import {isLoggedIn} from 'api/AuthSvc'
import {
LOGIN_AUTH_FAIL,
LOGIN_AUTH_SUCCESS,
LOGOUT_AUTH_SUCCESS
} from 'actions/auth'
let initialState = {
loggedIn: isLoggedIn()
}
export function auth(state = initialState, action) {
switch (action.type) {
case LOGOUT_AUTH_SUCCESS: {
return {
...state,
loggedIn: false
}
}
case LOGIN_AUTH_FAIL: {
return {
...state,
loggedIn: false
}
}
case LOGIN_AUTH_SUCCESS: {
return {
...state,
loggedIn: true
}
}
default:
return state
}
}

View File

@ -1,26 +0,0 @@
import {GET_STATISTICS_SUCCESS, GET_STATISTICS_FAIL} from 'actions/dashboard'
import {LOCATION_CHANGE} from 'actions/common'
const initialState = {
statistics: []
}
export function dashboard(state = initialState, action) {
switch (action.type) {
case GET_STATISTICS_SUCCESS:
return {
...state,
statistics: action.result
}
case GET_STATISTICS_FAIL:
return state
case LOCATION_CHANGE: {
if (action.payload.pathname !== '/') {
return initialState
}
return state
}
default:
return state
}
}

View File

@ -1,32 +0,0 @@
import {GET_INBOX_SUCCESS, GET_INBOX_FAIL} from 'actions/inbox'
import {LOCATION_CHANGE} from 'actions/common'
const initialState = {
isDataLoading: true,
errorLoadingConversations: false,
conversations: []
}
export function inbox(state = initialState, action) {
switch (action.type) {
case GET_INBOX_SUCCESS:
return {
...state,
conversations: action.result
}
case GET_INBOX_FAIL:
return {
...state,
errorLoadingConversations: true,
conversations: []
}
case LOCATION_CHANGE: {
if (action.payload.pathname !== '/inbox') {
return initialState
}
return state
}
default:
return state
}
}

View File

@ -1,49 +0,0 @@
import {UI_OPEN_SIDEBAR, UI_CLOSE_SIDEBAR, UI_WINDOW_RESIZE} from 'actions/layout'
import {LOCATION_CHANGE, APP_INIT} from 'actions/common';
// UI_ACTIVATE_OBFUSCATOR, UI_DEACTIVATE_OBFUSCATOR
const initialState = {
sidebarOpened: false,
obfuscatorActive: false,
isMobile: false
}
export function layout(state = initialState, action) {
switch (action.type) {
case APP_INIT: {
let {innerWidth} = window
let isMobile = innerWidth < 1025 // 1024px - is the main breakpoint in ui
return {
...state,
isMobile
}
}
case UI_WINDOW_RESIZE: {
let {innerWidth} = window
let isMobile = innerWidth < 1025 // 1024px - is the main breakpoint in ui
return {
...state,
isMobile
}
}
case UI_OPEN_SIDEBAR:
return {
...state,
sidebarOpened: true,
obfuscatorActive: true
}
case UI_CLOSE_SIDEBAR:
return {
...state,
sidebarOpened: false,
obfuscatorActive: false
}
case LOCATION_CHANGE:
return {
...state,
sidebarOpened: false,
obfuscatorActive: false
}
default:
return state
}
}

View File

@ -1,25 +0,0 @@
import {LOGIN_AUTH_FAIL, LOGIN_AUTH_SUCCESS} from 'actions/auth';
const initialState = {
loginError: false,
loginSuccess: false
}
export function loginCR(state = initialState, action) {
switch (action.type) {
case LOGIN_AUTH_FAIL:
return {
...state,
loginError: action.error,
loginSuccess: false
}
case LOGIN_AUTH_SUCCESS:
return {
...state,
loginError: false,
loginSuccess: true
}
default:
return state
}
}

View File

@ -14,8 +14,6 @@
"redux-form": "^6.6.3",
"redux-logger": "^3.0.1",
"redux-thunk": "^2.2.0",
"semantic-ui-css": "^2.2.9",
"semantic-ui-react": "^0.67.2",
"store2": "^2.5.0",
"whatwg-fetch": "^2.0.2"
},

View File

View File

@ -3,12 +3,12 @@ const path = require('path')
module.exports = {
port: 3000,
title: 'React-Semantic.UI-starter',
title: 'MEW',
publicPath: process.env.BUILD_GH_PAGES ? '/react-semantic.ui-starter/' : '/',
srcPath: path.join(__dirname, './../common'),
// add these dependencies to a standalone vendor bundle
vendor: [
'react', 'react-dom', 'react-router', 'redux', 'react-router-redux', 'redux-thunk', 'semantic-ui-react', 'whatwg-fetch', 'semantic-ui-css/semantic.css'
'react', 'react-dom', 'react-router', 'redux', 'react-router-redux', 'redux-thunk', 'whatwg-fetch'
],
// enable babelrc
babel: {

View File

@ -53,7 +53,8 @@ module.exports = {
test: /\.(js|jsx)$/,
loaders: ['babel-loader'],
exclude: [/node_modules/]
}, {
},
{
test: /\.(ico|jpg|png|gif|eot|otf|webp|ttf|woff|woff2)(\?.*)?$/,
loader: 'file-loader?limit=100000'
}, {