Skip to content

Commit

Permalink
show count in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil-ahlawat committed Mar 30, 2021
1 parent bda028b commit e37435c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions Backend/controllers/package-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const scanPackage = async (req, res, next) => {
message: 'Tag changed sucessfully!',
userPhoneNo: userPhoneNo,
lastPackageTag: lastPackageTag,
count: identifiedPackage.count,
});
};

Expand Down
2 changes: 1 addition & 1 deletion Backend/database/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const package = new mongoose.Schema({
},
count: {
type: Number,
default: 1,
default: 0,
},
});

Expand Down
26 changes: 25 additions & 1 deletion Frontend/screens/Scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ const Scan = ({ route, navigation }) => {
const [phoneNo, setPhoneNo] = useState(null);
const [packageTag, setPackageTag] = useState(null);
const [modeTag, setModeTag] = useState(null);
const [count, setCount] = useState(null);

const inFocus = navigation.addListener('focus', () => {
setScanned(false);
setSerialNumber(null);
setOrder(null);
setPhoneNo(global.user.phoneNo);
setModeTag(global.modeTag);
setCount(null);
let orderTemp = null;
if (route.params) {
setModeTag(route.params.modeTag);
Expand Down Expand Up @@ -162,6 +164,9 @@ const Scan = ({ route, navigation }) => {
if (!response.ok) {
throw new Error(responseData.message);
} else {
if (responseData.count) {
setCount(responseData.count);
}
if (modeTag === 'RestaurantDelivery') {
deleteOrder();
} else if (
Expand Down Expand Up @@ -326,7 +331,7 @@ const Scan = ({ route, navigation }) => {
var text;
if (modeTag === 'Restaurant') {
text =
"Thank you for collecting the package. We will soon collect the package for it's cleaning. ";
'Thank you for collecting the package. We will soon collect the package from you for cleaning. ';
} else if (modeTag === 'RestaurantDelivery') {
text =
'Our delivery personnel will shortly collect the package and will deliver it to the customer. Thank you for choosing to be a partner with Uber Eats.';
Expand All @@ -336,6 +341,24 @@ const Scan = ({ route, navigation }) => {
text =
'Thank you for collecting the package. Please deposit at any collection centre as per your convenience.';
}

function renderPackageCount() {
if (modeTag === 'Warehouse') {
return (
<Text
style={{
color: COLORS.black,
marginVertical: SIZES.padding,
marginLeft: 3 * SIZES.padding,
...FONTS.body2,
width: SIZES.width * 0.8,
}}
>
Fun Fact: This package has been used {count} times till now!.
</Text>
);
} else return <View></View>;
}
return (
<Modal animationType="slide" transparent={true} visible={modalVisible}>
<TouchableWithoutFeedback
Expand Down Expand Up @@ -401,6 +424,7 @@ const Scan = ({ route, navigation }) => {
>
{text}
</Text>
{renderPackageCount()}
</View>
</View>
</TouchableWithoutFeedback>
Expand Down

0 comments on commit e37435c

Please sign in to comment.