ordering-ui-react-native 0.11.19 → 0.11.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/providers/StoreUtil.tsx +4 -8
- package/themes/business/index.tsx +7 -1
- package/themes/business/src/components/LoginForm/index.tsx +62 -1
- package/themes/business/src/components/OrdersOption/index.tsx +2 -0
- package/themes/business/src/components/PreviousOrders/index.tsx +11 -4
- package/themes/business/src/components/PreviousOrders/styles.tsx +6 -0
- package/themes/business/src/providers/StoreUtil.tsx +4 -8
- package/themes/business/src/types/index.tsx +2 -0
- package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +1 -76
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -0
- package/themes/kiosk/src/components/Intro/index.tsx +1 -0
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/kiosk/src/components/NavBar/index.tsx +1 -1
- package/themes/kiosk/src/components/OptionCard/index.tsx +10 -2
- package/themes/kiosk/src/components/OptionCard/styles.tsx +9 -1
- package/themes/kiosk/src/components/OrderDetails/index.tsx +1 -0
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +32 -6
- package/themes/kiosk/src/components/OrderTypeSelector/index.tsx +2 -2
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +4 -1
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +21 -18
package/package.json
CHANGED
|
@@ -5,21 +5,17 @@ export const _retrieveStoreData = async (key: string) => {
|
|
|
5
5
|
if (!key) return
|
|
6
6
|
try {
|
|
7
7
|
const value = await AsyncStorage.getItem(key);
|
|
8
|
-
|
|
9
|
-
return JSON.parse(value)
|
|
10
|
-
}
|
|
8
|
+
return value != null ? JSON.parse(value) : null;
|
|
11
9
|
} catch {
|
|
12
10
|
return null
|
|
13
11
|
}
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
export const _setStoreData = (key: string, val: any) => {
|
|
14
|
+
export const _setStoreData = async (key: string, val: any) => {
|
|
17
15
|
if (!key) return
|
|
18
16
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
typeof (val) === 'string' ? val : JSON.stringify(val)
|
|
22
|
-
)
|
|
17
|
+
const value = JSON.stringify(val)
|
|
18
|
+
await AsyncStorage.setItem(key, value)
|
|
23
19
|
} catch {
|
|
24
20
|
return null
|
|
25
21
|
}
|
|
@@ -46,6 +46,10 @@ import { Container } from './src/layouts/Container';
|
|
|
46
46
|
import { SafeAreaContainer } from './src/layouts/SafeAreaContainer';
|
|
47
47
|
import { SafeAreaContainerLayout } from './src/layouts/SafeAreaContainer';
|
|
48
48
|
import { useLocation } from './src/hooks/useLocation';
|
|
49
|
+
|
|
50
|
+
// providers
|
|
51
|
+
import { StoreMethods } from './src/providers/StoreUtil';
|
|
52
|
+
|
|
49
53
|
export {
|
|
50
54
|
//Components
|
|
51
55
|
AcceptOrRejectOrder,
|
|
@@ -90,5 +94,7 @@ export {
|
|
|
90
94
|
//layouts
|
|
91
95
|
Container,
|
|
92
96
|
SafeAreaContainer,
|
|
93
|
-
useLocation
|
|
97
|
+
useLocation,
|
|
98
|
+
// providers
|
|
99
|
+
StoreMethods,
|
|
94
100
|
};
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
LoginForm as LoginFormController,
|
|
16
16
|
useLanguage,
|
|
17
17
|
useConfig,
|
|
18
|
+
useApi
|
|
18
19
|
} from 'ordering-components/native';
|
|
19
20
|
import { useTheme } from 'styled-components/native';
|
|
20
21
|
import {
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
OrSeparator,
|
|
26
27
|
LineSeparator,
|
|
27
28
|
} from './styles';
|
|
29
|
+
import { _setStoreData } from '../../providers/StoreUtil'
|
|
28
30
|
import { OText, OButton, OInput, OIconButton, OModal } from '../shared';
|
|
29
31
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
30
32
|
import { VerifyPhone } from '../VerifyPhone';
|
|
@@ -45,8 +47,10 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
45
47
|
handleCheckPhoneCode,
|
|
46
48
|
setCheckPhoneCodeState,
|
|
47
49
|
allowedLevels,
|
|
50
|
+
useRootPoint
|
|
48
51
|
} = props;
|
|
49
52
|
|
|
53
|
+
const [ordering, { setOrdering }] = useApi();
|
|
50
54
|
const [, { showToast }] = useToast();
|
|
51
55
|
const [, t] = useLanguage();
|
|
52
56
|
const theme = useTheme();
|
|
@@ -55,6 +59,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
55
59
|
|
|
56
60
|
const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
|
|
57
61
|
const inputRef = useRef<any>(null);
|
|
62
|
+
const inputMailRef = useRef<any>(null);
|
|
58
63
|
|
|
59
64
|
const [passwordSee, setPasswordSee] = useState(false);
|
|
60
65
|
const [isLoadingVerifyModal, setIsLoadingVerifyModal] = useState(false);
|
|
@@ -76,6 +81,9 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
76
81
|
: 'Landscape',
|
|
77
82
|
);
|
|
78
83
|
|
|
84
|
+
const [submitted, setSubmitted] = useState(false);
|
|
85
|
+
const [formValues, setFormValues] = useState(null);
|
|
86
|
+
|
|
79
87
|
const getTraduction = (key: string) => {
|
|
80
88
|
const keyList: any = {
|
|
81
89
|
// Add the key and traduction that you need below
|
|
@@ -142,9 +150,20 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
142
150
|
return;
|
|
143
151
|
}
|
|
144
152
|
|
|
153
|
+
if (values?.project_name) {
|
|
154
|
+
setOrdering({
|
|
155
|
+
...ordering,
|
|
156
|
+
project: values?.project_name
|
|
157
|
+
})
|
|
158
|
+
_setStoreData('project_name', values?.project_name)
|
|
159
|
+
setFormValues({ ...values, ...phoneInputData.phone })
|
|
160
|
+
setSubmitted(true)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
145
164
|
handleButtonLoginClick({
|
|
146
165
|
...values,
|
|
147
|
-
...phoneInputData.phone
|
|
166
|
+
...phoneInputData.phone
|
|
148
167
|
});
|
|
149
168
|
};
|
|
150
169
|
|
|
@@ -194,6 +213,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
194
213
|
t('PHONE_NUMER', 'Phone number'),
|
|
195
214
|
),
|
|
196
215
|
);
|
|
216
|
+
setSubmitted(false)
|
|
197
217
|
}
|
|
198
218
|
}, [formState]);
|
|
199
219
|
|
|
@@ -256,6 +276,15 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
256
276
|
}
|
|
257
277
|
}, [loading]);
|
|
258
278
|
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
if (ordering.project === null || !submitted || !useRootPoint) return
|
|
281
|
+
const values: any = formValues
|
|
282
|
+
if (values?.project_name) {
|
|
283
|
+
delete values.project_name
|
|
284
|
+
}
|
|
285
|
+
handleButtonLoginClick({ ...values })
|
|
286
|
+
}, [ordering, submitted])
|
|
287
|
+
|
|
259
288
|
Dimensions.addEventListener('change', ({ window: { width, height } }) => {
|
|
260
289
|
setWindowWidth(
|
|
261
290
|
parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
|
|
@@ -422,6 +451,37 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
422
451
|
|
|
423
452
|
{(useLoginByCellphone || useLoginByEmail) && (
|
|
424
453
|
<FormInput>
|
|
454
|
+
{useRootPoint && (
|
|
455
|
+
<Controller
|
|
456
|
+
control={control}
|
|
457
|
+
name='project_name'
|
|
458
|
+
rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
|
|
459
|
+
defaultValue=""
|
|
460
|
+
render={({ onChange, value }: any) => (
|
|
461
|
+
<OInput
|
|
462
|
+
name='project_name'
|
|
463
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
464
|
+
placeholder={t('PROJECT_NAME', 'Project Name')}
|
|
465
|
+
icon={theme.images.general.project}
|
|
466
|
+
iconColor={theme.colors.arrowColor}
|
|
467
|
+
onChange={(e: any) => {
|
|
468
|
+
onChange(e?.target?.value);
|
|
469
|
+
setSubmitted(false);
|
|
470
|
+
}}
|
|
471
|
+
selectionColor={theme.colors.primary}
|
|
472
|
+
color={theme.colors.textGray}
|
|
473
|
+
value={value}
|
|
474
|
+
style={styles.input}
|
|
475
|
+
returnKeyType='next'
|
|
476
|
+
autoCorrect={false}
|
|
477
|
+
autoCapitalize='none'
|
|
478
|
+
onSubmitEditing={() => inputMailRef.current?.focus()}
|
|
479
|
+
blurOnSubmit={false}
|
|
480
|
+
/>
|
|
481
|
+
)}
|
|
482
|
+
/>
|
|
483
|
+
)}
|
|
484
|
+
|
|
425
485
|
{useLoginByEmail && loginTab === 'email' && (
|
|
426
486
|
<Controller
|
|
427
487
|
control={control}
|
|
@@ -442,6 +502,7 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
442
502
|
autoCorrect={false}
|
|
443
503
|
type="email-address"
|
|
444
504
|
autoCompleteType="email"
|
|
505
|
+
forwardRef={inputMailRef}
|
|
445
506
|
returnKeyType="next"
|
|
446
507
|
onSubmitEditing={() => inputRef.current?.focus()}
|
|
447
508
|
blurOnSubmit={false}
|
|
@@ -47,6 +47,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
47
47
|
loadOrders,
|
|
48
48
|
loadMoreOrders,
|
|
49
49
|
onNavigationRedirect,
|
|
50
|
+
handleClickOrder
|
|
50
51
|
} = props;
|
|
51
52
|
|
|
52
53
|
const theme = useTheme();
|
|
@@ -328,6 +329,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
328
329
|
orders={currentOrdersGroup.orders}
|
|
329
330
|
onNavigationRedirect={onNavigationRedirect}
|
|
330
331
|
getOrderStatus={getOrderStatus}
|
|
332
|
+
handleClickOrder={handleClickOrder}
|
|
331
333
|
/>
|
|
332
334
|
)}
|
|
333
335
|
|
|
@@ -3,15 +3,17 @@ import { StyleSheet, TouchableOpacity } from 'react-native';
|
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import { useLanguage, useUtils } from 'ordering-components/native';
|
|
5
5
|
import { OIcon, OText } from '../shared';
|
|
6
|
-
import { Card, Logo, Information, MyOrderOptions } from './styles';
|
|
6
|
+
import { Card, Logo, Information, MyOrderOptions, NotificationIcon } from './styles';
|
|
7
|
+
import EntypoIcon from 'react-native-vector-icons/Entypo'
|
|
7
8
|
|
|
8
9
|
export const PreviousOrders = (props: any) => {
|
|
9
|
-
const { orders, onNavigationRedirect, getOrderStatus } = props;
|
|
10
|
+
const { orders, onNavigationRedirect, getOrderStatus, handleClickOrder } = props;
|
|
10
11
|
const [, t] = useLanguage();
|
|
11
12
|
const [{ parseDate, optimizeImage }] = useUtils();
|
|
12
13
|
const theme = useTheme();
|
|
13
14
|
|
|
14
15
|
const handlePressOrder = (order: any) => {
|
|
16
|
+
handleClickOrder && handleClickOrder(order)
|
|
15
17
|
onNavigationRedirect &&
|
|
16
18
|
onNavigationRedirect('OrderDetails', { order: order });
|
|
17
19
|
};
|
|
@@ -96,12 +98,17 @@ export const PreviousOrders = (props: any) => {
|
|
|
96
98
|
/>
|
|
97
99
|
</Logo>
|
|
98
100
|
)}
|
|
99
|
-
|
|
100
101
|
<Information>
|
|
101
102
|
<OText numberOfLines={1} style={styles.title}>
|
|
102
103
|
{order.business?.name}
|
|
103
104
|
</OText>
|
|
104
|
-
|
|
105
|
+
<NotificationIcon>
|
|
106
|
+
<EntypoIcon
|
|
107
|
+
name="dot-single"
|
|
108
|
+
size={32}
|
|
109
|
+
color={theme.colors.primary}
|
|
110
|
+
/>
|
|
111
|
+
</NotificationIcon>
|
|
105
112
|
<OText
|
|
106
113
|
style={styles.date}
|
|
107
114
|
numberOfLines={1}
|
|
@@ -13,6 +13,7 @@ export const Logo = styled.View`
|
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
15
|
export const Information = styled.View`
|
|
16
|
+
position: relative;
|
|
16
17
|
justify-content: flex-start;
|
|
17
18
|
margin-horizontal: 10px;
|
|
18
19
|
flex: 1;
|
|
@@ -23,3 +24,8 @@ export const MyOrderOptions = styled.View`
|
|
|
23
24
|
flex-direction: column;
|
|
24
25
|
justify-content: space-between;
|
|
25
26
|
`;
|
|
27
|
+
|
|
28
|
+
export const NotificationIcon = styled.View`
|
|
29
|
+
position: absolute;
|
|
30
|
+
left: 90%;
|
|
31
|
+
`
|
|
@@ -5,21 +5,17 @@ export const _retrieveStoreData = async (key: string) => {
|
|
|
5
5
|
if (!key) return
|
|
6
6
|
try {
|
|
7
7
|
const value = await AsyncStorage.getItem(key);
|
|
8
|
-
|
|
9
|
-
return JSON.parse(value)
|
|
10
|
-
}
|
|
8
|
+
return value != null ? JSON.parse(value) : null;
|
|
11
9
|
} catch {
|
|
12
10
|
return null
|
|
13
11
|
}
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
export const _setStoreData = (key: string, val: any) => {
|
|
14
|
+
export const _setStoreData = async (key: string, val: any) => {
|
|
17
15
|
if (!key) return
|
|
18
16
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
typeof (val) === 'string' ? val : JSON.stringify(val)
|
|
22
|
-
)
|
|
17
|
+
const value = JSON.stringify(val)
|
|
18
|
+
await AsyncStorage.setItem(key, value)
|
|
23
19
|
} catch {
|
|
24
20
|
return null
|
|
25
21
|
}
|
|
@@ -19,6 +19,7 @@ export interface LoginParams {
|
|
|
19
19
|
emailInputIcon?: any;
|
|
20
20
|
passwordInputIcon?: any;
|
|
21
21
|
allowedLevels?: any;
|
|
22
|
+
useRootPoint?: any;
|
|
22
23
|
}
|
|
23
24
|
export interface ProfileParams {
|
|
24
25
|
navigation?: any;
|
|
@@ -274,6 +275,7 @@ export interface OrdersOptionParams {
|
|
|
274
275
|
ordersGroup?: any;
|
|
275
276
|
setOrdersGroup?: any;
|
|
276
277
|
setCurrentFilters?: any;
|
|
278
|
+
handleClickOrder?: any;
|
|
277
279
|
}
|
|
278
280
|
export interface ActiveOrdersParams {
|
|
279
281
|
orders?: any;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
useApi
|
|
10
10
|
} from 'ordering-components/native'
|
|
11
11
|
import Carousel from 'react-native-snap-carousel';
|
|
12
|
-
import Geocoder from 'react-native-geocoding';
|
|
13
12
|
import { BusinessProductsListingParams, Business, Product } from '../../types'
|
|
14
13
|
import { OCard, OText } from '../shared'
|
|
15
14
|
import GridContainer from '../../layouts/GridContainer'
|
|
@@ -26,13 +25,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
26
25
|
|
|
27
26
|
const theme = useTheme();
|
|
28
27
|
const [, t] = useLanguage();
|
|
29
|
-
const [{user, accessToken}] = useSession()
|
|
30
|
-
const [, {changeAddress}] = useOrder()
|
|
31
28
|
const [orientationState] = useDeviceOrientation();
|
|
32
|
-
const [configState] = useConfig()
|
|
33
|
-
const [ordering] = useApi()
|
|
34
|
-
const [addressState, setAddressState] = useState<any>({ loading: false, changes: {}, error: null, address: {} })
|
|
35
|
-
const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value
|
|
36
29
|
|
|
37
30
|
const _categories: any = business?.original?.categories;
|
|
38
31
|
let _promos: any = [];
|
|
@@ -46,74 +39,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
46
39
|
}
|
|
47
40
|
});
|
|
48
41
|
|
|
49
|
-
const handleCurrentUserLocation = async () => {
|
|
50
|
-
let addressValue : any = []
|
|
51
|
-
let data: any = { address: null, error: null }
|
|
52
|
-
const filterAddressInfo = [
|
|
53
|
-
{ tag: 'street_number', isShort: true },
|
|
54
|
-
{ tag: 'route', isShort: true },
|
|
55
|
-
{ tag: 'locality', isShort: true },
|
|
56
|
-
{ tag: 'administrative_area_level_1', isShort: false },
|
|
57
|
-
{ tag: 'country', isShort: false },
|
|
58
|
-
]
|
|
59
|
-
Geocoder.init(googleMapsApiKey);
|
|
60
|
-
Geocoder.from({
|
|
61
|
-
latitude: business.location?.lat,
|
|
62
|
-
longitude: business.location?.lng
|
|
63
|
-
}).then( async (json : any) => {
|
|
64
|
-
if(json.results && json.results?.length > 0){
|
|
65
|
-
for (const component of json.results?.[0].address_components) {
|
|
66
|
-
const addressType = component.types?.[0]
|
|
67
|
-
for (const filterProps of filterAddressInfo) {
|
|
68
|
-
if(filterProps.tag.includes(addressType)) {
|
|
69
|
-
addressValue.push(filterProps.isShort ? component.short_name : component.long_name)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
data = {
|
|
74
|
-
address: addressValue.join(', '),
|
|
75
|
-
location: json.results[0].geometry.location,
|
|
76
|
-
map_data: {
|
|
77
|
-
library: 'google',
|
|
78
|
-
place_id: json.results?.[0].place_id
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
setAddressState({ ...addressState, loading: true })
|
|
82
|
-
try {
|
|
83
|
-
const { content } = await ordering
|
|
84
|
-
.users(user?.id)
|
|
85
|
-
.addresses()
|
|
86
|
-
.save(data.address, { accessToken })
|
|
87
|
-
setAddressState({
|
|
88
|
-
...addressState,
|
|
89
|
-
loading: false,
|
|
90
|
-
error: content.error ? content.result : null,
|
|
91
|
-
})
|
|
92
|
-
if (!content.error && data) {
|
|
93
|
-
setAddressState({
|
|
94
|
-
...addressState,
|
|
95
|
-
address: data
|
|
96
|
-
})
|
|
97
|
-
changeAddress(data)
|
|
98
|
-
}
|
|
99
|
-
} catch (err : any) {
|
|
100
|
-
setAddressState({
|
|
101
|
-
...addressState,
|
|
102
|
-
loading: false,
|
|
103
|
-
error: [err.message],
|
|
104
|
-
address: {}
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if(business?.location?.lat && business?.location?.lng){
|
|
113
|
-
handleCurrentUserLocation()
|
|
114
|
-
}
|
|
115
|
-
}, [business?.location, googleMapsApiKey])
|
|
116
|
-
|
|
117
42
|
const _renderTitle = (title: string): React.ReactElement => (
|
|
118
43
|
<View style={{paddingHorizontal: 20, paddingVertical: 40}}>
|
|
119
44
|
<OText size={orientationState?.dimensions?.width * 0.035} weight="bold">
|
|
@@ -199,7 +124,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
199
124
|
</>
|
|
200
125
|
);
|
|
201
126
|
|
|
202
|
-
if (businessState?.error
|
|
127
|
+
if (businessState?.error) {
|
|
203
128
|
return <OText>{t('ERROR', 'Error')}</OText>;
|
|
204
129
|
}
|
|
205
130
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ImageSourcePropType, ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import { ImageSourcePropType, ImageStyle, TextStyle, ViewStyle, ActivityIndicator } from 'react-native';
|
|
3
3
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
|
|
6
6
|
import { OButton, OIcon, OText } from '../shared';
|
|
7
|
-
import { Container, InnerContainer } from './styles';
|
|
7
|
+
import { Container, InnerContainer, ActivityIndicatorContainer } from './styles';
|
|
8
8
|
|
|
9
9
|
const OptionCard = (props: Props) => {
|
|
10
10
|
const theme = useTheme();
|
|
@@ -13,6 +13,7 @@ const OptionCard = (props: Props) => {
|
|
|
13
13
|
<TouchableOpacity
|
|
14
14
|
onPress={props.onClick}
|
|
15
15
|
activeOpacity={1}
|
|
16
|
+
disabled={props.isDisabled}
|
|
16
17
|
>
|
|
17
18
|
<Container
|
|
18
19
|
source={props.bgImage}
|
|
@@ -20,7 +21,13 @@ const OptionCard = (props: Props) => {
|
|
|
20
21
|
>
|
|
21
22
|
<InnerContainer
|
|
22
23
|
style={props.innerStyle}
|
|
24
|
+
isLoading={props.isLoading}
|
|
23
25
|
>
|
|
26
|
+
{props.isLoading && (
|
|
27
|
+
<ActivityIndicatorContainer>
|
|
28
|
+
<ActivityIndicator size='large' color='#ffffff' />
|
|
29
|
+
</ActivityIndicatorContainer>
|
|
30
|
+
)}
|
|
24
31
|
<OIcon
|
|
25
32
|
src={props.icon}
|
|
26
33
|
style={{ marginBottom: 10, ...props?.iconStyle }}
|
|
@@ -79,6 +86,7 @@ interface Props {
|
|
|
79
86
|
description: string;
|
|
80
87
|
descriptionStyle?: TextStyle;
|
|
81
88
|
isDisabled?: boolean;
|
|
89
|
+
isLoading?: boolean;
|
|
82
90
|
onClick?: () => void;
|
|
83
91
|
style?: ViewStyle;
|
|
84
92
|
bgImage: ImageSourcePropType;
|
|
@@ -6,9 +6,17 @@ export const Container = styled.ImageBackground`
|
|
|
6
6
|
`
|
|
7
7
|
export const InnerContainer = styled.View`
|
|
8
8
|
position: absolute;
|
|
9
|
-
background: rgba(24, 28, 50, 0.4);
|
|
9
|
+
background: ${(props : any) => props.isLoading ? 'rgba(24, 28, 50, 0.7)' : 'rgba(24, 28, 50, 0.4)'};
|
|
10
10
|
width: 100%;
|
|
11
11
|
height: 100%;
|
|
12
12
|
padding: 10%;
|
|
13
13
|
justify-content: center;
|
|
14
14
|
`
|
|
15
|
+
|
|
16
|
+
export const ActivityIndicatorContainer = styled.View`
|
|
17
|
+
flex: 1;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
position: absolute;
|
|
21
|
+
left: 60%
|
|
22
|
+
`
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import { View } from 'react-native'
|
|
3
3
|
import {
|
|
4
4
|
OrderTypeControl,
|
|
5
5
|
useLanguage,
|
|
6
|
+
useOrder
|
|
6
7
|
} from 'ordering-components/native'
|
|
7
8
|
import { useTheme } from 'styled-components/native'
|
|
8
9
|
|
|
@@ -29,7 +30,9 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
|
|
|
29
30
|
const theme = useTheme();
|
|
30
31
|
const [, t] = useLanguage();
|
|
31
32
|
const [orientationState] = useDeviceOrientation();
|
|
32
|
-
|
|
33
|
+
const [orderState] = useOrder()
|
|
34
|
+
const [isCardCliked, setIsCardClicked] = useState(false)
|
|
35
|
+
const [isLoadingCard, setIsLoadingCard] = useState<string | null>(null)
|
|
33
36
|
const _orderTypes = orderTypes.filter((type: any) => configTypes?.includes(type.value))
|
|
34
37
|
|
|
35
38
|
const _takeOut = _orderTypes?.find(item => item?.value === 2);
|
|
@@ -41,12 +44,21 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
|
|
|
41
44
|
height: orientationState?.orientation === PORTRAIT ? orientationState?.dimensions?.height * 0.34 : orientationState?.dimensions?.height * 0.45,
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if(isCardCliked){
|
|
49
|
+
callback?.()
|
|
50
|
+
setIsCardClicked(false)
|
|
51
|
+
setIsLoadingCard(null)
|
|
52
|
+
}
|
|
53
|
+
}, [orderState?.options?.type])
|
|
54
|
+
|
|
44
55
|
return (
|
|
45
56
|
typeSelected !== undefined && (
|
|
46
57
|
<Container>
|
|
47
58
|
<NavBar
|
|
48
59
|
title={t('DELIVERY_TYPE', 'Delivery type')}
|
|
49
60
|
{...(goBack && { onActionLeft: goBack } )}
|
|
61
|
+
btnStyle={{paddingLeft: 0}}
|
|
50
62
|
/>
|
|
51
63
|
|
|
52
64
|
<View style={{ marginVertical: orientationState?.dimensions?.height * 0.03 }}>
|
|
@@ -69,14 +81,21 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
|
|
|
69
81
|
>
|
|
70
82
|
<OptionCard
|
|
71
83
|
style={cardStyle}
|
|
84
|
+
isDisabled={isCardCliked}
|
|
85
|
+
isLoading={isLoadingCard === 'Eat In'}
|
|
72
86
|
title={t('EAT_IN','Eat In')}
|
|
73
87
|
description={t('EAT_IN_DESCRIPTION', 'We are very glad to have you here. Bon appetit!')}
|
|
74
88
|
bgImage={theme.images.general.eatIn}
|
|
75
89
|
icon={theme.images.general.pushPin}
|
|
76
90
|
callToActionText={t('START_MY_ORDER', 'Start my order')}
|
|
77
91
|
onClick={() => {
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
if(_eatIn?.value !== orderState?.options?.type){
|
|
93
|
+
handleChangeOrderType(_eatIn?.value);
|
|
94
|
+
setIsCardClicked(true)
|
|
95
|
+
setIsLoadingCard('Eat In')
|
|
96
|
+
} else {
|
|
97
|
+
callback?.()
|
|
98
|
+
}
|
|
80
99
|
}}
|
|
81
100
|
/>
|
|
82
101
|
|
|
@@ -88,13 +107,20 @@ const OrderTypeSelectorCardUI = (props: OrderTypeSelectParams) => {
|
|
|
88
107
|
<OptionCard
|
|
89
108
|
style={cardStyle}
|
|
90
109
|
title={t('TAKE_OUT','Take out')}
|
|
110
|
+
isDisabled={isCardCliked}
|
|
111
|
+
isLoading={isLoadingCard === 'Take out'}
|
|
91
112
|
description={t('TAKE_OUT_DESCRIPTION', 'You are very welcome anytime you visit us!')}
|
|
92
113
|
bgImage={theme.images.general.takeOut}
|
|
93
114
|
icon={theme.images.general.shoppingCart}
|
|
94
115
|
callToActionText={t('START_MY_ORDER', 'Start my order')}
|
|
95
116
|
onClick={() => {
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
if(_takeOut?.value !== orderState?.options?.type){
|
|
118
|
+
handleChangeOrderType(_takeOut?.value);
|
|
119
|
+
setIsCardClicked(true)
|
|
120
|
+
setIsLoadingCard('Take out')
|
|
121
|
+
} else {
|
|
122
|
+
callback?.()
|
|
123
|
+
}
|
|
98
124
|
}}
|
|
99
125
|
/>
|
|
100
126
|
</GridContainer>
|
|
@@ -52,7 +52,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
|
|
|
52
52
|
/* @ts-ignore */
|
|
53
53
|
renderButtonText={(value) => value?.label}
|
|
54
54
|
renderRow={(item : any) => (
|
|
55
|
-
<View style={{ padding: 5, backgroundColor: theme.colors.white }}>
|
|
55
|
+
<View style={{ padding: 5, paddingVertical: 0, backgroundColor: theme.colors.white }}>
|
|
56
56
|
<OText>{item.label}</OText>
|
|
57
57
|
</View>
|
|
58
58
|
)}
|
|
@@ -62,7 +62,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
|
|
|
62
62
|
</View>
|
|
63
63
|
)}
|
|
64
64
|
dropdownStyle={{
|
|
65
|
-
height:
|
|
65
|
+
height: 80,
|
|
66
66
|
borderRadius: 6,
|
|
67
67
|
padding: 10,
|
|
68
68
|
}}
|
|
@@ -192,6 +192,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
192
192
|
<NavBar
|
|
193
193
|
title={t('PAYMENT_METHODS', 'Payment methods')}
|
|
194
194
|
onActionLeft={goToBack}
|
|
195
|
+
btnStyle={{paddingLeft: 0}}
|
|
195
196
|
/>
|
|
196
197
|
|
|
197
198
|
<View
|
|
@@ -209,7 +210,9 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
209
210
|
{supportedMethods?.length > 0 && (
|
|
210
211
|
<GridContainer style={{justifyContent: 'space-between'}}>
|
|
211
212
|
{propsOfItems.CARD_ON_DELIVERY_ID && (
|
|
212
|
-
<
|
|
213
|
+
<View style={{marginBottom: orientationState?.orientation === LANDSCAPE ? 20 : 0}}>
|
|
214
|
+
<OptionCard {...propsOfItems?.CARD_ON_DELIVERY_ID} styke/>
|
|
215
|
+
</View>
|
|
213
216
|
)}
|
|
214
217
|
|
|
215
218
|
<View
|
|
@@ -38,6 +38,24 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
38
38
|
const [, t] = useLanguage()
|
|
39
39
|
const [orientationState] = useDeviceOrientation();
|
|
40
40
|
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
imageStyle: {
|
|
43
|
+
width: '100%',
|
|
44
|
+
height: Platform.OS === 'ios' ? 250 : 180,
|
|
45
|
+
resizeMode: 'cover',
|
|
46
|
+
borderRadius: 10,
|
|
47
|
+
},
|
|
48
|
+
closeUpsellingButton: {
|
|
49
|
+
marginVertical: 10,
|
|
50
|
+
marginHorizontal: 20,
|
|
51
|
+
marginLeft: orientationState.orientation === PORTRAIT ? 20 : 0
|
|
52
|
+
},
|
|
53
|
+
upsellingModal: {
|
|
54
|
+
height: '50%',
|
|
55
|
+
top: 250
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
41
59
|
useEffect(() => {
|
|
42
60
|
if (!isCustomMode) {
|
|
43
61
|
if (upsellingProducts?.products?.length && !upsellingProducts.loading) {
|
|
@@ -68,11 +86,12 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
68
86
|
<Container>
|
|
69
87
|
{
|
|
70
88
|
!upsellingProducts.loading ? (
|
|
71
|
-
orientationState.orientation
|
|
89
|
+
orientationState.orientation === PORTRAIT ? (
|
|
72
90
|
<>
|
|
73
91
|
<NavBar
|
|
74
92
|
title={t('BEFORE_YOU_GO', 'Before you go')}
|
|
75
93
|
onActionLeft={onClose}
|
|
94
|
+
btnStyle={{paddingLeft: 0}}
|
|
76
95
|
/>
|
|
77
96
|
|
|
78
97
|
<View style={{ marginVertical: orientationState?.dimensions?.height * 0.03 }}>
|
|
@@ -149,6 +168,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
149
168
|
<NavBar
|
|
150
169
|
title={t('BEFORE_YOU_GO', 'Before you go')}
|
|
151
170
|
onActionLeft={onClose}
|
|
171
|
+
btnStyle={{paddingLeft: 0}}
|
|
152
172
|
/>
|
|
153
173
|
|
|
154
174
|
<View
|
|
@@ -299,23 +319,6 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
299
319
|
)
|
|
300
320
|
}
|
|
301
321
|
|
|
302
|
-
const styles = StyleSheet.create({
|
|
303
|
-
imageStyle: {
|
|
304
|
-
width: '100%',
|
|
305
|
-
height: Platform.OS === 'ios' ? 250 : 180,
|
|
306
|
-
resizeMode: 'cover',
|
|
307
|
-
borderRadius: 10,
|
|
308
|
-
},
|
|
309
|
-
closeUpsellingButton: {
|
|
310
|
-
marginVertical: 10,
|
|
311
|
-
marginHorizontal: 20,
|
|
312
|
-
},
|
|
313
|
-
upsellingModal: {
|
|
314
|
-
height: '50%',
|
|
315
|
-
top: 250
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
|
|
319
322
|
export const UpsellingProducts = (props : UpsellingProductsParams) => {
|
|
320
323
|
const upsellingProductsProps = {
|
|
321
324
|
...props,
|