Skip to content

Commit

Permalink
feat: finalizing tunnel order for referent in guyane
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianRid committed Jul 6, 2021
1 parent 200d154 commit 8258507
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
6 changes: 5 additions & 1 deletion back-strapi/api/commande/models/commande.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"type": "enumeration",
"enum": [
"home",
"pickup"
"pickup",
"referent"
]
},
"content": {
Expand Down Expand Up @@ -72,6 +73,9 @@
},
"poi_number": {
"type": "string"
},
"referent": {
"model": "referent"
}
}
}
19 changes: 19 additions & 0 deletions tumeplay-app/src/screens/tunnel/TunnelCartSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export default function TunnelCartSummary(props) {
const [selectedProducts] = useState(
props.navigation.state.params.selectedProducts,
);
const [selectedReferent] = useState(
props.navigation.state.params.selectedReferent
)
const [userAdress] = useState(props.navigation.state.params.userAdress);

console.log('TUNNELSUMMARY', props)

async function _confirmOrder() {
//ORDER STRAPI API
let orderPost;
Expand Down Expand Up @@ -68,6 +73,20 @@ export default function TunnelCartSummary(props) {
poi_number: selectedPickup.Num,
delivery: deliveryType
}
} else if (deliveryType === 'referent') {
requestBody = {
...requestBody,
address: selectedReferent.address,
address_city: selectedReferent.address_city,
address_dept: selectedReferent.address_dept,
address_deptcode: selectedReferent.address_deptcode,
address_region: selectedReferent.address_region,
address_zipcode: selectedReferent.address_zipcode,
phone: selectedReferent.phone_number,
poi_name: selectedReferent.name,
delivery: deliveryType,
referent: selectedReferent.id
}
}
if (selectedItem.__typename === 'Box') {
requestBody = {
Expand Down
13 changes: 13 additions & 0 deletions tumeplay-app/src/screens/tunnel/TunnelUserAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ export default function TunnelUserAddress(props) {
props.navigation.state.params.selectedProducts,
);

const [selectedReferent] = useState(
props.navigation.state.params.selectedReferent,
);

const [localAdress, setLocalAdress] = useState(defaultUserAdress);
const [localValid, setLocalValid] = useState({});
const [mainValidFlag, setMainValidFlag] = useState(false);
const [invalidAddress, setInvalidAddress] = useState(false);
const [invalidZipCode, setInvalidZipCode] = useState(false);
const [disallowOrder, setDisallowOrder] = useState(false);

console.log('ADRESS', props)

useEffect(() => {
if (props.navigation.state.params.userAdress) {
const userAdress = props.navigation.state.params.userAdress;
Expand Down Expand Up @@ -234,6 +240,7 @@ export default function TunnelUserAddress(props) {
deliveryType: deliveryType,
userAdress: localAdress,
selectedPickup: selectedPickup,
selectedReferent: selectedReferent,
});
}

Expand Down Expand Up @@ -283,6 +290,12 @@ export default function TunnelUserAddress(props) {
selectedItem: selectedItem,
selectedProducts: selectedProducts,
});
} else if (deliveryType === 'referent') {
props.navigation.navigate('TunnelReferentSelect', {
selectedItem: selectedItem,
selectedProducts: selectedProducts,
selectedReferent: selectedReferent,
});
} else {
props.navigation.navigate('TunnelPickupSelect', {
selectedItem: selectedItem,
Expand Down
3 changes: 2 additions & 1 deletion tumeplay-app/src/services/api/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const OrdersAPI = {
address_zipcode: order.address_zipcode,
address_city: order.address_city,
poi_name: order.poi_name,
poi_number: order.poi_number
poi_number: order.poi_number,
referent: order.referent
}),
});
return res;
Expand Down

0 comments on commit 8258507

Please sign in to comment.