diff --git a/database/db_build.js b/database/db_build.js index 611a590..33da535 100644 --- a/database/db_build.js +++ b/database/db_build.js @@ -16,8 +16,9 @@ MongoClient.connect(DB_URL, (err, db) => { }); // inserts data to the collection guestHouse.insert({ - GuestHouses: { - Daher: { + GuestHouses: [ + { + id: 0, name: 'Daher', address: '6098 St 8, Nazareth', phone: '052-535-0691', @@ -32,7 +33,8 @@ MongoClient.connect(DB_URL, (err, db) => { longitude: 35.298813, }, }, - SimSim: { + { + id: 1, name: 'SimSim', address: '632 St 3, Nazareth', phone: '077-551-7275', @@ -47,7 +49,8 @@ MongoClient.connect(DB_URL, (err, db) => { longitude: 35.298813, }, }, - Vitrage: { + { + id: 2, name: 'Vitrage', address: '6083 St 4, Nazareth', phone: '04-601-2130', @@ -62,7 +65,7 @@ MongoClient.connect(DB_URL, (err, db) => { longitude: 35.298813, }, }, - }, + ], }, (insertErr) => { if (insertErr) throw insertErr; // searches through the collection to make sure that the data that we inserted is there diff --git a/mockData.js b/mockData.js new file mode 100644 index 0000000..2256190 --- /dev/null +++ b/mockData.js @@ -0,0 +1,51 @@ +module.exports = +[ + { + id: 0, + name: 'Daher', + address: '6098 St 8, Nazareth', + phone: '052-535-0691', + coordinates: { + latitude: 32.704783, + longitude: 35.298489, + }, + parkingLotName: 'Al Mutran Parking', + parkingLotAddress: '6100 St, Nazareth', + parkingLotCoordinates: { + latitude: 32.705329, + longitude: 35.298813, + }, + }, + { + id: 1, + name: 'SimSim', + address: '632 St 3, Nazareth', + phone: '077-551-7275', + coordinates: { + latitude: 32.704375, + longitude: 35.298083, + }, + parkingLotName: 'Al Mutran Parking', + parkingLotAddress: '6100 St, Nazareth', + parkingLotCoordinates: { + latitude: 32.705329, + longitude: 35.298813, + }, + }, + { + id: 2, + name: 'Vitrage', + address: '6083 St 4, Nazareth', + phone: '04-601-2130', + coordinates: { + latitude: 32.705086, + longitude: 35.298032, + }, + parkingLotName: 'Al Mutran Parking', + parkingLotAddress: '6100 St, Nazareth', + parkingLotCoordinates: { + latitude: 32.705329, + longitude: 35.298813, + }, + }, +]; diff --git a/server.js b/server.js index a8a3fac..7c62851 100644 --- a/server.js +++ b/server.js @@ -1,16 +1,13 @@ -import { matchPath } from 'react-router-dom'; - const express = require('express'); const webpackDevMiddleware = require('webpack-dev-middleware'); const webpack = require('webpack'); const path = require('path'); const webpackConfig = require('./webpack.config.js'); -const DB_URL = require('./database/url.js'); -const db = require('./database/db.js'); -const Routes = require('./src/routes.jsx'); +const mockData = require('./mockData.js'); const app = express(); + // initiates webapck using your config rules const compiler = webpack(webpackConfig); @@ -27,32 +24,12 @@ app.use(webpackDevMiddleware(compiler, { historyApiFallback: true, })); -// have express parse url and send it to react react-router -app.get('*', (request, response, next) => { - matchPath({ Routes, location: request.url }, () => { - response.sendFile(path.resolve(__dirname, 'public', 'index.html')); - }); - next(); -}); app.get('/api', (request, response) => { - const data = db.get(); - let result = {}; - const guestHouse = data.collection('GuestHouse'); - guestHouse.find({ }).toArray((error, documents) => { - result = documents[0].GuestHouses; - response.send(result); - }); + response.send(mockData); }); // connects with the database before starting the server -db.connect(DB_URL, (err) => { - if (err) { - console.log('Unable to connect to mongo'); - process.exit(1); - } else { - app.listen(process.env.PORT || 3000, () => { - console.log('Listening on port 3000'); - }); - } +app.listen(process.env.PORT || 3000, () => { + console.log('Listening on port 3000'); }); diff --git a/src/components/search_bar.jsx b/src/components/search_bar.jsx deleted file mode 100644 index cc5bd61..0000000 --- a/src/components/search_bar.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { Link } from 'react-router-dom'; - -const SearchBar = () => - ( -
- ); - -export default SearchBar; diff --git a/src/components/search_list.jsx b/src/components/search_list.jsx new file mode 100644 index 0000000..f41dd2a --- /dev/null +++ b/src/components/search_list.jsx @@ -0,0 +1,34 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; + +class SearchList extends Component { + constructor(props) { + super(props); + this.renderList = this.renderList.bind(this); + + this.state = {}; + } + + renderList() { + return this.props.guesthouses.map(guesthouse => + ( + +