diff --git a/App.js b/App.js
index 3ab1814..e78900d 100644
--- a/App.js
+++ b/App.js
@@ -18,19 +18,9 @@ import {Notifications} from 'expo';
import * as Permissions from 'expo-permissions';
import * as SecureStore from 'expo-secure-store';
import RoleSelectionScreen from "./screens/RoleSelectionScreen";
-import {Overlay} from 'react-native-elements';
const Drawer = createDrawerNavigator();
-const userInfo = {
- name: "John Doe",
- email: "john.doe@gmail.com",
- phone: "(416) 132-4634",
- timeout: "00:34",
- role: "Worker",
- description: "Worker for Walmart"
-};
-
function DrawerContent(props) {
const {user, setUser} = useContext(UserContext);
@@ -61,7 +51,13 @@ function DrawerContent(props) {
export default function App() {
const [currentStore, setCurrentStore] = useState({name: "Walmart", id: 0});
const [groceryList, setGroceryList] = useState({});
- const [user, setUser] = useState(null);
+ const [user, setUser] = useState({
+ role: 'Worker',
+ phoneNumber: '4161324634',
+ email: 'john.doe@gmail.com',
+ firstName: 'John',
+ lastName: 'Doe'
+ });
useEffect(() => {
(async() => {
@@ -71,6 +67,7 @@ export default function App() {
vibrate: [250],
sound: true,
});
+
await Notifications.createChannelAndroidAsync('activated', {
name: 'Activated',
});
@@ -98,7 +95,6 @@ export default function App() {
if (!id) return;
const response = await fetch(`https://grocerserver.herokuapp.com/users/${id}`);
const result = await response.json();
-
})();
}, []);
diff --git a/components/GoBackIcon.js b/components/GoBackIcon.js
index 4273253..cfde937 100644
--- a/components/GoBackIcon.js
+++ b/components/GoBackIcon.js
@@ -11,7 +11,6 @@ export default function GoBackIcon({navigation}) {
type="entypo"
containerStyle={{marginLeft: 15}}
onPress={() => {
- console.log(navigation);
navigation.dangerouslyGetParent()?.setOptions({
...StackWrapperScreenOptions,
title: currentStore.name
diff --git a/components/GroceryList.js b/components/GroceryList.js
deleted file mode 100644
index 12b8cc5..0000000
--- a/components/GroceryList.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import React from 'react';
-import {ListItem} from "react-native-elements";
-
-function GroceryList() {
- return
-}
\ No newline at end of file
diff --git a/screens/GroceryItemOrderScreen.js b/screens/GroceryItemOrderScreen.js
index 5c96c5b..ffd80c8 100644
--- a/screens/GroceryItemOrderScreen.js
+++ b/screens/GroceryItemOrderScreen.js
@@ -57,6 +57,15 @@ export default function GroceryItemScreen({navigation, route}) {
+
diff --git a/screens/GroceryListSearchScreen.js b/screens/GroceryListSearchScreen.js
index cd51c99..b62f5fa 100644
--- a/screens/GroceryListSearchScreen.js
+++ b/screens/GroceryListSearchScreen.js
@@ -1,5 +1,5 @@
import React, {useState, useEffect, useContext} from 'react';
-import {FlatList, SafeAreaView, StyleSheet, View} from 'react-native';
+import {FlatList, SafeAreaView, StyleSheet, Text, View} from 'react-native';
import StackWrapper from '../navigation/StackWrapper';
import {ListItem, SearchBar} from "react-native-elements";
import GroceryListSummaryScreen from "./GroceryListSummaryScreen";
@@ -10,6 +10,7 @@ import UserContext from "../contexts/User";
function GroceryListSearch({navigation}) {
const [groceryLists, updateGroceryLists] = useState([]);
+ const [refreshing, setRefreshing] = useState(false);
const {user} = useContext(UserContext);
useEffect(() => {
@@ -20,25 +21,29 @@ function GroceryListSearch({navigation}) {
async function updateData() {
const listsUrl = 'https://grocerserver.herokuapp.com/lists';
+ setRefreshing(true);
const response = await fetch(listsUrl);
const result = await response.json();
+ setRefreshing(false);
updateGroceryLists(result);
}
return (
{
- if (!user) {
+ if (user.role === 'Worker') {
alert("You need to be a shopper to access this screen.");
return;
}
@@ -47,6 +52,13 @@ function GroceryListSearch({navigation}) {
/>}
keyExtractor={(groceryList) => groceryList._id.toString()}
contentContainerStyle={styles.listContainer}
+ ListEmptyComponent={
+
+
+ Sorry, this store doesn't have any active grocery lists.
+
+
+ }
/>
);
diff --git a/screens/GroceryListSummaryScreen.js b/screens/GroceryListSummaryScreen.js
index b2ec336..51d006b 100644
--- a/screens/GroceryListSummaryScreen.js
+++ b/screens/GroceryListSummaryScreen.js
@@ -24,7 +24,7 @@ export default function GroceryListSummaryScreen({navigation, route}) {
useEffect(() => {
navigation.dangerouslyGetParent()?.setOptions({
headerLeft: () => ,
- title: groceryList.author
+ title: `${groceryList.user.firstName} ${groceryList.user.lastName}`
});
}, []);
diff --git a/screens/RoleSelectionScreen.js b/screens/RoleSelectionScreen.js
index 45f748a..5ef5457 100644
--- a/screens/RoleSelectionScreen.js
+++ b/screens/RoleSelectionScreen.js
@@ -1,33 +1,46 @@
import React, {useEffect, useState, useContext} from 'react';
import {View, Text, StyleSheet} from 'react-native';
-import {Button} from 'react-native-elements';
+import {Button, Input} from 'react-native-elements';
import StackWrapper from "../navigation/StackWrapper";
import * as SecureStore from 'expo-secure-store';
import UserContext from "../contexts/User";
function RoleSelectionScreen() {
- const [pushToken, setPushToken] = useState('');
- const {user, setUser} = useContext(UserContext);
+ const [firstName, setFirstName] = useState('John');
+ const [lastName, setLastName] = useState('Doe');
+ const [email, setEmail] = useState('john.doe@gmail.com');
- useEffect(() => {
- (async() => {
- setPushToken(await SecureStore.getItemAsync('pushToken'));
- })();
- }, []);
+ const {user, setUser} = useContext(UserContext);
return (
If you're looking to test role-specific features of our app, you
- need to select a role that you wish to test. If you're just looking
- for a general concept and overview, you can press the menu in the
- top left corner and navigate to all the screens, but keep in mind
- that specific features for those screens may not work if you haven't
- selected a role.
+ need to select a role that you wish to test. Keep in mind
+ that specific features for some screens may not work if you haven't
+ selected the appropriate role.
+ setFirstName(text)}
+ />
+ setLastName(text)}
+ label="Last Name"
+ />
+ setEmail(text)}
+ label="Email"
+ />
{
const pushToken = await SecureStore.getItemAsync('pushToken');
const usersUrl = 'https://grocerserver.herokuapp.com/users';
@@ -39,9 +52,9 @@ function RoleSelectionScreen() {
},
body: JSON.stringify({
phoneNumber: '4161324634',
- email: 'john.doe@gmail.com',
- firstName: 'John',
- lastName: 'Doe',
+ email,
+ firstName,
+ lastName,
role: 'Shopper',
pushToken
})
@@ -49,22 +62,19 @@ function RoleSelectionScreen() {
const result = await response.json();
setUser(result);
await SecureStore.setItemAsync('userId', result._id);
-
- }}
- />
- {
-
}}
/>
{
+ setUser(null);
}}
/>
+
+ Current Role:
+ {user ? "Shopper/Requestor" : "Worker"}
+
);
}
@@ -79,8 +89,12 @@ const styles = StyleSheet.create({
notice: {
fontWeight: 'bold',
textAlign: 'center'
+ },
+ input: {
+ marginVertical: 10
}
});
+
export default StackWrapper(RoleSelectionScreen, {
title: 'Change Role'
});
diff --git a/screens/YourGroceryListScreen.js b/screens/YourGroceryListScreen.js
index cb68515..b08da86 100644
--- a/screens/YourGroceryListScreen.js
+++ b/screens/YourGroceryListScreen.js
@@ -58,7 +58,7 @@ function YourGroceryListScreen() {
title="Submit Grocery List Request"
disabled={Object.keys(groceryList).length === 0}
onPress={async () => {
- if (!user) {
+ if (user.role === 'Worker') {
alert("You need to be a shopper to perform this action.");
return;
}
@@ -79,8 +79,13 @@ function YourGroceryListScreen() {
}),
});
setLoading(false);
- const result = await response.json();
-
+ if (response.status === 400) {
+ alert("Something went wrong while trying to process your order");
+ return;
+ }
+ setGroceryList({});
+ alert("Your grocery list was sucessfully submitted.");
+ navigation.navigate("GrocerySearch");
}}
containerStyle={{
width: '80%',