diff --git a/back-strapi/api/commande/models/commande.settings.json b/back-strapi/api/commande/models/commande.settings.json index 4f1d11a6..7f249983 100644 --- a/back-strapi/api/commande/models/commande.settings.json +++ b/back-strapi/api/commande/models/commande.settings.json @@ -25,7 +25,8 @@ "type": "enumeration", "enum": [ "home", - "pickup" + "pickup", + "referent" ] }, "content": { @@ -72,6 +73,9 @@ }, "poi_number": { "type": "string" + }, + "referent": { + "model": "referent" } } } diff --git a/tumeplay-app/src/screens/tunnel/TunnelCartSummary.js b/tumeplay-app/src/screens/tunnel/TunnelCartSummary.js index 344bba48..cf6df83f 100644 --- a/tumeplay-app/src/screens/tunnel/TunnelCartSummary.js +++ b/tumeplay-app/src/screens/tunnel/TunnelCartSummary.js @@ -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; @@ -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 = { diff --git a/tumeplay-app/src/screens/tunnel/TunnelUserAddress.js b/tumeplay-app/src/screens/tunnel/TunnelUserAddress.js index ca1ac48e..0655e2bc 100644 --- a/tumeplay-app/src/screens/tunnel/TunnelUserAddress.js +++ b/tumeplay-app/src/screens/tunnel/TunnelUserAddress.js @@ -82,6 +82,10 @@ 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); @@ -89,6 +93,8 @@ export default function TunnelUserAddress(props) { 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; @@ -234,6 +240,7 @@ export default function TunnelUserAddress(props) { deliveryType: deliveryType, userAdress: localAdress, selectedPickup: selectedPickup, + selectedReferent: selectedReferent, }); } @@ -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, diff --git a/tumeplay-app/src/services/api/orders.js b/tumeplay-app/src/services/api/orders.js index c3989c94..b6ffd307 100644 --- a/tumeplay-app/src/services/api/orders.js +++ b/tumeplay-app/src/services/api/orders.js @@ -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;