Skip to content

Commit

Permalink
Merge pull request #187 from MarkusPaulsen/dev
Browse files Browse the repository at this point in the history
Need to merge dev into backendSprint7 for latest API referanses
  • Loading branch information
frikkha authored Jan 7, 2020
2 parents fd5b94c + d698685 commit ee4bc3a
Show file tree
Hide file tree
Showing 77 changed files with 5,812 additions and 3,838 deletions.
26 changes: 23 additions & 3 deletions API_reference.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
swagger: "2.0"
info:
description: "This is the API reference of The Spoon project.\n \n VERSIONING: The version number works in this way: it's composed of two numbers separated by a point. The first number identifies the Sprint, so for example the version 2.1 of the API reference is related to the Sprint number 2. The second number starts from 0 and has to be increased by one each time the file is modified. The person who modifies this document is responsible for increasing the number.\n \n GROUPING OF ENDPOINTS: The endpoints are grouped by dividing them into customers' operations and owners' operations. All the endpoints that are not strictly related to customers nor owners remain inside the default group.\n \n AUTHENTICATION/AUTHORIZATION: The json web token returned when the login is performed is supposed to be put into x-auth-token header in the endpoints that require authorization"
version: "8.0"
version: "8.1"
title: "The Spoon API reference"
tags:
- name: "customer"
Expand Down Expand Up @@ -411,7 +411,7 @@ paths:
- "customer"
- "Frikk"
summary: "Search by menu item"
description: "Returns all the menus with given menu item (dish/drink) with menuID. It also returns the names of the associated restaurants with restaurantID.\n The menu items inside every menu are not returned. It will be needed to access the endpoint /api/user/customer/menu/{menuID} to get the menu items of a specific menu (the menuID passed can be obtained from the response of this endpoint, since it returns the menuID of every menu)."
description: "Returns all the menus with given menu item (dish/drink) with menuID. It also returns the names of the associated restaurants with restaurantID.\n The menu items inside every menu are not returned. It will be needed to access the endpoint /api/user/customer/menu/{menuID} to get the menu items of a specific menu (the menuID passed can be obtained from the response of this endpoint, since it returns the menuID of every menu).\n The customer can be not logged in, if that is the case then the authentication token must be sent with a null value. The authentication in this endpoint is necessary to collect the search done by the customer and use it to collect statistics."
operationId: "searchByMenuItem"
produces:
- "application/json"
Expand Down Expand Up @@ -443,6 +443,15 @@ paths:
schema:
type: "string"
example: "Internal server error."
401:
description: "Access denied"
schema:
type: "string"
example: "Access denied."
security:
- Bearer: []
x-security-scopes:
- "customer"
/api/user/customer/menu/{menuID}:
get:
tags:
Expand Down Expand Up @@ -1842,6 +1851,17 @@ definitions:
type: "number"
longitude:
type: "number"
openingHours:
type: "array"
items:
type: "object"
properties:
day:
type: "string"
openTime:
type: "string"
closeTime:
type: "string"
menuName:
type: "string"
description:
Expand All @@ -1857,7 +1877,7 @@ definitions:
items:
$ref: "#/definitions/MenuItemWithID"
example:
restaurant: {"restaurantName": "Emilio's Pizza", "address": "Piazzale Susa", "city": "Milan", "country": "Italy", "latitude": 45.4688346, "longitude": 9.2234114}
restaurant: {"restaurantName": "Emilio's Pizza", "address": "Piazzale Susa", "city": "Milan", "country": "Italy", "latitude": 45.4688346, "longitude": 9.2234114, "openingHours": [{"day": "Wednesday", "openTime": "12.30", "closeTime": "14.30"}, {"day": "Saturday", "openTime": "12.00", "closeTime": "15.00"}]}
menuName: "Emilio's menu of the day"
description: "Our special menu of today"
tags: [{"name": "Italian", "color": "#FFBC8C"}, {"name": "Mediterranean", "color": "#FFBC8C"}]
Expand Down
1 change: 0 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"jwtExpirationTime": "",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"companySecret": "",
"sequelize_Database": "postgres://vlbganljybqkij:19f31cdd0c3704ba6f463d0236de1e224187121d17811cb950b46c29daa5ace4@ec2-54-246-100-246.eu-west-1.compute.amazonaws.com:5432/d9dfhu5citam1c?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
}
1 change: 0 additions & 1 deletion middleware/authorizationMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const jwt = require('jsonwebtoken');
const config = require('config');

//NOTE: not tested yet
module.exports = (req, res, next) => {
//the token is supposed to be in x-auth-token header, the first thing to be done is checking if it's there
const token = req.header('x-auth-token');
Expand Down
45 changes: 41 additions & 4 deletions mobileApp/components/menupage/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import * as Colors from "../../styles/colors";
import * as Api from "../../services/api";
import { AirbnbRating } from "react-native-ratings";
import Icon from "react-native-vector-icons/MaterialIcons";
import { Dimensions } from "react-native";
import OpeningHours from "./OpeningHours";

function MenuItem({
menuItemName,
Expand Down Expand Up @@ -121,7 +123,8 @@ export default class Menu extends Component {
dishItems: "",
drinkItems: "",
menuID: null,
restaurantImage: null
restaurantImage: null,
showOpeningHours: false
};
}

Expand All @@ -133,7 +136,10 @@ export default class Menu extends Component {
"restaurantName",
"default value"
);
const restaurantImage = navigation.getParam("restaurantImage", "default value");
const restaurantImage = navigation.getParam(
"restaurantImage",
"default value"
);
this.setState({ restaurantImage: restaurantImage });
await this.getMenuItem(menuId, restaurantName);
};
Expand Down Expand Up @@ -168,7 +174,8 @@ export default class Menu extends Component {
longitude: parseFloat(responseJson["restaurant"]["longitude"]),
address: responseJson["restaurant"]["address"],
city: responseJson["restaurant"]["city"],
country: responseJson["restaurant"]["country"]
country: responseJson["restaurant"]["country"],
openingHours: responseJson["restaurant"]["openingHours"]
};

const dishItems = [];
Expand Down Expand Up @@ -196,6 +203,7 @@ export default class Menu extends Component {
}

render() {
const screenWidth = Math.round(Dimensions.get("window").width);
return (
<SafeAreaView style={styles.container}>
<ScrollView
Expand Down Expand Up @@ -376,6 +384,35 @@ export default class Menu extends Component {
/>
</View>
) : null}
<TouchableOpacity
style={{
flex: 1,
flexDirection: "row",
height: 50,
width: screenWidth * 0.9,
justifyContent: "space-between",
alignItems: "center",
marginTop: 5
}}
onPress={() => this.setState({ showOpeningHours: true })}
>
<View style={{ flexDirection: "row", alignItems: "center" }}>
<Icon name={"access-time"} size={30} color={Colors.GRAY_DARK} />
<Text style={{ color: Colors.GRAY_DARK, marginLeft: 5 }}>
Opening Hours
</Text>
</View>
<Icon
name={"keyboard-arrow-right"}
size={30}
color={Colors.GRAY_DARK}
/>
</TouchableOpacity>
<OpeningHours
data={this.state.restaurantInfo.openingHours}
visible={this.state.showOpeningHours}
backButton={() => this.setState({ showOpeningHours: false })}
/>
<View style={{ flex: 1 }}>
{this.state.isLoading ? (
<Text> No map to display </Text>
Expand All @@ -391,7 +428,7 @@ export default class Menu extends Component {
width: 360,
height: 270,
alignSelf: "center",
marginTop: 30
marginTop: 15
}}
>
<MapView.Marker
Expand Down
60 changes: 60 additions & 0 deletions mobileApp/components/menupage/OpeningHours.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from "react";
import {
FlatList,
Modal,
View,
Text,
StyleSheet,
TouchableOpacity
} from "react-native";
import Icon from "react-native-vector-icons/MaterialIcons";
import * as Typography from "../../styles/typography";

const renderItem = item => {
return (
<View style={{ flexDirection: "row", justifyContent: "space-between", width: 200, marginBottom: 20 }}>
<Text style={Typography.FONT_MED_BLACK}>{item.day}</Text>
<View style={{ flexDirection: "row" }}>
<Text style={Typography.FONT_REGULAR_THIN}>{item.openTime}</Text>
<Text style={Typography.FONT_REGULAR_THIN}> - </Text>
<Text style={Typography.FONT_REGULAR_THIN}>{item.closeTime}</Text>
</View>
</View>
);
};

const OpeningHours = ({ visible, data, backButton }) => {
return (
<Modal visible={visible}>
<View style={styles.container}>
<TouchableOpacity onPress={backButton}>
<Icon name={"chevron-left"} size={40} style={styles.button} />
</TouchableOpacity>
<Text
style={[
Typography.FONT_H3_BLACK,
{ alignSelf: "center", marginBottom: 30 }
]}
>
Opening Hours
</Text>
<View style={{ alignSelf: "center" }}>
<FlatList
data={data}
renderItem={({ item }) => renderItem(item)}
keyExtractor={(item, index) => index.toString()}
/>
</View>
</View>
</Modal>
);
};

export default OpeningHours;

const styles = StyleSheet.create({
container: {
marginTop: 40,
marginBottom: 40
}
});
134 changes: 64 additions & 70 deletions mobileApp/components/review/views/ReviewItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BackButton from "../components/backButton";
import ContinueButton from "../components/continueButton";
import { AirbnbRating } from "react-native-ratings";
import * as Colors from "../../../styles/colors";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";

export default class ReviewItems extends Component {
constructor(props) {
Expand Down Expand Up @@ -32,91 +33,84 @@ export default class ReviewItems extends Component {
this.setState({ imageID, menuItems, menuID, menuName, restaurant, token });
};

setRatingCount(rating, item, itemID) {
setRatingCount(rating, item) {
item.rating = rating;

const menuItems = this.state.menuItems.filter(e => e.menuItemID !== itemID);
const updatedMenuItems = menuItems.concat(item);

this.setState({menuItems: updatedMenuItems}
);
this.state.reviewedScores.push(item);
if (this.state.reviewedScores.length === this.state.menuItems.length) {
if (this.state.menuItems.every(e => e.rating !== null)) {
this.setState({ disableButton: false });
}
}

onChangeText(text, item, itemID) {
onChangeText(text, item) {
item.content = text;
const menuItems = this.state.menuItems.filter(e => e.menuItemID !== itemID);
const updatedMenuItems = menuItems.concat(item);
this.setState({menuItems: updatedMenuItems});
}

render() {
return (
<View style={styles.container}>
<View>
<View style={styles.header}>
<Text style={Typography.FONT_H3_BLACK}>Write review</Text>
<KeyboardAwareScrollView>
<View style={styles.container}>
<View>
<View style={styles.header}>
<Text style={Typography.FONT_H3_BLACK}>Write review</Text>
</View>
<BackButton navigation={this.props.navigation} />
</View>
<BackButton navigation={this.props.navigation} />
</View>
<FlatList
data={this.state.menuItems}
renderItem={({ item }) => (
<View style={styles.reviewContainer}>
<View style={{ flexDirection: "row", marginBottom: 15 }}>
<Text
style={[Typography.FONT_MED_BLACK, { textAlign: "left" }]}
>
Item:{" "}
</Text>
<Text
style={[Typography.FONT_MED_PINK, { textAlign: "right" }]}
>
{item.menuItemName}
</Text>
</View>
<AirbnbRating
showRating={false}
defaultRating={0}
size={30}
selectedColor={Colors.PINK}
onFinishRating={rating =>
this.setRatingCount(rating, item, item.menuItemID)
}
/>
<View style={styles.textBox}>
<TextInput
style={styles.textInput}
maxLength={200}
multiline={true}
placeholder={"Review"}
textAlignVertical={"top"}
onChangeText={text =>
this.onChangeText(text, item, item.menuItemID)
<FlatList
data={this.state.menuItems}
renderItem={({ item }) => (
<View style={styles.reviewContainer}>
<View style={{ flexDirection: "row", marginBottom: 15 }}>
<Text
style={[Typography.FONT_MED_BLACK, { textAlign: "left" }]}
>
Item:{" "}
</Text>
<Text
style={[Typography.FONT_MED_PINK, { textAlign: "right" }]}
>
{item.menuItemName}
</Text>
</View>
<AirbnbRating
showRating={false}
defaultRating={0}
size={30}
selectedColor={Colors.PINK}
onFinishRating={rating =>
this.setRatingCount(rating, item)
}
/>
<View style={styles.textBox}>
<TextInput
style={styles.textInput}
maxLength={200}
multiline={true}
placeholder={"Review"}
textAlignVertical={"top"}
onChangeText={text =>
this.onChangeText(text, item)
}
/>
</View>
</View>
</View>
)}
keyExtractor={item => item.menuItemID}
/>
<ContinueButton
disableButton={this.state.disableButton}
navigation={this.props}
menuItemReviews={this.state.menuItems}
imageID={this.state.imageID}
menuID={this.state.menuID}
menuName={this.state.menuName}
restaurant={this.state.restaurant}
token={this.state.token}
view={"ReviewOverall"}
text={"CONTINUE"}
colorIndex={this.state.colorIndex}
/>
</View>
)}
keyExtractor={item => item.menuItemID}
/>
<ContinueButton
disableButton={this.state.disableButton}
navigation={this.props}
menuItemReviews={this.state.menuItems}
imageID={this.state.imageID}
menuID={this.state.menuID}
menuName={this.state.menuName}
restaurant={this.state.restaurant}
token={this.state.token}
view={"ReviewOverall"}
text={"CONTINUE"}
colorIndex={this.state.colorIndex}
/>
</View>
</KeyboardAwareScrollView>
);
}
}
Expand Down
Loading

0 comments on commit ee4bc3a

Please sign in to comment.