Skip to content

Commit

Permalink
update database and correct scanPackage api logic
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil-ahlawat committed Mar 29, 2021
1 parent 57b7fa7 commit a322e6f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 178 deletions.
61 changes: 37 additions & 24 deletions Backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,55 @@ const app = express();

const DUMMY_USERS = [
{
name: 'Piyush Maheshwari',
emailID: 'piyush',
phoneNo: '9818284670',
password: 'treats',
userType: 'Delivery Personnel',
},
{
name: 'Wandan Tibrewal',
emailID: 'wandan',
phoneNo: '9818284671',
password: 'treats',
userType: 'Restaurant',
orders:[]
name: 'Warehouse',
phoneNo: '98980',
password: 'admin',
userType: 'Warehouse'
},
{
name: 'Swapnil Ahlawat',
emailID: 'swapnil',
phoneNo: '9818284672',
password: 'treats',
emailID: 'swapnil.ahlawat@gmail.com',
phoneNo: '98981',
password: 'admin',
userType: 'Customer',
address: "Dwarka, New Delhi",
wallet: 500.10,
wallet: 500.00,
promos:[{
title: "Special Reward",
description: "Get extra 10%* off on your next order!",
promoCode: "REUSE1"
},]
},
{
name: 'Swapnil Ahlawat',
emailID: 'swapnil',
phoneNo: '9818284672',
password: 'treats',
userType: 'Warehouse',
address: "Dwarka, New Delhi",
}
name: "Harley's Burgers",
phoneNo: '98982',
password: 'admin',
userType: 'Restaurant',
},
{
name: "Mama Mia Pizza",
phoneNo: '98983',
password: 'admin',
userType: 'Restaurant',
},
{
name: "Grand Hotdogs",
phoneNo: '98984',
password: 'admin',
userType: 'Restaurant',
},
{
name: "Manchow Cuisine",
phoneNo: '98985',
password: 'admin',
userType: 'Restaurant',
},
{
name: 'Andy',
phoneNo: '98986',
password: 'admin',
userType: 'Delivery Personnel',
},
]
connectDB();
// User.insertMany(DUMMY_USERS);
Expand Down
4 changes: 3 additions & 1 deletion Backend/controllers/package-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const scanPackage= async(req, res, next) => {
}

let userPhoneNo= identifiedPackage.userPhoneNo;
let lastPackageTag= identifiedPackage.packageTag;
identifiedPackage.userPhoneNo= phoneNo;
identifiedPackage.packageTag= packageTag;
if(packageTag==="Warehouse"){
Expand All @@ -25,7 +26,8 @@ const scanPackage= async(req, res, next) => {
console.log(userPhoneNo);
res.json({
message: 'Tag changed sucessfully!',
userPhoneNo: userPhoneNo
userPhoneNo: userPhoneNo,
lastPackageTag: lastPackageTag
});

}
Expand Down
178 changes: 26 additions & 152 deletions Frontend/screens/CustomerHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,28 @@ import {
import {icons, images, SIZES, COLORS, FONTS } from '../constants'

const CustomerHome = ({ navigation }) => {
global.name="Swapnil Ahlawat"
global.address="Najafgarh, New Delhi"
global.wallet= 500.00

const categoryData = [
{
id: 1,
name: "Rice",
icon: icons.rice_bowl,
name: "All",
icon: icons.hotdog,
},
{
id: 2,
name: "Noodles",
icon: icons.noodle,
name: "Rice",
icon: icons.rice_bowl,
},
{
id: 3,
name: "Hot Dogs",
icon: icons.hotdog,
name: "Snacks",
icon: icons.hamburger,
},
{
id: 4,
name: "Salads",
icon: icons.salad,
},
{
id: 5,
name: "Burgers",
icon: icons.hamburger,
},
{
id: 6,
name: "Pizza",
icon: icons.pizza,
},
{
id: 7,
name: "Snacks",
icon: icons.fries,
},
{
id: 8,
name: "Sushi",
icon: icons.sushi,
},
{
id: 9,
name: "Desserts",
icon: icons.donut,
},
{
id: 10,
name: "Drinks",
icon: icons.drink,
},

]

// price rating
Expand All @@ -80,21 +46,17 @@ const CustomerHome = ({ navigation }) => {
const restaurantData = [
{
id: 1,
name: "ByProgrammers Burger",
name: "Harley's Burgers",
reusablePackage: true,
rating: 4.8,
categories: [5, 7],
categories: [1, 3],
priceRating: affordable,
phoneNo: 9818284671,
phoneNo: 98982,
photo: images.burger_restaurant_1,
duration: "30 - 45 min",
location: {
latitude: 1.5347282806345879,
longitude: 110.35632207358996,
},
courier: {
avatar: images.avatar_1,
name: "Piyush Maheshwari"
name: "Andy",
phoneNo: 98986
},
menu: [
{
Expand Down Expand Up @@ -125,21 +87,17 @@ const CustomerHome = ({ navigation }) => {
},
{
id: 2,
name: "ByProgrammers Pizza",
name: "Mama Mia Pizza",
reusablePackage: false,
rating: 4.8,
categories: [2, 4, 6],
categories: [1, 3, 4],
priceRating: expensive,
phoneNo: 9818284671,
phoneNo: 98983,
photo: images.pizza_restaurant,
duration: "15 - 20 min",
location: {
latitude: 1.556306570595712,
longitude: 110.35504616746915,
},
courier: {
avatar: images.avatar_2,
name: "Piyush Maheshwari"
name: "Andy",
phoneNo: 98986
},
menu: [
{
Expand Down Expand Up @@ -178,21 +136,17 @@ const CustomerHome = ({ navigation }) => {
},
{
id: 3,
name: "ByProgrammers Hotdogs",
name: "Grand Hotdogs",
reusablePackage: true,
rating: 4.8,
categories: [3],
categories: [1, 3],
priceRating: expensive,
phoneNo: 9818284671,
phoneNo: 98984,
photo: images.hot_dog_restaurant,
duration: "20 - 25 min",
location: {
latitude: 1.5238753474714375,
longitude: 110.34261833833622,
},
courier: {
avatar: images.avatar_3,
name: "Piyush Maheshwari"
name: "Andy",
phoneNo: 98986
},
menu: [
{
Expand All @@ -207,50 +161,17 @@ const CustomerHome = ({ navigation }) => {
},
{
id: 4,
name: "ByProgrammers Sushi",
name: "Manchow Cuisine",
reusablePackage: false,
rating: 4.8,
categories: [8],
priceRating: expensive,
phoneNo: 9818284671,
photo: images.japanese_restaurant,
duration: "10 - 15 min",
location: {
latitude: 1.5578068150528928,
longitude: 110.35482523764315,
},
courier: {
avatar: images.avatar_4,
name: "Piyush Maheshwari"
},
menu: [
{
menuId: 9,
name: "Sushi sets",
photo: images.sushi,
description: "Fresh salmon, sushi rice, fresh juicy avocado",
calories: 100,
price: 50
}
]
},
{
id: 5,
name: "ByProgrammers Cuisine",
reusablePackage: false,
rating: 4.8,
categories: [1, 2],
categories: [1, 2, 4],
priceRating: affordable,
phoneNo: 9818284671,
phoneNo: 98985,
photo: images.noodle_shop,
duration: "15 - 20 min",
location: {
latitude: 1.558050496260768,
longitude: 110.34743759630511,
},
courier: {
avatar: images.avatar_4,
name: "Piyush Maheshwari"
name: "Andy",
phoneNo: 98986
},
menu: [
{
Expand Down Expand Up @@ -288,53 +209,6 @@ const CustomerHome = ({ navigation }) => {

]
},
{

id: 6,
name: "ByProgrammers Dessets",
reusablePackage: true,
rating: 4.9,
categories: [9, 10],
priceRating: affordable,
phoneNo: 9818284671,
photo: images.kek_lapis_shop,
duration: "35 - 40 min",
location: {
latitude: 1.5573478487252896,
longitude: 110.35568783282145,
},
courier: {
avatar: images.avatar_1,
name: "Piyush Maheshwari"
},
menu: [
{
menuId: 12,
name: "Teh C Peng",
photo: images.teh_c_peng,
description: "Three Layer Teh C Peng",
calories: 100,
price: 2
},
{
menuId: 13,
name: "ABC Ice Kacang",
photo: images.ice_kacang,
description: "Shaved Ice with red beans",
calories: 100,
price: 3
},
{
menuId: 14,
name: "Kek Lapis",
photo: images.kek_lapis,
description: "Layer cakes",
calories: 300,
price: 20
}
]

}
]

const [categories, setCategories] = React.useState(categoryData)
Expand Down
2 changes: 1 addition & 1 deletion Frontend/screens/Scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const Scan = ({route, navigation }) => {
console.log("done");
deleteOrder();
}
else if(modeTag==="Delivery Personnel"){
else if(responseData.lastPackageTag && responseData.lastPackageTag==="Customer"){
console.log(responseData.userPhoneNo +"response")
addWalletMoney(responseData.userPhoneNo);
addPromoReward(responseData.userPhoneNo);
Expand Down

0 comments on commit a322e6f

Please sign in to comment.