Skip to content

Commit

Permalink
feat: unavailable orders redirect to contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianRid committed Jun 25, 2021
1 parent 45c7cea commit a4b4924
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
3 changes: 3 additions & 0 deletions back-strapi/api/contact/models/contact.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
},
"zipcode": {
"type": "integer"
},
"box": {
"model": "box"
}
}
}
7 changes: 6 additions & 1 deletion tumeplay-app/src/screens/StayInTouchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export default function StayInTouchScreen(props) {
// }

if (_isValid) {
ContactsAPI.postContact(localAdress);
let box_id = props.navigation.state.params.box_id;
let userAdress = {
...localAdress,
box_id: box_id
}
ContactsAPI.postContact(userAdress);
props.navigation.navigate('StayInTouchConfirm', {outOfStock: outOfStock});
}
}
Expand Down
46 changes: 45 additions & 1 deletion tumeplay-app/src/screens/components/tunnel/ProductCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useState} from 'react';
import PropTypes from 'prop-types';
import {Text, View, Image, StyleSheet} from 'react-native';
import {Text, View, Image, StyleSheet, TouchableOpacity} from 'react-native';

import Colors from '../../../styles/Color';
import Styles from '../../../styles/Styles';
Expand All @@ -10,6 +10,7 @@ import CustomTouchableOpacity from '../global/CustomTouchableOpacity';
ProductCard.propTypes = {
item: PropTypes.object,
onPress: PropTypes.func,
navigation: PropTypes.object
};

export default function ProductCard(props) {
Expand Down Expand Up @@ -67,6 +68,30 @@ export default function ProductCard(props) {
paddingTop: 0,
resizeMode: 'contain',
},
descriptionCard: {
position: 'absolute',
top: '35%',
left: '35%',
marginHorizontal: 'auto',
opacity: 1,
zIndex: 10
},
descriptionTitle: {
color: "#FFFF",
fontFamily: Colors.appTitleFont,
fontSize: 30,
marginBottom: 5,
},
descriptionButton: {
backgroundColor: 'rgb(200,3,82)',
paddingHorizontal: 10,
textAlign: 'center',
paddingVertical: 10,
borderRadius: 30,
},
descriptionText: {
color: "#FFFF",
},
notAvailableWrapper: {
position: 'absolute',
flex: 1,
Expand Down Expand Up @@ -102,7 +127,25 @@ export default function ProductCard(props) {
}
};

const redirectContact = () => {
props.navigation.navigate('StayInTouch', {
box_id: props.item.id
})
}

return (
<>
{
!productBox.available ?
<View style={cardStyle.descriptionCard}>
<Text style={cardStyle.descriptionTitle}>Box indisponible</Text>
<CustomTouchableOpacity style={cardStyle.descriptionButton} onPress={() => {redirectContact()}}>
<Text style={cardStyle.descriptionText}>Laisse nous tes coordonnées</Text>
</CustomTouchableOpacity>
</View>
:
null
}
<View style={cardStyle.container}>
<CustomTouchableOpacity
style={cardStyle.buttonWrapper}
Expand All @@ -126,5 +169,6 @@ export default function ProductCard(props) {
</View>
</CustomTouchableOpacity>
</View>
</>
);
}
3 changes: 2 additions & 1 deletion tumeplay-app/src/screens/tunnel/TunnelProductSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ export default function TunnelProductSelect(props) {
return (
<ProductCard
key={key}
navigation={props.navigation}
item={item}
onPress={() => _onBoxClicked(item)}
/>
);
});
}

return (
<SafeAreaView style={Styles.safeAreaView}>
<View style={[Styles.safeAreaViewInner, {flex: 1}]}>
Expand Down
1 change: 1 addition & 0 deletions tumeplay-app/src/services/api/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ContactsAPI = {
name: userAdress.firstName,
email: userAdress.emailAdress,
zipcode: userAdress.zipCode,
box: userAdress.box_id
}),
});
},
Expand Down

0 comments on commit a4b4924

Please sign in to comment.