ordering-ui-react-native 0.14.70 → 0.14.73
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/components/ProductForm/index.tsx +1 -1
- package/themes/kiosk/index.tsx +6 -0
- package/themes/kiosk/src/components/BusinessController/index.tsx +67 -0
- package/themes/kiosk/src/components/BusinessController/styles.tsx +23 -0
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +119 -0
- package/themes/kiosk/src/components/BusinessesListing/styles.tsx +24 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +62 -2
- package/themes/kiosk/src/components/LogoutButton/index.tsx +74 -0
- package/themes/kiosk/src/types/index.d.ts +1 -0
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +32 -1
- package/themes/original/src/components/BusinessInformation/index.tsx +7 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +8 -9
- package/themes/original/src/components/Cart/index.tsx +8 -8
- package/themes/original/src/components/Checkout/index.tsx +82 -70
- package/themes/original/src/components/LoginForm/index.tsx +6 -4
- package/themes/original/src/components/OrderDetails/index.tsx +58 -6
- package/themes/original/src/components/OrderProgress/index.tsx +39 -31
- package/themes/original/src/components/OrderSummary/index.tsx +8 -8
- package/themes/original/src/components/OrdersOption/index.tsx +40 -16
- package/themes/original/src/components/OrdersOption/styles.tsx +5 -0
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PhoneInputNumber/styles.tsx +1 -1
- package/themes/original/src/components/ProductForm/index.tsx +42 -11
- package/themes/original/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +1 -1
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -1
- package/themes/original/src/components/SingleProductCard/index.tsx +15 -8
- package/themes/original/src/components/UpsellingProducts/index.tsx +1 -4
- package/themes/original/src/components/UserProfile/index.tsx +13 -11
- package/themes/original/src/components/WalletTransactionItem/index.tsx +5 -5
- package/themes/original/src/components/Wallets/styles.tsx +1 -1
- package/themes/original/src/components/shared/OInput.tsx +6 -2
- package/themes/original/src/utils/index.tsx +7 -0
package/package.json
CHANGED
package/themes/kiosk/index.tsx
CHANGED
|
@@ -30,6 +30,9 @@ import { ProductOptionSubOption } from './src/components/ProductOptionSubOption'
|
|
|
30
30
|
import PromoCard from './src/components/PromoCard'
|
|
31
31
|
import QuantityControl from './src/components/QuantityControl'
|
|
32
32
|
import { UpsellingProducts } from './src/components/UpsellingProducts'
|
|
33
|
+
import { BusinessController } from './src/components/BusinessController'
|
|
34
|
+
import { BusinessesListing } from './src/components/BusinessesListing'
|
|
35
|
+
import { LogoutButton } from './src/components/LogoutButton'
|
|
33
36
|
|
|
34
37
|
import {
|
|
35
38
|
OAlert,
|
|
@@ -95,6 +98,9 @@ export {
|
|
|
95
98
|
PromoCard,
|
|
96
99
|
QuantityControl,
|
|
97
100
|
UpsellingProducts,
|
|
101
|
+
BusinessController,
|
|
102
|
+
BusinessesListing,
|
|
103
|
+
LogoutButton,
|
|
98
104
|
OAlert,
|
|
99
105
|
OBottomPopup,
|
|
100
106
|
OButton,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { useTheme } from 'styled-components/native';
|
|
4
|
+
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
5
|
+
import {
|
|
6
|
+
BusinessController as BusinessSingleCard,
|
|
7
|
+
useUtils,
|
|
8
|
+
} from 'ordering-components/native';
|
|
9
|
+
|
|
10
|
+
import { Card, BusinessLogo } from './styles';
|
|
11
|
+
|
|
12
|
+
import { OText } from '../shared';
|
|
13
|
+
|
|
14
|
+
export const BusinessControllerUI = (props: any) => {
|
|
15
|
+
const { business, handleClick, isLoading } = props;
|
|
16
|
+
const [{ optimizeImage }] = useUtils();
|
|
17
|
+
const theme = useTheme()
|
|
18
|
+
|
|
19
|
+
const [orientationState] = useDeviceOrientation();
|
|
20
|
+
|
|
21
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
22
|
+
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
businessName: {
|
|
25
|
+
width: '100%',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
textAlign: 'center',
|
|
28
|
+
marginTop: 10
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const handleBusinessClick = (selectedBusiness: any) => {
|
|
33
|
+
if (isLoading) return
|
|
34
|
+
handleClick && handleClick(selectedBusiness)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Card
|
|
39
|
+
activeOpacity={1}
|
|
40
|
+
onPress={() => handleBusinessClick(business)}
|
|
41
|
+
>
|
|
42
|
+
<BusinessLogo
|
|
43
|
+
source={business?.logo ? {
|
|
44
|
+
uri: optimizeImage(business?.logo, 'h_120,c_limit'),
|
|
45
|
+
} : theme.images.dummies.businessLogo}
|
|
46
|
+
resizeMode='contain'
|
|
47
|
+
/>
|
|
48
|
+
<OText
|
|
49
|
+
size={WIDTH_SCREEN * 0.012}
|
|
50
|
+
numberOfLines={2}
|
|
51
|
+
ellipsizeMode='tail'
|
|
52
|
+
style={styles.businessName}
|
|
53
|
+
>
|
|
54
|
+
{business?.name}
|
|
55
|
+
</OText>
|
|
56
|
+
</Card>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const BusinessController = (props: any) => {
|
|
61
|
+
const BusinessControllerProps = {
|
|
62
|
+
...props,
|
|
63
|
+
UIComponent: BusinessControllerUI,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return <BusinessSingleCard {...BusinessControllerProps} />;
|
|
67
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Card = styled.TouchableOpacity`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
margin: 0 15px 20px;
|
|
9
|
+
width: 120px;
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
export const BusinessLogo = styled.ImageBackground`
|
|
13
|
+
position: relative;
|
|
14
|
+
height: 120px;
|
|
15
|
+
width: 120px;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
align-items: center;
|
|
21
|
+
border-width: 1px;
|
|
22
|
+
border-color: ${(props: any) => props.theme.colors.border};
|
|
23
|
+
`
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
3
|
+
import { View, ScrollView, Platform } from 'react-native';
|
|
4
|
+
import { useTheme } from 'styled-components/native';
|
|
5
|
+
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
6
|
+
import {
|
|
7
|
+
BusinessList as BusinessesListingController,
|
|
8
|
+
useLanguage,
|
|
9
|
+
useOrder,
|
|
10
|
+
} from 'ordering-components/native';
|
|
11
|
+
|
|
12
|
+
import { ListWrapper, CardsContainer, WrapperList } from './styles';
|
|
13
|
+
|
|
14
|
+
import { NotFoundSource } from '../NotFoundSource';
|
|
15
|
+
import { BusinessController } from '../BusinessController';
|
|
16
|
+
import { OText } from '../shared';
|
|
17
|
+
import { LogoutButton } from '../LogoutButton';
|
|
18
|
+
|
|
19
|
+
const BusinessesListingUI = (props: any) => {
|
|
20
|
+
const {
|
|
21
|
+
navigation,
|
|
22
|
+
businessesList,
|
|
23
|
+
handleBusinessClick,
|
|
24
|
+
paginationProps,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const [, t] = useLanguage();
|
|
29
|
+
const [orderState] = useOrder();
|
|
30
|
+
const [orientationState] = useDeviceOrientation();
|
|
31
|
+
|
|
32
|
+
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<ScrollView showsVerticalScrollIndicator={false}>
|
|
36
|
+
<ListWrapper>
|
|
37
|
+
{!businessesList.loading ? (
|
|
38
|
+
<>
|
|
39
|
+
<OText
|
|
40
|
+
size={WIDTH_SCREEN * 0.02}
|
|
41
|
+
weight='bold'
|
|
42
|
+
style={{ paddingHorizontal: 15 }}
|
|
43
|
+
>
|
|
44
|
+
{t('STORES', 'Stores')}
|
|
45
|
+
</OText>
|
|
46
|
+
<OText
|
|
47
|
+
size={WIDTH_SCREEN * 0.014}
|
|
48
|
+
color={theme.colors.paleGray}
|
|
49
|
+
style={{
|
|
50
|
+
paddingHorizontal: 15,
|
|
51
|
+
paddingBottom: 40
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{t('SELECT_STORE_MESSAGE', 'Please select the store that do you need')}
|
|
55
|
+
</OText>
|
|
56
|
+
<View style={{ position: 'absolute', top: 25, right: 20 }}>
|
|
57
|
+
<LogoutButton />
|
|
58
|
+
</View>
|
|
59
|
+
</>
|
|
60
|
+
) : (
|
|
61
|
+
<View style={{ paddingHorizontal: 20 }}>
|
|
62
|
+
<PlaceholderLine width={80} height={50} style={{ marginBottom: 10 }} />
|
|
63
|
+
<PlaceholderLine height={50} style={{ marginBottom: 40 }} />
|
|
64
|
+
</View>
|
|
65
|
+
)}
|
|
66
|
+
<CardsContainer>
|
|
67
|
+
{!businessesList.loading && businessesList.businesses?.map(
|
|
68
|
+
(business: any) => (
|
|
69
|
+
<BusinessController
|
|
70
|
+
key={business.id}
|
|
71
|
+
business={business}
|
|
72
|
+
isBusinessOpen={business.open}
|
|
73
|
+
handleCustomClick={handleBusinessClick}
|
|
74
|
+
orderType={orderState?.options?.type}
|
|
75
|
+
navigation={navigation}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
)}
|
|
79
|
+
</CardsContainer>
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
{!businessesList.loading && businessesList.businesses.length === 0 && (
|
|
83
|
+
<NotFoundSource
|
|
84
|
+
content={t(
|
|
85
|
+
'NOT_FOUND_BUSINESSES',
|
|
86
|
+
'No businesses to delivery / pick up at this address, please change filters or change address.',
|
|
87
|
+
)}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{businessesList.loading && (
|
|
92
|
+
<WrapperList>
|
|
93
|
+
{[...Array(24).keys()].map(i => (
|
|
94
|
+
<PlaceholderLine
|
|
95
|
+
key={i}
|
|
96
|
+
width={15}
|
|
97
|
+
height={120}
|
|
98
|
+
style={{
|
|
99
|
+
marginBottom: 20,
|
|
100
|
+
borderRadius: 8
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</WrapperList>
|
|
105
|
+
)}
|
|
106
|
+
</ListWrapper>
|
|
107
|
+
</ScrollView>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const BusinessesListing = (props: any) => {
|
|
112
|
+
const BusinessesListingProps = {
|
|
113
|
+
...props,
|
|
114
|
+
isForceSearch: Platform.OS === 'ios',
|
|
115
|
+
UIComponent: BusinessesListingUI,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return <BusinessesListingController {...BusinessesListingProps} />;
|
|
119
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const ListWrapper = styled.View`
|
|
4
|
+
background-color: ${(props: any) => props.theme.colors.backgroundLight};
|
|
5
|
+
padding: 20px 5px 0;
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
export const CardsContainer = styled.View`
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
|
+
justify-content: flex-start;
|
|
12
|
+
text-align: center;
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
`
|
|
16
|
+
|
|
17
|
+
export const WrapperList = styled.View`
|
|
18
|
+
width: 100%;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
padding: 0 20px;
|
|
24
|
+
`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useForm, Controller } from 'react-hook-form';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
LoginForm as LoginFormController,
|
|
8
8
|
useLanguage,
|
|
9
9
|
ToastType,
|
|
10
|
-
useToast
|
|
10
|
+
useToast,
|
|
11
|
+
useApi
|
|
11
12
|
} from 'ordering-components/native';
|
|
12
13
|
|
|
13
14
|
import {
|
|
@@ -18,21 +19,40 @@ import {
|
|
|
18
19
|
import { OText, OButton, OInput, OIcon } from '../shared';
|
|
19
20
|
import { LoginParams } from '../../types';
|
|
20
21
|
import { LANDSCAPE, PORTRAIT, useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
22
|
+
import { _setStoreData } from '../../../../../src/providers/StoreUtil'
|
|
21
23
|
|
|
22
24
|
const LoginFormUI = (props: LoginParams) => {
|
|
23
25
|
const {
|
|
24
26
|
loginButtonText,
|
|
25
27
|
formState,
|
|
26
28
|
handleButtonLoginClick,
|
|
29
|
+
useRootPoint
|
|
27
30
|
} = props;
|
|
28
31
|
|
|
29
32
|
const theme = useTheme()
|
|
33
|
+
const [ordering, { setOrdering }] = useApi();
|
|
30
34
|
const [, { showToast }] = useToast();
|
|
31
35
|
const [, t] = useLanguage();
|
|
32
36
|
const {control, handleSubmit, formState: {errors}} = useForm();
|
|
33
37
|
const [orientationState] = useDeviceOrientation();
|
|
34
38
|
|
|
39
|
+
const [formsStateValues, setFormsStateValues] = useState<any>({ isSubmitted: false })
|
|
40
|
+
|
|
35
41
|
const onSubmit = (values: any) => {
|
|
42
|
+
if (values?.project_name) {
|
|
43
|
+
setOrdering({
|
|
44
|
+
...ordering,
|
|
45
|
+
project: values?.project_name
|
|
46
|
+
})
|
|
47
|
+
_setStoreData('project_name', values?.project_name)
|
|
48
|
+
setFormsStateValues({
|
|
49
|
+
...formsStateValues,
|
|
50
|
+
isSubmitted: true,
|
|
51
|
+
values
|
|
52
|
+
})
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
36
56
|
handleButtonLoginClick(values);
|
|
37
57
|
};
|
|
38
58
|
|
|
@@ -73,9 +93,22 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
73
93
|
? formState.result?.result
|
|
74
94
|
: formState.result?.result[0]
|
|
75
95
|
)
|
|
96
|
+
setFormsStateValues({
|
|
97
|
+
...formsStateValues,
|
|
98
|
+
isSubmitted: false,
|
|
99
|
+
})
|
|
76
100
|
}
|
|
77
101
|
}, [formState]);
|
|
78
102
|
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (ordering.project === null || !formsStateValues.isSubmitted || !useRootPoint) return
|
|
105
|
+
const values: any = formsStateValues.values
|
|
106
|
+
if (values?.project_name) {
|
|
107
|
+
delete values.project_name
|
|
108
|
+
}
|
|
109
|
+
handleButtonLoginClick({ ...values })
|
|
110
|
+
}, [ordering, formsStateValues.isSubmitted])
|
|
111
|
+
|
|
79
112
|
|
|
80
113
|
useEffect(() => {
|
|
81
114
|
if (Object.keys(errors)?.length > 0) {
|
|
@@ -97,6 +130,33 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
97
130
|
|
|
98
131
|
const InputControllers = (
|
|
99
132
|
<>
|
|
133
|
+
{useRootPoint && (
|
|
134
|
+
<Controller
|
|
135
|
+
control={control}
|
|
136
|
+
name='project_name'
|
|
137
|
+
rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
|
|
138
|
+
defaultValue=""
|
|
139
|
+
render={({ onChange, value }: any) => (
|
|
140
|
+
<OInput
|
|
141
|
+
name='project_name'
|
|
142
|
+
placeholder={t('PROJECT_NAME', 'Project Name')}
|
|
143
|
+
style={styles.inputStyle}
|
|
144
|
+
value={value}
|
|
145
|
+
autoCapitalize='none'
|
|
146
|
+
autoCorrect={false}
|
|
147
|
+
inputStyle={{textAlign: 'center'}}
|
|
148
|
+
onChange={(e: any) => {
|
|
149
|
+
onChange(e?.target?.value);
|
|
150
|
+
setFormsStateValues({
|
|
151
|
+
...formsStateValues,
|
|
152
|
+
isSubmitted: false,
|
|
153
|
+
})
|
|
154
|
+
}}
|
|
155
|
+
/>
|
|
156
|
+
)}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
|
|
100
160
|
<Controller
|
|
101
161
|
control={control}
|
|
102
162
|
render={({ onChange, value }: any) => (
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { LogoutAction, ToastType, useToast, useLanguage, useCustomer, useBusiness, useOrder } from 'ordering-components/native';
|
|
4
|
+
|
|
5
|
+
import { OIcon } from '../shared';
|
|
6
|
+
import { useTheme } from 'styled-components/native';
|
|
7
|
+
import { _clearStoreData, _retrieveStoreData } from '../../../../../src/providers/StoreUtil'
|
|
8
|
+
|
|
9
|
+
const LogoutButtonUI = (props: any) => {
|
|
10
|
+
const { handleLogoutClick, formState, ButtonUI } = props
|
|
11
|
+
|
|
12
|
+
const [theme] = useTheme();
|
|
13
|
+
const [, { setStateValues }] = useOrder();
|
|
14
|
+
const [, { showToast }] = useToast();
|
|
15
|
+
const [, t] = useLanguage();
|
|
16
|
+
const [, { deleteUserCustomer }] = useCustomer();
|
|
17
|
+
const [, { setBusiness }] = useBusiness();
|
|
18
|
+
|
|
19
|
+
const handleClick = async () => {
|
|
20
|
+
const data = await _retrieveStoreData('notification_state');
|
|
21
|
+
const res = await handleLogoutClick(data);
|
|
22
|
+
if (res) {
|
|
23
|
+
_clearStoreData({ excludedKeys: ['isTutorial'] })
|
|
24
|
+
deleteUserCustomer(true)
|
|
25
|
+
setBusiness({})
|
|
26
|
+
setStateValues({
|
|
27
|
+
options: {
|
|
28
|
+
moment: null
|
|
29
|
+
},
|
|
30
|
+
carts: {},
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!formState.loading && formState.result?.error) {
|
|
37
|
+
formState.result?.result && showToast(
|
|
38
|
+
ToastType.Error,
|
|
39
|
+
typeof formState.result?.result === 'string'
|
|
40
|
+
? formState.result?.result
|
|
41
|
+
: formState.result?.result[0]
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}, [formState])
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
ButtonUI ? (
|
|
48
|
+
<ButtonUI onPress={() => handleClick()} />
|
|
49
|
+
) : (
|
|
50
|
+
<TouchableOpacity
|
|
51
|
+
onPress={() => handleClick()}
|
|
52
|
+
style={{ flexDirection: 'row', alignItems: 'center' }}
|
|
53
|
+
>
|
|
54
|
+
<OIcon
|
|
55
|
+
src={theme.images.general.menulogout}
|
|
56
|
+
width={24}
|
|
57
|
+
height={24}
|
|
58
|
+
color={theme.colors.disabledContrast}
|
|
59
|
+
/>
|
|
60
|
+
</TouchableOpacity>
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const LogoutButton = (props: any) => {
|
|
66
|
+
const logoutProps = {
|
|
67
|
+
...props,
|
|
68
|
+
isNative: true,
|
|
69
|
+
UIComponent: LogoutButtonUI
|
|
70
|
+
}
|
|
71
|
+
return (
|
|
72
|
+
<LogoutAction {...logoutProps} />
|
|
73
|
+
)
|
|
74
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { StyleSheet, View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useUtils, useOrder, useLanguage } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
@@ -7,6 +7,12 @@ import { BusinessBasicInformationParams } from '../../types';
|
|
|
7
7
|
import { convertHoursToMinutes } from '../../utils';
|
|
8
8
|
import { BusinessInformation } from '../BusinessInformation';
|
|
9
9
|
import { BusinessReviews } from '../BusinessReviews';
|
|
10
|
+
import dayjs from 'dayjs';
|
|
11
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
12
|
+
import isBetween from 'dayjs/plugin/isBetween';
|
|
13
|
+
|
|
14
|
+
dayjs.extend(timezone);
|
|
15
|
+
dayjs.extend(isBetween);
|
|
10
16
|
|
|
11
17
|
import {
|
|
12
18
|
BusinessContainer,
|
|
@@ -45,6 +51,31 @@ export const BusinessBasicInformation = (
|
|
|
45
51
|
return _types.join(', ');
|
|
46
52
|
};
|
|
47
53
|
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (businessState?.loading) return
|
|
57
|
+
let timeout: any = null
|
|
58
|
+
const currentDate = dayjs().tz(businessState?.business?.timezone)
|
|
59
|
+
let lapse = null
|
|
60
|
+
if (businessState?.business?.today?.enabled) {
|
|
61
|
+
lapse = businessState?.business?.today?.lapses?.find((lapse: any) => {
|
|
62
|
+
const from = currentDate.hour(lapse.open.hour).minute(lapse.open.minute)
|
|
63
|
+
const to = currentDate.hour(lapse.close.hour).minute(lapse.close.minute)
|
|
64
|
+
return currentDate.unix() >= from.unix() && currentDate.unix() <= to.unix()
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
if (lapse) {
|
|
68
|
+
const to = currentDate.hour(lapse.close.hour).minute(lapse.close.minute)
|
|
69
|
+
const timeToClose = (to.unix() - currentDate.unix()) * 1000
|
|
70
|
+
timeout = setTimeout(() => {
|
|
71
|
+
navigation.navigate('BusinessPreorder', { business: businessState?.business, handleBusinessClick: () => navigation?.goBack() })
|
|
72
|
+
}, timeToClose)
|
|
73
|
+
}
|
|
74
|
+
return () => {
|
|
75
|
+
timeout && clearTimeout(timeout)
|
|
76
|
+
}
|
|
77
|
+
}, [businessState?.business])
|
|
78
|
+
|
|
48
79
|
return (
|
|
49
80
|
<BusinessContainer>
|
|
50
81
|
<BusinessHeader
|
|
@@ -20,7 +20,7 @@ import { Platform, StyleSheet, View } from 'react-native';
|
|
|
20
20
|
import { BusinessInformationParams } from '../../types';
|
|
21
21
|
import { GoogleMap } from '../GoogleMap';
|
|
22
22
|
import { WebView } from 'react-native-webview';
|
|
23
|
-
|
|
23
|
+
import { formatUrlVideo } from '../../utils'
|
|
24
24
|
const BusinessInformationUI = (props: BusinessInformationParams) => {
|
|
25
25
|
const { businessState, businessSchedule, businessLocation } = props;
|
|
26
26
|
|
|
@@ -152,7 +152,12 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
|
|
|
152
152
|
style={{ width: 210, height: 127, borderRadius: 7.6 }}
|
|
153
153
|
javaScriptEnabled={true}
|
|
154
154
|
domStorageEnabled={true}
|
|
155
|
-
source={{
|
|
155
|
+
source={{
|
|
156
|
+
html: `
|
|
157
|
+
<iframe width='80%' height='80%' src="${formatUrlVideo(v.video)}" frameBorder='0' allow='autoplay; encrypted-media' allowFullScreen />
|
|
158
|
+
`,
|
|
159
|
+
}}
|
|
160
|
+
mediaPlaybackRequiresUserAction={true}
|
|
156
161
|
/>
|
|
157
162
|
))}
|
|
158
163
|
</MediaWrapper>
|
|
@@ -300,15 +300,14 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
300
300
|
</View>
|
|
301
301
|
</OrderControlContainer>
|
|
302
302
|
</HeaderWrapper>
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
303
|
+
|
|
304
|
+
<OrderProgressWrapper>
|
|
305
|
+
<OrderProgress
|
|
306
|
+
{...props}
|
|
307
|
+
isFocused={isFocused}
|
|
308
|
+
/>
|
|
309
|
+
</OrderProgressWrapper>
|
|
310
|
+
|
|
312
311
|
{
|
|
313
312
|
!businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
|
|
314
313
|
<FeaturedWrapper>
|
|
@@ -207,10 +207,10 @@ const CartUI = (props: any) => {
|
|
|
207
207
|
<OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
208
208
|
)}
|
|
209
209
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
210
|
-
<AntIcon name='
|
|
210
|
+
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
211
211
|
</TouchableOpacity>
|
|
212
212
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
213
|
-
<AntIcon name='closecircle' size={
|
|
213
|
+
<AntIcon name='closecircle' size={16} color={theme.colors.primary} />
|
|
214
214
|
</TouchableOpacity>
|
|
215
215
|
</OSRow>
|
|
216
216
|
<OText size={12} lineHeight={18}>
|
|
@@ -239,7 +239,7 @@ const CartUI = (props: any) => {
|
|
|
239
239
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
240
240
|
</OText>
|
|
241
241
|
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
|
|
242
|
-
<AntIcon name='
|
|
242
|
+
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
243
243
|
</TouchableOpacity>
|
|
244
244
|
</OSRow>
|
|
245
245
|
<OText size={12} lineHeight={18}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
@@ -255,7 +255,7 @@ const CartUI = (props: any) => {
|
|
|
255
255
|
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
256
256
|
</OText>
|
|
257
257
|
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
258
|
-
<AntIcon name='
|
|
258
|
+
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
259
259
|
</TouchableOpacity>
|
|
260
260
|
</OSRow>
|
|
261
261
|
<OText size={12} lineHeight={18}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
@@ -271,10 +271,10 @@ const CartUI = (props: any) => {
|
|
|
271
271
|
<OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
272
272
|
)}
|
|
273
273
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
274
|
-
<AntIcon name='
|
|
274
|
+
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
275
275
|
</TouchableOpacity>
|
|
276
276
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
277
|
-
<AntIcon name='closecircle' size={
|
|
277
|
+
<AntIcon name='closecircle' size={16} color={theme.colors.primary} />
|
|
278
278
|
</TouchableOpacity>
|
|
279
279
|
</OSRow>
|
|
280
280
|
<OText size={12} lineHeight={18}>
|
|
@@ -298,10 +298,10 @@ const CartUI = (props: any) => {
|
|
|
298
298
|
<OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
299
299
|
)}
|
|
300
300
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
301
|
-
<AntIcon name='
|
|
301
|
+
<AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
|
|
302
302
|
</TouchableOpacity>
|
|
303
303
|
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
304
|
-
<AntIcon name='closecircle' size={
|
|
304
|
+
<AntIcon name='closecircle' size={16} color={theme.colors.primary} />
|
|
305
305
|
</TouchableOpacity>
|
|
306
306
|
</OSRow>
|
|
307
307
|
<OText size={12} lineHeight={18}>
|