Merge branch 'master' of honey.fitz.guru:eventment-app
# Conflicts: # app/components/Login/LocalLogin.js # app/screens/Register.js
This commit is contained in:
77
.eslintrc.js
77
.eslintrc.js
@@ -1,4 +1,81 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: '@react-native-community',
|
||||
env: {
|
||||
mocha: true,
|
||||
browser: true,
|
||||
},
|
||||
// parser: 'babel-eslint',
|
||||
// plugins: ['babel', 'immutablejs'],
|
||||
plugins: ['immutablejs'],
|
||||
rules: {
|
||||
'comma-dangle': 'off',
|
||||
'func-call-spacing': 'off',
|
||||
'import/prefer-default-export': 'off',
|
||||
'max-len': ['error', 150, { ignoreComments: true, ignoreTemplateLiterals: true }],
|
||||
'no-confusing-arrow': 'off',
|
||||
'no-mixed-operators': 'off',
|
||||
'no-restricted-properties': [
|
||||
2,
|
||||
{
|
||||
object: 'describe',
|
||||
property: 'only',
|
||||
message:
|
||||
'Please remove any instance of .only from unit tests. If .only is required outside of a unit test, feel free to add an eslint override to ignore this instance of this error.',
|
||||
},
|
||||
{
|
||||
object: 'it',
|
||||
property: 'only',
|
||||
message:
|
||||
'Please remove any instance of .only from unit tests. If .only is required outside of a unit test, feel free to add an eslint override to ignore this instance of this error.',
|
||||
},
|
||||
{
|
||||
object: 'context',
|
||||
property: 'only',
|
||||
message:
|
||||
'Please remove any instance of .only from unit tests. If .only is required outside of a unit test, feel free to add an eslint override to ignore this instance of this error.',
|
||||
},
|
||||
{
|
||||
object: 'tape',
|
||||
property: 'only',
|
||||
message:
|
||||
'Please remove any instance of .only from unit tests. If .only is required outside of a unit test, feel free to add an eslint override to ignore this instance of this error.',
|
||||
},
|
||||
{
|
||||
object: 'test',
|
||||
property: 'only',
|
||||
message:
|
||||
'Please remove any instance of .only from unit tests. If .only is required outside of a unit test, feel free to add an eslint override to ignore this instance of this error.',
|
||||
},
|
||||
{
|
||||
object: 'fixture',
|
||||
property: 'only',
|
||||
message:
|
||||
'Please remove any instance of .only from unit tests. If .only is required outside of a unit test, feel free to add an eslint override to ignore this instance of this error.',
|
||||
},
|
||||
],
|
||||
'no-spaced-func': 'off',
|
||||
'react/jsx-closing-bracket-location': 'off',
|
||||
'react/jsx-first-prop-new-line': 'off',
|
||||
'react/jsx-no-literals': ['error', { noStrings: true }],
|
||||
'react/jsx-no-target-blank': 'off',
|
||||
'react/no-danger': 'off',
|
||||
'space-before-function-paren': 'off',
|
||||
indent: 'off',
|
||||
'indent-legacy': 'off',
|
||||
'immutablejs/no-native-map-set': 'error',
|
||||
'no-invalid-this': 'off',
|
||||
// 'babel/no-invalid-this': 'error',
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['lib/fixtures/**/*.js', '**/testHelper.js'],
|
||||
rules: {
|
||||
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
||||
},
|
||||
globals: {
|
||||
expect: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"arrowParens": "always",
|
||||
"jsxBracketSameLine": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 4,
|
||||
"printWidth": 100,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
@@ -10,5 +10,5 @@ import App from '../App';
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
renderer.create(<App />);
|
||||
renderer.create(<App />);
|
||||
});
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { createAppContainer } from 'react-navigation';
|
||||
|
||||
import { Tabs } from './router.js';
|
||||
|
||||
6
app/actions/activeEvent.js
Normal file
6
app/actions/activeEvent.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { SET_ACTIVE_EVENT } from '../constants/actionTypes.js';
|
||||
|
||||
export const setActiveEvent = (eventId) => ({
|
||||
type: SET_ACTIVE_EVENT,
|
||||
payload: eventId,
|
||||
});
|
||||
@@ -1,52 +1,54 @@
|
||||
import { blockUI, unblockUI } from './index.js';
|
||||
|
||||
import { placeBid as placeBidApi } from '../api/bid.js';
|
||||
import {
|
||||
BID_FAILURE,
|
||||
BID_SUCCESS,
|
||||
PLACE_BID,
|
||||
SET_AUCTION_FILTER,
|
||||
SET_AUCTION_VIEW_MODE,
|
||||
BID_FAILURE,
|
||||
BID_SUCCESS,
|
||||
PLACE_BID,
|
||||
SET_AUCTION_FILTER,
|
||||
SET_AUCTION_VIEW_MODE,
|
||||
} from '../constants/actionTypes.js';
|
||||
import { getActiveEventId } from '../selectors/activeEvent.js';
|
||||
import { getAuthToken } from '../selectors/auth.js';
|
||||
|
||||
const placeBidFailure = (bid, dispatch) => {
|
||||
dispatch({ type: BID_FAILURE, bid });
|
||||
dispatch(unblockUI);
|
||||
const placeBidFailure = (payload) => ({
|
||||
type: BID_FAILURE,
|
||||
payload,
|
||||
});
|
||||
|
||||
const placeBidSuccess = (payload) => ({
|
||||
type: BID_SUCCESS,
|
||||
payload,
|
||||
});
|
||||
|
||||
const handleBidFailure = (error) => (dispatch) => {
|
||||
console.error('[postBid]', error);
|
||||
dispatch(placeBidFailure(error));
|
||||
};
|
||||
|
||||
const placeBidSuccess = (bid, dispatch) => {
|
||||
dispatch({ type: BID_SUCCESS, bid });
|
||||
dispatch(unblockUI);
|
||||
const handleBidSuccess = (result) => (dispatch) => {
|
||||
dispatch(placeBidSuccess(result));
|
||||
};
|
||||
|
||||
const startPlacingBid = (itemId) => ({
|
||||
type: PLACE_BID,
|
||||
payload: itemId,
|
||||
});
|
||||
|
||||
export const changeFilterMode = (payload) => ({
|
||||
type: SET_AUCTION_FILTER,
|
||||
payload,
|
||||
type: SET_AUCTION_FILTER,
|
||||
payload,
|
||||
});
|
||||
|
||||
export const changeViewMode = (payload) => ({
|
||||
type: SET_AUCTION_VIEW_MODE,
|
||||
payload,
|
||||
type: SET_AUCTION_VIEW_MODE,
|
||||
payload,
|
||||
});
|
||||
|
||||
export const placeBid = (payload) => ({
|
||||
type: PLACE_BID,
|
||||
payload,
|
||||
});
|
||||
export const placeBid = ({ bidAmount, itemId, maxAmount }) => (dispatch, getState) => {
|
||||
const authToken = getAuthToken(getState());
|
||||
const eventId = getActiveEventId(getState());
|
||||
|
||||
export const postBid = () => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const activeEvent = state.get('activeEvent');
|
||||
|
||||
let apiUrl = getEndpointUrl(API_ENDPOINTS.GET_ITEMS);
|
||||
apiUrl = apiUrl.replace(/:event_id$/, '');
|
||||
if (activeEvent) {
|
||||
apiUrl = `${apiUrl}${activeEvent}`;
|
||||
}
|
||||
|
||||
dispatch(blockUI());
|
||||
|
||||
fetch(apiUrl)
|
||||
.then(response => response.json())
|
||||
.then(payload => itemsLoadSuccess(payload, dispatch))
|
||||
.catch(err => console.error('[actions::getItems]', err));
|
||||
dispatch(startPlacingBid(itemId));
|
||||
placeBidApi({ bidAmount, eventId, itemId, maxAmount }, authToken)
|
||||
.then((payload) => dispatch(handleBidSuccess(payload)))
|
||||
.catch((err) => dispatch(handleBidFailure(err)));
|
||||
};
|
||||
|
||||
@@ -1,39 +1,27 @@
|
||||
import { List } from 'immutable';
|
||||
|
||||
import { getEndpointUrl } from '../api/index.js';
|
||||
|
||||
import {
|
||||
AUCTIONS_UPDATED,
|
||||
ITEMS_LOADED,
|
||||
} from '../constants/actionTypes.js';
|
||||
|
||||
import { blockUI, unblockUI } from './index.js';
|
||||
import { API_ENDPOINTS } from '../constants/constants.js';
|
||||
import { fetchAuctionStatus as fetchActionStatusApi } from '../api/actionStatus.js';
|
||||
import { AUCTIONS_UPDATED } from '../constants/actionTypes.js';
|
||||
import { getActiveEventId } from '../selectors/activeEvent.js';
|
||||
import { getAuthToken } from '../selectors/auth.js';
|
||||
|
||||
import Auction from '../domain/Auction.js';
|
||||
|
||||
const auctionsUpdated = (payload) => ({
|
||||
type: AUCTIONS_UPDATED,
|
||||
payload,
|
||||
});
|
||||
|
||||
const autionStatusLoadSuccess = (auctions, dispatch) => {
|
||||
const payload = List(auctions).map((i) => Auction.fromJS(i));
|
||||
dispatch({ type: AUCTIONS_UPDATED, payload });
|
||||
dispatch(unblockUI);
|
||||
const autionStatusLoadSuccess = (auctions) => (dispatch) => {
|
||||
const payload = List(auctions).map((i) => Auction.fromJS(i));
|
||||
dispatch(auctionsUpdated(payload));
|
||||
};
|
||||
|
||||
export const fetchAuctionStatus = () => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const activeEvent = state.get('activeEvent');
|
||||
const authToken = getAuthToken(getState());
|
||||
const eventId = getActiveEventId(getState());
|
||||
|
||||
let apiUrl = getEndpointUrl(API_ENDPOINTS.GET_STATUS);
|
||||
apiUrl = apiUrl.replace(/:event_id$/, '');
|
||||
if (activeEvent) {
|
||||
apiUrl = `${apiUrl}${activeEvent}`;
|
||||
}
|
||||
|
||||
dispatch(blockUI());
|
||||
|
||||
return fetch(apiUrl)
|
||||
.then(response => response.json())
|
||||
.then(payload => autionStatusLoadSuccess(payload, dispatch))
|
||||
.catch(err => console.error('[actions::getStatus]', err));
|
||||
return fetchActionStatusApi(eventId, authToken)
|
||||
.then((payload) => dispatch(autionStatusLoadSuccess(payload)))
|
||||
.catch((err) => console.error('[actions::getStatus]', err));
|
||||
};
|
||||
|
||||
|
||||
@@ -1,36 +1,31 @@
|
||||
import { List } from 'immutable';
|
||||
|
||||
import { blockUI, unblockUI } from './index.js';
|
||||
import { fetchEvents as fetchEventsApi } from '../api/events.js';
|
||||
import {
|
||||
EVENTS_LOAD_FAILED,
|
||||
EVENTS_LOADED,
|
||||
GET_EVENTS,
|
||||
} from '../constants/actionTypes.js';
|
||||
import { EVENTS_LOAD_FAILED, EVENTS_LOADED, GET_EVENTS } from '../constants/actionTypes.js';
|
||||
import Event from '../domain/Event.js';
|
||||
import { getAuthToken } from '../selectors/auth.js';
|
||||
|
||||
const beginFetchEvents = () => ({ type: GET_EVENTS });
|
||||
|
||||
const eventsLoaded = (payload) => ({ type: EVENTS_LOADED, payload });
|
||||
|
||||
const eventsLoadError = (payload) => ({ type: EVENTS_LOAD_FAILED, payload });
|
||||
|
||||
const eventsFetchSuccess = (items) => (dispatch) => {
|
||||
const payload = List(items).map((i) => Event.fromJS(i));
|
||||
|
||||
dispatch(eventsLoaded(payload));
|
||||
dispatch(unblockUI);
|
||||
const payload = List(items).map((i) => Event.fromJS(i));
|
||||
dispatch(eventsLoaded(payload));
|
||||
};
|
||||
|
||||
const eventsFetchFailure = (error) => (dispatch) => {
|
||||
console.error('[actions::events::eventsFetchFailure]', error);
|
||||
dispatch(eventsLoadError(error));
|
||||
dispatch(unblockUI);
|
||||
console.error('[actions::events::eventsFetchFailure]', error);
|
||||
dispatch(eventsLoadError(error));
|
||||
};
|
||||
|
||||
export const fetchEvents = () => (dispatch, getState) => {
|
||||
const authToken = getAuthToken(getState());
|
||||
const authToken = getAuthToken(getState());
|
||||
|
||||
fetchEventsApi(authToken)
|
||||
.then(payload => dispatch(eventsFetchSuccess(payload)))
|
||||
.catch(err => dispatch(eventsFetchFailure(err)));
|
||||
dispatch(beginFetchEvents());
|
||||
fetchEventsApi(authToken)
|
||||
.then((payload) => dispatch(eventsFetchSuccess(payload)))
|
||||
.catch((err) => dispatch(eventsFetchFailure(err)));
|
||||
};
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import {
|
||||
BLOCK_UI,
|
||||
UNBLOCK_UI,
|
||||
} from '../constants/actionTypes.js';
|
||||
import { BLOCK_UI, UNBLOCK_UI } from '../constants/actionTypes.js';
|
||||
|
||||
export const blockUI = () => ({
|
||||
type: BLOCK_UI,
|
||||
type: BLOCK_UI,
|
||||
});
|
||||
|
||||
export const unblockUI = () => ({
|
||||
type: UNBLOCK_UI,
|
||||
type: UNBLOCK_UI,
|
||||
});
|
||||
|
||||
@@ -1,39 +1,34 @@
|
||||
import { List } from 'immutable';
|
||||
|
||||
import { fetchItems as fetchItemsApi } from '../api/items.js';
|
||||
import {
|
||||
GET_ITEMS,
|
||||
ITEMS_LOADED,
|
||||
} from '../constants/actionTypes.js';
|
||||
import { GET_ITEMS, ITEMS_LOAD_FAILED, ITEMS_LOADED } from '../constants/actionTypes.js';
|
||||
import { getActiveEventId } from '../selectors/activeEvent.js';
|
||||
import { getAuthToken } from '../selectors/auth.js';
|
||||
|
||||
import { blockUI, unblockUI } from './index.js';
|
||||
|
||||
import Item from '../domain/Item.js';
|
||||
|
||||
const beginItemLoad = () => ({ type: GET_ITEMS });
|
||||
|
||||
const itemsLoaded = (payload) => ({ type: ITEMS_LOADED, payload });
|
||||
|
||||
const itemsLoadError = (payload) => ({ type: ITEMS_LOAD_FAILED, payload });
|
||||
const itemsLoadFailure = (payload) => ({ type: ITEMS_LOAD_FAILED, payload });
|
||||
|
||||
const itemsFetchSuccess = (items) => (dispatch) => {
|
||||
const payload = List(items).map((i) => Item.fromJS(i));
|
||||
|
||||
dispatch(itemsLoaded(payload));
|
||||
dispatch(unblockUI);
|
||||
const payload = List(items).map((i) => Item.fromJS(i));
|
||||
dispatch(itemsLoaded(payload));
|
||||
};
|
||||
|
||||
const itemsFetchFailure = (error) => (dispatch) => {
|
||||
console.error('[actions::items::itemsFetchFailure]', error);
|
||||
dispatch(itemsLoadFailure(error));
|
||||
dispatch(unblockUI);
|
||||
console.error('[actions::items::itemsFetchFailure]', error);
|
||||
dispatch(itemsLoadFailure(error));
|
||||
};
|
||||
|
||||
export const fetchItems = () => (dispatch, getState) => {
|
||||
const eventId = getActiveEventId(getState());
|
||||
const authToken = getAuthToken(getState());
|
||||
const authToken = getAuthToken(getState());
|
||||
const eventId = getActiveEventId(getState());
|
||||
|
||||
fetchItemsApi(activeEvent, authToken)
|
||||
.then(payload => dispatch(itemsFetchSuccess(payload)))
|
||||
.catch(err => dispatch(itemsFetchFailure(err)));
|
||||
dispatch(beginItemLoad());
|
||||
fetchItemsApi(eventId, authToken)
|
||||
.then((payload) => dispatch(itemsFetchSuccess(payload)))
|
||||
.catch((err) => dispatch(itemsFetchFailure(err)));
|
||||
};
|
||||
|
||||
@@ -1,124 +1,117 @@
|
||||
import { blockUI, unblockUI } from './index.js';
|
||||
|
||||
import {
|
||||
getEmailAvailability,
|
||||
getNomAvailaibility,
|
||||
loginUser,
|
||||
registerNewUser,
|
||||
getEmailAvailability,
|
||||
getNomAvailaibility,
|
||||
loginUser,
|
||||
registerNewUser,
|
||||
} from '../api/profile.js';
|
||||
|
||||
import {
|
||||
DO_LOGOUT,
|
||||
LOGIN_FAILURE,
|
||||
LOGIN_SUCCESS,
|
||||
PROFILE_EMAIL_AVAILABLE,
|
||||
PROFILE_NOM_AVAILABLE,
|
||||
UNSET_AUTH,
|
||||
UNSET_PROFILE,
|
||||
UPDATE_PROFILE,
|
||||
DO_LOGOUT,
|
||||
LOGIN_FAILURE,
|
||||
LOGIN_SUCCESS,
|
||||
PROFILE_EMAIL_AVAILABLE,
|
||||
PROFILE_NOM_AVAILABLE,
|
||||
REGISTRATION_FAILURE,
|
||||
REGISTRATION_SUCCESS,
|
||||
UNSET_AUTH,
|
||||
UNSET_PROFILE,
|
||||
UPDATE_PROFILE,
|
||||
} from '../constants/actionTypes.js';
|
||||
|
||||
const isValidEmail = (payload) => ({
|
||||
type: PROFILE_EMAIL_AVAILABLE,
|
||||
payload,
|
||||
type: PROFILE_EMAIL_AVAILABLE,
|
||||
payload,
|
||||
});
|
||||
|
||||
const isValidNom = (payload) => ({
|
||||
type: PROFILE_NOM_AVAILABLE,
|
||||
payload,
|
||||
type: PROFILE_NOM_AVAILABLE,
|
||||
payload,
|
||||
});
|
||||
|
||||
const loginFailure = (payload) => ({
|
||||
type: LOGIN_FAILURE,
|
||||
payload,
|
||||
type: LOGIN_FAILURE,
|
||||
payload,
|
||||
});
|
||||
|
||||
const loginSuccess = (payload) => ({
|
||||
type: LOGIN_SUCCESS,
|
||||
payload,
|
||||
type: LOGIN_SUCCESS,
|
||||
payload,
|
||||
});
|
||||
|
||||
const logoutUser = () => ({
|
||||
type: DO_LOGOUT,
|
||||
type: DO_LOGOUT,
|
||||
});
|
||||
|
||||
const registrationFailure = (payload) => ({
|
||||
type: REGISTRATION_FAILURE,
|
||||
payload,
|
||||
type: REGISTRATION_FAILURE,
|
||||
payload,
|
||||
});
|
||||
|
||||
const registrationSuccess = (payload) => ({
|
||||
type: REGISTRATION_SUCCESS,
|
||||
payload,
|
||||
type: REGISTRATION_SUCCESS,
|
||||
payload,
|
||||
});
|
||||
|
||||
const unsetAuth = () => ({
|
||||
type: UNSET_AUTH,
|
||||
type: UNSET_AUTH,
|
||||
});
|
||||
|
||||
const unsetProfile = () => ({
|
||||
type: UNSET_PROFILE,
|
||||
type: UNSET_PROFILE,
|
||||
});
|
||||
|
||||
const updateProfile = (profile) => ({
|
||||
type: UPDATE_PROFILE,
|
||||
payload: profile,
|
||||
type: UPDATE_PROFILE,
|
||||
payload: profile,
|
||||
});
|
||||
|
||||
export const checkEmailAvailability = (email) => (dispatch) => {
|
||||
export const checkEmailAvailability = (email) => (dispatch) => {};
|
||||
|
||||
};
|
||||
|
||||
export const checkNomAvailability = (nomDeBid) => (dispatch) => {
|
||||
|
||||
};
|
||||
export const checkNomAvailability = (nomDeBid) => (dispatch) => {};
|
||||
|
||||
export const login = (username, password) => (dispatch) => {
|
||||
dispatch(blockUI());
|
||||
loginUser(username, password)
|
||||
.then(result => {
|
||||
dispatch(loginSuccess(result))
|
||||
})
|
||||
.catch(err => dispatch(loginFailure(err)));
|
||||
dispatch(blockUI());
|
||||
loginUser(username, password)
|
||||
.then((result) => {
|
||||
dispatch(loginSuccess(result));
|
||||
})
|
||||
.catch((err) => dispatch(loginFailure(err)));
|
||||
};
|
||||
|
||||
export const logout = () => (dispatch) => {
|
||||
dispatch(unsetProfile());
|
||||
dispatch(unsetAuth());
|
||||
dispatch(logoutUser());
|
||||
dispatch(unsetProfile());
|
||||
dispatch(unsetAuth());
|
||||
dispatch(logoutUser());
|
||||
};
|
||||
|
||||
// USER REGISTRATION
|
||||
const handleRegistrationSuccess = (user) => (dispatch) => {
|
||||
dispatch(unblockUI());
|
||||
dispatch(registrationSuccess());
|
||||
dispatch(loginSuccess(user));
|
||||
dispatch(unblockUI());
|
||||
dispatch(registrationSuccess());
|
||||
dispatch(loginSuccess(user));
|
||||
};
|
||||
|
||||
const handleRegistrationFailure = (error) => (dispatch) => {
|
||||
dispatch(unblockUI());
|
||||
dispatch(registrationFailure(error));
|
||||
dispatch(unblockUI());
|
||||
dispatch(registrationFailure(error));
|
||||
};
|
||||
|
||||
export const registerUser = (user) => (dispatch) => {
|
||||
dispatch(blockUI());
|
||||
registerNewUser(user)
|
||||
.then(user => dispatch(handleRegistrationSuccess(user)))
|
||||
.catch(err => dispatch(handleRegistrationFailure(err)));
|
||||
dispatch(blockUI());
|
||||
registerNewUser(user)
|
||||
.then((user) => dispatch(handleRegistrationSuccess(user)))
|
||||
.catch((err) => dispatch(handleRegistrationFailure(err)));
|
||||
};
|
||||
|
||||
// FACEBOOK
|
||||
export const facebookLoginSuccess = (result) => (dispatch) => {
|
||||
console.log('facebookLoginSuccess', result);
|
||||
dispatch(facebookLoginSuccess(result));
|
||||
console.log('facebookLoginSuccess', result);
|
||||
dispatch(facebookLoginSuccess(result));
|
||||
};
|
||||
|
||||
|
||||
// LOGIN SERVICES COMMON ACTIONS
|
||||
export const serviceRegistrationError = (error) => (dispatch) => {
|
||||
export const serviceRegistrationError = (error) => (dispatch) => {};
|
||||
|
||||
};
|
||||
|
||||
export const serviceRegistrationCanceled = () => (dispatch) => {
|
||||
|
||||
};
|
||||
export const serviceRegistrationCanceled = () => (dispatch) => {};
|
||||
|
||||
7
app/api/auctionStatus.js
Normal file
7
app/api/auctionStatus.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||
|
||||
export const fetchAuctionStatus = (eventId, auth) => {
|
||||
const path = `${API_ENDPOINTS.GET_STATUS})/${eventId}`;
|
||||
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||
return requestGet(path, null, opts);
|
||||
};
|
||||
10
app/api/bid.js
Normal file
10
app/api/bid.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { API_ENDPOINTS, requestPost } from './index.js';
|
||||
|
||||
export const placeBid = ({ bidAmount, bidderId, eventId, itemId, maxAmount }, auth) => {
|
||||
const requestOptions = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||
return requestPost({
|
||||
path: `${API_ENDPOINTS.PLACE_BID}/${itemId}`,
|
||||
body: { bidAmount, bidderId, eventId, maxAmount },
|
||||
requestOptions,
|
||||
});
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||
|
||||
export const fetchEvents = (auth) => {
|
||||
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||
return requestGet(API_ENDPOINTS.GET_EVENTS, null, opts);
|
||||
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||
return requestGet(API_ENDPOINTS.GET_EVENTS, null, opts);
|
||||
};
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
import { API_URL } from '../constants/constants.js';
|
||||
|
||||
export const constructUrl = (path, params, host = API_URL) => {
|
||||
if (!(/^\//g).test(path)) {
|
||||
throw new Error(`Invalid path! Expecting a valid relative path (path needs to start with /)(${path})`);
|
||||
}
|
||||
if (!/^\//g.test(path)) {
|
||||
throw new Error(
|
||||
`Invalid path! Expecting a valid relative path (path needs to start with /)(${path})`,
|
||||
);
|
||||
}
|
||||
|
||||
let url = path;
|
||||
let url = path;
|
||||
|
||||
if (host) {
|
||||
url = `${host}${url}`;
|
||||
}
|
||||
if (host) {
|
||||
url = `${host}${url}`;
|
||||
}
|
||||
|
||||
if (params) {
|
||||
url = `${url}?${params}`;
|
||||
}
|
||||
if (params) {
|
||||
url = `${url}?${params}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
return url;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -26,59 +28,57 @@ export const constructUrl = (path, params, host = API_URL) => {
|
||||
* this serializes data in a way that helps support legacy endpoints
|
||||
*/
|
||||
export const formatPostData = (body) => {
|
||||
const postData = new FormData();
|
||||
Object.keys(body).forEach(key => postData.append(key, body[key]));
|
||||
return postData;
|
||||
const postData = new FormData();
|
||||
Object.keys(body).forEach((key) => postData.append(key, body[key]));
|
||||
return postData;
|
||||
};
|
||||
|
||||
const parseQueryParamsString = (queryParams) => {
|
||||
if (typeof queryParams !== 'string') {
|
||||
return null;
|
||||
}
|
||||
if (typeof queryParams !== 'string') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return queryParams;
|
||||
return queryParams;
|
||||
};
|
||||
|
||||
const parseQueryParamsObject = (queryParams) => {
|
||||
if (queryParams === null || typeof queryParams !== 'object' || Array.isArray(queryParams)) {
|
||||
return null;
|
||||
}
|
||||
if (queryParams === null || typeof queryParams !== 'object' || Array.isArray(queryParams)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Object
|
||||
.keys(queryParams)
|
||||
.map((key) => {
|
||||
const value = queryParams[key];
|
||||
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
||||
})
|
||||
.join('&');
|
||||
return Object.keys(queryParams)
|
||||
.map((key) => {
|
||||
const value = queryParams[key];
|
||||
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
||||
})
|
||||
.join('&');
|
||||
};
|
||||
|
||||
const parseQueryParamsArray = (queryParams) => {
|
||||
if (!Array.isArray(queryParams)) {
|
||||
return null;
|
||||
}
|
||||
if (!Array.isArray(queryParams)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return queryParams
|
||||
.map((param) => {
|
||||
const [key, value] = param.split('=');
|
||||
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
||||
})
|
||||
.join('&');
|
||||
return queryParams
|
||||
.map((param) => {
|
||||
const [key, value] = param.split('=');
|
||||
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
||||
})
|
||||
.join('&');
|
||||
};
|
||||
|
||||
export const parseQueryParams = queryParams => (
|
||||
parseQueryParamsString(queryParams) ||
|
||||
parseQueryParamsObject(queryParams) ||
|
||||
parseQueryParamsArray(queryParams) ||
|
||||
''
|
||||
);
|
||||
export const parseQueryParams = (queryParams) =>
|
||||
parseQueryParamsString(queryParams) ||
|
||||
parseQueryParamsObject(queryParams) ||
|
||||
parseQueryParamsArray(queryParams) ||
|
||||
'';
|
||||
|
||||
export const request = (url, options) => {
|
||||
try {
|
||||
return fetch(url, options).catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
try {
|
||||
return fetch(url, options).catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const unwrapJson = (response) => response.json();
|
||||
|
||||
126
app/api/index.js
126
app/api/index.js
@@ -1,95 +1,95 @@
|
||||
import {
|
||||
constructUrl,
|
||||
formatPostData,
|
||||
parseQueryParams,
|
||||
request,
|
||||
unwrapJson,
|
||||
validateResponse,
|
||||
constructUrl,
|
||||
formatPostData,
|
||||
parseQueryParams,
|
||||
request,
|
||||
unwrapJson,
|
||||
validateResponse,
|
||||
} from './helpers.js';
|
||||
|
||||
import { API_URL } from '../constants/constants.js';
|
||||
|
||||
const DefaultRequestOptions = {};
|
||||
|
||||
const endpoints = {
|
||||
// Events and Items
|
||||
GET_EVENTS: '/events',
|
||||
// GET_ITEMS: '/items?eventId=:event_id',
|
||||
GET_ITEMS: '/items',
|
||||
export const API_ENDPOINTS = {
|
||||
// Events and Items
|
||||
GET_EVENTS: '/events',
|
||||
// GET_ITEMS: '/items?eventId=:event_id',
|
||||
GET_ITEMS: '/items',
|
||||
|
||||
// Auction Interactions
|
||||
// GET_STATUS: '/auction/:event_id',
|
||||
GET_STATUS: '/auction',
|
||||
PLACE_BID: '/bids/:item_id',
|
||||
PURCHASE_ITEM: '/sales',
|
||||
// Auction Interactions
|
||||
// GET_STATUS: '/auction/:event_id',
|
||||
GET_STATUS: '/auction',
|
||||
PLACE_BID: '/bids',
|
||||
PURCHASE_ITEM: '/sales',
|
||||
|
||||
// User/Profile
|
||||
USER_SIGNUP: '/signup',
|
||||
USER_PROFILE: '/users/:user_id',
|
||||
// User/Profile
|
||||
USER_SIGNUP: '/signup',
|
||||
USER_PROFILE: '/users/:user_id',
|
||||
|
||||
VALIDATE_SIGNUP_EMAIL: '/signup/validate/email',
|
||||
VALIDATE_SIGNUP_NOM: '/signup/validate/nom',
|
||||
VALIDATE_SIGNUP_EMAIL: '/signup/validate/email',
|
||||
VALIDATE_SIGNUP_NOM: '/signup/validate/nom',
|
||||
|
||||
// Services
|
||||
APPLE_SIGNUP: '/auth/apple/login',
|
||||
APPLE_LINK: '/auth/apple/link',
|
||||
FACEBOOK_SIGNUP: '/auth/facebook/login',
|
||||
FACEBOOK_LINK: '/auth/facebook/link',
|
||||
GOOGLE_SIGNUP: '/auth/google/login',
|
||||
GOOGLE_LINK: '/auth/google/link',
|
||||
// Services
|
||||
APPLE_SIGNUP: '/auth/apple/login',
|
||||
APPLE_LINK: '/auth/apple/link',
|
||||
FACEBOOK_SIGNUP: '/auth/facebook/login',
|
||||
FACEBOOK_LINK: '/auth/facebook/link',
|
||||
GOOGLE_SIGNUP: '/auth/google/login',
|
||||
GOOGLE_LINK: '/auth/google/link',
|
||||
};
|
||||
|
||||
const cacheBuster = () => {
|
||||
const timestamp = String(Date.now());
|
||||
return `?buster=${timestamp}`;
|
||||
const timestamp = String(Date.now());
|
||||
return `?buster=${timestamp}`;
|
||||
};
|
||||
|
||||
export const getEndpointUrl = (endpoint) => {
|
||||
if (!endpoints[endpoint]) {
|
||||
throw new Error('Invalid API endpoint specified');
|
||||
}
|
||||
if (!endpoints[endpoint]) {
|
||||
throw new Error('Invalid API endpoint specified');
|
||||
}
|
||||
|
||||
return `${API_URL}${endpoints[endpoint]}`; //`${cacheBuster()}`;
|
||||
return `${API_URL}${endpoints[endpoint]}`; //`${cacheBuster()}`;
|
||||
};
|
||||
|
||||
export const requestGet = (path, queryParams = [], requestOptions = {}) => {
|
||||
const params = parseQueryParams(queryParams);
|
||||
const params = parseQueryParams(queryParams);
|
||||
|
||||
if (params === null) {
|
||||
throw new Error('Invalid queryParams');
|
||||
}
|
||||
if (params === null) {
|
||||
throw new Error('Invalid queryParams');
|
||||
}
|
||||
|
||||
return request(constructUrl(path, params), {
|
||||
...DefaultRequestOptions,
|
||||
...requestOptions
|
||||
return request(constructUrl(path, params), {
|
||||
...DefaultRequestOptions,
|
||||
...requestOptions,
|
||||
})
|
||||
.then(validateResponse)
|
||||
.then(unwrapJson);
|
||||
.then(validateResponse)
|
||||
.then(unwrapJson);
|
||||
};
|
||||
|
||||
export const requestPost = (options) => {
|
||||
const {
|
||||
path,
|
||||
body = {},
|
||||
queryParams = [],
|
||||
requestOptions = {},
|
||||
isFormattedPostData = false
|
||||
} = options;
|
||||
const {
|
||||
path,
|
||||
body = {},
|
||||
queryParams = [],
|
||||
requestOptions = {},
|
||||
isFormattedPostData = false,
|
||||
} = options;
|
||||
|
||||
const params = parseQueryParams(queryParams || []);
|
||||
const params = parseQueryParams(queryParams || []);
|
||||
|
||||
if (params === null) {
|
||||
throw new Error('invalid queryParams');
|
||||
}
|
||||
if (params === null) {
|
||||
throw new Error('invalid queryParams');
|
||||
}
|
||||
|
||||
// Additional formatting happens in `formatPostData()`
|
||||
// like handling what jQuery calls `traditional` form data
|
||||
return request(constructUrl(path, params), {
|
||||
...DefaultRequestOptions,
|
||||
...requestOptions,
|
||||
method: 'POST',
|
||||
body: isFormattedPostData ? body : formatPostData(body)
|
||||
// Additional formatting happens in `formatPostData()`
|
||||
// like handling what jQuery calls `traditional` form data
|
||||
return request(constructUrl(path, params), {
|
||||
...DefaultRequestOptions,
|
||||
...requestOptions,
|
||||
method: 'POST',
|
||||
body: isFormattedPostData ? body : formatPostData(body),
|
||||
})
|
||||
.then(validateResponse)
|
||||
.then(unwrapJson);
|
||||
.then(validateResponse)
|
||||
.then(unwrapJson);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||
|
||||
export const fetchItems = (eventId, auth) => {
|
||||
const path = String(API_ENDPOINTS.GET_ITEMS).replace(/:event_id$/, eventId);
|
||||
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||
return requestGet(path, null, opts);
|
||||
const path = String(API_ENDPOINTS.GET_ITEMS).replace(/:event_id$/, eventId);
|
||||
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||
return requestGet(path, null, opts);
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||
|
||||
export const getEmailAvailability = (email) => requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_EMAIL}/&{encodeURI(email)}`);
|
||||
export const getEmailAvailability = (email) =>
|
||||
requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_EMAIL}/&{encodeURI(email)}`);
|
||||
|
||||
export const getNomAvailaibility = (nomDeBid) => requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_NOM}/${encodeURI(nomDeBid)}`);
|
||||
export const getNomAvailaibility = (nomDeBid) =>
|
||||
requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_NOM}/${encodeURI(nomDeBid)}`);
|
||||
|
||||
export const loginUser = (username, password) => requestPost({
|
||||
path: API_ENDPOINTS.LOGIN,
|
||||
body: { username, password },
|
||||
});
|
||||
export const loginUser = (username, password) =>
|
||||
requestPost({
|
||||
path: API_ENDPOINTS.LOGIN,
|
||||
body: { username, password },
|
||||
});
|
||||
|
||||
export const registerNewUser = (user) => requestPost({
|
||||
path: API_ENDPOINTS.USER_SIGNUP,
|
||||
body: { user },
|
||||
});
|
||||
export const registerNewUser = (user) =>
|
||||
requestPost({
|
||||
path: API_ENDPOINTS.USER_SIGNUP,
|
||||
body: { user },
|
||||
});
|
||||
|
||||
@@ -5,7 +5,10 @@ import { fetchEvents } from '../../actions/events.js';
|
||||
import AppHeader from './AppHeader.js';
|
||||
|
||||
const matchDispatchToProps = (dispatch) => ({
|
||||
fetchEvents: () => dispatch(fetchEvents()),
|
||||
fetchEvents: () => dispatch(fetchEvents()),
|
||||
});
|
||||
|
||||
export default connect(null, matchDispatchToProps)(AppHeader);
|
||||
export default connect(
|
||||
null,
|
||||
matchDispatchToProps,
|
||||
)(AppHeader);
|
||||
|
||||
@@ -10,27 +10,26 @@ import HeaderContentRight from './HeaderContentRight.container.js';
|
||||
import styles from './AppHeader.styles.js';
|
||||
|
||||
export default class AppHeader extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
fetchEvents: PropTypes.func.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
static get propTypes() {
|
||||
return {
|
||||
fetchEvents: PropTypes.func.isRequired,
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.fetchEvents();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchEvents();
|
||||
}
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
render () {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<Header
|
||||
placement="left"
|
||||
leftComponent={<HeaderContentRight navigation={navigation} />}
|
||||
centerComponent={<HeaderTitle navigation={navigation} />}
|
||||
rightComponent={<HeaderContentLeft navigation={navigation} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Header
|
||||
placement="left"
|
||||
leftComponent={<HeaderContentRight navigation={navigation} />}
|
||||
centerComponent={<HeaderTitle navigation={navigation} />}
|
||||
rightComponent={<HeaderContentLeft navigation={navigation} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,15 @@ import { hasMultipleEvents } from '../../selectors/events.js';
|
||||
import HeaderContentLeft from './HeaderContentLeft.js';
|
||||
|
||||
const matchStateToProps = (state, ownProps) => {
|
||||
const { routeName } = ownProps.navigation.state;
|
||||
const { routeName } = ownProps.navigation.state;
|
||||
|
||||
return {
|
||||
activeRoute: routeName,
|
||||
hasMultipleEvents: hasMultipleEvents(state),
|
||||
};
|
||||
return {
|
||||
activeRoute: routeName,
|
||||
hasMultipleEvents: hasMultipleEvents(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(matchStateToProps, null)(HeaderContentLeft);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
null,
|
||||
)(HeaderContentLeft);
|
||||
|
||||
@@ -1,53 +1,43 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
import BackIcon from './IconButtons/BackIcon.js';
|
||||
import EventsIcon from './IconButtons/EventsIcon.js';
|
||||
|
||||
export default function HeaderContentLeft({
|
||||
activeRoute,
|
||||
hasMultipleEvents,
|
||||
navigation,
|
||||
}) {
|
||||
export default function HeaderContentLeft({ activeRoute, hasMultipleEvents, navigation }) {
|
||||
const _goBack = () => {
|
||||
if (hasActiveEvent) {
|
||||
navigation.goBack();
|
||||
return false;
|
||||
}
|
||||
|
||||
const _goBack = () => {
|
||||
if (hasActiveEvent) {
|
||||
navigation.goBack();
|
||||
return false;
|
||||
console.log('nowhere to go...');
|
||||
};
|
||||
|
||||
const _showEvents = () => {
|
||||
navigation.navigate('Events');
|
||||
return false;
|
||||
};
|
||||
|
||||
if (activeRoute === 'Events') {
|
||||
return <EventsIcon action={_goBack} />;
|
||||
}
|
||||
|
||||
console.log('nowhere to go...');
|
||||
};
|
||||
if (activeRoute === 'Profile') {
|
||||
return <BackIcon action={_goBack} />;
|
||||
}
|
||||
|
||||
const _showEvents = () => {
|
||||
navigation.navigate('Events');
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
if (activeRoute === 'Events') {
|
||||
return <EventsIcon action={_goBack} />;
|
||||
}
|
||||
|
||||
if (activeRoute === 'Profile') {
|
||||
return <BackIcon action={_goBack} />;
|
||||
}
|
||||
|
||||
return <EventsIcon action={hasMultipleEvents ? _showEvents : null} />
|
||||
return <EventsIcon action={hasMultipleEvents ? _showEvents : null} />;
|
||||
}
|
||||
|
||||
HeaderContentLeft.propTypes = {
|
||||
activeRoute: PropTypes.string.isRequired,
|
||||
hasActiveEvent: PropTypes.bool,
|
||||
navigation: PropTypes.func.isRequired,
|
||||
activeRoute: PropTypes.string.isRequired,
|
||||
hasActiveEvent: PropTypes.bool,
|
||||
navigation: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
HeaderContentLeft.defaultProps = {
|
||||
hasActiveEvent: false,
|
||||
hasActiveEvent: false,
|
||||
};
|
||||
|
||||
@@ -5,8 +5,11 @@ import { getProfileAvatarUrl } from '../../selectors/profile.js';
|
||||
import HeaderContentRight from './HeaderContentRight.js';
|
||||
|
||||
const matchStateToProps = (state, ownProps) => ({
|
||||
avatarUrl: getProfileAvatarUrl(state),
|
||||
hideUserProfileButton: ownProps.navigation.state.routeName === 'Profile',
|
||||
avatarUrl: getProfileAvatarUrl(state),
|
||||
hideUserProfileButton: ownProps.navigation.state.routeName === 'Profile',
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, null)(HeaderContentRight);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
null,
|
||||
)(HeaderContentRight);
|
||||
|
||||
@@ -4,14 +4,13 @@ import PropTypes from 'prop-types';
|
||||
import UserProfileButton from './UserProfileButton/UserProfileButton.container.js';
|
||||
|
||||
export default function HeaderContentRight({ hideUserProfileButton, navigation }) {
|
||||
if (hideUserProfileButton) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (hideUserProfileButton) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <UserProfileButton />;
|
||||
return <UserProfileButton />;
|
||||
}
|
||||
|
||||
HeaderContentRight.propTypes = {
|
||||
hideUserProfileButton: PropTypes.bool.isRequired,
|
||||
hideUserProfileButton: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
@@ -5,14 +5,17 @@ import { getActiveEvent, getDefaultEvent } from '../../../../selectors/events.js
|
||||
import EventTitle from './EventTitle.js';
|
||||
|
||||
const matchStateToProps = (state) => {
|
||||
const event = hasActiveEvent(state) ? getActiveEvent(state) : getDefaultEvent(state);
|
||||
const event = hasActiveEvent(state) ? getActiveEvent(state) : getDefaultEvent(state);
|
||||
|
||||
return {
|
||||
date: event.get('date'),
|
||||
end: event.get('end'),
|
||||
name: event.get('name'),
|
||||
start: event.get('start'),
|
||||
};
|
||||
return {
|
||||
date: event.get('date'),
|
||||
end: event.get('end'),
|
||||
name: event.get('name'),
|
||||
start: event.get('start'),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(matchStateToProps, null)(EventTitle);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
null,
|
||||
)(EventTitle);
|
||||
|
||||
@@ -1,43 +1,33 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
import styles from './EventTitle.styles.js';
|
||||
|
||||
export default function EventTitle({
|
||||
action,
|
||||
date,
|
||||
end,
|
||||
name,
|
||||
start,
|
||||
}) {
|
||||
const _generateEventTitle = () => (
|
||||
<View style={styles.eventInfo}>
|
||||
<Text style={styles.eventName}>{name}</Text>
|
||||
<Text style={styles.eventDate}>{`${date} | ${start} - ${end}`}</Text>
|
||||
</View>
|
||||
);
|
||||
export default function EventTitle({ action, date, end, name, start }) {
|
||||
const _generateEventTitle = () => (
|
||||
<View style={styles.eventInfo}>
|
||||
<Text style={styles.eventName}>{name}</Text>
|
||||
<Text style={styles.eventDate}>{`${date} | ${start} - ${end}`}</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
if (action) {
|
||||
return <TouchableOpacity onPress={action}>{_generateEventTitle()}</TouchableOpacity>;
|
||||
}
|
||||
if (action) {
|
||||
return <TouchableOpacity onPress={action}>{_generateEventTitle()}</TouchableOpacity>;
|
||||
}
|
||||
|
||||
return _generateEventTitle();
|
||||
return _generateEventTitle();
|
||||
}
|
||||
|
||||
EventTitle.propTypes = {
|
||||
action: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
end: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
start: PropTypes.string.isRequired,
|
||||
action: PropTypes.func,
|
||||
date: PropTypes.string.isRequired,
|
||||
end: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
start: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
EventTitle.defaultProps = {
|
||||
action: null,
|
||||
action: null,
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
eventInfo: {
|
||||
flexDirection: 'row',
|
||||
},
|
||||
eventName: {
|
||||
flex: 1,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
eventDate: {
|
||||
flex: 1,
|
||||
},
|
||||
});
|
||||
export default (styles = StyleSheet.create({
|
||||
eventInfo: {
|
||||
flexDirection: 'row',
|
||||
},
|
||||
eventName: {
|
||||
flex: 1,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
eventDate: {
|
||||
flex: 1,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -6,13 +6,16 @@ import { hasMultipleEvents } from '../../../selectors/events.js';
|
||||
import HeaderTitle from './HeaderTitle.js';
|
||||
|
||||
const matchStateToProps = (state, ownProps) => {
|
||||
const { routeName } = ownProps.navigation.state;
|
||||
const { routeName } = ownProps.navigation.state;
|
||||
|
||||
return {
|
||||
activeRoute: routeName,
|
||||
hasActiveEvent: hasActiveEvent(state),
|
||||
hasMultipleEvents: hasMultipleEvents(state),
|
||||
};
|
||||
return {
|
||||
activeRoute: routeName,
|
||||
hasActiveEvent: hasActiveEvent(state),
|
||||
hasMultipleEvents: hasMultipleEvents(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(matchStateToProps, null)(HeaderTitle);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
null,
|
||||
)(HeaderTitle);
|
||||
|
||||
@@ -1,60 +1,54 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
import EventTitle from './EventTitle/EventTitle.container.js';
|
||||
|
||||
import styles from './HeaderTitle.styles.js';
|
||||
|
||||
export default function HeaderTitle({
|
||||
activeRoute,
|
||||
hasActiveEvent,
|
||||
hasMultipleEvents,
|
||||
navigation,
|
||||
activeRoute,
|
||||
hasActiveEvent,
|
||||
hasMultipleEvents,
|
||||
navigation,
|
||||
}) {
|
||||
const _goBack = () => {
|
||||
if (hasActiveEvent) {
|
||||
navigation.goBack();
|
||||
return false;
|
||||
}
|
||||
|
||||
const _goBack = () => {
|
||||
if (hasActiveEvent) {
|
||||
navigation.goBack();
|
||||
return false;
|
||||
console.log('nowhere to go...');
|
||||
};
|
||||
|
||||
const _showEvents = () => {
|
||||
navigation.navigate('Events');
|
||||
return false;
|
||||
};
|
||||
|
||||
if (activeRoute === 'Events') {
|
||||
return (
|
||||
<TouchableOpacity onPress={_goBack}>
|
||||
<Text style={styles.screenHeader}>Profile</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
console.log('nowhere to go...');
|
||||
};
|
||||
if (activeRoute === 'Profile') {
|
||||
return <Text style={styles.screenHeader}>Profile</Text>;
|
||||
}
|
||||
|
||||
const _showEvents = () => {
|
||||
navigation.navigate('Events');
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
if (activeRoute === 'Events') {
|
||||
return (
|
||||
<TouchableOpacity onPress={_goBack}>
|
||||
<Text style={styles.screenHeader}>Profile</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
if (activeRoute === 'Profile') {
|
||||
return <Text style={styles.screenHeader}>Profile</Text>;
|
||||
}
|
||||
|
||||
return <EventTitle action={hasMultipleEvents ? _showEvents : null} />
|
||||
return <EventTitle action={hasMultipleEvents ? _showEvents : null} />;
|
||||
}
|
||||
|
||||
HeaderTitle.propTypes = {
|
||||
activeRoute: PropTypes.string.isRequired,
|
||||
hasActiveEvent: PropTypes.bool,
|
||||
hasMultipleEvents: PropTypes.bool.isRequired,
|
||||
navigation: PropTypes.func.isRequired,
|
||||
activeRoute: PropTypes.string.isRequired,
|
||||
hasActiveEvent: PropTypes.bool,
|
||||
hasMultipleEvents: PropTypes.bool.isRequired,
|
||||
navigation: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
HeaderTitle.defaultProps = {
|
||||
hasActiveEvent: false,
|
||||
hasActiveEvent: false,
|
||||
};
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
filterBar: {
|
||||
backgroundColor: '#0F0',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
filter: {
|
||||
flex: 2,
|
||||
},
|
||||
view: {
|
||||
flex: 2,
|
||||
},
|
||||
});
|
||||
|
||||
export default (styles = StyleSheet.create({
|
||||
filterBar: {
|
||||
backgroundColor: '#0F0',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
filter: {
|
||||
flex: 2,
|
||||
},
|
||||
view: {
|
||||
flex: 2,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -5,13 +5,13 @@ import { TouchableOpacity } from 'react-native';
|
||||
import { Icon } from 'react-native-elements';
|
||||
|
||||
export default function BackIcon({ action }) {
|
||||
return (
|
||||
<TouchableOpacity onPress={action}>
|
||||
<Icon name="ei-chevron-left" type="evilicons" size={28} />;
|
||||
</TouchableOpacity>
|
||||
);
|
||||
return (
|
||||
<TouchableOpacity onPress={action}>
|
||||
<Icon name="ei-chevron-left" type="evilicons" size={28} />;
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
BackIcon.propTypes = {
|
||||
action: PropTypes.func.isRequired,
|
||||
action: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -5,20 +5,19 @@ import { TouchableOpacity } from 'react-native';
|
||||
import { Icon } from 'react-native-elements';
|
||||
|
||||
export default function EventsIcon({ action }) {
|
||||
const renderEventsIcon = () => <Icon name="ei-calendar" type="evilicons" size={28} />;
|
||||
|
||||
const renderEventsIcon = () => <Icon name="ei-calendar" type="evilicons" size={28} />;
|
||||
if (action) {
|
||||
return <TouchableOpacity onPress={action}>{renderEventsIcon()}</TouchableOpacity>;
|
||||
}
|
||||
|
||||
if (action) {
|
||||
return <TouchableOpacity onPress={action}>{renderEventsIcon()}</TouchableOpacity>;
|
||||
}
|
||||
|
||||
return renderEventsIcon();
|
||||
return renderEventsIcon();
|
||||
}
|
||||
|
||||
EventsIcon.propTypes = {
|
||||
action: PropTypes.func,
|
||||
action: PropTypes.func,
|
||||
};
|
||||
|
||||
EventsIcon.defaultProps = {
|
||||
action: null,
|
||||
action: null,
|
||||
};
|
||||
|
||||
@@ -5,7 +5,10 @@ import { getProfileAvatarUrl } from '../../../selectors/profile.js';
|
||||
import UserProfileButton from './UserProfileButton.js';
|
||||
|
||||
const matchStateToProps = (state) => ({
|
||||
avatarUrl: getProfileAvatarUrl(state),
|
||||
avatarUrl: getProfileAvatarUrl(state),
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, null)(UserProfileButton);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
null,
|
||||
)(UserProfileButton);
|
||||
|
||||
@@ -7,29 +7,28 @@ import { Icon } from 'react-native-elements';
|
||||
import styles from './UserProfileButton.styles.js';
|
||||
|
||||
export default function UserProfileButton({ avatarUrl, navigation }) {
|
||||
const _goToProfile = () => {
|
||||
navigation.navigate('Profile');
|
||||
return false;
|
||||
};
|
||||
|
||||
const _goToProfile = () => {
|
||||
navigation.navigate('Profile');
|
||||
return false;
|
||||
};
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={_goToProfile}>
|
||||
{avatarUrl !== null ? (
|
||||
<View style={styles.avatarWrap}>
|
||||
<Image source={{ uri: avatarUrl }} />
|
||||
</View>
|
||||
) : (
|
||||
<Icon name="ei-user" type="evilicons" size={28} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
return (
|
||||
<TouchableOpacity onPress={_goToProfile}>
|
||||
{avatarUrl !== null ? (
|
||||
<View style={styles.avatarWrap}>
|
||||
<Image source={{ uri: avatarUrl }} />
|
||||
</View>
|
||||
) : (
|
||||
<Icon name="ei-user" type="evilicons" size={28} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
UserProfileButton.propTypes = {
|
||||
avatarUrl: PropTypes.string,
|
||||
avatarUrl: PropTypes.string,
|
||||
};
|
||||
|
||||
UserProfileButton.propTypes = {
|
||||
avatarUrl: null,
|
||||
avatarUrl: null,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Text,
|
||||
Image,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { StyleSheet, TouchableOpacity, Text, Image, View } from 'react-native';
|
||||
|
||||
import GallerySwiper from 'react-native-gallery-swiper';
|
||||
|
||||
@@ -18,173 +12,173 @@ import { ITEM_TYPES } from '../../constants/constants.js';
|
||||
import { formatPrice, getAuctionTime } from '../../library/helpers.js';
|
||||
|
||||
export default class AuctionListItem extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
description: PropTypes.string,
|
||||
donor: PropTypes.string,
|
||||
end: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
url: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
start: PropTypes.string.isRequired,
|
||||
startingPrice: PropTypes.number.isRequired,
|
||||
subtitle: PropTypes.string,
|
||||
title: PropTypes.string.isRequired,
|
||||
type: PropTypes.string.isRequired,
|
||||
static get propTypes() {
|
||||
return {
|
||||
description: PropTypes.string,
|
||||
donor: PropTypes.string,
|
||||
end: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
url: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
start: PropTypes.string.isRequired,
|
||||
startingPrice: PropTypes.number.isRequired,
|
||||
subtitle: PropTypes.string,
|
||||
title: PropTypes.string.isRequired,
|
||||
type: PropTypes.string.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
description: null,
|
||||
donor: null,
|
||||
images: null,
|
||||
subtitle: null,
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
_getBidTime = () => {
|
||||
const { end, start } = this.props;
|
||||
return getAuctionTime({ end, start });
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
description: null,
|
||||
donor: null,
|
||||
images: null,
|
||||
subtitle: null,
|
||||
_viewItemDetail = () => {
|
||||
const { _id: id } = this.props.details;
|
||||
this.props.navigation.navigate('Item', { id });
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
const {
|
||||
description,
|
||||
donor,
|
||||
end,
|
||||
id,
|
||||
images,
|
||||
start,
|
||||
startingPrice,
|
||||
subtitle,
|
||||
title,
|
||||
type,
|
||||
} = this.props;
|
||||
|
||||
_getBidTime = () => {
|
||||
const { end, start } = this.props;
|
||||
return getAuctionTime({ end, start });
|
||||
}
|
||||
|
||||
_viewItemDetail = () => {
|
||||
const { _id: id } = this.props.details;
|
||||
this.props.navigation.navigate('Item', { id });
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
description,
|
||||
donor,
|
||||
end,
|
||||
id,
|
||||
images,
|
||||
start,
|
||||
startingPrice,
|
||||
subtitle,
|
||||
title,
|
||||
type,
|
||||
} = this.props;
|
||||
|
||||
return(
|
||||
<TouchableOpacity onPress={this._viewItemDetail}>
|
||||
<View style={styles.rowContainer}>
|
||||
{images !== null && images.length > 0 && (
|
||||
<GallerySwiper
|
||||
enableScale={false}
|
||||
images={images}
|
||||
initialNumToRender={2}
|
||||
resizeMode="cover"
|
||||
sensitiveScroll={false}
|
||||
style={{height: 280}}
|
||||
/>
|
||||
)}
|
||||
<View style={styles.rowText}>
|
||||
{type === ITEM_TYPES.AUCTION && <BidStatus itemId={id} />}
|
||||
<Text style={styles.title} numberOfLines={2} ellipsizeMode={'tail'}>
|
||||
{title}
|
||||
</Text>
|
||||
<Text style={styles.subtitle} numberOfLines={1} ellipsizeMode={'tail'}>
|
||||
{subtitle}
|
||||
</Text>
|
||||
{donor && (
|
||||
<Text style={styles.donor} numberOfLines={1} ellipsizeMode={'tail'}>
|
||||
{donor}
|
||||
</Text>
|
||||
)}
|
||||
{type === ITEM_TYPES.AUCTION ? (
|
||||
<AuctionPriceAndBidCount itemId={id} />
|
||||
) : (
|
||||
<Text style={styles.price} numberOfLines={1} ellipsizeMode={'tail'}>
|
||||
{formatPrice(startingPrice)}
|
||||
</Text>
|
||||
)}
|
||||
<Text style={styles.timeline} numberOfLines={1}>
|
||||
{this._getBidTime()}
|
||||
</Text>
|
||||
<Text style={styles.description} numberOfLines={3} ellipsizeMode={'tail'}>
|
||||
{description}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<TouchableOpacity onPress={this._viewItemDetail}>
|
||||
<View style={styles.rowContainer}>
|
||||
{images !== null && images.length > 0 && (
|
||||
<GallerySwiper
|
||||
enableScale={false}
|
||||
images={images}
|
||||
initialNumToRender={2}
|
||||
resizeMode="cover"
|
||||
sensitiveScroll={false}
|
||||
style={{ height: 280 }}
|
||||
/>
|
||||
)}
|
||||
<View style={styles.rowText}>
|
||||
{type === ITEM_TYPES.AUCTION && <BidStatus itemId={id} />}
|
||||
<Text style={styles.title} numberOfLines={2} ellipsizeMode={'tail'}>
|
||||
{title}
|
||||
</Text>
|
||||
<Text style={styles.subtitle} numberOfLines={1} ellipsizeMode={'tail'}>
|
||||
{subtitle}
|
||||
</Text>
|
||||
{donor && (
|
||||
<Text style={styles.donor} numberOfLines={1} ellipsizeMode={'tail'}>
|
||||
{donor}
|
||||
</Text>
|
||||
)}
|
||||
{type === ITEM_TYPES.AUCTION ? (
|
||||
<AuctionPriceAndBidCount itemId={id} />
|
||||
) : (
|
||||
<Text style={styles.price} numberOfLines={1} ellipsizeMode={'tail'}>
|
||||
{formatPrice(startingPrice)}
|
||||
</Text>
|
||||
)}
|
||||
<Text style={styles.timeline} numberOfLines={1}>
|
||||
{this._getBidTime()}
|
||||
</Text>
|
||||
<Text style={styles.description} numberOfLines={3} ellipsizeMode={'tail'}>
|
||||
{description}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
description: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
},
|
||||
donor: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
},
|
||||
image: {
|
||||
flex: 1,
|
||||
height: undefined,
|
||||
width: undefined,
|
||||
},
|
||||
price: {
|
||||
color: '#777',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
paddingLeft: 10,
|
||||
paddingTop: 5,
|
||||
},
|
||||
rowContainer: {
|
||||
backgroundColor: '#FFF',
|
||||
borderRadius: 4,
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
marginRight: 10,
|
||||
marginLeft: 10,
|
||||
marginTop: 10,
|
||||
padding: 10,
|
||||
shadowColor: '#CCC',
|
||||
shadowOffset: {
|
||||
width: 1,
|
||||
height: 1
|
||||
description: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
},
|
||||
donor: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
},
|
||||
image: {
|
||||
flex: 1,
|
||||
height: undefined,
|
||||
width: undefined,
|
||||
},
|
||||
price: {
|
||||
color: '#777',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
paddingLeft: 10,
|
||||
paddingTop: 5,
|
||||
},
|
||||
rowContainer: {
|
||||
backgroundColor: '#FFF',
|
||||
borderRadius: 4,
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
marginRight: 10,
|
||||
marginLeft: 10,
|
||||
marginTop: 10,
|
||||
padding: 10,
|
||||
shadowColor: '#CCC',
|
||||
shadowOffset: {
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
shadowOpacity: 1.0,
|
||||
shadowRadius: 1,
|
||||
},
|
||||
rowText: {
|
||||
flex: 4,
|
||||
flexDirection: 'column',
|
||||
},
|
||||
subtitle: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
},
|
||||
timeline: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
},
|
||||
title: {
|
||||
color: '#777',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
paddingLeft: 10,
|
||||
paddingTop: 5,
|
||||
},
|
||||
shadowOpacity: 1.0,
|
||||
shadowRadius: 1,
|
||||
},
|
||||
rowText: {
|
||||
flex: 4,
|
||||
flexDirection: 'column',
|
||||
},
|
||||
subtitle: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
},
|
||||
timeline: {
|
||||
color: '#777',
|
||||
fontSize: 14,
|
||||
marginTop: 5,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
},
|
||||
title: {
|
||||
color: '#777',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
paddingLeft: 10,
|
||||
paddingTop: 5,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,29 +3,26 @@ import PropTypes from 'prop-types';
|
||||
|
||||
import { formatPrice } from '../../library/helpers.js';
|
||||
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text } from 'react-native';
|
||||
|
||||
const AuctionPriceAndBidCount = ({ bidCount, currentPrice }) => {
|
||||
return (
|
||||
<Text style={styles.currentPriceAndBidCount} numberOfLines={1}>
|
||||
{`${formatPrice(currentPrice)} (${bidCount} bids)`}
|
||||
</Text>
|
||||
);
|
||||
return (
|
||||
<Text style={styles.currentPriceAndBidCount} numberOfLines={1}>
|
||||
{`${formatPrice(currentPrice)} (${bidCount} bids)`}
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
||||
AuctionPriceAndBidCount.propTypes = {
|
||||
itemId: PropTypes.string.isRequired,
|
||||
bidCount: PropTypes.number.isRequired,
|
||||
currentPrice: PropTypes.number.isRequired,
|
||||
itemId: PropTypes.string.isRequired,
|
||||
bidCount: PropTypes.number.isRequired,
|
||||
currentPrice: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
currentPriceAndBidCount: {
|
||||
color: '#000',
|
||||
},
|
||||
currentPriceAndBidCount: {
|
||||
color: '#000',
|
||||
},
|
||||
});
|
||||
|
||||
export default AuctionPriceAndBidCount;
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text } from 'react-native';
|
||||
|
||||
const BidStatus = ({ isBidding, isWinning }) => {
|
||||
if (!isBidding) {
|
||||
return null;
|
||||
}
|
||||
if (!isBidding) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const statusBarStyle = isWinning
|
||||
? [ styles.bidStatus, styes.isWinning ]
|
||||
: [ styles.bidStatus, styles.isOutbid ];
|
||||
const statusBarStyle = isWinning
|
||||
? [styles.bidStatus, styes.isWinning]
|
||||
: [styles.bidStatus, styles.isOutbid];
|
||||
|
||||
return (
|
||||
<Text style={statusBarStyle} numberOfLines={1}>
|
||||
{isWinning && `Oh no! You have been outbid!`}
|
||||
{!isWinning && isBidding && `You have the winning bid! (for now...)`}
|
||||
</Text>
|
||||
);
|
||||
return (
|
||||
<Text style={statusBarStyle} numberOfLines={1}>
|
||||
{isWinning && 'Oh no! You have been outbid!'}
|
||||
{!isWinning && isBidding && 'You have the winning bid! (for now...)'}
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
||||
BidStatus.propTypes = {
|
||||
isBidding: PropTypes.bool.isRequired,
|
||||
isWinning: PropTypes.bool.isRequired,
|
||||
itemId: PropTypes.string.isRequired,
|
||||
isBidding: PropTypes.bool.isRequired,
|
||||
isWinning: PropTypes.bool.isRequired,
|
||||
itemId: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
bidStatus: {
|
||||
color: '#fff',
|
||||
},
|
||||
isWinning: {
|
||||
backgroundColor: '#F00',
|
||||
},
|
||||
isOutbid: {
|
||||
backgroundColor: '#0F0',
|
||||
},
|
||||
bidStatus: {
|
||||
color: '#fff',
|
||||
},
|
||||
isWinning: {
|
||||
backgroundColor: '#F00',
|
||||
},
|
||||
isOutbid: {
|
||||
backgroundColor: '#0F0',
|
||||
},
|
||||
});
|
||||
|
||||
export default BidStatus;
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
const FilterBar = ({ changeFilterer, changeViewMode, filterMode, viewMode }) => (
|
||||
<View style={styles.filterBar}>
|
||||
<Text style={styles.filter}>Filter</Text>
|
||||
<Text style={styles.view}>View</Text>
|
||||
<Text style={styles.filter}>Filter</Text>
|
||||
<Text style={styles.view}>View</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
FilterBar.propTypes = {
|
||||
changeFilterer: PropTypes.func.isRequired,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
filterMode: PropTypes.string,
|
||||
viewMode: PropTypes.string,
|
||||
changeFilterer: PropTypes.func.isRequired,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
filterMode: PropTypes.string,
|
||||
viewMode: PropTypes.string,
|
||||
};
|
||||
|
||||
FilterBar.defaultProps = {
|
||||
filterMode: null,
|
||||
viewMode: null,
|
||||
filterMode: null,
|
||||
viewMode: null,
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
filterBar: {
|
||||
backgroundColor: '#0F0',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
filter: {
|
||||
flex: 2,
|
||||
},
|
||||
view: {
|
||||
flex: 2,
|
||||
},
|
||||
filterBar: {
|
||||
backgroundColor: '#0F0',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
filter: {
|
||||
flex: 2,
|
||||
},
|
||||
view: {
|
||||
flex: 2,
|
||||
},
|
||||
});
|
||||
|
||||
export default FilterBar;
|
||||
|
||||
@@ -1,84 +1,79 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Text,
|
||||
Image,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { StyleSheet, TouchableOpacity, Text, Image, View } from 'react-native';
|
||||
|
||||
export default class EventListItem extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
description: PropTypes.string.isRequired,
|
||||
endTime: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
url: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
isTicketed: PropTypes.bool,
|
||||
postCount: PropTypes.number,
|
||||
setActiveEvent: PropTypes.func.isRequired,
|
||||
showFrom: PropTypes.string.isRequired,
|
||||
showUntil: PropTypes.string.isRequired,
|
||||
startTime: PropTypes.string.isRequired,
|
||||
tagline: PropTypes.string,
|
||||
title: PropTypes.string.isRequired,
|
||||
static get propTypes() {
|
||||
return {
|
||||
end: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
url: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
setActiveEvent: PropTypes.func.isRequired,
|
||||
showFrom: PropTypes.string.isRequired,
|
||||
showUntil: PropTypes.string.isRequired,
|
||||
start: PropTypes.string.isRequired,
|
||||
tagline: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
images: null,
|
||||
isTicketed: false,
|
||||
postCount: 0,
|
||||
tagline: null,
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
_viewEventDetail = () => {
|
||||
this.props.setActiveEvent(this.props.id);
|
||||
this.props.navigation.navigate('Event');
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
images: null,
|
||||
isTicketed: false,
|
||||
postCount: 0,
|
||||
tagline: null,
|
||||
};
|
||||
}
|
||||
render() {
|
||||
const { date, description, end, name, start } = this.props;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
_viewEventDetail = () => {
|
||||
const { id } = this.props.details;
|
||||
this.props.setActiveEvent(id);
|
||||
this.props.navigation.navigate('Event');
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
} = this.props;
|
||||
|
||||
return(
|
||||
<TouchableOpacity onPress={this._viewEventDetail}>
|
||||
<View style={styles.rowContainer}>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<TouchableOpacity onPress={this._viewEventDetail}>
|
||||
<View style={styles.rowContainer}>
|
||||
<Text>{name}</Text>
|
||||
<Text>{date}</Text>
|
||||
<Text>
|
||||
{start} - {end}
|
||||
</Text>
|
||||
<Text>{description}</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
rowContainer: {
|
||||
backgroundColor: '#FFF',
|
||||
borderRadius: 4,
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
marginRight: 10,
|
||||
marginLeft: 10,
|
||||
marginTop: 10,
|
||||
padding: 10,
|
||||
shadowColor: '#CCC',
|
||||
shadowOffset: {
|
||||
width: 1,
|
||||
height: 1
|
||||
rowContainer: {
|
||||
backgroundColor: '#FFF',
|
||||
borderRadius: 4,
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
marginRight: 10,
|
||||
marginLeft: 10,
|
||||
marginTop: 10,
|
||||
padding: 10,
|
||||
shadowColor: '#CCC',
|
||||
shadowOffset: {
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
shadowOpacity: 1.0,
|
||||
shadowRadius: 1,
|
||||
},
|
||||
shadowOpacity: 1.0,
|
||||
shadowRadius: 1,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import {
|
||||
facebookLoginSuccess,
|
||||
logout,
|
||||
registrationServiceError,
|
||||
userCanceledRegistration,
|
||||
facebookLoginSuccess,
|
||||
logout,
|
||||
registrationServiceError,
|
||||
userCanceledRegistration,
|
||||
} from '../../actions/profile.js';
|
||||
|
||||
import FacebookLogin from './FacebookLogin.js';
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
doCancelAction: () => dispatch(userCanceledRegistration()),
|
||||
doErrorAction: (error) => dispatch(registrationServiceError(error)),
|
||||
doLogoutAction: () => dispatch(logout()),
|
||||
doSuccessAction: (result) => dispatch(facebookLoginSuccess(result)),
|
||||
doCancelAction: () => dispatch(userCanceledRegistration()),
|
||||
doErrorAction: (error) => dispatch(registrationServiceError(error)),
|
||||
doLogoutAction: () => dispatch(logout()),
|
||||
doSuccessAction: (result) => dispatch(facebookLoginSuccess(result)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(FacebookLogin);
|
||||
export default connect(
|
||||
null,
|
||||
mapDispatchToProps,
|
||||
)(FacebookLogin);
|
||||
|
||||
@@ -6,36 +6,33 @@ import { LoginButton } from 'react-native-fbsdk';
|
||||
import { PERMISSIONS } from '../../constants/constants.js';
|
||||
|
||||
export default function FacebookLogin({
|
||||
doCancelAction,
|
||||
doErrorAction,
|
||||
doLogoutAction,
|
||||
doSuccessAction,
|
||||
doCancelAction,
|
||||
doErrorAction,
|
||||
doLogoutAction,
|
||||
doSuccessAction,
|
||||
}) {
|
||||
|
||||
return (
|
||||
<View>
|
||||
<LoginButton
|
||||
publishPermissions={PERMISSIONS.FACEBOOK}
|
||||
onLoginFinished={
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
doErrorAction(error);
|
||||
} else if (result.isCancelled) {
|
||||
doCancelAction();
|
||||
} else {
|
||||
doSuccessAction(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
onLogoutFinished={doLogoutAction}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
return (
|
||||
<View>
|
||||
<LoginButton
|
||||
publishPermissions={PERMISSIONS.FACEBOOK}
|
||||
onLoginFinished={(error, result) => {
|
||||
if (error) {
|
||||
doErrorAction(error);
|
||||
} else if (result.isCancelled) {
|
||||
doCancelAction();
|
||||
} else {
|
||||
doSuccessAction(result);
|
||||
}
|
||||
}}
|
||||
onLogoutFinished={doLogoutAction}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
FacebookLogin.propTypes = {
|
||||
doCancelAction: PropTypes.func.isRequired,
|
||||
doErrorAction: PropTypes.func.isRequired,
|
||||
doLogoutAction: PropTypes.func.isRequired,
|
||||
doSuccessAction: PropTypes.func.isRequired,
|
||||
doCancelAction: PropTypes.func.isRequired,
|
||||
doErrorAction: PropTypes.func.isRequired,
|
||||
doLogoutAction: PropTypes.func.isRequired,
|
||||
doSuccessAction: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -5,7 +5,10 @@ import { login } from '../../actions/profile.js';
|
||||
import LocalLogin from './LocalLogin.js';
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
doLoginAction: (username, password) => dispatch(login(username, password)),
|
||||
doLoginAction: (username, password) => dispatch(login(username, password)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(LocalLogin);
|
||||
export default connect(
|
||||
null,
|
||||
mapDispatchToProps,
|
||||
)(LocalLogin);
|
||||
|
||||
@@ -54,5 +54,5 @@ export default function LocalLogin({ doLoginAction }) {
|
||||
}
|
||||
|
||||
LocalLogin.propTypes = {
|
||||
doLoginAction: PropTypes.func.isRequired,
|
||||
doLoginAction: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
export const ITEM_FILTERS = {
|
||||
ALL: 'ALL',
|
||||
ALL: 'ALL',
|
||||
};
|
||||
|
||||
export const ITEM_TYPES = {
|
||||
AUCTION: 'auction',
|
||||
DONATION: 'donation',
|
||||
EVENT: 'event',
|
||||
MEMBERSHIP: 'membership',
|
||||
POPUP: 'popup',
|
||||
RAFFLE: 'raffle',
|
||||
TICKET: 'ticket',
|
||||
AUCTION: 'auction',
|
||||
DONATION: 'donation',
|
||||
EVENT: 'event',
|
||||
MEMBERSHIP: 'membership',
|
||||
POPUP: 'popup',
|
||||
RAFFLE: 'raffle',
|
||||
TICKET: 'ticket',
|
||||
};
|
||||
|
||||
export const SORT_MODES = {
|
||||
BIDDERS_ASC: 'BIDDERS_ASC',
|
||||
BIDDERS_DSC: 'BIDDERS_DSC',
|
||||
ENDING_ASC: 'ENDING_ASC',
|
||||
ENDING_DSC: 'ENDING_DSC',
|
||||
PRICE_ASC: 'PRICE_ASC',
|
||||
PRICE_DSC: 'PRICE_DSC',
|
||||
TITLE_ASC: 'TITLE_ASC',
|
||||
TITLE_DSC: 'TITLE_DSC',
|
||||
BIDDERS_ASC: 'BIDDERS_ASC',
|
||||
BIDDERS_DSC: 'BIDDERS_DSC',
|
||||
ENDING_ASC: 'ENDING_ASC',
|
||||
ENDING_DSC: 'ENDING_DSC',
|
||||
PRICE_ASC: 'PRICE_ASC',
|
||||
PRICE_DSC: 'PRICE_DSC',
|
||||
TITLE_ASC: 'TITLE_ASC',
|
||||
TITLE_DSC: 'TITLE_DSC',
|
||||
};
|
||||
|
||||
export const AUCTION_VIEW_MODES = {
|
||||
ALL: 'ALL',
|
||||
BIDDING: 'BIDDING',
|
||||
NO_BIDS: 'NO_BIDS',
|
||||
WINNING: 'WINNING',
|
||||
ALL: 'ALL',
|
||||
BIDDING: 'BIDDING',
|
||||
NO_BIDS: 'NO_BIDS',
|
||||
WINNING: 'WINNING',
|
||||
};
|
||||
|
||||
export const API_URL = 'http://localhost:3001';
|
||||
|
||||
export const API_ENDPOINTS = {
|
||||
GET_EVENTS: 'GET_EVENTS',
|
||||
GET_ITEMS: 'GET_ITEMS',
|
||||
GET_STATUS: 'GET_STATUS',
|
||||
PLACE_BID: 'PLACE_BID',
|
||||
PURCHASE_ITEM: 'PURCHASE_ITEM',
|
||||
USER_SIGNUP: 'USER_SIGNUP',
|
||||
USER_PROFILE: 'USER_PROFILE',
|
||||
APPLE_SIGNUP: 'APPLE_SIGNUP',
|
||||
APPLE_LINK: 'APPLE_LINK',
|
||||
FACEBOOK_SIGNUP: 'FACEBOOK_SIGNUP',
|
||||
FACEBOOK_LINK: 'FACEBOOK_LINK',
|
||||
GOOGLE_SIGNUP: 'GOOGLE_SIGNUP',
|
||||
GOOGLE_LINK: 'GOOGLE_LINK',
|
||||
GET_EVENTS: 'GET_EVENTS',
|
||||
GET_ITEMS: 'GET_ITEMS',
|
||||
GET_STATUS: 'GET_STATUS',
|
||||
PLACE_BID: 'PLACE_BID',
|
||||
PURCHASE_ITEM: 'PURCHASE_ITEM',
|
||||
USER_SIGNUP: 'USER_SIGNUP',
|
||||
USER_PROFILE: 'USER_PROFILE',
|
||||
APPLE_SIGNUP: 'APPLE_SIGNUP',
|
||||
APPLE_LINK: 'APPLE_LINK',
|
||||
FACEBOOK_SIGNUP: 'FACEBOOK_SIGNUP',
|
||||
FACEBOOK_LINK: 'FACEBOOK_LINK',
|
||||
GOOGLE_SIGNUP: 'GOOGLE_SIGNUP',
|
||||
GOOGLE_LINK: 'GOOGLE_LINK',
|
||||
};
|
||||
|
||||
export const PERMISSIONS = {
|
||||
FACEBOOK: [ 'email', 'public_profile' ],
|
||||
FACEBOOK: ['email', 'public_profile'],
|
||||
};
|
||||
|
||||
@@ -5,25 +5,27 @@ import { placeBid } from '../../actions/auction.js';
|
||||
import AuctionListItem from '../../components/Auction/AuctionListItem.js';
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { item } = ownProps;
|
||||
const { item } = ownProps;
|
||||
|
||||
return {
|
||||
description: item.get('description'),
|
||||
donor: item.get('donor'),
|
||||
end: item.get('end'),
|
||||
id: item.get('id'),
|
||||
images: item.get('images').toArray(),
|
||||
start: item.get('start'),
|
||||
startingPrice: item.get('startingPrice'),
|
||||
subtitle: item.get('subtitle'),
|
||||
title: item.get('title'),
|
||||
type: item.get('type'),
|
||||
};
|
||||
return {
|
||||
description: item.get('description'),
|
||||
donor: item.get('donor'),
|
||||
end: item.get('end'),
|
||||
id: item.get('id'),
|
||||
images: item.get('images').toArray(),
|
||||
start: item.get('start'),
|
||||
startingPrice: item.get('startingPrice'),
|
||||
subtitle: item.get('subtitle'),
|
||||
title: item.get('title'),
|
||||
type: item.get('type'),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
placeBid: (data) => dispatch(placeBid(data)),
|
||||
placeBid: (data) => dispatch(placeBid(data)),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, null)(AuctionListItem);
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null,
|
||||
)(AuctionListItem);
|
||||
|
||||
@@ -5,12 +5,15 @@ import { getItemBidCount, getItemPrice } from '../../selectors/auctions.js';
|
||||
import AuctionPriceAndBidCount from '../../components/Auction/AuctionPriceAndBidCount.js';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const { itemId } = ownProps;
|
||||
const { itemId } = ownProps;
|
||||
|
||||
return {
|
||||
bidCount: getItemBidCount(state, itemId),
|
||||
currentPrice: getItemPrice(state, itemId),
|
||||
};
|
||||
return {
|
||||
bidCount: getItemBidCount(state, itemId),
|
||||
currentPrice: getItemPrice(state, itemId),
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(AuctionPriceAndBidCount);
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null,
|
||||
)(AuctionPriceAndBidCount);
|
||||
|
||||
@@ -5,12 +5,15 @@ import { isBiddingItem, isWinningItem } from '../../selectors/auctions.js';
|
||||
import AuctionPriceAndBidCount from '../../components/Auction/BidStatus.js';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const { itemId } = ownProps;
|
||||
const { itemId } = ownProps;
|
||||
|
||||
return {
|
||||
isBidding: isBiddingItem(state, itemId),
|
||||
isWinning: isWinningItem(state, itemId),
|
||||
};
|
||||
return {
|
||||
isBidding: isBiddingItem(state, itemId),
|
||||
isWinning: isWinningItem(state, itemId),
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(AuctionPriceAndBidCount);
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null,
|
||||
)(AuctionPriceAndBidCount);
|
||||
|
||||
@@ -6,14 +6,17 @@ import { getEventsAsList } from '../selectors/events.js';
|
||||
import Events from '../screens/Events.js';
|
||||
|
||||
const matchStateToProps = (state) => {
|
||||
const events = getEventsAsList(state);
|
||||
console.log('events:', events);
|
||||
const events = getEventsAsList(state);
|
||||
console.log('events:', events);
|
||||
|
||||
return { events };
|
||||
return { events };
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
fetchEvents: () => dispatch(fetchEvents(dispatch)),
|
||||
fetchEvents: () => dispatch(fetchEvents(dispatch)),
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Events);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Events);
|
||||
|
||||
@@ -4,26 +4,28 @@ import { setActiveEvent } from '../../actions/events.js';
|
||||
import EventListItem from '../../components/Events/EventListItem.js';
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { event } = ownProps;
|
||||
const { event } = ownProps;
|
||||
|
||||
return {
|
||||
description: event.get('description'),
|
||||
endTime: event.get('endTime'),
|
||||
id: event.get('id'),
|
||||
images: event.get('images').toArray(),
|
||||
isTicketed: event.get('isTicketed'),
|
||||
postCount: event.get('posts').size,
|
||||
showFrom: event.get('showFrom'),
|
||||
showUntil: event.get('showUntil'),
|
||||
startTime: event.get('startTime'),
|
||||
tagline: event.get('tagline'),
|
||||
title: event.get('title'),
|
||||
};
|
||||
return {
|
||||
description: event.get('description'),
|
||||
endTime: event.get('endTime'),
|
||||
id: event.get('id'),
|
||||
images: event.get('images').toArray(),
|
||||
isTicketed: event.get('isTicketed'),
|
||||
postCount: event.get('posts').size,
|
||||
showFrom: event.get('showFrom'),
|
||||
showUntil: event.get('showUntil'),
|
||||
startTime: event.get('startTime'),
|
||||
tagline: event.get('tagline'),
|
||||
title: event.get('title'),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setActiveEvent: (eventId) => dispatch(setActiveEvent(eventId)),
|
||||
setActiveEvent: (eventId) => dispatch(setActiveEvent(eventId)),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, null)(AuctionListItem);
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null,
|
||||
)(AuctionListItem);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Record } from 'immutable';
|
||||
|
||||
export default class Auction extends Record({
|
||||
id: null,
|
||||
bidCount: 0,
|
||||
isBidding: false,
|
||||
isWinning: false,
|
||||
itemPrice: 0,
|
||||
id: null,
|
||||
bidCount: 0,
|
||||
isBidding: false,
|
||||
isWinning: false,
|
||||
itemPrice: 0,
|
||||
}) {}
|
||||
|
||||
Auction.fromJS = (data = {}) => {
|
||||
return new Auction({
|
||||
id: data._id,
|
||||
...data,
|
||||
});
|
||||
return new Auction({
|
||||
id: data._id,
|
||||
...data,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,36 +4,36 @@ import Post from './Post.js';
|
||||
import TicketClass from './TicketClass.js';
|
||||
|
||||
export default class Event extends Record({
|
||||
id: null,
|
||||
isTicketed: false,
|
||||
requireLoginToSeeAuction: false,
|
||||
description: null,
|
||||
endTime: null,
|
||||
images: new List(),
|
||||
posts: new List(),
|
||||
showFrom: null,
|
||||
showUntil: null,
|
||||
startTime: null,
|
||||
tagline: null,
|
||||
title: null,
|
||||
url: null,
|
||||
ticketClasses: new List(),
|
||||
id: null,
|
||||
isTicketed: false,
|
||||
requireLoginToSeeAuction: false,
|
||||
description: null,
|
||||
endTime: null,
|
||||
images: new List(),
|
||||
posts: new List(),
|
||||
showFrom: null,
|
||||
showUntil: null,
|
||||
startTime: null,
|
||||
tagline: null,
|
||||
title: null,
|
||||
url: null,
|
||||
ticketClasses: new List(),
|
||||
}) {
|
||||
get isSoldOut() {
|
||||
if (this.isTicketed) {
|
||||
return false;
|
||||
}
|
||||
get isSoldOut() {
|
||||
if (this.isTicketed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.ticketClasses.find(t => t.available > 0) || false;
|
||||
}
|
||||
return this.ticketClasses.find((t) => t.available > 0) || false;
|
||||
}
|
||||
}
|
||||
|
||||
Event.fromJS = (data = {}) => {
|
||||
return new Event({
|
||||
id: data._id,
|
||||
...data,
|
||||
images: new List(data.images),
|
||||
posts: new List(data.posts.map(p => Post.fromJS(p))),
|
||||
ticketClasses: new List(data.ticketClasses.map(t => TicketClass.fromJS(t))),
|
||||
});
|
||||
return new Event({
|
||||
id: data._id,
|
||||
...data,
|
||||
images: new List(data.images),
|
||||
posts: new List(data.posts.map((p) => Post.fromJS(p))),
|
||||
ticketClasses: new List(data.ticketClasses.map((t) => TicketClass.fromJS(t))),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import { List, Record } from 'immutable';
|
||||
|
||||
export default class Item extends Record({
|
||||
bidCount: 0,
|
||||
bidIncrement: 10,
|
||||
catalogNumber: null,
|
||||
currentPrice: 0,
|
||||
description: null,
|
||||
donor: null,
|
||||
end: null,
|
||||
estimatedValue: null,
|
||||
eventId: null,
|
||||
hideAfterEnd: false,
|
||||
hideBeforeStart: false,
|
||||
id: null,
|
||||
images: new List(),
|
||||
isShippable: false,
|
||||
notifyOnAvailable: false,
|
||||
quantityAvailable: 1,
|
||||
soldCount: 0,
|
||||
start: null,
|
||||
startingPrice: null,
|
||||
subtitle: null,
|
||||
title: null,
|
||||
type: null,
|
||||
shippingCost: 0,
|
||||
bidCount: 0,
|
||||
bidIncrement: 10,
|
||||
catalogNumber: null,
|
||||
currentPrice: 0,
|
||||
description: null,
|
||||
donor: null,
|
||||
end: null,
|
||||
estimatedValue: null,
|
||||
eventId: null,
|
||||
hideAfterEnd: false,
|
||||
hideBeforeStart: false,
|
||||
id: null,
|
||||
images: new List(),
|
||||
isShippable: false,
|
||||
notifyOnAvailable: false,
|
||||
quantityAvailable: 1,
|
||||
soldCount: 0,
|
||||
start: null,
|
||||
startingPrice: null,
|
||||
subtitle: null,
|
||||
title: null,
|
||||
type: null,
|
||||
shippingCost: 0,
|
||||
}) {
|
||||
get isSoldOut() {
|
||||
return this.quantityAvailable > this.soldCount;
|
||||
}
|
||||
get isSoldOut() {
|
||||
return this.quantityAvailable > this.soldCount;
|
||||
}
|
||||
|
||||
get totalWithShipping() {
|
||||
return this.currentPrice + this.shippingCost;
|
||||
}
|
||||
get totalWithShipping() {
|
||||
return this.currentPrice + this.shippingCost;
|
||||
}
|
||||
}
|
||||
|
||||
Item.fromJS = (data = {}) => {
|
||||
return new Item({
|
||||
id: data._id,
|
||||
...data,
|
||||
images: List(data.images),
|
||||
});
|
||||
return new Item({
|
||||
id: data._id,
|
||||
...data,
|
||||
images: List(data.images),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import { Record } from 'immutable';
|
||||
|
||||
export default class Post extends Record({
|
||||
author: null,
|
||||
content: null,
|
||||
id: null,
|
||||
isPublic: false,
|
||||
scheduledPost: false,
|
||||
sendNotification: false,
|
||||
timestamp: null,
|
||||
title: null,
|
||||
}) {};
|
||||
|
||||
author: null,
|
||||
content: null,
|
||||
id: null,
|
||||
isPublic: false,
|
||||
scheduledPost: false,
|
||||
sendNotification: false,
|
||||
timestamp: null,
|
||||
title: null,
|
||||
}) {}
|
||||
|
||||
Post.fromJS = (data = {}) => {
|
||||
return new Post({
|
||||
id: data._id,
|
||||
...data,
|
||||
});
|
||||
return new Post({
|
||||
id: data._id,
|
||||
...data,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,44 +1,48 @@
|
||||
import { List, Record } from 'immutable';
|
||||
|
||||
export default class Profile extends Record({
|
||||
addresses: new List(),
|
||||
avatar: null,
|
||||
email: null,
|
||||
firstName: null,
|
||||
generatedNomDeBid: false,
|
||||
hasLinkedApple: false,
|
||||
hasLinkedFacebook: false,
|
||||
hasLinkedGoogle: false,
|
||||
hasLocalAccount: false,
|
||||
id: null,
|
||||
isAllowedToBid: false,
|
||||
isOrganizationEmployee: false,
|
||||
isVerified: false,
|
||||
lastName: null,
|
||||
nomDeBid: null,
|
||||
organizationIdentifier: null,
|
||||
paymentToken: null,
|
||||
phones: new List(),
|
||||
addresses: new List(),
|
||||
avatar: null,
|
||||
email: null,
|
||||
firstName: null,
|
||||
generatedNomDeBid: false,
|
||||
hasLinkedApple: false,
|
||||
hasLinkedFacebook: false,
|
||||
hasLinkedGoogle: false,
|
||||
hasLocalAccount: false,
|
||||
id: null,
|
||||
isAllowedToBid: false,
|
||||
isOrganizationEmployee: false,
|
||||
isVerified: false,
|
||||
lastName: null,
|
||||
nomDeBid: null,
|
||||
organizationIdentifier: null,
|
||||
paymentToken: null,
|
||||
phones: new List(),
|
||||
}) {
|
||||
get canBid() {
|
||||
return this.isAllowedToBid && this.paymentToken !== null;
|
||||
}
|
||||
get canBid() {
|
||||
return this.isAllowedToBid && this.paymentToken !== null;
|
||||
}
|
||||
|
||||
get fullName() {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
}
|
||||
get fullName() {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
}
|
||||
|
||||
get isRegisteredAccount() {
|
||||
return this.hasLinkedApple ||
|
||||
this.hasLinkedFacebook || this.hasLinkedGoogle || this.hasLocalAccount;
|
||||
}
|
||||
get isRegisteredAccount() {
|
||||
return (
|
||||
this.hasLinkedApple ||
|
||||
this.hasLinkedFacebook ||
|
||||
this.hasLinkedGoogle ||
|
||||
this.hasLocalAccount
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Profile.fromJS = (data = {}) => {
|
||||
return new Profile({
|
||||
id: data._id,
|
||||
...data,
|
||||
addresses: new List(data.addresses),
|
||||
phones: new List(data.phones),
|
||||
});
|
||||
return new Profile({
|
||||
id: data._id,
|
||||
...data,
|
||||
addresses: new List(data.addresses),
|
||||
phones: new List(data.phones),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { List, Record } from 'immutable';
|
||||
|
||||
export default class TicketClass extends Record({
|
||||
available: 0,
|
||||
capacity: 0,
|
||||
endSale: null,
|
||||
id: null,
|
||||
itemId: null,
|
||||
name: null,
|
||||
price: 0,
|
||||
startSale: null,
|
||||
available: 0,
|
||||
capacity: 0,
|
||||
endSale: null,
|
||||
id: null,
|
||||
itemId: null,
|
||||
name: null,
|
||||
price: 0,
|
||||
startSale: null,
|
||||
}) {
|
||||
get isAlmostGone() {
|
||||
return this.available < (this.capacity * 0.20);
|
||||
}
|
||||
get isAlmostGone() {
|
||||
return this.available < this.capacity * 0.2;
|
||||
}
|
||||
|
||||
get isSoldOut() {
|
||||
return this.available === 0;
|
||||
}
|
||||
get isSoldOut() {
|
||||
return this.available === 0;
|
||||
}
|
||||
}
|
||||
|
||||
TicketClass.fromJS = (data = {}) => {
|
||||
return new TicketClass({
|
||||
id: data._id,
|
||||
...data,
|
||||
});
|
||||
return new TicketClass({
|
||||
id: data._id,
|
||||
...data,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5,60 +5,60 @@ export const formatPrice = (price, format = '$ 0,0[.]00') => {
|
||||
};
|
||||
|
||||
export const getAuctionTime = ({ end, start }) => {
|
||||
const now = new Date();
|
||||
const compareToEnd = new Date(end);
|
||||
const compareToStart = new Date(start);
|
||||
const now = new Date();
|
||||
const compareToEnd = new Date(end);
|
||||
const compareToStart = new Date(start);
|
||||
|
||||
let delta;
|
||||
if (now < start) {
|
||||
delta = start - now;
|
||||
return 'Bidding starts in ${parseTimeDifferential(delta)}';
|
||||
}
|
||||
let delta;
|
||||
if (now < start) {
|
||||
delta = start - now;
|
||||
return 'Bidding starts in ${parseTimeDifferential(delta)}';
|
||||
}
|
||||
|
||||
if (now > start && now < end) {
|
||||
delta = end - now;
|
||||
return 'Bidding ends in ${parseTimeDifferential(delta)}';
|
||||
}
|
||||
if (now > start && now < end) {
|
||||
delta = end - now;
|
||||
return 'Bidding ends in ${parseTimeDifferential(delta)}';
|
||||
}
|
||||
|
||||
return 'Bidding has ended';
|
||||
return 'Bidding has ended';
|
||||
};
|
||||
|
||||
export const parseHumanReadableTimeDifferential = (delta) => {
|
||||
const oneMinute = 60 * 1000;
|
||||
const oneHour = oneMinute * 60;
|
||||
const oneDay = oneHour * 24;
|
||||
const oneWeek = oneDay * 7;
|
||||
const oneMonth = oneWeek * 4;
|
||||
const oneMinute = 60 * 1000;
|
||||
const oneHour = oneMinute * 60;
|
||||
const oneDay = oneHour * 24;
|
||||
const oneWeek = oneDay * 7;
|
||||
const oneMonth = oneWeek * 4;
|
||||
|
||||
let compare = delta / oneMonth;
|
||||
if (compare >= 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} month${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
let compare = delta / oneMonth;
|
||||
if (compare >= 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} month${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
|
||||
compare = delta / oneWeek;
|
||||
if (compare >= 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} week${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
compare = delta / oneWeek;
|
||||
if (compare >= 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} week${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
|
||||
compare = delta / oneDay;
|
||||
if (compare > 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} day${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
compare = delta / oneDay;
|
||||
if (compare > 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} day${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
|
||||
compare = delta / oneHour;
|
||||
if (compare > 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} hour${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
compare = delta / oneHour;
|
||||
if (compare > 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} hour${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
|
||||
compare = delta / oneMinute;
|
||||
if (compare > 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} minute${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
compare = delta / oneMinute;
|
||||
if (compare > 1) {
|
||||
compare = Math.floor(compare);
|
||||
return `${compare} minute${compare > 1 ? 's' : ''}`;
|
||||
}
|
||||
|
||||
return 'less than a minute';
|
||||
return 'less than a minute';
|
||||
};
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { SET_ACTIVE_EVENT, UNSET_ACTIVE_EVENT } from '../constants/actionTypes.js';
|
||||
import { EVENTS_LOADED, SET_ACTIVE_EVENT, UNSET_ACTIVE_EVENT } from '../constants/actionTypes.js';
|
||||
|
||||
export const activeEvent = (state = null, action) => {
|
||||
switch (action.type) {
|
||||
case SET_ACTIVE_EVENT:
|
||||
return action.payload;
|
||||
case UNSET_ACTIVE_EVENT:
|
||||
return null;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case EVENTS_LOADED:
|
||||
return action.payload.size === 1 ? action.payload.get(0).get('id') : null;
|
||||
case SET_ACTIVE_EVENT:
|
||||
return action.payload;
|
||||
case UNSET_ACTIVE_EVENT:
|
||||
return null;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { SET_ACTIVE_ITEM, UNSET_ACTIVE_ITEM } from '../constants/actionTypes.js';
|
||||
|
||||
export const activeItem = (state = null, action) => {
|
||||
switch (action.type) {
|
||||
case SET_ACTIVE_ITEM:
|
||||
return action.payload;
|
||||
case UNSET_ACTIVE_ITEM:
|
||||
return null;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case SET_ACTIVE_ITEM:
|
||||
return action.payload;
|
||||
case UNSET_ACTIVE_ITEM:
|
||||
return null;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,10 +2,10 @@ import { SET_AUCTION_FILTER } from '../constants/actionTypes.js';
|
||||
import { ITEM_FILTERS } from '../constants/constants.js';
|
||||
|
||||
export const auctionFilter = (state = ITEM_FILTERS.ALL, action) => {
|
||||
switch (action.type) {
|
||||
case SET_AUCTION_FILTER:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case SET_AUCTION_FILTER:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,10 +2,10 @@ import { SET_AUCTION_VIEW_MODE } from '../constants/actionTypes.js';
|
||||
import { AUCTION_VIEW_MODES } from '../constants/constants.js';
|
||||
|
||||
export const auctionView = (state = AUCTION_VIEW_MODES.ALL, action) => {
|
||||
switch (action.type) {
|
||||
case SET_AUCTION_VIEW_MODE:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case SET_AUCTION_VIEW_MODE:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,16 +3,16 @@ import { Map } from 'immutable';
|
||||
import { AUCTIONS_UPDATED, UPDATE_AUCTIONS } from '../constants/actionTypes.js';
|
||||
|
||||
export const auctions = (state = new Map(), action) => {
|
||||
switch (action.type) {
|
||||
case AUCTIONS_UPDATED:
|
||||
return state.merge(
|
||||
action.payload.toMap().mapEntries((entry) => {
|
||||
const [, item] = entry;
|
||||
return [`${item.id}`, item];
|
||||
}),
|
||||
);
|
||||
case UPDATE_AUCTIONS:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case AUCTIONS_UPDATED:
|
||||
return state.merge(
|
||||
action.payload.toMap().mapEntries((entry) => {
|
||||
const [, item] = entry;
|
||||
return [`${item.id}`, item];
|
||||
}),
|
||||
);
|
||||
case UPDATE_AUCTIONS:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { LOGIN_SUCCESS, SET_AUTH, UNSET_AUTH } from '../constants/actionTypes.js';
|
||||
|
||||
export const auth = (state = null, action) => {
|
||||
switch (action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
return action.payload.token;
|
||||
case SET_AUTH:
|
||||
return action.payload;
|
||||
case UNSET_AUTH:
|
||||
return null;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
return action.payload.token;
|
||||
case SET_AUTH:
|
||||
return action.payload;
|
||||
case UNSET_AUTH:
|
||||
return null;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { BLOCK_UI, UNBLOCK_UI } from '../constants/actionTypes.js';
|
||||
|
||||
export const blockUI = (state = false, action) => {
|
||||
switch (action.type) {
|
||||
case BLOCK_UI:
|
||||
return true;
|
||||
case UNBLOCK_UI:
|
||||
return false;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case BLOCK_UI:
|
||||
return true;
|
||||
case UNBLOCK_UI:
|
||||
return false;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,15 +3,15 @@ import { Map } from 'immutable';
|
||||
import { EVENTS_LOADED, GET_EVENTS } from '../constants/actionTypes.js';
|
||||
|
||||
export const events = (state = new Map(), action) => {
|
||||
switch (action.type) {
|
||||
case EVENTS_LOADED:
|
||||
const mapped = action.payload.toMap().mapEntries((entry) => {
|
||||
const [, event] = entry;
|
||||
return [`${event.id}`, event];
|
||||
});
|
||||
return state.merge(mapped);
|
||||
case GET_EVENTS:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case EVENTS_LOADED:
|
||||
const mapped = action.payload.toMap().mapEntries((entry) => {
|
||||
const [, event] = entry;
|
||||
return [`${event.id}`, event];
|
||||
});
|
||||
return state.merge(mapped);
|
||||
case GET_EVENTS:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,16 +12,16 @@ import { items } from './items.js';
|
||||
import { profile } from './profile.js';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
activeEvent,
|
||||
activeItem,
|
||||
auctionFilter,
|
||||
auctions,
|
||||
auctionView,
|
||||
auth,
|
||||
blockUI,
|
||||
events,
|
||||
items,
|
||||
profile,
|
||||
activeEvent,
|
||||
activeItem,
|
||||
auctionFilter,
|
||||
auctions,
|
||||
auctionView,
|
||||
auth,
|
||||
blockUI,
|
||||
events,
|
||||
items,
|
||||
profile,
|
||||
});
|
||||
|
||||
export default rootReducer;
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import { Map } from 'immutable';
|
||||
|
||||
import {
|
||||
GET_ITEMS,
|
||||
ITEMS_LOADED,
|
||||
} from '../constants/actionTypes.js';
|
||||
import { GET_ITEMS, ITEMS_LOADED } from '../constants/actionTypes.js';
|
||||
|
||||
export const items = (state = new Map(), action) => {
|
||||
switch (action.type) {
|
||||
case ITEMS_LOADED:
|
||||
const mapped = action.payload.toMap().mapEntries((entry) => {
|
||||
const [, item] = entry;
|
||||
return [`${item.id}`, item];
|
||||
});
|
||||
return state.merge(mapped);
|
||||
case GET_ITEMS:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case ITEMS_LOADED:
|
||||
const mapped = action.payload.toMap().mapEntries((entry) => {
|
||||
const [, item] = entry;
|
||||
return [`${item.id}`, item];
|
||||
});
|
||||
return state.merge(mapped);
|
||||
case GET_ITEMS:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { Map } from 'immutable';
|
||||
|
||||
import {
|
||||
LOGIN_SUCCESS,
|
||||
SET_PROFILE,
|
||||
UNSET_PROFILE,
|
||||
UPDATE_PROFILE,
|
||||
LOGIN_SUCCESS,
|
||||
SET_PROFILE,
|
||||
UNSET_PROFILE,
|
||||
UPDATE_PROFILE,
|
||||
} from '../constants/actionTypes.js';
|
||||
|
||||
export const profile = (state = new Map(), action) => {
|
||||
switch (action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
return action.payload.user;
|
||||
case SET_PROFILE:
|
||||
return action.payload;
|
||||
case UNSET_PROFILE:
|
||||
return new Map();
|
||||
case UPDATE_PROFILE:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
switch (action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
return action.payload.user;
|
||||
case SET_PROFILE:
|
||||
return action.payload;
|
||||
case UNSET_PROFILE:
|
||||
return new Map();
|
||||
case UPDATE_PROFILE:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
298
app/router.js
298
app/router.js
@@ -16,155 +16,177 @@ import Profile from './screens/Profile.container.js';
|
||||
import Register from './screens/Register.js';
|
||||
import SignInOrRegister from './screens/SignInOrRegister.js';
|
||||
|
||||
export const Tabs = createBottomTabNavigator({
|
||||
'Event': {
|
||||
screen: Event,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Event',
|
||||
tabBarIcon: ({ tintColor }) => <Icon name="black-tie" type="font-awesome" size={28} color={tintColor} />,
|
||||
},
|
||||
},
|
||||
'Auction': {
|
||||
screen: Auction,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Silent Auction',
|
||||
tabBarIcon: ({ tintColor }) => <Icon name="gavel" type="font-awesome" size={28} color={tintColor} />,
|
||||
},
|
||||
},
|
||||
'Bazaar': {
|
||||
screen: Marketplace,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Bazaar',
|
||||
tabBarIcon: ({ tintColor }) => <Icon name="store" type="fontisto" size={28} color={tintColor} />,
|
||||
},
|
||||
},
|
||||
'Profile': {
|
||||
screen: Profile,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Profile',
|
||||
tabBarIcon: ({ tintColor }) => <Icon name="ios-person" type="font-awesome" size={28} color={tintColor} />,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const SignInOrRegisterStack = createStackNavigator({
|
||||
SignInOrRegister: {
|
||||
screen: SignInOrRegister,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Register: {
|
||||
screen: Register,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
SignInOrRegister: {
|
||||
screen: SignInOrRegister,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Register: {
|
||||
screen: Register,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const AuctionStack = createStackNavigator({
|
||||
Auction: {
|
||||
screen: Auction,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
}),
|
||||
},
|
||||
Item: {
|
||||
screen: Item,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
ImageDetail: {
|
||||
screen: ImageDetail,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Auction: {
|
||||
screen: Auction,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
}),
|
||||
},
|
||||
Item: {
|
||||
screen: Item,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
ImageDetail: {
|
||||
screen: ImageDetail,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const BazaarStack = createStackNavigator({
|
||||
Bazaar: {
|
||||
screen: Marketplace,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
}),
|
||||
},
|
||||
Item: {
|
||||
screen: Item,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
ImageDetail: {
|
||||
screen: ImageDetail,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Checkout: {
|
||||
screen: Checkout,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Bazaar: {
|
||||
screen: Marketplace,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
}),
|
||||
},
|
||||
Item: {
|
||||
screen: Item,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
ImageDetail: {
|
||||
screen: ImageDetail,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Checkout: {
|
||||
screen: Checkout,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const EventsStack = createStackNavigator({
|
||||
Events: {
|
||||
screen: Events,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
}
|
||||
Events: {
|
||||
screen: Events,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
Event: {
|
||||
screen: Event,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: <AppHeader navigation={navigation} />,
|
||||
tabBarVisible: false,
|
||||
gesturesEnabled: false,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const Tabs = createBottomTabNavigator({
|
||||
Event: {
|
||||
screen: EventsStack,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Event',
|
||||
tabBarIcon: ({ tintColor }) => (
|
||||
<Icon name="black-tie" type="font-awesome" size={28} color={tintColor} />
|
||||
),
|
||||
},
|
||||
},
|
||||
Auction: {
|
||||
screen: AuctionStack,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Silent Auction',
|
||||
tabBarIcon: ({ tintColor }) => (
|
||||
<Icon name="gavel" type="font-awesome" size={28} color={tintColor} />
|
||||
),
|
||||
},
|
||||
},
|
||||
Bazaar: {
|
||||
screen: BazaarStack,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Bazaar',
|
||||
tabBarIcon: ({ tintColor }) => (
|
||||
<Icon name="store" type="fontisto" size={28} color={tintColor} />
|
||||
),
|
||||
},
|
||||
},
|
||||
Profile: {
|
||||
screen: Profile,
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Profile',
|
||||
tabBarIcon: ({ tintColor }) => (
|
||||
<Icon name="ios-person" type="font-awesome" size={28} color={tintColor} />
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const createRootNavigator = () => {
|
||||
return StackNavigator(
|
||||
{
|
||||
AuctionStack: {
|
||||
screen: AuctionStack,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
}
|
||||
},
|
||||
BazaarStack: {
|
||||
screen: BazaarStack,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
}
|
||||
},
|
||||
EventsStack: {
|
||||
screen: EventsStack,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
}
|
||||
},
|
||||
Tabs: {
|
||||
screen: Tabs,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
mode: "modal",
|
||||
}
|
||||
);
|
||||
return StackNavigator(
|
||||
{
|
||||
AuctionStack: {
|
||||
screen: AuctionStack,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
},
|
||||
},
|
||||
BazaarStack: {
|
||||
screen: BazaarStack,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
},
|
||||
},
|
||||
EventsStack: {
|
||||
screen: EventsStack,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
},
|
||||
},
|
||||
SignInOrRegisterStack: {
|
||||
screen: SignInOrRegister,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
},
|
||||
},
|
||||
Tabs: {
|
||||
screen: Tabs,
|
||||
navigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
mode: 'modal',
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,16 +8,19 @@ import { getAuctionItemsAsList } from '../selectors/items.js';
|
||||
import Auction from './Auction.js';
|
||||
|
||||
const matchStateToProps = (state) => {
|
||||
const items = getAuctionItemsAsList(state);
|
||||
console.log('items:', items);
|
||||
const items = getAuctionItemsAsList(state);
|
||||
console.log('items:', items);
|
||||
|
||||
return { items };
|
||||
return { items };
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
changeViewMode: (mode) => dispatch(changeViewMode(mode)),
|
||||
fetchItems: () => dispatch(fetchItems(dispatch)),
|
||||
fetchStatus: () => dispatch(fetchAuctionStatus(dispatch)),
|
||||
changeViewMode: (mode) => dispatch(changeViewMode(mode)),
|
||||
fetchItems: () => dispatch(fetchItems(dispatch)),
|
||||
fetchStatus: () => dispatch(fetchAuctionStatus(dispatch)),
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Auction);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Auction);
|
||||
|
||||
@@ -2,11 +2,7 @@ import { List } from 'immutable';
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
FlatList,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { FlatList, Text, View } from 'react-native';
|
||||
|
||||
import { SORT_MODES, AUCTION_VIEW_MODES } from '../constants/constants.js';
|
||||
|
||||
@@ -16,70 +12,74 @@ import AuctionListItem from '../containers/Auction/AuctionListItem.js';
|
||||
import styles from './Auction.styles.js';
|
||||
|
||||
export default class Auction extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
changeFilter: PropTypes.func,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
fetchItems: PropTypes.func.isRequired,
|
||||
fetchStatus: PropTypes.func.isRequired,
|
||||
items: PropTypes.oneOfType([
|
||||
PropTypes.array,
|
||||
PropTypes.instanceOf(List),
|
||||
]),
|
||||
};
|
||||
}
|
||||
static get propTypes() {
|
||||
return {
|
||||
changeFilter: PropTypes.func,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
fetchItems: PropTypes.func.isRequired,
|
||||
fetchStatus: PropTypes.func.isRequired,
|
||||
items: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]),
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
changeFilter: () => { console.log('Change Filter Default Prop', arguments); },
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
static get defaultProps() {
|
||||
return {
|
||||
changeFilter: () => {
|
||||
console.log('Change Filter Default Prop', arguments);
|
||||
},
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.changeFilter = this.changeFilter.bind(this);
|
||||
this.changeViewMode = this.changeViewMode.bind(this);
|
||||
this.changeFilter = this.changeFilter.bind(this);
|
||||
this.changeViewMode = this.changeViewMode.bind(this);
|
||||
|
||||
this.state = {
|
||||
sort: SORT_MODES.TITLE_ASC,
|
||||
view: AUCTION_VIEW_MODES.ALL,
|
||||
};
|
||||
}
|
||||
this.state = {
|
||||
sort: SORT_MODES.TITLE_ASC,
|
||||
view: AUCTION_VIEW_MODES.ALL,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchStatus();
|
||||
this.props.fetchItems();
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.fetchStatus();
|
||||
this.props.fetchItems();
|
||||
}
|
||||
|
||||
changeFilter(filter) {
|
||||
this.props.changeFilter('auction', filter);
|
||||
}
|
||||
changeFilter(filter) {
|
||||
this.props.changeFilter('auction', filter);
|
||||
}
|
||||
|
||||
_keyExtractor = (item, index) => `${item._id}_${index}`;
|
||||
changeViewMode(viewMode) {
|
||||
this.props.changeViewMode(viewMode);
|
||||
}
|
||||
|
||||
_renderAuctionListItem = ({ item }) => <AuctionListItem item={item} />;
|
||||
_keyExtractor = (item, index) => `${item.id}_${index}`;
|
||||
|
||||
render() {
|
||||
const { items } = this.props;
|
||||
const { sort, view } = this.state;
|
||||
_renderAuctionListItem = ({ item }) => <AuctionListItem item={item} />;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FilterBar
|
||||
changeFilterer={this.changeFilter}
|
||||
/>
|
||||
{items.size > 0 && (
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderAuctionListItem}
|
||||
contentContainerStyle={styles.itemListContentContainer}
|
||||
style={styles.itemList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
const { items } = this.props;
|
||||
const { sort, view } = this.state;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FilterBar
|
||||
changeFilterer={this.changeFilter}
|
||||
changeViewMode={this.changeViewMode}
|
||||
/>
|
||||
{items.size > 0 && (
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderAuctionListItem}
|
||||
contentContainerStyle={styles.itemListContentContainer}
|
||||
style={styles.itemList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
itemList: {
|
||||
width: '100%',
|
||||
},
|
||||
itemListContentContainer: {
|
||||
alignItems: 'stretch',
|
||||
justifyContent: 'flex-start',
|
||||
},
|
||||
});
|
||||
export default (styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
itemList: {
|
||||
width: '100%',
|
||||
},
|
||||
itemListContentContainer: {
|
||||
alignItems: 'stretch',
|
||||
justifyContent: 'flex-start',
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
export default class Checkout extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Checkout
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Checkout</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,30 +7,33 @@ import { getActiveEvent, getDefaultEvent } from '../selectors/events.js';
|
||||
import Event from './Event.js';
|
||||
|
||||
const matchStateToProps = (state) => {
|
||||
const event = getActiveEvent(state) || getDefaultEvent(state) || new EventRecord();
|
||||
const event = getActiveEvent(state) || getDefaultEvent(state) || new EventRecord();
|
||||
|
||||
if (!event) {
|
||||
return {};
|
||||
}
|
||||
if (!event) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
description: event.get('description'),
|
||||
endTime: event.get('endTime'),
|
||||
id: event.get('id'),
|
||||
images: event.get('images').toArray(),
|
||||
isTicketed: event.get('isTicketed'),
|
||||
posts: event.get('posts').toArray(),
|
||||
requireLoginToSeeAuction: event.get('requireLoginToSeeAuction'),
|
||||
showFrom: event.get('showFrom'),
|
||||
showUntil: event.get('showUntil'),
|
||||
startTime: event.get('startTime'),
|
||||
tagline: event.get('tagline'),
|
||||
ticketClasses: event.get('ticketClasses').toArray(),
|
||||
title: event.get('title'),
|
||||
url: event.get('url'),
|
||||
};
|
||||
return {
|
||||
description: event.get('description'),
|
||||
endTime: event.get('endTime'),
|
||||
id: event.get('id'),
|
||||
images: event.get('images').toArray(),
|
||||
isTicketed: event.get('isTicketed'),
|
||||
posts: event.get('posts').toArray(),
|
||||
requireLoginToSeeAuction: event.get('requireLoginToSeeAuction'),
|
||||
showFrom: event.get('showFrom'),
|
||||
showUntil: event.get('showUntil'),
|
||||
startTime: event.get('startTime'),
|
||||
tagline: event.get('tagline'),
|
||||
ticketClasses: event.get('ticketClasses').toArray(),
|
||||
title: event.get('title'),
|
||||
url: event.get('url'),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Event);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Event);
|
||||
|
||||
@@ -5,82 +5,76 @@ import { Text, View } from 'react-native';
|
||||
import styles from './Event.styles.js';
|
||||
|
||||
export default class Event extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
description: PropTypes.string,
|
||||
endTime: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
url: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
isTicketed: PropTypes.bool,
|
||||
posts: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
author: PropTypes.string,
|
||||
content: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
isPublic: PropTypes.bool,
|
||||
scheduledPost: PropTypes.bool,
|
||||
sendNotification: PropTypes.bool,
|
||||
timestamp: PropTypes.string,
|
||||
title: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
requireLoginToSeeAuction: PropTypes.bool,
|
||||
showFrom: PropTypes.string,
|
||||
showUntil: PropTypes.string,
|
||||
startTime: PropTypes.string,
|
||||
tagline: PropTypes.string,
|
||||
ticketClasses: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
static get propTypes() {
|
||||
return {
|
||||
description: PropTypes.string,
|
||||
endTime: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
url: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
isTicketed: PropTypes.bool,
|
||||
posts: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
author: PropTypes.string,
|
||||
content: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
isPublic: PropTypes.bool,
|
||||
scheduledPost: PropTypes.bool,
|
||||
sendNotification: PropTypes.bool,
|
||||
timestamp: PropTypes.string,
|
||||
title: PropTypes.string,
|
||||
}),
|
||||
),
|
||||
requireLoginToSeeAuction: PropTypes.bool,
|
||||
showFrom: PropTypes.string,
|
||||
showUntil: PropTypes.string,
|
||||
startTime: PropTypes.string,
|
||||
tagline: PropTypes.string,
|
||||
ticketClasses: PropTypes.arrayOf(PropTypes.shape({})),
|
||||
title: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
};
|
||||
}
|
||||
|
||||
}),
|
||||
),
|
||||
title: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
};
|
||||
}
|
||||
static get defaultProps() {
|
||||
return {
|
||||
images: null,
|
||||
isTicketed: false,
|
||||
posts: null,
|
||||
requireLoginToSeeAuction: false,
|
||||
tagline: null,
|
||||
ticketClasses: null,
|
||||
url: null,
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
images: null,
|
||||
isTicketed: false,
|
||||
posts: null,
|
||||
requireLoginToSeeAuction: false,
|
||||
tagline: null,
|
||||
ticketClasses: null,
|
||||
url: null,
|
||||
};
|
||||
}
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
const {
|
||||
description,
|
||||
endTime,
|
||||
images,
|
||||
isTicketed,
|
||||
requireLoginToSeeAuction,
|
||||
showFrom,
|
||||
showUntil,
|
||||
startTime,
|
||||
tagline,
|
||||
ticketClasses,
|
||||
title,
|
||||
url,
|
||||
} = this.props;
|
||||
|
||||
render() {
|
||||
const {
|
||||
description,
|
||||
endTime,
|
||||
images,
|
||||
isTicketed,
|
||||
requireLoginToSeeAuction,
|
||||
showFrom,
|
||||
showUntil,
|
||||
startTime,
|
||||
tagline,
|
||||
ticketClasses,
|
||||
title,
|
||||
url,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Event
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Event</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
});
|
||||
|
||||
export default styles;
|
||||
export default (styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { setActiveEvent } from '../actions/activeEvent.js';
|
||||
import { fetchEvents } from '../actions/events.js';
|
||||
import { getEventsAsList } from '../selectors/events.js';
|
||||
|
||||
import Events from './Events.js';
|
||||
|
||||
const matchStateToProps = (state) => {
|
||||
const events = getEventsAsList(state);
|
||||
console.log('events:', events);
|
||||
|
||||
return { events };
|
||||
const events = getEventsAsList(state);
|
||||
return { events };
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
fetchEvents: () => dispatch(fetchEvents(dispatch)),
|
||||
fetchEvents: () => dispatch(fetchEvents()),
|
||||
setActiveEvent: (eventId) => dispatch(setActiveEvent(eventId)),
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Events);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Events);
|
||||
|
||||
@@ -1,58 +1,71 @@
|
||||
import { List } from 'immutable';
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { FlatList, StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import EventListItem from '../components/Events/EventListItem.js';
|
||||
|
||||
export default class Events extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
events: PropTypes.array.isRequired,
|
||||
fetchEvents: PropTypes.func.isRequired,
|
||||
};
|
||||
}
|
||||
static get propTypes() {
|
||||
return {
|
||||
events: PropTypes.instanceOf(List),
|
||||
fetchEvents: PropTypes.func.isRequired,
|
||||
setActiveEvent: PropTypes.func.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static get defaultProps() {
|
||||
return {
|
||||
events: new List(),
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchEvents();
|
||||
}
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
_keyExtractor = (event, index) => `${event._id}_${index}`;
|
||||
this._setActiveEvent = this.setActiveEvent.bind(this);
|
||||
}
|
||||
|
||||
_renderEventListItem = ({ event }) => <EventListItem event={event} />;
|
||||
componentDidMount() {
|
||||
this.props.fetchEvents();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { events } = this.props;
|
||||
setActiveEvent(eventId) {
|
||||
this.props.setActiveEvent(eventId);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
{events.size > 0 && (
|
||||
<FlatList
|
||||
data={events}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderEventListItem}
|
||||
contentContainerStyle={styles.eventListContentContainer}
|
||||
style={styles.eventList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
_keyExtractor = (event, index) => `${event.id}_${index}`;
|
||||
|
||||
_renderEventListItem = ({ event }) => (
|
||||
<EventListItem {...event} setActiveEvent={this.setActiveEvent} />
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { events } = this.props;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
{events.size > 0 && (
|
||||
<FlatList
|
||||
data={events}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderEventListItem}
|
||||
contentContainerStyle={styles.eventListContentContainer}
|
||||
style={styles.eventList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
eventListContentContainer: {
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
eventListContentContainer: {},
|
||||
});
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
export default class ImageDetail extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Item
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Item</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
export default class Item extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Item
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Item</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
export default class Login extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Login
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Login</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,11 +2,7 @@ import { List } from 'immutable';
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
FlatList,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { FlatList, Text, View } from 'react-native';
|
||||
|
||||
import { SORT_MODES, AUCTION_VIEW_MODES } from '../constants/constants.js';
|
||||
|
||||
@@ -16,70 +12,67 @@ import AuctionListItem from '../containers/Auction/AuctionListItem.js';
|
||||
//import styles from './Marketplace.styles.js';
|
||||
|
||||
export default class Marketplace extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
changeFilter: PropTypes.func,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
fetchItems: PropTypes.func.isRequired,
|
||||
fetchStatus: PropTypes.func.isRequired,
|
||||
items: PropTypes.oneOfType([
|
||||
PropTypes.array,
|
||||
PropTypes.instanceOf(List),
|
||||
]),
|
||||
};
|
||||
}
|
||||
static get propTypes() {
|
||||
return {
|
||||
changeFilter: PropTypes.func,
|
||||
changeViewMode: PropTypes.func.isRequired,
|
||||
fetchItems: PropTypes.func.isRequired,
|
||||
fetchStatus: PropTypes.func.isRequired,
|
||||
items: PropTypes.oneOfType([PropTypes.array, PropTypes.instanceOf(List)]),
|
||||
};
|
||||
}
|
||||
|
||||
static get defaultProps() {
|
||||
return {
|
||||
changeFilter: () => { console.log('Change Filter Default Prop', arguments); },
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
static get defaultProps() {
|
||||
return {
|
||||
changeFilter: () => {
|
||||
console.log('Change Filter Default Prop', arguments);
|
||||
},
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.changeFilter = this.changeFilter.bind(this);
|
||||
this.changeViewMode = this.changeViewMode.bind(this);
|
||||
this.changeFilter = this.changeFilter.bind(this);
|
||||
this.changeViewMode = this.changeViewMode.bind(this);
|
||||
|
||||
this.state = {
|
||||
sort: SORT_MODES.TITLE_ASC,
|
||||
view: AUCTION_VIEW_MODES.ALL,
|
||||
};
|
||||
}
|
||||
this.state = {
|
||||
sort: SORT_MODES.TITLE_ASC,
|
||||
view: AUCTION_VIEW_MODES.ALL,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchStatus();
|
||||
this.props.fetchItems();
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.fetchStatus();
|
||||
this.props.fetchItems();
|
||||
}
|
||||
|
||||
changeFilter(filter) {
|
||||
this.props.changeFilter('auction', filter);
|
||||
}
|
||||
changeFilter(filter) {
|
||||
this.props.changeFilter('auction', filter);
|
||||
}
|
||||
|
||||
_keyExtractor = (item, index) => `${item._id}_${index}`;
|
||||
_keyExtractor = (item, index) => `${item._id}_${index}`;
|
||||
|
||||
_renderAuctionListItem = ({ item }) => <AuctionListItem item={item} />;
|
||||
_renderAuctionListItem = ({ item }) => <AuctionListItem item={item} />;
|
||||
|
||||
render() {
|
||||
const { items } = this.props;
|
||||
const { sort, view } = this.state;
|
||||
render() {
|
||||
const { items } = this.props;
|
||||
const { sort, view } = this.state;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FilterBar
|
||||
changeFilterer={this.changeFilter}
|
||||
/>
|
||||
{items.size > 0 && (
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderAuctionListItem}
|
||||
contentContainerStyle={styles.itemListContentContainer}
|
||||
style={styles.itemList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FilterBar changeFilterer={this.changeFilter} />
|
||||
{items.size > 0 && (
|
||||
<FlatList
|
||||
data={items}
|
||||
keyExtractor={this._keyExtractor}
|
||||
renderItem={this._renderAuctionListItem}
|
||||
contentContainerStyle={styles.itemListContentContainer}
|
||||
style={styles.itemList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,27 +6,30 @@ import { getNomDeBid, getProfile, isAllowedToBid } from '../selectors/profile.js
|
||||
import Profile from './Profile.js';
|
||||
|
||||
const matchStateToProps = (state) => {
|
||||
const profile = getProfile(state);
|
||||
const profile = getProfile(state);
|
||||
|
||||
return {
|
||||
hasLinkedApple: profile.get('hasLinkedApple'),
|
||||
hasLinkedFacebook: profile.get('hasLinkedFacebook'),
|
||||
hasLinkedGoogle: profile.get('hasLinkedGoogle'),
|
||||
hasLocalAccount: profile.get('hasLocalAccount'),
|
||||
hasRegisteredAcccount: profile.get('hasRegisteredAcccount'),
|
||||
id: profile.get('id'),
|
||||
isAllowedToBid: isAllowedToBid(state),
|
||||
isVerified: profile.get('isVerified'),
|
||||
lastName: profile.get('lastName'),
|
||||
nomDeBid: getNomDeBid(state),
|
||||
organizationIdentifier: profile.get('organizationIdentifier'),
|
||||
paymentToken: profile.get('paymentToken'),
|
||||
};
|
||||
return {
|
||||
hasLinkedApple: profile.get('hasLinkedApple'),
|
||||
hasLinkedFacebook: profile.get('hasLinkedFacebook'),
|
||||
hasLinkedGoogle: profile.get('hasLinkedGoogle'),
|
||||
hasLocalAccount: profile.get('hasLocalAccount'),
|
||||
hasRegisteredAcccount: profile.get('hasRegisteredAcccount'),
|
||||
id: profile.get('id'),
|
||||
isAllowedToBid: isAllowedToBid(state),
|
||||
isVerified: profile.get('isVerified'),
|
||||
lastName: profile.get('lastName'),
|
||||
nomDeBid: getNomDeBid(state),
|
||||
organizationIdentifier: profile.get('organizationIdentifier'),
|
||||
paymentToken: profile.get('paymentToken'),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
fetchProfile: () => dispatch(fetchProfile(dispatch)),
|
||||
updateProfile: () => dispatch(updateProfile(dispatch)),
|
||||
fetchProfile: () => dispatch(fetchProfile(dispatch)),
|
||||
updateProfile: () => dispatch(updateProfile(dispatch)),
|
||||
});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Profile);
|
||||
export default connect(
|
||||
matchStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Profile);
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
export default class Profile extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Profile
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Profile</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import {
|
||||
checkEmailAvailability,
|
||||
checkNomAvailability,
|
||||
registerUser,
|
||||
} from '../actions/profile.js';
|
||||
import { checkEmailAvailability, checkNomAvailability, registerUser } from '../actions/profile.js';
|
||||
|
||||
import Register from './Register.js';
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
checkEmail: (email) => dispatch(checkEmailAvailability(email)),
|
||||
checkNomDeBid: (nomDeBid) => dispatch(checkNomAvailability(nomDeBid)),
|
||||
doRegistration: (user) => dispatch(registerUser(user)),
|
||||
checkEmail: (email) => dispatch(checkEmailAvailability(email)),
|
||||
checkNomDeBid: (nomDeBid) => dispatch(checkNomAvailability(nomDeBid)),
|
||||
doRegistration: (user) => dispatch(registerUser(user)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(Register);
|
||||
export default connect(
|
||||
null,
|
||||
mapDispatchToProps,
|
||||
)(Register);
|
||||
|
||||
@@ -9,72 +9,80 @@ const STRINGS = {
|
||||
};
|
||||
|
||||
export default class Register extends Component {
|
||||
|
||||
static get propTypes() {
|
||||
return {
|
||||
checkEmail: PropTypes.func.isRequired,
|
||||
checkNomDeBid: PropTypes.func.isRequired,
|
||||
doRegistration: PropTypes.func.isRequired,
|
||||
// invalidEmail: PropTypes.bool.isRequired,
|
||||
// invalidNomDeBid: PropTypes.bool.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
addresses: [],
|
||||
avatar: null,
|
||||
email: null,
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
nomDeBid: null,
|
||||
invalidEmail: false,
|
||||
invalidNomDeBid: false,
|
||||
password: null,
|
||||
phones: [],
|
||||
};
|
||||
|
||||
this._doRegistration = this._doRegistration.bind(this);
|
||||
}
|
||||
|
||||
_doRegistration() {
|
||||
if (!this.isFormComplete()) {
|
||||
console.error('Incomplete form... how did the button become enabled?');
|
||||
alert('Please complete all of the required fields. They have bold labels.');
|
||||
return;
|
||||
static get propTypes() {
|
||||
return {
|
||||
checkEmail: PropTypes.func.isRequired,
|
||||
checkNomDeBid: PropTypes.func.isRequired,
|
||||
doRegistration: PropTypes.func.isRequired,
|
||||
// invalidEmail: PropTypes.bool.isRequired,
|
||||
// invalidNomDeBid: PropTypes.bool.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
this.props.doRegistration(this.getUserRegistration());
|
||||
}
|
||||
constructor() {
|
||||
super(props);
|
||||
|
||||
_validateEmail() {
|
||||
this.props.checkEmail(this.state.email, (valid) => this.setState('invalidEmail', valid));
|
||||
}
|
||||
this.state = {
|
||||
addresses: [],
|
||||
avatar: null,
|
||||
email: null,
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
nomDeBid: null,
|
||||
invalidEmail: false,
|
||||
invalidNomDeBid: false,
|
||||
password: null,
|
||||
phones: [],
|
||||
};
|
||||
|
||||
_validateNomDeBid() {
|
||||
this.props.checkNomDeBid(this.state.nomDeBid, (valid) => this.setState('invalidNomDeBid', valid));
|
||||
}
|
||||
this._doRegistration = this._doRegistration.bind(this);
|
||||
}
|
||||
|
||||
getUserRegistration() {
|
||||
return {
|
||||
addresses: this.state.addresses,
|
||||
avatar: this.state.avatar,
|
||||
email: this.state.email,
|
||||
firstName: this.state.firstName,
|
||||
lastName: this.state.lastName,
|
||||
nomDeBid: this.state.nomDeBid,
|
||||
password: this.state.password,
|
||||
phones: this.state.phones,
|
||||
};
|
||||
}
|
||||
_doRegistration() {
|
||||
if (!this.isFormComplete()) {
|
||||
console.error('Incomplete form... how did the button become enabled?');
|
||||
alert('Please complete all of the required fields. They have bold labels.');
|
||||
return;
|
||||
}
|
||||
|
||||
isFormComplete() {
|
||||
return !this.state.invalidEmail && !this.state.invalidNomDeBid &&
|
||||
!!this.state.firstName && !!this.state.lastName && !!this.state.email &&
|
||||
!!this.state.nomDeBid && !!this.state.phones.length && !!this.state.password;
|
||||
}
|
||||
this.props.doRegistration(this.getUserRegistration());
|
||||
}
|
||||
|
||||
_validateEmail() {
|
||||
this.props.checkEmail(this.state.email, (valid) => this.setState('invalidEmail', valid));
|
||||
}
|
||||
|
||||
_validateNomDeBid() {
|
||||
this.props.checkNomDeBid(this.state.nomDeBid, (valid) =>
|
||||
this.setState('invalidNomDeBid', valid),
|
||||
);
|
||||
}
|
||||
|
||||
getUserRegistration() {
|
||||
return {
|
||||
addresses: this.state.addresses,
|
||||
avatar: this.state.avatar,
|
||||
email: this.state.email,
|
||||
firstName: this.state.firstName,
|
||||
lastName: this.state.lastName,
|
||||
nomDeBid: this.state.nomDeBid,
|
||||
password: this.state.password,
|
||||
phones: this.state.phones,
|
||||
};
|
||||
}
|
||||
|
||||
isFormComplete() {
|
||||
return (
|
||||
!this.state.invalidEmail &&
|
||||
!this.state.invalidNomDeBid &&
|
||||
!!this.state.firstName &&
|
||||
!!this.state.lastName &&
|
||||
!!this.state.email &&
|
||||
!!this.state.nomDeBid &&
|
||||
!!this.state.phones.length &&
|
||||
!!this.state.password
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
},
|
||||
title: {
|
||||
},
|
||||
localLogin: {
|
||||
},
|
||||
services: {
|
||||
},
|
||||
register: {
|
||||
},
|
||||
});
|
||||
export default (styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
},
|
||||
title: {},
|
||||
localLogin: {},
|
||||
services: {},
|
||||
register: {},
|
||||
}));
|
||||
|
||||
@@ -8,31 +8,30 @@ import LocalLogin from '../components/Login/LocalLogin.container.js';
|
||||
import styles from './SignInOrRegister.styles.js';
|
||||
|
||||
export default class SignInOrRegister extends Component {
|
||||
constructor() {
|
||||
super(props);
|
||||
|
||||
constructor() {
|
||||
super(props);
|
||||
this._doRegistration = this._doRegistration.bind(this);
|
||||
}
|
||||
|
||||
this._doRegistration = this._doRegistration.bind(this);
|
||||
}
|
||||
_doRegistration() {
|
||||
this.props.navigation.navigate('Register');
|
||||
}
|
||||
|
||||
_doRegistration() {
|
||||
this.props.navigation.navigate('Register');
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Sign In or Register</Text>
|
||||
<View style={styles.localLogin}>
|
||||
<LocalLogin />
|
||||
</View>
|
||||
<View style={styles.services}>
|
||||
<FacebookLogin />
|
||||
</View>
|
||||
<View style={styles.register}>
|
||||
<Button title="Signup with Email" onPress={this._doRegistration} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Sign In or Register</Text>
|
||||
<View style={styles.localLogin}>
|
||||
<LocalLogin />
|
||||
</View>
|
||||
<View style={styles.services}>
|
||||
<FacebookLogin />
|
||||
</View>
|
||||
<View style={styles.register}>
|
||||
<Button title="Signup with Email" onPress={this._doRegistration} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
});
|
||||
export default (styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,33 +1,26 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
export default class Ticketing extends Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>
|
||||
Ticketing
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Ticketing</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
}
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ import { createSelector } from 'reselect';
|
||||
const getState = (state) => state;
|
||||
|
||||
export const getActiveEventId = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('activeEvent'),
|
||||
[getState],
|
||||
(state) => state.get('activeEvent'),
|
||||
);
|
||||
|
||||
export const hasActiveEvent = createSelector(
|
||||
[getActiveEventId],
|
||||
(eventId) => !!eventId,
|
||||
[getActiveEventId],
|
||||
(eventId) => !!eventId,
|
||||
);
|
||||
|
||||
@@ -6,28 +6,30 @@ export const getItemBidCount = (state, itemId) => state.getIn(['auctions', itemI
|
||||
|
||||
export const getItemPrice = (state, itemId) => state.getIn(['auctions', itemId, 'currentPrice'], 0);
|
||||
|
||||
export const isBiddingItem = (state, itemId) => state.getIn(['auctions', itemId, 'isBidding'], false);
|
||||
export const isBiddingItem = (state, itemId) =>
|
||||
state.getIn(['auctions', itemId, 'isBidding'], false);
|
||||
|
||||
export const isWinningItem = (state, itemId) => state.getIn(['auctions', itemId, 'isWinning'], false);
|
||||
export const isWinningItem = (state, itemId) =>
|
||||
state.getIn(['auctions', itemId, 'isWinning'], false);
|
||||
|
||||
export const getAuctionStatus = (state, itemId) => state.getIn(['actions', itemId], false);
|
||||
|
||||
export const getAuctionStatuses = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('actions') || new Map(),
|
||||
[getState],
|
||||
(state) => state.get('actions') || new Map(),
|
||||
);
|
||||
|
||||
export const getItemsIdsWithNoBids = createSelector(
|
||||
[getAuctionStatuses],
|
||||
(auctions) => auctions.filter(auction => auction.bidCount === 0),
|
||||
[getAuctionStatuses],
|
||||
(auctions) => auctions.filter((auction) => auction.bidCount === 0),
|
||||
);
|
||||
|
||||
export const getMyBidItemIds = createSelector(
|
||||
[getAuctionStatuses],
|
||||
(auctions) => auctions.filter(auction => auction.isBidding),
|
||||
[getAuctionStatuses],
|
||||
(auctions) => auctions.filter((auction) => auction.isBidding),
|
||||
);
|
||||
|
||||
export const getMyWinningItemIds = createSelector(
|
||||
[getAuctionStatuses],
|
||||
(auctions) => auctions.filter(auction => auction.isWinning),
|
||||
[getAuctionStatuses],
|
||||
(auctions) => auctions.filter((auction) => auction.isWinning),
|
||||
);
|
||||
|
||||
@@ -3,6 +3,6 @@ import { createSelector } from 'reselect';
|
||||
const getState = (state) => state;
|
||||
|
||||
export const getAuthToken = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('auth'),
|
||||
[getState],
|
||||
(state) => state.get('auth'),
|
||||
);
|
||||
|
||||
@@ -8,26 +8,26 @@ const getState = (state) => state;
|
||||
export const getEventById = (state, eventId) => state.getIn(['events', eventId], false);
|
||||
|
||||
export const getEvents = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('events') || new Map(),
|
||||
[getState],
|
||||
(state) => state.get('events') || new Map(),
|
||||
);
|
||||
|
||||
export const getActiveEvent = createSelector(
|
||||
[getActiveEventId, getEvents],
|
||||
(eventId, eventsAsMap) => eventId ? eventsAsMap.get(eventId) : null,
|
||||
[getActiveEventId, getEvents],
|
||||
(eventId, eventsAsMap) => (eventId ? eventsAsMap.get(eventId) : null),
|
||||
);
|
||||
|
||||
export const getDefaultEvent = createSelector(
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.first(),
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.first(),
|
||||
);
|
||||
|
||||
export const getEventsAsList = createSelector(
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.toList(),
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const hasMultipleEvents = createSelector(
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.size > 1,
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.size > 1,
|
||||
);
|
||||
|
||||
@@ -8,61 +8,61 @@ const getState = (state) => state;
|
||||
export const getItem = (state, itemId) => state.getIn(['items', itemId], false);
|
||||
|
||||
export const getItems = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('items') || new Map(),
|
||||
[getState],
|
||||
(state) => state.get('items') || new Map(),
|
||||
);
|
||||
|
||||
export const getItemsAsList = createSelector(
|
||||
[getItems],
|
||||
(itemsAsMap) => itemsAsMap.toList(),
|
||||
[getItems],
|
||||
(itemsAsMap) => itemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItems = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('items').filter(i => i.type === 'auction') || new Map(),
|
||||
[getState],
|
||||
(state) => state.get('items').filter((i) => i.type === 'auction') || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsAsList = createSelector(
|
||||
[getAuctionItems],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
[getAuctionItems],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsBidding = createSelector(
|
||||
[getAuctionItems, getMyBidItemIds],
|
||||
(items, myBids) => items.filter(i => myBids.indexOf(i.id)) || new Map(),
|
||||
[getAuctionItems, getMyBidItemIds],
|
||||
(items, myBids) => items.filter((i) => myBids.indexOf(i.id)) || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsBiddingAsList = createSelector(
|
||||
[getAuctionItemsUserIsBidding],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
[getAuctionItemsUserIsBidding],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsWinning = createSelector(
|
||||
[getAuctionItemsUserIsBidding, getMyWinningItemIds],
|
||||
(items, myWins) => items.filter(i => myWins.indexOf(i.id)) || new Map(),
|
||||
[getAuctionItemsUserIsBidding, getMyWinningItemIds],
|
||||
(items, myWins) => items.filter((i) => myWins.indexOf(i.id)) || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsWinningAsList = createSelector(
|
||||
[getAuctionItemsUserIsWinning],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
[getAuctionItemsUserIsWinning],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsWithNoBids = createSelector(
|
||||
[getAuctionItems, getItemsIdsWithNoBids],
|
||||
(items, noBids) => items.filter(i => noBids.indexOf(i.id)) || new Map(),
|
||||
[getAuctionItems, getItemsIdsWithNoBids],
|
||||
(items, noBids) => items.filter((i) => noBids.indexOf(i.id)) || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsWithNoBidsAsList = createSelector(
|
||||
[getAuctionItemsWithNoBids],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
[getAuctionItemsWithNoBids],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getTicketItems = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('items').filter(i => i.type === 'ticket') || new Map(),
|
||||
[getState],
|
||||
(state) => state.get('items').filter((i) => i.type === 'ticket') || new Map(),
|
||||
);
|
||||
|
||||
export const getTicketItemsAsList = createSelector(
|
||||
[getTicketItems],
|
||||
(ticketItemsAsMap) => ticketItemsAsMap.toList(),
|
||||
[getTicketItems],
|
||||
(ticketItemsAsMap) => ticketItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
@@ -4,21 +4,21 @@ import { createSelector } from 'reselect';
|
||||
const getState = (state) => state;
|
||||
|
||||
export const getProfile = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('profile'),
|
||||
[getState],
|
||||
(state) => state.get('profile'),
|
||||
);
|
||||
|
||||
export const getNomDeBid = createSelector(
|
||||
[getProfile],
|
||||
(profile) => profile.get('nomDeBid'),
|
||||
[getProfile],
|
||||
(profile) => profile.get('nomDeBid'),
|
||||
);
|
||||
|
||||
export const getProfileAvatarUrl = createSelector(
|
||||
[getProfile],
|
||||
(profile) => profile.get('avatar'),
|
||||
[getProfile],
|
||||
(profile) => profile.get('avatar'),
|
||||
);
|
||||
|
||||
export const isAllowedToBid = createSelector(
|
||||
[getProfile],
|
||||
(profile) => profile.get('isAllowedToBid'),
|
||||
[getProfile],
|
||||
(profile) => profile.get('isAllowedToBid'),
|
||||
);
|
||||
|
||||
@@ -5,10 +5,10 @@ import thunk from 'redux-thunk';
|
||||
|
||||
import rootReducer from '../reducers/index.js';
|
||||
|
||||
const composeEnhancers = composeWithDevTools({ port: 8000, realtime: true, suppressConnectErrors: false });
|
||||
const composeEnhancers = composeWithDevTools({
|
||||
port: 8000,
|
||||
realtime: true,
|
||||
suppressConnectErrors: false,
|
||||
});
|
||||
|
||||
export const store = createStore(
|
||||
rootReducer,
|
||||
Map(),
|
||||
composeEnhancers(applyMiddleware(thunk)),
|
||||
);
|
||||
export const store = createStore(rootReducer, Map(), composeEnhancers(applyMiddleware(thunk)));
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module.exports = {
|
||||
presets: ['module:metro-react-native-babel-preset'],
|
||||
presets: ['module:metro-react-native-babel-preset'],
|
||||
};
|
||||
|
||||
@@ -11,11 +11,11 @@ import { name as appName } from './app.json';
|
||||
import { store } from './app/store/index.js';
|
||||
|
||||
const connectedApp = () => {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
};
|
||||
|
||||
AppRegistry.registerComponent(appName, () => connectedApp);
|
||||
|
||||
10
index.ios.js
10
index.ios.js
@@ -11,11 +11,11 @@ import { name as appName } from './app.json';
|
||||
import { store } from './app/store/index.js';
|
||||
|
||||
const connectedApp = () => {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
};
|
||||
|
||||
AppRegistry.registerComponent(appName, () => connectedApp);
|
||||
|
||||
10
index.js
10
index.js
@@ -11,11 +11,11 @@ import { name as appName } from './app.json';
|
||||
import { store } from './app/store/index.js';
|
||||
|
||||
const connectedApp = () => {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
};
|
||||
|
||||
AppRegistry.registerComponent(appName, () => connectedApp);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user