From 847c9b192aa6afca805a6a239d3740de1e62a55e Mon Sep 17 00:00:00 2001 From: Mike Fitzpatrick Date: Wed, 7 Aug 2019 01:59:10 -0400 Subject: [PATCH] - Linting... Prettier... --- .eslintrc.js | 77 ++++ .prettierrc | 8 + __tests__/App-test.js | 2 +- app/App.js | 9 - app/actions/activeEvent.js | 6 + app/actions/auction.js | 76 ++-- app/actions/auctionStatus.js | 44 +-- app/actions/events.js | 29 +- app/actions/index.js | 9 +- app/actions/items.js | 33 +- app/actions/profile.js | 117 +++---- app/api/auctionStatus.js | 7 + app/api/bid.js | 10 + app/api/events.js | 4 +- app/api/helpers.js | 96 ++--- app/api/index.js | 126 +++---- app/api/items.js | 6 +- app/api/profile.js | 24 +- .../AppHeader/AppHeader.container.js | 7 +- app/components/AppHeader/AppHeader.js | 39 +-- .../AppHeader/HeaderContentLeft.container.js | 15 +- app/components/AppHeader/HeaderContentLeft.js | 60 ++-- .../AppHeader/HeaderContentRight.container.js | 9 +- .../AppHeader/HeaderContentRight.js | 11 +- .../EventTitle/EventTitle.container.js | 19 +- .../HeaderTitle/EventTitle/EventTitle.js | 46 +-- .../EventTitle/EventTitle.styles.js | 24 +- .../HeaderTitle/HeaderTitle.container.js | 17 +- .../AppHeader/HeaderTitle/HeaderTitle.js | 72 ++-- .../HeaderTitle/HeaderTitle.styles.js | 25 +- .../AppHeader/IconButtons/BackIcon.js | 12 +- .../AppHeader/IconButtons/EventsIcon.js | 15 +- .../UserProfileButton.container.js | 7 +- .../UserProfileButton/UserProfileButton.js | 35 +- app/components/Auction/AuctionListItem.js | 328 +++++++++--------- .../Auction/AuctionPriceAndBidCount.js | 27 +- app/components/Auction/BidStatus.js | 53 ++- app/components/Auction/FilterBar.js | 42 +-- app/components/Events/EventListItem.js | 137 ++++---- .../Login/FacebookLogin.container.js | 21 +- app/components/Login/FacebookLogin.js | 53 ++- app/components/Login/LocalLogin.container.js | 7 +- app/components/Login/LocalLogin.js | 75 ++-- app/constants/constants.js | 68 ++-- app/containers/Auction/AuctionListItem.js | 34 +- .../Auction/AuctionPriceAndBidCount.js | 15 +- app/containers/Auction/BidStatus.js | 15 +- app/containers/Events.js | 13 +- app/containers/Events/EventListItem.js | 36 +- app/domain/Auction.js | 18 +- app/domain/Event.js | 54 +-- app/domain/Item.js | 68 ++-- app/domain/Post.js | 27 +- app/domain/Profile.js | 72 ++-- app/domain/TicketClass.js | 36 +- app/library/helpers.js | 88 ++--- app/reducers/activeEvent.js | 20 +- app/reducers/activeItem.js | 16 +- app/reducers/auctionFilter.js | 12 +- app/reducers/auctionView.js | 12 +- app/reducers/auctions.js | 24 +- app/reducers/auth.js | 20 +- app/reducers/blockUI.js | 16 +- app/reducers/events.js | 22 +- app/reducers/index.js | 20 +- app/reducers/items.js | 27 +- app/reducers/profile.js | 32 +- app/router.js | 298 ++++++++-------- app/screens/Auction.container.js | 17 +- app/screens/Auction.js | 122 +++---- app/screens/Auction.styles.js | 30 +- app/screens/Checkout.js | 44 +-- app/screens/Event.container.js | 45 +-- app/screens/Event.js | 142 ++++---- app/screens/Event.styles.js | 28 +- app/screens/Events.container.js | 15 +- app/screens/Events.js | 97 +++--- app/screens/ImageDetail.js | 44 +-- app/screens/Item.js | 44 +-- app/screens/Login.js | 44 +-- app/screens/Marketplace.js | 115 +++--- app/screens/Profile.container.js | 39 ++- app/screens/Profile.js | 44 +-- app/screens/Register.container.js | 17 +- app/screens/Register.js | 160 +++++---- app/screens/Register.styles.js | 24 +- app/screens/SignInOrRegister.js | 47 ++- app/screens/SignInOrRegister.styles.js | 26 +- app/screens/Ticketing.js | 45 +-- app/selectors/activeEvent.js | 8 +- app/selectors/auctions.js | 22 +- app/selectors/auth.js | 4 +- app/selectors/events.js | 20 +- app/selectors/items.js | 48 +-- app/selectors/profile.js | 16 +- app/store/index.js | 12 +- babel.config.js | 2 +- index.android.js | 10 +- index.ios.js | 10 +- index.js | 10 +- metro.config.js | 16 +- package.json | 1 + 102 files changed, 2161 insertions(+), 2109 deletions(-) create mode 100644 .prettierrc create mode 100644 app/actions/activeEvent.js create mode 100644 app/api/auctionStatus.js create mode 100644 app/api/bid.js diff --git a/.eslintrc.js b/.eslintrc.js index 40c6dcd..33941fa 100644 --- a/.eslintrc.js +++ b/.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, + }, + }, + ], }; diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..862bdb6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "arrowParens": "always", + "jsxBracketSameLine": false, + "singleQuote": true, + "tabWidth": 4, + "printWidth": 100, + "trailingComma": "all" +} diff --git a/__tests__/App-test.js b/__tests__/App-test.js index 1784766..090aefa 100644 --- a/__tests__/App-test.js +++ b/__tests__/App-test.js @@ -10,5 +10,5 @@ import App from '../App'; import renderer from 'react-test-renderer'; it('renders correctly', () => { - renderer.create(); + renderer.create(); }); diff --git a/app/App.js b/app/App.js index c0b07db..6c19f99 100644 --- a/app/App.js +++ b/app/App.js @@ -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'; diff --git a/app/actions/activeEvent.js b/app/actions/activeEvent.js new file mode 100644 index 0000000..604d859 --- /dev/null +++ b/app/actions/activeEvent.js @@ -0,0 +1,6 @@ +import { SET_ACTIVE_EVENT } from '../constants/actionTypes.js'; + +export const setActiveEvent = (eventId) => ({ + type: SET_ACTIVE_EVENT, + payload: eventId, +}); diff --git a/app/actions/auction.js b/app/actions/auction.js index c9f806d..2377bf4 100644 --- a/app/actions/auction.js +++ b/app/actions/auction.js @@ -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))); }; diff --git a/app/actions/auctionStatus.js b/app/actions/auctionStatus.js index e939d04..c3df807 100644 --- a/app/actions/auctionStatus.js +++ b/app/actions/auctionStatus.js @@ -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)); }; - diff --git a/app/actions/events.js b/app/actions/events.js index b52ef30..9e03bd6 100644 --- a/app/actions/events.js +++ b/app/actions/events.js @@ -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))); }; diff --git a/app/actions/index.js b/app/actions/index.js index 2b7aac3..39add96 100644 --- a/app/actions/index.js +++ b/app/actions/index.js @@ -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, }); diff --git a/app/actions/items.js b/app/actions/items.js index becac35..3fd962a 100644 --- a/app/actions/items.js +++ b/app/actions/items.js @@ -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))); }; diff --git a/app/actions/profile.js b/app/actions/profile.js index 9e6b0da..412a6bc 100644 --- a/app/actions/profile.js +++ b/app/actions/profile.js @@ -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) => {}; diff --git a/app/api/auctionStatus.js b/app/api/auctionStatus.js new file mode 100644 index 0000000..fe6eb54 --- /dev/null +++ b/app/api/auctionStatus.js @@ -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); +}; diff --git a/app/api/bid.js b/app/api/bid.js new file mode 100644 index 0000000..3efee96 --- /dev/null +++ b/app/api/bid.js @@ -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, + }); +}; diff --git a/app/api/events.js b/app/api/events.js index e08ab70..8f367da 100644 --- a/app/api/events.js +++ b/app/api/events.js @@ -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); }; diff --git a/app/api/helpers.js b/app/api/helpers.js index 2ddea3c..dadd206 100644 --- a/app/api/helpers.js +++ b/app/api/helpers.js @@ -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(); diff --git a/app/api/index.js b/app/api/index.js index 37f1020..89c035c 100644 --- a/app/api/index.js +++ b/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); }; diff --git a/app/api/items.js b/app/api/items.js index f1ece26..dd04a09 100644 --- a/app/api/items.js +++ b/app/api/items.js @@ -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); }; diff --git a/app/api/profile.js b/app/api/profile.js index a674339..639e907 100644 --- a/app/api/profile.js +++ b/app/api/profile.js @@ -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 }, + }); diff --git a/app/components/AppHeader/AppHeader.container.js b/app/components/AppHeader/AppHeader.container.js index 536ea7a..b765897 100644 --- a/app/components/AppHeader/AppHeader.container.js +++ b/app/components/AppHeader/AppHeader.container.js @@ -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); diff --git a/app/components/AppHeader/AppHeader.js b/app/components/AppHeader/AppHeader.js index 17233c8..c6218f3 100644 --- a/app/components/AppHeader/AppHeader.js +++ b/app/components/AppHeader/AppHeader.js @@ -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 ( -
} - centerComponent={} - rightComponent={} - /> - ); - } + return ( +
} + centerComponent={} + rightComponent={} + /> + ); + } } diff --git a/app/components/AppHeader/HeaderContentLeft.container.js b/app/components/AppHeader/HeaderContentLeft.container.js index a9b0d62..e56f8a2 100644 --- a/app/components/AppHeader/HeaderContentLeft.container.js +++ b/app/components/AppHeader/HeaderContentLeft.container.js @@ -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); diff --git a/app/components/AppHeader/HeaderContentLeft.js b/app/components/AppHeader/HeaderContentLeft.js index d22354f..4915467 100644 --- a/app/components/AppHeader/HeaderContentLeft.js +++ b/app/components/AppHeader/HeaderContentLeft.js @@ -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 ; } - console.log('nowhere to go...'); - }; + if (activeRoute === 'Profile') { + return ; + } - const _showEvents = () => { - navigation.navigate('Events'); - return false; - }; - - - if (activeRoute === 'Events') { - return ; - } - - if (activeRoute === 'Profile') { - return ; - } - - return + return ; } 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, }; diff --git a/app/components/AppHeader/HeaderContentRight.container.js b/app/components/AppHeader/HeaderContentRight.container.js index b4ad083..52f77c4 100644 --- a/app/components/AppHeader/HeaderContentRight.container.js +++ b/app/components/AppHeader/HeaderContentRight.container.js @@ -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); diff --git a/app/components/AppHeader/HeaderContentRight.js b/app/components/AppHeader/HeaderContentRight.js index 9d693df..07b90df 100644 --- a/app/components/AppHeader/HeaderContentRight.js +++ b/app/components/AppHeader/HeaderContentRight.js @@ -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 ; + return ; } HeaderContentRight.propTypes = { - hideUserProfileButton: PropTypes.bool.isRequired, + hideUserProfileButton: PropTypes.bool.isRequired, }; diff --git a/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.container.js b/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.container.js index 77bfcd8..69ea31e 100644 --- a/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.container.js +++ b/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.container.js @@ -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); diff --git a/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.js b/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.js index 7a3a87f..6a0958a 100644 --- a/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.js +++ b/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.js @@ -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 = () => ( - - {name} - {`${date} | ${start} - ${end}`} - - ); +export default function EventTitle({ action, date, end, name, start }) { + const _generateEventTitle = () => ( + + {name} + {`${date} | ${start} - ${end}`} + + ); - if (action) { - return {_generateEventTitle()}; - } + if (action) { + return {_generateEventTitle()}; + } - 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, }; diff --git a/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.styles.js b/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.styles.js index 1140069..16fe7ff 100644 --- a/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.styles.js +++ b/app/components/AppHeader/HeaderTitle/EventTitle/EventTitle.styles.js @@ -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, + }, +})); diff --git a/app/components/AppHeader/HeaderTitle/HeaderTitle.container.js b/app/components/AppHeader/HeaderTitle/HeaderTitle.container.js index 1c3584a..8b1f2fb 100644 --- a/app/components/AppHeader/HeaderTitle/HeaderTitle.container.js +++ b/app/components/AppHeader/HeaderTitle/HeaderTitle.container.js @@ -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); diff --git a/app/components/AppHeader/HeaderTitle/HeaderTitle.js b/app/components/AppHeader/HeaderTitle/HeaderTitle.js index 4a583e0..6429c4e 100644 --- a/app/components/AppHeader/HeaderTitle/HeaderTitle.js +++ b/app/components/AppHeader/HeaderTitle/HeaderTitle.js @@ -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 ( + + Profile + + ); } - console.log('nowhere to go...'); - }; + if (activeRoute === 'Profile') { + return Profile; + } - const _showEvents = () => { - navigation.navigate('Events'); - return false; - }; - - - if (activeRoute === 'Events') { - return ( - - Profile - - ); - } - - if (activeRoute === 'Profile') { - return Profile; - } - - return + return ; } 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, }; diff --git a/app/components/AppHeader/HeaderTitle/HeaderTitle.styles.js b/app/components/AppHeader/HeaderTitle/HeaderTitle.styles.js index e0207bc..e4c5889 100644 --- a/app/components/AppHeader/HeaderTitle/HeaderTitle.styles.js +++ b/app/components/AppHeader/HeaderTitle/HeaderTitle.styles.js @@ -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, + }, +})); diff --git a/app/components/AppHeader/IconButtons/BackIcon.js b/app/components/AppHeader/IconButtons/BackIcon.js index dfa08e8..c2e314d 100644 --- a/app/components/AppHeader/IconButtons/BackIcon.js +++ b/app/components/AppHeader/IconButtons/BackIcon.js @@ -5,13 +5,13 @@ import { TouchableOpacity } from 'react-native'; import { Icon } from 'react-native-elements'; export default function BackIcon({ action }) { - return ( - - ; - - ); + return ( + + ; + + ); } BackIcon.propTypes = { - action: PropTypes.func.isRequired, + action: PropTypes.func.isRequired, }; diff --git a/app/components/AppHeader/IconButtons/EventsIcon.js b/app/components/AppHeader/IconButtons/EventsIcon.js index d100ba6..2f37b28 100644 --- a/app/components/AppHeader/IconButtons/EventsIcon.js +++ b/app/components/AppHeader/IconButtons/EventsIcon.js @@ -5,20 +5,19 @@ import { TouchableOpacity } from 'react-native'; import { Icon } from 'react-native-elements'; export default function EventsIcon({ action }) { + const renderEventsIcon = () => ; - const renderEventsIcon = () => ; + if (action) { + return {renderEventsIcon()}; + } - if (action) { - return {renderEventsIcon()}; - } - - return renderEventsIcon(); + return renderEventsIcon(); } EventsIcon.propTypes = { - action: PropTypes.func, + action: PropTypes.func, }; EventsIcon.defaultProps = { - action: null, + action: null, }; diff --git a/app/components/AppHeader/UserProfileButton/UserProfileButton.container.js b/app/components/AppHeader/UserProfileButton/UserProfileButton.container.js index b0cb7a2..0832bbb 100644 --- a/app/components/AppHeader/UserProfileButton/UserProfileButton.container.js +++ b/app/components/AppHeader/UserProfileButton/UserProfileButton.container.js @@ -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); diff --git a/app/components/AppHeader/UserProfileButton/UserProfileButton.js b/app/components/AppHeader/UserProfileButton/UserProfileButton.js index 61307ed..1897118 100644 --- a/app/components/AppHeader/UserProfileButton/UserProfileButton.js +++ b/app/components/AppHeader/UserProfileButton/UserProfileButton.js @@ -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 ( - - {avatarUrl !== null ? ( - - - - ) : ( - - )} - - ); + return ( + + {avatarUrl !== null ? ( + + + + ) : ( + + )} + + ); } UserProfileButton.propTypes = { - avatarUrl: PropTypes.string, + avatarUrl: PropTypes.string, }; UserProfileButton.propTypes = { - avatarUrl: null, + avatarUrl: null, }; diff --git a/app/components/Auction/AuctionListItem.js b/app/components/Auction/AuctionListItem.js index b3466c0..341b85d 100644 --- a/app/components/Auction/AuctionListItem.js +++ b/app/components/Auction/AuctionListItem.js @@ -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( - - - {images !== null && images.length > 0 && ( - - )} - - {type === ITEM_TYPES.AUCTION && } - - {title} - - - {subtitle} - - {donor && ( - - {donor} - - )} - {type === ITEM_TYPES.AUCTION ? ( - - ) : ( - - {formatPrice(startingPrice)} - - )} - - {this._getBidTime()} - - - {description} - - - - - ); - } + return ( + + + {images !== null && images.length > 0 && ( + + )} + + {type === ITEM_TYPES.AUCTION && } + + {title} + + + {subtitle} + + {donor && ( + + {donor} + + )} + {type === ITEM_TYPES.AUCTION ? ( + + ) : ( + + {formatPrice(startingPrice)} + + )} + + {this._getBidTime()} + + + {description} + + + + + ); + } } 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, - }, }); diff --git a/app/components/Auction/AuctionPriceAndBidCount.js b/app/components/Auction/AuctionPriceAndBidCount.js index 94c8aa9..2d25cdd 100644 --- a/app/components/Auction/AuctionPriceAndBidCount.js +++ b/app/components/Auction/AuctionPriceAndBidCount.js @@ -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 ( - - {`${formatPrice(currentPrice)} (${bidCount} bids)`} - - ); + return ( + + {`${formatPrice(currentPrice)} (${bidCount} bids)`} + + ); }; 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; diff --git a/app/components/Auction/BidStatus.js b/app/components/Auction/BidStatus.js index 64c012d..eceed62 100644 --- a/app/components/Auction/BidStatus.js +++ b/app/components/Auction/BidStatus.js @@ -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 ( - - {isWinning && `Oh no! You have been outbid!`} - {!isWinning && isBidding && `You have the winning bid! (for now...)`} - - ); + return ( + + {isWinning && 'Oh no! You have been outbid!'} + {!isWinning && isBidding && 'You have the winning bid! (for now...)'} + + ); }; 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; diff --git a/app/components/Auction/FilterBar.js b/app/components/Auction/FilterBar.js index 2da7503..95b926e 100644 --- a/app/components/Auction/FilterBar.js +++ b/app/components/Auction/FilterBar.js @@ -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 }) => ( - Filter - View + Filter + 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; diff --git a/app/components/Events/EventListItem.js b/app/components/Events/EventListItem.js index d1286b1..ed99893 100644 --- a/app/components/Events/EventListItem.js +++ b/app/components/Events/EventListItem.js @@ -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( - - - - - ); - } + return ( + + + {name} + {date} + + {start} - {end} + + {description} + + + ); + } } 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, - }, }); diff --git a/app/components/Login/FacebookLogin.container.js b/app/components/Login/FacebookLogin.container.js index bd46217..eb3d862 100644 --- a/app/components/Login/FacebookLogin.container.js +++ b/app/components/Login/FacebookLogin.container.js @@ -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); diff --git a/app/components/Login/FacebookLogin.js b/app/components/Login/FacebookLogin.js index 4d749c3..c3e8a75 100644 --- a/app/components/Login/FacebookLogin.js +++ b/app/components/Login/FacebookLogin.js @@ -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 ( - - { - if (error) { - doErrorAction(error); - } else if (result.isCancelled) { - doCancelAction(); - } else { - doSuccessAction(result); - } - } - } - onLogoutFinished={doLogoutAction} - /> - - ); + return ( + + { + if (error) { + doErrorAction(error); + } else if (result.isCancelled) { + doCancelAction(); + } else { + doSuccessAction(result); + } + }} + onLogoutFinished={doLogoutAction} + /> + + ); } 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, }; diff --git a/app/components/Login/LocalLogin.container.js b/app/components/Login/LocalLogin.container.js index cdeb6a7..aa1f891 100644 --- a/app/components/Login/LocalLogin.container.js +++ b/app/components/Login/LocalLogin.container.js @@ -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); diff --git a/app/components/Login/LocalLogin.js b/app/components/Login/LocalLogin.js index 0f0d621..7fc815b 100644 --- a/app/components/Login/LocalLogin.js +++ b/app/components/Login/LocalLogin.js @@ -4,52 +4,47 @@ import PropTypes from 'prop-types'; import { Button, TextInput, View } from 'react-native'; export default function LocalLogin({ doLoginAction }) { + const [enabled, setEnableSubmit] = useState(false); + const [password, setPassword] = useState(null); + const [username, setUsername] = useState(null); - const [ enabled, setEnableSubmit ] = useState(false); - const [ password, setPassword ] = useState(null); - const [ username, setUsername ] = useState(null); + const _handleLoginSubmit = () => { + doLoginAction(username, password); + }; - const _handleLoginSubmit = () => { - doLoginAction(username, password); - }; + const _updateState = (field, value) => { + if (field === 'username') { + setUsername(value); + } - const _updateState = (field, value) => { - if (field === 'username') { - setUsername(value); - } + if (field === 'password') { + setPassword(value); + } - if (field === 'password') { - setPassword(value); - } + if (!!username && !!password) { + setEnableSubmit(true); + } + }; - if (!!username && !!password) { - setEnableSubmit(true); - } - }; - - return ( - - _updateState('username', text)} - value={username} - /> - _updateState('password', text)} - value={password} - /> -