- more!
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||||
|
|
||||||
export const fetchEvents = (auth) => {
|
export const fetchEvents = (auth) => {
|
||||||
const path = String(API_ENDPOINTS.GET_EVENTS);
|
|
||||||
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
const opts = { Authorization: auth ? `Bearer ${auth}` : null };
|
||||||
return requestGet(path, null, opts);
|
return requestGet(API_ENDPOINTS.GET_EVENTS, null, opts);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { API_URL } from '../constants/constants.js';
|
|||||||
|
|
||||||
const DefaultRequestOptions = {};
|
const DefaultRequestOptions = {};
|
||||||
|
|
||||||
export const API_ENDPOINTS = {
|
const endpoints = {
|
||||||
// Events and Items
|
// Events and Items
|
||||||
GET_EVENTS: '/events',
|
GET_EVENTS: '/events',
|
||||||
// GET_ITEMS: '/items?eventId=:event_id',
|
// GET_ITEMS: '/items?eventId=:event_id',
|
||||||
@@ -23,13 +23,13 @@ export const API_ENDPOINTS = {
|
|||||||
PLACE_BID: '/bids/:item_id',
|
PLACE_BID: '/bids/:item_id',
|
||||||
PURCHASE_ITEM: '/sales',
|
PURCHASE_ITEM: '/sales',
|
||||||
|
|
||||||
// Login
|
|
||||||
LOGIN: '/auth',
|
|
||||||
|
|
||||||
// User/Profile
|
// User/Profile
|
||||||
USER_SIGNUP: '/signup',
|
USER_SIGNUP: '/signup',
|
||||||
USER_PROFILE: '/users/:user_id',
|
USER_PROFILE: '/users/:user_id',
|
||||||
|
|
||||||
|
VALIDATE_SIGNUP_EMAIL: '/signup/validate/email',
|
||||||
|
VALIDATE_SIGNUP_NOM: '/signup/validate/nom',
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
APPLE_SIGNUP: '/auth/apple/login',
|
APPLE_SIGNUP: '/auth/apple/login',
|
||||||
APPLE_LINK: '/auth/apple/link',
|
APPLE_LINK: '/auth/apple/link',
|
||||||
@@ -45,11 +45,11 @@ const cacheBuster = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getEndpointUrl = (endpoint) => {
|
export const getEndpointUrl = (endpoint) => {
|
||||||
if (!API_ENDPOINTS[endpoint]) {
|
if (!endpoints[endpoint]) {
|
||||||
throw new Error('Invalid API endpoint specified');
|
throw new Error('Invalid API endpoint specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${API_URL}${API_ENDPOINTS[endpoint]}`; //`${cacheBuster()}`;
|
return `${API_URL}${endpoints[endpoint]}`; //`${cacheBuster()}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestGet = (path, queryParams = [], requestOptions = {}) => {
|
export const requestGet = (path, queryParams = [], requestOptions = {}) => {
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||||
|
|
||||||
export const getEmailAvailability = (email) => {
|
export const getEmailAvailability = (email) => requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_EMAIL}/&{encodeURI(email)}`);
|
||||||
};
|
|
||||||
|
|
||||||
export const getNomAvailaibility = (nomDeBid) => {
|
export const getNomAvailaibility = (nomDeBid) => requestGet(`${API_ENDPOINTS.VALIDATE_SIGNUP_NOM}/${encodeURI(nomDeBid)}`);
|
||||||
};
|
|
||||||
|
|
||||||
export const loginUser = (username, password) => {
|
export const loginUser = (username, password) => requestPost({
|
||||||
const path = String(API_ENDPOINTS.LOGIN);
|
|
||||||
return requestPost({
|
|
||||||
path: API_ENDPOINTS.LOGIN,
|
path: API_ENDPOINTS.LOGIN,
|
||||||
body: { username, password },
|
body: { username, password },
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
export const registerNewUser = (user) => {
|
export const registerNewUser = (user) => requestPost({
|
||||||
};
|
path: API_ENDPOINTS.USER_SIGNUP,
|
||||||
|
body: { user },
|
||||||
|
});
|
||||||
|
|||||||
11
app/components/AppHeader/AppHeader.container.js
Normal file
11
app/components/AppHeader/AppHeader.container.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import { fetchEvents } from '../../actions/events.js';
|
||||||
|
|
||||||
|
import AppHeader from './AppHeader.js';
|
||||||
|
|
||||||
|
const matchDispatchToProps = (dispatch) => ({
|
||||||
|
fetchEvents: () => dispatch(fetchEvents()),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(null, matchDispatchToProps)(AppHeader);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { Header } from 'react-native-elements';
|
import { Header } from 'react-native-elements';
|
||||||
@@ -9,7 +9,21 @@ import HeaderContentRight from './HeaderContentRight.container.js';
|
|||||||
|
|
||||||
import styles from './AppHeader.styles.js';
|
import styles from './AppHeader.styles.js';
|
||||||
|
|
||||||
export default function AppHeader({ navigation }) {
|
export default class AppHeader extends Component {
|
||||||
|
|
||||||
|
static get propTypes() {
|
||||||
|
return {
|
||||||
|
fetchEvents: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.props.fetchEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { navigation } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Header
|
<Header
|
||||||
placement="left"
|
placement="left"
|
||||||
@@ -18,8 +32,5 @@ export default function AppHeader({ navigation }) {
|
|||||||
rightComponent={<HeaderContentLeft navigation={navigation} />}
|
rightComponent={<HeaderContentLeft navigation={navigation} />}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AppHeader.propTypes = {
|
|
||||||
navigation: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import Event from './Event.js';
|
|||||||
const matchStateToProps = (state) => {
|
const matchStateToProps = (state) => {
|
||||||
const event = getActiveEvent(state) || getDefaultEvent(state) || new EventRecord();
|
const event = getActiveEvent(state) || getDefaultEvent(state) || new EventRecord();
|
||||||
|
|
||||||
|
if (!event) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
description: event.get('description'),
|
description: event.get('description'),
|
||||||
endTime: event.get('endTime'),
|
endTime: event.get('endTime'),
|
||||||
@@ -27,8 +31,6 @@ const matchStateToProps = (state) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({});
|
||||||
fetchEvents: () => dispatch(fetchEvents()),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(matchStateToProps, mapDispatchToProps)(Event);
|
export default connect(matchStateToProps, mapDispatchToProps)(Event);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ export default class Event extends Component {
|
|||||||
return {
|
return {
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
endTime: PropTypes.string,
|
endTime: PropTypes.string,
|
||||||
fetchEvents: PropTypes.func,
|
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
images: PropTypes.arrayOf(
|
images: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
@@ -60,10 +59,6 @@ export default class Event extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.props.fetchEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
description,
|
description,
|
||||||
|
|||||||
Reference in New Issue
Block a user