Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"import"
],
"rules": {
"arrow-parens": "off",
"implicit-arrow-linebreak": "off",
"react/no-unused-prop-types": "off",
"import/prefer-default-export": "off",
"react/require-default-props": "off",
"object-curly-newline": "off",
Expand Down
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
; Ignore metro
.*/node_modules/metro/.*

; Ignore redux
.*/app/actions/*

[include]

[libs]
Expand Down
22 changes: 0 additions & 22 deletions App.js

This file was deleted.

File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions app/actions/shifts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// @flow

import crud from './utils/crud';

const getAllShifts = () =>
crud({
dispatch: {
begin: 'BEGIN_GET_SHIFTS',
end: 'END_GET_SHIFTS',
fail: 'FAILED_GET_SHIFTS',
},
method: 'GET',
url: '/api/v1/shifts',
});

const updateShift = (id, data) =>
crud({
dispatch: {
begin: 'BEGIN_PUT_SHIFT',
end: 'END_PUT_SHIFT',
fail: 'FAILED_PUT_SHIFT',
},
method: 'PUT',
url: `/api/v1/shifts/${id}`,
data,
});

const createShift = data =>
crud({
dispatch: {
begin: 'BEGIN_POST_SHIFT',
end: 'END_POST_SHIFT',
fail: 'FAILED_POST_SHIFT',
},
method: 'POST',
url: '/api/v1/shifts',
data,
});

const deleteShift = id =>
crud({
dispatch: {
begin: 'BEGIN_DELETE_SHIFT',
end: 'END_DELETE_SHIFT',
fail: 'FAILED_DELETE_SHIFT',
},
method: 'DELETE',
url: `/api/v1/shifts/${id}`,
});

const addUserToShift = (userID, shiftID) =>
crud({
dispatch: {
begin: 'BEGIN_POST_SHIFT',
end: 'END_POST_SHIFT',
fail: 'FAILED_POST_SHIFT',
},
method: 'POST',
url: '/api/v1/user/shifts',
data: {
user_id: userID,
shift_id: shiftID,
},
});

const dragDropUpdate = (oldShifts, newShift) => {
// NOTE: There is both a oldShift and oldShifts variable and the same for newShift and newShifts
const oldShift = oldShifts.find(shift => shift.id === newShift.id);
const index = oldShifts.indexOf(oldShift);
const newShifts = [...oldShifts];
newShifts.splice(index, 1, newShift);
return {
type: 'DRAG_DROP',
payload: newShifts,
};
};

export { getAllShifts, updateShift, createShift, deleteShift, addUserToShift, dragDropUpdate };
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions Login/LoginForm.js → app/components/Login/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';

import { EditText, Button } from '../UI';
import { EditText, Button } from '../general';

export default class LoginForm extends Component {
type Props = {}; // TODO: Add props

export default class LoginForm extends Component<Props> {
render() {
return (
<View style={styles.container}>
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions UI/EditText.js → app/components/general/EditText.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import React, { Component } from 'react';
import { TextInput, StyleSheet } from 'react-native';

type Props = {
type Props = TextInput.propTypes & {
placeholder: string,
keyboardType?: boolean,
secureTextEntry?: boolean,
};

Expand All @@ -16,7 +15,7 @@ export default class EditText extends Component<Props> {
<TextInput
style={styles.input}
autoCapitalize="none"
onSubmitEditing={() => this.passwordInput.focus()}
// onSubmitEditing={() => this.passwordInput.focus()}
autoCorrect={false}
keyboardType={keyboardType || 'default'}
returnKeyType="next"
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions app/containers/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @flow

import React, { Component } from 'react';

// import { createBottomTabNavigator } from 'react-navigation';

// ui
// import { Personal, Group, Settings, Availability } from '../components/HomeTabs';
import Login from './Login';

// const Home = createBottomTabNavigator({
// Personal,
// Group,
// Settings,
// Availability,
// });

type Props = {}; // TODO: Add props

export default class App extends Component<Props> {
render() {
return <Login />;
}
}
22 changes: 13 additions & 9 deletions Login/index.js → app/containers/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
import React, { Component } from 'react';
import { KeyboardAvoidingView, View, StyleSheet, Image } from 'react-native';

// ui
import LoginForm from './LoginForm';
// components
import LoginForm from '../components/Login/LoginForm';

// images
import * as logo from '../images/logo.png';

type Props = {
// TODO(anesu): Add more accurate types
login: any,
user: any,
loginUser: any,
clearError: any,
login?: any,
user?: any,
loginUser?: any,
clearError?: any,
};

export default class Login extends Component<Props> {
render() {
const { login, user, loginUser, clearError } = this.props;
// TODO: Use variables below
// const { login, user, loginUser, clearError } = this.props;

return (
<KeyboardAvoidingView behavior="padding" style={styles.container}>
Expand All @@ -25,11 +29,11 @@ export default class Login extends Component<Props> {
resizeMode="contain"
style={styles.logo}
// eslint-disable-next-line global-require
source={require('../assets/images/logo.png')}
source={logo}
/>
</View>

<View style={styles.formContainer}>
<View>
<LoginForm />
</View>
</KeyboardAvoidingView>
Expand Down
File renamed without changes
8 changes: 5 additions & 3 deletions Home.js → app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import { Provider } from 'react-redux';
import { createStore, combineReducers } from 'redux';

// reducers
import * as allReducers from './app/redux/reducers';
import * as allReducers from './reducers';

// ui
import App from './App';
import App from './containers/App';

const store = createStore(combineReducers(allReducers));

export default class Home extends Component {
type Props = {}; // TODO: Add props

export default class GTHC extends Component<Props> {
render() {
return (
<Provider store={store}>
Expand Down
2 changes: 0 additions & 2 deletions app/redux/reducers/index.js → app/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

export { default as user } from './user';
export { default as login } from './login';
export { default as shifts } from './shifts';
Expand Down
2 changes: 0 additions & 2 deletions app/redux/reducers/login.js → app/reducers/login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const initialState = {
type: 'login', // login or signup
signUpData: {
Expand Down
2 changes: 0 additions & 2 deletions app/redux/reducers/posts.js → app/reducers/posts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const initialState = {
data: [],
isLoading: false,
Expand Down
2 changes: 0 additions & 2 deletions app/redux/reducers/shifts.js → app/reducers/shifts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const initialState = {
team_shifts: [],
user_shifts: [],
Expand Down
2 changes: 0 additions & 2 deletions app/redux/reducers/team.js → app/reducers/team.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const initialState = {
data: {},
isLoading: false,
Expand Down
2 changes: 0 additions & 2 deletions app/redux/reducers/user.js → app/reducers/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const initialState = {
data: {},
isLoggedIn: false,
Expand Down
73 changes: 0 additions & 73 deletions app/redux/actions/shifts.js

This file was deleted.

8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/** @format */

import { AppRegistry } from 'react-native';
import Home from './Home';
import Login from './Login';

AppRegistry.registerComponent('GTHC', () => Home);
AppRegistry.registerComponent('Login', () => Login);
import GTHC from './app';

AppRegistry.registerComponent('GTHC', () => GTHC);