- more!
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { API_ENDPOINTS, requestGet } from './index.js';
|
||||
|
||||
export const fetchEvents = (auth) => {
|
||||
const path = String(API_ENDPOINTS.GET_EVENTS);
|
||||
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 = {};
|
||||
|
||||
export const API_ENDPOINTS = {
|
||||
const endpoints = {
|
||||
// Events and Items
|
||||
GET_EVENTS: '/events',
|
||||
// GET_ITEMS: '/items?eventId=:event_id',
|
||||
@@ -23,13 +23,13 @@ export const API_ENDPOINTS = {
|
||||
PLACE_BID: '/bids/:item_id',
|
||||
PURCHASE_ITEM: '/sales',
|
||||
|
||||
// Login
|
||||
LOGIN: '/auth',
|
||||
|
||||
// User/Profile
|
||||
USER_SIGNUP: '/signup',
|
||||
USER_PROFILE: '/users/:user_id',
|
||||
|
||||
VALIDATE_SIGNUP_EMAIL: '/signup/validate/email',
|
||||
VALIDATE_SIGNUP_NOM: '/signup/validate/nom',
|
||||
|
||||
// Services
|
||||
APPLE_SIGNUP: '/auth/apple/login',
|
||||
APPLE_LINK: '/auth/apple/link',
|
||||
@@ -45,11 +45,11 @@ const cacheBuster = () => {
|
||||
};
|
||||
|
||||
export const getEndpointUrl = (endpoint) => {
|
||||
if (!API_ENDPOINTS[endpoint]) {
|
||||
if (!endpoints[endpoint]) {
|
||||
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 = {}) => {
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
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) => {
|
||||
const path = String(API_ENDPOINTS.LOGIN);
|
||||
return 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) => {
|
||||
};
|
||||
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 { Header } from 'react-native-elements';
|
||||
@@ -9,17 +9,28 @@ import HeaderContentRight from './HeaderContentRight.container.js';
|
||||
|
||||
import styles from './AppHeader.styles.js';
|
||||
|
||||
export default function AppHeader({ navigation }) {
|
||||
return (
|
||||
<Header
|
||||
placement="left"
|
||||
leftComponent={<HeaderContentRight navigation={navigation} />}
|
||||
centerComponent={<HeaderTitle navigation={navigation} />}
|
||||
rightComponent={<HeaderContentLeft navigation={navigation} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export default class AppHeader extends Component {
|
||||
|
||||
AppHeader.propTypes = {
|
||||
navigation: PropTypes.func.isRequired,
|
||||
};
|
||||
static get propTypes() {
|
||||
return {
|
||||
fetchEvents: PropTypes.func.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchEvents();
|
||||
}
|
||||
|
||||
render () {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<Header
|
||||
placement="left"
|
||||
leftComponent={<HeaderContentRight navigation={navigation} />}
|
||||
centerComponent={<HeaderTitle navigation={navigation} />}
|
||||
rightComponent={<HeaderContentLeft navigation={navigation} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ import Event from './Event.js';
|
||||
const matchStateToProps = (state) => {
|
||||
const event = getActiveEvent(state) || getDefaultEvent(state) || new EventRecord();
|
||||
|
||||
if (!event) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
description: event.get('description'),
|
||||
endTime: event.get('endTime'),
|
||||
@@ -27,8 +31,6 @@ const matchStateToProps = (state) => {
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
fetchEvents: () => dispatch(fetchEvents()),
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export default connect(matchStateToProps, mapDispatchToProps)(Event);
|
||||
|
||||
@@ -9,7 +9,6 @@ export default class Event extends Component {
|
||||
return {
|
||||
description: PropTypes.string,
|
||||
endTime: PropTypes.string,
|
||||
fetchEvents: PropTypes.func,
|
||||
id: PropTypes.string,
|
||||
images: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
@@ -60,10 +59,6 @@ export default class Event extends Component {
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchEvents();
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
description,
|
||||
|
||||
Reference in New Issue
Block a user