File tree Expand file tree Collapse file tree 4 files changed +22
-13
lines changed
Expand file tree Collapse file tree 4 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export default function NewDeliveryPrice({ route }) {
2525 const priceExcludingTax = useSelector ( selectPriceExcludingTax ) ;
2626 const [ isManualPriceEnabled , setIsManualPriceEnabled ] = useState ( false ) ;
2727
28- const { deliveryCallback } = useDeliveryCallback ( ) ;
28+ const { deliveryCallback, allowManualPrice = false } = useDeliveryCallback ( ) ;
2929
3030 useEffect ( ( ) => {
3131 dispatch ( getPrice ( delivery ) ) ;
@@ -130,9 +130,11 @@ export default function NewDeliveryPrice({ route }) {
130130 ) }
131131 </ View >
132132 </ > ) : null }
133- < Button onPress = { onPressManualPriceToggle ( setFieldValue ) } >
134- < ButtonText > { t ( 'MANUAL_PRICE_TOGGLE_' + ( isManualPriceEnabled ? 'OFF' : 'ON' ) ) } </ ButtonText >
135- </ Button >
133+ { allowManualPrice ? (
134+ < Button onPress = { onPressManualPriceToggle ( setFieldValue ) } >
135+ < ButtonText > { t ( 'MANUAL_PRICE_TOGGLE_' + ( isManualPriceEnabled ? 'OFF' : 'ON' ) ) } </ ButtonText >
136+ </ Button >
137+ ) : null }
136138 </ ModalFormWrapper >
137139 ) }
138140 </ Formik >
Original file line number Diff line number Diff line change 11import React , { createContext , useContext } from 'react' ;
22
3- const DeliveryCallbackContext = createContext ( ) ;
3+ const DeliveryCallbackContext = createContext ( { } ) ;
44
5- export const DeliveryCallbackProvider = ( { children, callback } ) => (
5+ export const DeliveryCallbackProvider = ( { children, callback, options = { } } ) => (
66 < DeliveryCallbackContext . Provider
77 value = { {
88 deliveryCallback : callback ,
9+ ...options
910 } } >
1011 { children }
1112 </ DeliveryCallbackContext . Provider >
Original file line number Diff line number Diff line change @@ -194,20 +194,23 @@ export default function DispatchNavigator({ navigation }) {
194194 presentation : 'modal' ,
195195 } ) ;
196196
197- const deliveryCallback = newDelivery => {
198- navigation . navigate ( 'DispatchAllTasks' ) ;
199- dispatch ( createDeliverySuccess ( newDelivery ) ) ;
200- } ;
201-
202197 useEffect ( ( ) => {
203198 const clearSelectedTasksState = navigation . addListener ( 'blur' , ( ) => {
204199 dispatch ( clearSelectedTasks ( ) ) ;
205200 } ) ;
206201 return clearSelectedTasksState ;
207202 } , [ navigation , dispatch ] ) ;
208203
204+ const deliveryCallback = newDelivery => {
205+ navigation . navigate ( 'DispatchAllTasks' ) ;
206+ dispatch ( createDeliverySuccess ( newDelivery ) ) ;
207+ } ;
208+ const deliveryCallbackOptions = {
209+ allowManualPrice : true ,
210+ } ;
211+
209212 return (
210- < DeliveryCallbackProvider callback = { deliveryCallback } >
213+ < DeliveryCallbackProvider callback = { deliveryCallback } options = { deliveryCallbackOptions } >
211214 < TaskListsProvider defaultIsFromCourier = { false } >
212215 < RootStack . Navigator screenOptions = { screenOptions } >
213216 < RootStack . Screen
Original file line number Diff line number Diff line change @@ -82,9 +82,12 @@ export default ({ navigation }) => {
8282 navigation . navigate ( 'StoreHome' ) ;
8383 dispatch ( createDeliverySuccess ( newDelivery ) ) ;
8484 } ;
85+ const deliveryCallbackOptions = {
86+ allowManualPrice : false ,
87+ } ;
8588
8689 return (
87- < DeliveryCallbackProvider callback = { deliveryCallback } >
90+ < DeliveryCallbackProvider callback = { deliveryCallback } options = { deliveryCallbackOptions } >
8891 < RootStack . Navigator screenOptions = { screenOptions } >
8992 < RootStack . Screen
9093 name = "StoreHome"
You can’t perform that action at this time.
0 commit comments