Skip to content

Commit efb6218

Browse files
author
Sean Paterson
committed
Sets up reservation pages AND makes the other side panels look better with grid
1 parent ab50832 commit efb6218

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+844
-225
lines changed

native/.expo/packager-info.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"devToolsPort": 19002,
3-
"expoServerPort": null,
4-
"packagerPort": null,
5-
"packagerPid": null,
3+
"expoServerPort": 19000,
4+
"packagerPort": 19001,
5+
"packagerPid": 4944,
66
"expoServerNgrokUrl": "https://ia-6ey.ssp6.native.exp.direct",
77
"packagerNgrokUrl": "https://packager.ia-6ey.ssp6.native.exp.direct",
8-
"ngrokPid": 71700
8+
"ngrokPid": 4959
99
}

native/ios/.expo/packager-info.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"devToolsPort": 19002
3+
}

native/ios/.expo/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"hostType": "lan",
3+
"lanType": "ip",
4+
"dev": true,
5+
"minify": false,
6+
"urlRandomness": null
7+
}

native/shared/api/firebase.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const firebaseLoginEmail = async (email, password) => {
3333
*
3434
* @param id
3535
* @param name
36+
* @param type - manager/operators/user
3637
* @returns {Promise<void>}
3738
*/
3839
export const firebaseUpdateProfile = ({ id, name }) =>

native/shared/api/tap2go.js

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,17 @@ export const apiUserDelete = authToken => axiosBaseUrl.delete('/users/me', getCo
105105
* @param stripeToken
106106
* @returns {AxiosPromise<any>}
107107
*/
108-
export const apiUserSetPaymentDetails = (authToken, stripeToken) => {
109-
// const dbId = Firebase.auth().currentUser.photoURL;
110-
console.log(stripeToken);
108+
export const apiUserSetPaymentDetails = async (authToken, stripeToken) => {
109+
const dbId = Firebase.auth().currentUser.photoURL;
111110
try {
112-
// return axiosBaseUrl.post(
113-
// `/users/${dbId}/payment`,
114-
// {
115-
// stripe_source_token: stripeToken,
116-
// },
117-
// getConfig(authToken)
118-
// );
119-
// return;
111+
await axiosBaseUrl.put(
112+
`/users/${dbId}/payment`,
113+
{
114+
token: stripeToken,
115+
},
116+
getConfig(authToken)
117+
);
118+
return null;
120119
} catch (e) {
121120
throw e;
122121
}
@@ -131,7 +130,6 @@ export const apiUserSetPaymentDetails = (authToken, stripeToken) => {
131130
* @returns {Promise<*>}
132131
*/
133132
export const apiRentalStartId = async (authToken, bikeId) => {
134-
// throw new Error('NO PAYMENT METHOD'); // TESTING
135133
try {
136134
const result = await axiosBaseUrl.post(`/bikes/${bikeId}/rentals`, {}, getConfig(authToken));
137135

@@ -148,7 +146,6 @@ export const apiRentalStartId = async (authToken, bikeId) => {
148146
* @returns {Promise<result.data.rental|{estimated_price, start_time, bike_id, current_location}>}
149147
*/
150148
export const apiRentalFetchCurrent = async authToken => {
151-
// console.log(authToken);
152149
const dbId = Firebase.auth().currentUser.photoURL;
153150
try {
154151
const result = await axiosBaseUrl.get(`/users/${dbId}/rentals/current`, getConfig(authToken));
@@ -203,7 +200,6 @@ export const apiRentalEndCurrent = async (authToken, cancel = false) => {
203200
* @param authToken
204201
* @returns {Promise<void>}
205202
*/
206-
// eslint-disable-next-line camelcase
207203
export const apiIssueCreate = async (authToken, data) => {
208204
const dbId = Firebase.auth().currentUser.photoURL;
209205
try {
@@ -215,6 +211,16 @@ export const apiIssueCreate = async (authToken, data) => {
215211
}
216212
};
217213

214+
/**
215+
* Gets all pickup points - at some point will
216+
* be in order of closes to current location and
217+
* within the range
218+
*
219+
* @param latitude
220+
* @param longitude
221+
* @param range
222+
* @returns {Promise<pickupsReducer|Array>}
223+
*/
218224
export const apiPickupPointsFetch = async (latitude = 55.949159, longitude = -3.199293, range = 4) => {
219225
try {
220226
const result = await axiosBaseUrl.get(`/pickups?latitude=${latitude}&longitude=${longitude}&range=${range}miles`);
@@ -236,6 +242,11 @@ export const apiPickupFetchSingle = async (authToken, id) => {
236242
return result.data.data.pickup;
237243
};
238244

245+
export const apiPickupFetchBikes = async (authToken, pickupId) => {
246+
const result = await axiosBaseUrl.get(`/pickups/${pickupId}/bikes`);
247+
return result.data.data.bikes;
248+
};
249+
239250
/**
240251
* Api end point to create a reservation at a location
241252
* for a set date date and time
@@ -246,7 +257,7 @@ export const apiPickupFetchSingle = async (authToken, id) => {
246257
* @returns {Promise<void>}
247258
*/
248259
export const apiReservationCreate = async (authToken, pickupId, datetime) => {
249-
// throw new Error('NO PAYMENT METHOD');
260+
// throw new Error('NO PAYMENT METHOD'); // TESTING
250261
try {
251262
const result = await axiosBaseUrl.post(
252263
`/pickups/${pickupId}/reservations`,
@@ -255,6 +266,7 @@ export const apiReservationCreate = async (authToken, pickupId, datetime) => {
255266
},
256267
getConfig(authToken)
257268
);
269+
258270
return result.data.data.reservation;
259271
} catch (e) {
260272
throw e;
@@ -270,22 +282,56 @@ export const apiReservationCreate = async (authToken, pickupId, datetime) => {
270282
*/
271283
export const apiReservationCancel = async (authToken, reservationId) => {
272284
try {
273-
await axiosAuth.delete(`/reservations/${reservationId}`, getConfig(authToken));
274-
return null;
285+
const result = await axiosBaseUrl.delete(`/reservations/${reservationId}`, getConfig(authToken));
286+
return result.data.data.reservation;
275287
} catch (e) {
276288
throw e;
277289
}
278290
};
279291

280292
/**
281-
* Api end point to fetch all rentals for a user that
293+
* Api end point to fetch all reservations for a user that
282294
* have not been collected and are in the future
283295
*
284296
* @param authToken
285297
* @returns {Promise<*>}
286298
*/
287-
export const apiReservationsFetch = async authToken => {
299+
export const apiReservationsUserFetch = async authToken => {
288300
const dbId = Firebase.auth().currentUser.photoURL;
289-
const result = await axiosAuth.get(`/users/${dbId || 'me'}/reservations/current`, getConfig(authToken));
301+
const result = await axiosBaseUrl.get(`/users/${dbId || 'me'}/reservations/current`, getConfig(authToken));
302+
return result.data.data.reservations;
303+
};
304+
305+
/**
306+
* Api end point to fetch all reservations
307+
* must be an admin to access
308+
*
309+
* @param authToken
310+
* @returns {Promise<*>}
311+
*/
312+
export const apiReservationsAdminFetch = async authToken => {
313+
const result = await axiosBaseUrl.get('/reservations', getConfig(authToken));
290314
return result.data.data.reservations;
291315
};
316+
317+
/**
318+
* Api end point to fetch all of the bikes on the system
319+
* @returns {Promise<*>}
320+
*/
321+
export const apiBikesFetch = async authToken => {
322+
const result = await axiosBaseUrl.get('/bikes', getConfig(authToken));
323+
return result.data.data.bikes;
324+
};
325+
326+
/**
327+
* Api end point for a single bike based on its
328+
* identifier 6 digit hex number
329+
*
330+
* @param authToken
331+
* @param bikeId
332+
* @returns {Promise<BikeListItem.propTypes.bike|{}>}
333+
*/
334+
export const apiBikeSingleFetch = async (authToken, bikeId) => {
335+
const result = await axiosBaseUrl.get(`/bikes/${bikeId}`, getConfig(authToken));
336+
return result.data.data.bike;
337+
};

native/shared/redux/containers/BikesContainer.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
44

55
import { bikesFetch, BikePropTypes } from '../ducks/bikes';
6+
import { setBike, bikeSingleFetch } from '../ducks/bikeSingle';
67

78
export const BikesProps = {
89
locale: PropTypes.string.isRequired,
@@ -11,21 +12,37 @@ export const BikesProps = {
1112
...BikePropTypes,
1213
})
1314
).isRequired,
15+
bike: PropTypes.shape({
16+
...BikePropTypes,
17+
}),
1418
loading: PropTypes.bool.isRequired,
1519
fetchBikes: PropTypes.func.isRequired,
20+
fetchSingleBike: PropTypes.func.isRequired,
1621
};
1722

1823
export default function withBikes(WrappedComponent) {
1924
// Pure function always auto re-loads children on prop change!
2025
class BikesContainer extends React.PureComponent {
2126
render() {
22-
const { locale, loading, bikes, fetchBikes, ...restProps } = this.props;
27+
const {
28+
locale,
29+
loading,
30+
bikes,
31+
bike,
32+
fetchBikes,
33+
fetchSingleBike,
34+
setSingleReservationDisplay,
35+
...restProps
36+
} = this.props;
2337
return (
2438
<WrappedComponent
2539
locale={locale}
2640
loading={loading} // from bikes reducer
2741
bikes={bikes}
42+
bike={bike}
2843
fetchBikes={fetchBikes}
44+
fetchSingleBike={fetchSingleBike}
45+
setSingleBikeDisplay={setSingleReservationDisplay}
2946
{...restProps} // passes any others through
3047
/>
3148
);
@@ -40,10 +57,13 @@ export default function withBikes(WrappedComponent) {
4057
locale: state.locale.country,
4158
loading: state.bikes.loading,
4259
bikes: state.bikes.bikes,
60+
bike: state.bikeSingle,
4361
});
4462

4563
const mapDispatchToProp = {
4664
fetchBikes: bikesFetch,
65+
setSingleReservationDisplay: setBike,
66+
fetchSingleBike: bikeSingleFetch,
4767
};
4868

4969
return connect(

native/shared/redux/containers/LoginAndOutContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const LoginAndOutProps = {
2121

2222
export default function withLogin(WrappedComponent) {
2323
const LoginAndOutContainer = ({ locale, login, logout, ...restProps }) => (
24-
<WrappedComponent locale={locale} login={login} logout={logout} test={userSignOut} {...restProps} />
24+
<WrappedComponent locale={locale} login={login} logout={logout} {...restProps} />
2525
);
2626

2727
LoginAndOutContainer.propTypes = {

native/shared/redux/containers/PickupPointsContainer.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import PropTypes from 'prop-types';
1212
import { connect } from 'react-redux';
1313

1414
import { pickupPointsFetch, PickupPropTypes } from '../ducks/pickups';
15+
import { setPickup, pickupSingleFetch, pickupBikesFetch } from '../ducks/pickupSingle';
16+
import { BikePropTypes } from '../ducks/bikeSingle';
1517

1618
export const PickupProps = {
1719
locale: PropTypes.string.isRequired,
@@ -22,19 +24,44 @@ export const PickupProps = {
2224
).isRequired,
2325
loading: PropTypes.bool.isRequired,
2426
getPickupPoints: PropTypes.func.isRequired,
27+
setSinglePickupDisplay: PropTypes.func.isRequired,
28+
fetchSinglePickup: PropTypes.func.isRequired,
29+
fetchPickupBikes: PropTypes.func.isRequired,
30+
pickupPointBikes: PropTypes.arrayOf(
31+
PropTypes.shape({
32+
...BikePropTypes,
33+
})
34+
).isRequired,
35+
// fetchPickupReservation: PropTypes.func.isRequired,
2536
};
2637

2738
export default function withPickupPoints(WrappedComponent) {
2839
// Pure function always auto re-loads children on prop change!
2940
class PickupPointsContainer extends React.PureComponent {
3041
render() {
31-
const { locale, pickups, loading, getPickupPoints, ...restProps } = this.props;
42+
const {
43+
locale,
44+
pickups,
45+
pickup,
46+
loading,
47+
getPickupPoints,
48+
fetchSinglePickup,
49+
fetchPickupBikes,
50+
setSinglePickupDisplay,
51+
pickupPointBikes,
52+
...restProps
53+
} = this.props;
3254
return (
3355
<WrappedComponent
3456
locale={locale}
3557
pickups={pickups}
58+
pickup={pickup}
3659
loading={loading} // from pickups reducer
3760
getPickupPoints={getPickupPoints}
61+
fetchSinglePickup={fetchSinglePickup}
62+
fetchPickupBikes={fetchPickupBikes}
63+
setSinglePickupDisplay={setSinglePickupDisplay}
64+
pickupPointBikes={pickupPointBikes}
3865
{...restProps} // passes any others through
3966
/>
4067
);
@@ -48,11 +75,17 @@ export default function withPickupPoints(WrappedComponent) {
4875
const mapStateToProps = state => ({
4976
locale: state.locale.country,
5077
pickups: state.pickups.pickups,
78+
pickup: state.pickupSingle.pickup,
79+
pickupPointBikes: state.pickupSingle.bikes,
5180
loading: state.pickups.loading,
5281
});
5382

5483
const mapDispatchToProp = {
5584
getPickupPoints: pickupPointsFetch,
85+
setSinglePickupDisplay: setPickup,
86+
fetchSinglePickup: pickupSingleFetch,
87+
fetchPickupBikes: pickupBikesFetch,
88+
// fetchPickupReservation: pickupReservationsFetch,
5689
};
5790

5891
return connect(

0 commit comments

Comments
 (0)