Skip to content

Commit

Permalink
fix restraunt post
Browse files Browse the repository at this point in the history
  • Loading branch information
wandan23 committed Mar 28, 2021
1 parent 69b9126 commit 9a47654
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Frontend/screens/RestaurantHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ const RestaurantHome = ({ navigation }) => {




const [currentLocation,setCurrentLocation] = React.useState(initialCurrentLocation)
const [orders, setOrders] = React.useState(null)
const [fetchFlag,setFetchFlag] = React.useState(true)


React.useEffect(() => setOrders(fetchOrder()), [orders]);



async function fetchOrder(){
if (fetchFlag)
{
setFetchFlag(false)
console.log(global.user.phoneNo)

var url = "http://c47f3fbd2a93.ngrok.io/user/restaurant?phoneNo=" + global.user.phoneNo
var url = "http://c47f3fbd2a93.ngrok.io/user/restaurant?phoneNo=" + global.user.phoneNo + "&userType=Restaurant"
console.log(url)
try {
const response = await fetch(url, {
Expand All @@ -53,12 +57,13 @@ const RestaurantHome = ({ navigation }) => {
}
else{
console.log(responseData)
return responseData
setOrders(responseData.pendingOrders)
}
} catch (err) {
console.log(err)
return null
}
}


};
Expand Down Expand Up @@ -130,7 +135,7 @@ const RestaurantHome = ({ navigation }) => {
}}
>
<Text style={{ ...FONTS.body3,color: COLORS.black }}>{item.customerName}</Text>
{/* <Text style={{ ...FONTS.body3,color: COLORS.black }}>${item.price.toFixed(2)}</Text> */}
<Text style={{ ...FONTS.body3,color: COLORS.black }}>${item.customerPhoneNo}</Text>
</View>
<View
style={{
Expand All @@ -148,10 +153,10 @@ const RestaurantHome = ({ navigation }) => {

return (
<View style={{ paddingHorizontal: SIZES.padding * 2, marginTop:SIZES.padding*2}}>
<Text style={{paddingVertical:10, ...FONTS.h2,color: COLORS.white }}>In Progress ()</Text>
<Text style={{paddingVertical:10, ...FONTS.h2,color: COLORS.white }}>In Progress ({orders?.pendingorders?.length})</Text>
<FlatList
data={orders}
keyExtractor={item => `${item.id}`}
data={orders?.pendingOrders}
keyExtractor={item => `${item['_id']}`}
renderItem={renderItem}
contentContainerStyle={{
paddingBottom: 30
Expand All @@ -161,7 +166,7 @@ const RestaurantHome = ({ navigation }) => {
)
}


fetchOrder()
return (

<SafeAreaView style={styles.container}>
Expand Down

0 comments on commit 9a47654

Please sign in to comment.