diff --git a/app/api/events.js b/app/api/events.js
index 1cf72ae..e08ab70 100644
--- a/app/api/events.js
+++ b/app/api/events.js
@@ -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);
};
diff --git a/app/api/index.js b/app/api/index.js
index 408053b..37f1020 100644
--- a/app/api/index.js
+++ b/app/api/index.js
@@ -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 = {}) => {
diff --git a/app/api/profile.js b/app/api/profile.js
index 4c92f81..a674339 100644
--- a/app/api/profile.js
+++ b/app/api/profile.js
@@ -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 },
+});
diff --git a/app/components/AppHeader/AppHeader.container.js b/app/components/AppHeader/AppHeader.container.js
new file mode 100644
index 0000000..536ea7a
--- /dev/null
+++ b/app/components/AppHeader/AppHeader.container.js
@@ -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);
diff --git a/app/components/AppHeader/AppHeader.js b/app/components/AppHeader/AppHeader.js
index 3c58171..17233c8 100644
--- a/app/components/AppHeader/AppHeader.js
+++ b/app/components/AppHeader/AppHeader.js
@@ -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 (
- }
- centerComponent={}
- rightComponent={}
- />
- );
-}
+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 (
+ }
+ centerComponent={}
+ rightComponent={}
+ />
+ );
+ }
+}
diff --git a/app/screens/Event.container.js b/app/screens/Event.container.js
index 34132d3..18c7628 100644
--- a/app/screens/Event.container.js
+++ b/app/screens/Event.container.js
@@ -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);
diff --git a/app/screens/Event.js b/app/screens/Event.js
index 79c6acc..ac1baf3 100644
--- a/app/screens/Event.js
+++ b/app/screens/Event.js
@@ -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,