ordering-ui-react-native 0.21.48 → 0.21.49
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/themes/business/src/components/MessagesOption/index.tsx +2 -1
- package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
- package/themes/business/src/components/OrdersOption/index.tsx +2 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
- package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +7 -4
- package/themes/original/src/components/Cart/index.tsx +2 -0
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import { PreviousMessages } from '../PreviousMessages';
|
|
|
12
12
|
import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
|
|
13
13
|
import { MessagesOptionParams } from '../../types';
|
|
14
14
|
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
15
|
+
import { WebsocketStatus } from '../WebsocketStatus'
|
|
15
16
|
|
|
16
17
|
const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
17
18
|
const {
|
|
@@ -163,7 +164,7 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
|
163
164
|
<View style={styles.header}>
|
|
164
165
|
<OText style={styles.title}>{t('MESSAGES', 'Messages')}</OText>
|
|
165
166
|
</View>
|
|
166
|
-
|
|
167
|
+
<WebsocketStatus />
|
|
167
168
|
<FiltersTab>
|
|
168
169
|
<TabsContainer width={dimensions.width - 42}>
|
|
169
170
|
{tabs.map((tab: any) => (
|
|
@@ -40,6 +40,7 @@ import { OrdersOptionPaymethod } from '../OrdersOptionPaymethod';
|
|
|
40
40
|
import { OrdersOptionDriver } from '../OrdersOptionDriver';
|
|
41
41
|
import { OrdersOptionDate } from '../OrdersOptionDate';
|
|
42
42
|
import { OrderDetailsBusiness } from '../OrderDetails/Business';
|
|
43
|
+
import { WebsocketStatus } from '../WebsocketStatus'
|
|
43
44
|
|
|
44
45
|
const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
|
|
45
46
|
|
|
@@ -314,7 +315,11 @@ const OrdersListManagerUI = (props: OrdersOptionParams) => {
|
|
|
314
315
|
</View>
|
|
315
316
|
{configState?.configs?.order_deadlines_enabled?.value === '1' && (
|
|
316
317
|
<View style={styles.SLAwrapper}>
|
|
317
|
-
<View style={{ flex:
|
|
318
|
+
<View style={{ flex: 1 }}>
|
|
319
|
+
<WebsocketStatus />
|
|
320
|
+
</View>
|
|
321
|
+
<View style={{ width: 10, height: '100%' }} />
|
|
322
|
+
<View style={{ flex: 1 }}>
|
|
318
323
|
<OButton
|
|
319
324
|
text={t('SLA_SETTING', 'SLA’s Settings')}
|
|
320
325
|
textStyle={{ color: theme.colors.backArrow }}
|
|
@@ -330,7 +335,7 @@ const OrdersListManagerUI = (props: OrdersOptionParams) => {
|
|
|
330
335
|
/>
|
|
331
336
|
</View>
|
|
332
337
|
<View style={{ width: 10, height: '100%' }} />
|
|
333
|
-
<View style={{ flex:
|
|
338
|
+
<View style={{ flex: 1, justifyContent: 'center' }}>
|
|
334
339
|
<SelectDropdown
|
|
335
340
|
defaultButtonText={t('SLA', 'SLA\'s')}
|
|
336
341
|
data={preorderTypeList}
|
|
@@ -11,6 +11,7 @@ import { useTheme } from 'styled-components/native';
|
|
|
11
11
|
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
12
12
|
import { NotificationSetting } from '../../../../../src/components/NotificationSetting'
|
|
13
13
|
import { NewOrderNotification } from '../NewOrderNotification';
|
|
14
|
+
import { WebsocketStatus } from '../WebsocketStatus'
|
|
14
15
|
|
|
15
16
|
import { OText, OButton, OModal, OInput, OIcon } from '../shared';
|
|
16
17
|
import { NotFoundSource } from '../NotFoundSource';
|
|
@@ -407,6 +408,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
407
408
|
/>
|
|
408
409
|
</IconWrapper>
|
|
409
410
|
</View>
|
|
411
|
+
<WebsocketStatus />
|
|
410
412
|
{configState?.configs?.order_deadlines_enabled?.value === '1' && (
|
|
411
413
|
<View style={styles.SLAwrapper}>
|
|
412
414
|
<View style={{ flex: 0.5 }}>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { useLanguage, useUtils, WebsocketStatus as WebsocketStatusController } from 'ordering-components/native'
|
|
3
|
+
import { TouchableOpacity, View, StyleSheet } from 'react-native'
|
|
4
|
+
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
5
|
+
import { useTheme } from 'styled-components/native'
|
|
6
|
+
import RNRestart from 'react-native-restart'
|
|
7
|
+
import { OModal, OButton, OText, OIcon } from '../shared'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Container,
|
|
11
|
+
ModalContainer,
|
|
12
|
+
ModalTitle,
|
|
13
|
+
StatusItemWrapper,
|
|
14
|
+
StatusText
|
|
15
|
+
} from './styles'
|
|
16
|
+
|
|
17
|
+
const SocketStatusUI = (props: any) => {
|
|
18
|
+
const {
|
|
19
|
+
socketStatus,
|
|
20
|
+
connectedDate
|
|
21
|
+
} = props
|
|
22
|
+
|
|
23
|
+
const theme = useTheme()
|
|
24
|
+
const [, t] = useLanguage()
|
|
25
|
+
const [{ parseDate }] = useUtils()
|
|
26
|
+
const [openModal, setOpenModal] = useState(false)
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
btnBackArrow: {
|
|
30
|
+
borderWidth: 0,
|
|
31
|
+
width: 32,
|
|
32
|
+
height: 32,
|
|
33
|
+
tintColor: theme.colors.textGray,
|
|
34
|
+
backgroundColor: theme.colors.clear,
|
|
35
|
+
borderColor: theme.colors.clear,
|
|
36
|
+
shadowColor: theme.colors.clear,
|
|
37
|
+
paddingLeft: 0,
|
|
38
|
+
paddingRight: 0,
|
|
39
|
+
marginBottom: 30,
|
|
40
|
+
marginTop: 30
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const getStatusColor = (status: number) => {
|
|
45
|
+
switch (status) {
|
|
46
|
+
case 0:
|
|
47
|
+
return '#FF9922';
|
|
48
|
+
case 1:
|
|
49
|
+
return '#00D27A';
|
|
50
|
+
case 2:
|
|
51
|
+
return '#E63757';
|
|
52
|
+
default:
|
|
53
|
+
return '#FF9922';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Container>
|
|
59
|
+
<TouchableOpacity
|
|
60
|
+
style={{
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
justifyContent: 'center',
|
|
64
|
+
backgroundColor: theme.colors.inputChat,
|
|
65
|
+
borderRadius: 7.6,
|
|
66
|
+
marginVertical: 10,
|
|
67
|
+
paddingVertical: 10,
|
|
68
|
+
paddingHorizontal: 15,
|
|
69
|
+
}}
|
|
70
|
+
activeOpacity={0.6}
|
|
71
|
+
onPress={() => setOpenModal(true)}
|
|
72
|
+
>
|
|
73
|
+
<OText
|
|
74
|
+
style={{ color: theme.colors.backArrow, fontSize: 16, marginBottom: 0, lineHeight: 16 }}
|
|
75
|
+
>
|
|
76
|
+
{t('CONNECTION_STATUS', 'Connection status')}
|
|
77
|
+
</OText>
|
|
78
|
+
<MaterialIcon
|
|
79
|
+
name='circle'
|
|
80
|
+
size={12}
|
|
81
|
+
color={getStatusColor(socketStatus)}
|
|
82
|
+
style={{ marginLeft: 8 }}
|
|
83
|
+
/>
|
|
84
|
+
</TouchableOpacity>
|
|
85
|
+
|
|
86
|
+
<OModal
|
|
87
|
+
open={openModal}
|
|
88
|
+
onClose={() => setOpenModal(false)}
|
|
89
|
+
entireModal
|
|
90
|
+
customClose
|
|
91
|
+
>
|
|
92
|
+
<ModalContainer nestedScrollEnabled={true}>
|
|
93
|
+
<TouchableOpacity
|
|
94
|
+
onPress={() => setOpenModal(false)}
|
|
95
|
+
style={styles.btnBackArrow}
|
|
96
|
+
>
|
|
97
|
+
<OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
|
|
98
|
+
</TouchableOpacity>
|
|
99
|
+
<View>
|
|
100
|
+
<ModalTitle>{t('CONNECTION_STATUS', 'Connection status')}</ModalTitle>
|
|
101
|
+
<OText style={{ marginBottom: 20 }}>
|
|
102
|
+
{t('LAST_UPDATE', 'Last update')}: {parseDate(connectedDate)}
|
|
103
|
+
</OText>
|
|
104
|
+
<StatusItemWrapper>
|
|
105
|
+
<MaterialIcon
|
|
106
|
+
name='circle'
|
|
107
|
+
size={12}
|
|
108
|
+
color={getStatusColor(1)}
|
|
109
|
+
style={{ marginTop: 10, marginHorizontal: 8 }}
|
|
110
|
+
/>
|
|
111
|
+
<View style={{ marginLeft: 16 }}>
|
|
112
|
+
<StatusText>{t('OK', 'Ok')}</StatusText>
|
|
113
|
+
<OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_OK', 'The websocket works normally.')}</OText>
|
|
114
|
+
</View>
|
|
115
|
+
</StatusItemWrapper>
|
|
116
|
+
<StatusItemWrapper>
|
|
117
|
+
<MaterialIcon
|
|
118
|
+
name='circle'
|
|
119
|
+
size={12}
|
|
120
|
+
color={getStatusColor(0)}
|
|
121
|
+
style={{ marginTop: 10, marginHorizontal: 8 }}
|
|
122
|
+
/>
|
|
123
|
+
<View style={{ marginLeft: 16 }}>
|
|
124
|
+
<StatusText>{t('CONNECTING', 'Connecting')}</StatusText>
|
|
125
|
+
<OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_CONNECTING', 'The websocket is connecting.')}</OText>
|
|
126
|
+
</View>
|
|
127
|
+
</StatusItemWrapper>
|
|
128
|
+
<StatusItemWrapper>
|
|
129
|
+
<MaterialIcon
|
|
130
|
+
name='circle'
|
|
131
|
+
size={12}
|
|
132
|
+
color={getStatusColor(2)}
|
|
133
|
+
style={{ marginTop: 10, marginHorizontal: 8 }}
|
|
134
|
+
/>
|
|
135
|
+
<View style={{ marginLeft: 16 }}>
|
|
136
|
+
<StatusText>{t('DISCONNECTED', 'Disconnected')}</StatusText>
|
|
137
|
+
<OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_DISCONNECTED', 'The server is slow, please reload.')}</OText>
|
|
138
|
+
</View>
|
|
139
|
+
</StatusItemWrapper>
|
|
140
|
+
|
|
141
|
+
<View style={{ flexDirection: 'row', marginTop: 50 }}>
|
|
142
|
+
<OButton
|
|
143
|
+
onClick={() => setOpenModal(false)}
|
|
144
|
+
bgColor={theme.colors.white}
|
|
145
|
+
borderColor={theme.colors.primary}
|
|
146
|
+
textStyle={{ color: theme.colors.primary }}
|
|
147
|
+
style={{ borderRadius: 8, height: 48 }}
|
|
148
|
+
text={t('CLOSE', 'Close')}
|
|
149
|
+
/>
|
|
150
|
+
<OButton
|
|
151
|
+
onClick={() => RNRestart.Restart()}
|
|
152
|
+
borderColor={theme.colors.primary}
|
|
153
|
+
textStyle={{ color: theme.colors.white }}
|
|
154
|
+
style={{ borderRadius: 8, marginLeft: 16, height: 48 }}
|
|
155
|
+
text={t('UPDATE', 'Update')}
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
</View>
|
|
159
|
+
</ModalContainer>
|
|
160
|
+
</OModal>
|
|
161
|
+
</Container>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const WebsocketStatus = (props: any) => {
|
|
166
|
+
const socketProps = {
|
|
167
|
+
...props,
|
|
168
|
+
UIComponent: SocketStatusUI
|
|
169
|
+
}
|
|
170
|
+
return <WebsocketStatusController {...socketProps} />
|
|
171
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const Container = styled.View`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
`
|
|
7
|
+
export const ModalContainer = styled.ScrollView`
|
|
8
|
+
padding: 0px 30px;
|
|
9
|
+
`
|
|
10
|
+
export const ModalTitle = styled.Text`
|
|
11
|
+
font-family: Poppins;
|
|
12
|
+
font-style: normal;
|
|
13
|
+
font-weight: bold;
|
|
14
|
+
font-size: 20px;
|
|
15
|
+
color: ${(props: any) => props.theme.colors.textGray};
|
|
16
|
+
margin-bottom: 10px;
|
|
17
|
+
`
|
|
18
|
+
export const StatusItemWrapper = styled.View`
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
margin-bottom: 16px;
|
|
21
|
+
`
|
|
22
|
+
export const StatusText = styled.Text`
|
|
23
|
+
font-family: Poppins;
|
|
24
|
+
font-style: normal;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
font-size: 18px;
|
|
27
|
+
color: ${(props: any) => props.theme.colors.textGray};
|
|
28
|
+
`
|
|
@@ -23,7 +23,8 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
23
23
|
handleClickCheckout,
|
|
24
24
|
checkoutButtonDisabled,
|
|
25
25
|
isMultiCheckout,
|
|
26
|
-
isFromUpselling
|
|
26
|
+
isFromUpselling,
|
|
27
|
+
isGiftCart
|
|
27
28
|
} = props
|
|
28
29
|
|
|
29
30
|
const [orderState] = useOrder();
|
|
@@ -75,7 +76,7 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
75
76
|
<BIContentInfo>
|
|
76
77
|
<OText size={16} lineHeight={24} weight={'600'}>{cart?.business?.name}</OText>
|
|
77
78
|
<View style={{ flexDirection: 'row' }}>
|
|
78
|
-
{props.onNavigationRedirect && !isClosed && (
|
|
79
|
+
{props.onNavigationRedirect && !isClosed && !isGiftCart && (
|
|
79
80
|
<>
|
|
80
81
|
<TouchableOpacity onPress={() => props.onNavigationRedirect('Business', { store: cart?.business?.slug })}>
|
|
81
82
|
<OText color={theme.colors.primary} size={12} lineHeight={18} style={{ textDecorationLine: 'underline' }}>{t('GO_TO_STORE', 'Go to store')}</OText>
|
|
@@ -84,7 +85,9 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
84
85
|
)}
|
|
85
86
|
{!isCartPending && (
|
|
86
87
|
<>
|
|
87
|
-
|
|
88
|
+
{!isGiftCart && (
|
|
89
|
+
<OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
90
|
+
)}
|
|
88
91
|
<OAlert
|
|
89
92
|
title={t('DELETE_CART', 'Delete Cart')}
|
|
90
93
|
message={t('QUESTION_DELETE_CART', 'Are you sure to you wants delete the selected cart')}
|
|
@@ -94,7 +97,7 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
94
97
|
</OAlert>
|
|
95
98
|
</>
|
|
96
99
|
)}
|
|
97
|
-
{isBusinessChangeEnabled && props.handleChangeStore && (
|
|
100
|
+
{isBusinessChangeEnabled && props.handleChangeStore && !isGiftCart && (
|
|
98
101
|
<>
|
|
99
102
|
<OText color={theme.colors.textSecondary}>{' \u2022 '}</OText>
|
|
100
103
|
<TouchableOpacity
|
|
@@ -232,6 +232,7 @@ const CartUI = (props: any) => {
|
|
|
232
232
|
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
233
233
|
isMultiCheckout={isMultiCheckout}
|
|
234
234
|
isFromUpselling={isFromUpselling}
|
|
235
|
+
isGiftCart={!cart?.business_id}
|
|
235
236
|
>
|
|
236
237
|
{cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
|
|
237
238
|
<ProductItemAccordion
|
|
@@ -423,6 +424,7 @@ const CartUI = (props: any) => {
|
|
|
423
424
|
cart?.status !== 2 &&
|
|
424
425
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
425
426
|
driverTipsOptions && driverTipsOptions?.length > 0 &&
|
|
427
|
+
cart?.business_id &&
|
|
426
428
|
(
|
|
427
429
|
<DriverTipsContainer>
|
|
428
430
|
<OText size={14} lineHeight={20} color={theme.colors.textNormal}>
|