@@ -3,7 +3,7 @@ import { Switch } from '@/components/ui/switch';
33import { Text } from '@/components/ui/text' ;
44import { Button , ButtonText } from '@/components/ui/button' ;
55import React , { Component } from 'react' ;
6- import { FlatList } from 'react-native' ;
6+ import { Alert , FlatList } from 'react-native' ;
77import { SafeAreaView } from 'react-native-safe-area-context' ;
88
99import { withTranslation } from 'react-i18next' ;
@@ -14,6 +14,8 @@ import {
1414 changeProductEnabled ,
1515 loadMoreProducts ,
1616 loadProducts ,
17+ changeProductEnabledRequest ,
18+ disableProductUntilTomorrow ,
1719} from '../../redux/Restaurant/actions' ;
1820
1921class ProductsScreen extends Component {
@@ -22,7 +24,34 @@ class ProductsScreen extends Component {
2224 }
2325
2426 _toggleProductEnabled ( product , value ) {
25- this . props . changeProductEnabled ( product , value ) ;
27+
28+ if ( value === false ) {
29+
30+ this . props . changeProductEnabledRequest ( product , value ) ;
31+
32+ Alert . alert (
33+ this . props . t ( 'RESTAURANT_PRODUCT_DISABLE_ENABLE_TOMORROW' ) ,
34+ '' ,
35+ [
36+ {
37+ text : this . props . t ( 'NO_THANKS' ) ,
38+ onPress : ( ) => {
39+ this . props . changeProductEnabled ( product , value ) ;
40+ } ,
41+ } ,
42+ {
43+ text : this . props . t ( 'YES' ) ,
44+ onPress : ( ) => {
45+ this . props . disableProductUntilTomorrow ( product ) ;
46+ }
47+ } ,
48+ ] ,
49+ ) ;
50+
51+ } else {
52+ this . props . changeProductEnabled ( product , value ) ;
53+ }
54+
2655 }
2756
2857 renderItem ( item ) {
@@ -89,6 +118,8 @@ function mapDispatchToProps(dispatch) {
89118 loadProducts : ( restaurant ) => dispatch ( loadProducts ( restaurant ) ) ,
90119 loadMoreProducts : ( ) => dispatch ( loadMoreProducts ( ) ) ,
91120 changeProductEnabled : ( product , enabled ) => dispatch ( changeProductEnabled ( product , enabled ) ) ,
121+ changeProductEnabledRequest : ( product , enabled ) => dispatch ( changeProductEnabledRequest ( product , enabled ) ) ,
122+ disableProductUntilTomorrow : ( product ) => dispatch ( disableProductUntilTomorrow ( product ) ) ,
92123 } ;
93124}
94125
0 commit comments