ordering-ui-react-native 0.21.86 → 0.21.87
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/UserProfileForm/index.tsx +13 -10
- package/themes/original/index.tsx +2 -1
- package/themes/original/src/components/Checkout/index.tsx +4 -1
- package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
- package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
- package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
- package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
- package/themes/original/src/components/MultiCheckout/index.tsx +9 -1
- package/themes/original/src/components/MyOrders/index.tsx +11 -3
- package/themes/original/src/components/OrdersOption/index.tsx +1 -0
- package/themes/original/src/components/UserProfile/index.tsx +2 -1
- package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
- package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useToast,
|
|
12
12
|
useLanguage,
|
|
13
13
|
useUtils,
|
|
14
|
+
useConfig
|
|
14
15
|
} from 'ordering-components/native';
|
|
15
16
|
import {
|
|
16
17
|
CenterView,
|
|
@@ -55,6 +56,7 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
55
56
|
const [, t] = useLanguage();
|
|
56
57
|
const [, { showToast }] = useToast();
|
|
57
58
|
const [{ optimizeImage }] = useUtils();
|
|
59
|
+
const [{ configs }] = useConfig()
|
|
58
60
|
const { errors } = useForm();
|
|
59
61
|
const theme = useTheme();
|
|
60
62
|
|
|
@@ -70,7 +72,7 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
70
72
|
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
71
73
|
const [phoneToShow, setPhoneToShow] = useState('');
|
|
72
74
|
const [openModal, setOpenModal] = useState(false)
|
|
73
|
-
|
|
75
|
+
const allowDriverUpdateData = user?.level !== 4 || configs?.allow_driver_update_data?.value === "1"
|
|
74
76
|
useEffect(() => {
|
|
75
77
|
if (phoneInputData.phone.cellphone) {
|
|
76
78
|
const codeNumberPhone = phoneInputData.phone.cellphone.slice(0, 3);
|
|
@@ -352,14 +354,15 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
352
354
|
height={150}
|
|
353
355
|
style={{ borderRadius: 7.2 }}
|
|
354
356
|
/>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
357
|
+
{allowDriverUpdateData && (
|
|
358
|
+
<OIconButton
|
|
359
|
+
icon={theme.images.general.camera}
|
|
360
|
+
borderColor={theme.colors.clear}
|
|
361
|
+
iconStyle={{ width: 21, height: 21 }}
|
|
362
|
+
style={{ maxWidth: 40 }}
|
|
363
|
+
onClick={() => handleImagePicker()}
|
|
364
|
+
/>
|
|
365
|
+
)}
|
|
363
366
|
</CenterView>
|
|
364
367
|
|
|
365
368
|
{user?.level === 4 && (
|
|
@@ -485,7 +488,7 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
485
488
|
/>
|
|
486
489
|
</View>
|
|
487
490
|
)}
|
|
488
|
-
{!validationFields.loading && !isEdit && (
|
|
491
|
+
{!validationFields.loading && !isEdit && allowDriverUpdateData && (
|
|
489
492
|
<EditButton>
|
|
490
493
|
<OButton
|
|
491
494
|
text={t('EDIT', 'Edit')}
|
|
@@ -100,7 +100,7 @@ import { PageBanner } from './src/components/PageBanner'
|
|
|
100
100
|
import { MultiCart } from './src/components/MultiCart'
|
|
101
101
|
import { USER_TYPE, ORDER_TYPES } from './src/config/constants'
|
|
102
102
|
import { DatePickerUI } from './src/components/DatePicker'
|
|
103
|
-
|
|
103
|
+
import { WebsocketStatus } from './src/components/WebsocketStatus';
|
|
104
104
|
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from './src/components/OrderSummary/styles';
|
|
105
105
|
|
|
106
106
|
import { FormInput, FormSide, ButtonsWrapper, LoginWith, OTab, OTabs } from './src/components/LoginForm/styles';
|
|
@@ -265,6 +265,7 @@ export {
|
|
|
265
265
|
PageBanner,
|
|
266
266
|
MyOrders,
|
|
267
267
|
MultiCart,
|
|
268
|
+
WebsocketStatus,
|
|
268
269
|
ORDER_TYPES,
|
|
269
270
|
USER_TYPE,
|
|
270
271
|
|
|
@@ -5,6 +5,7 @@ import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
|
|
|
5
5
|
import Picker from 'react-native-country-picker-modal';
|
|
6
6
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
|
|
7
7
|
import IconAntDesign from 'react-native-vector-icons/AntDesign';
|
|
8
|
+
import { useIsFocused } from '@react-navigation/native';
|
|
8
9
|
|
|
9
10
|
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
10
11
|
import {
|
|
@@ -104,6 +105,7 @@ const CheckoutUI = (props: any) => {
|
|
|
104
105
|
} = props
|
|
105
106
|
|
|
106
107
|
const theme = useTheme();
|
|
108
|
+
const isFocused = useIsFocused();
|
|
107
109
|
|
|
108
110
|
const styles = StyleSheet.create({
|
|
109
111
|
btnBackArrow: {
|
|
@@ -413,6 +415,7 @@ const CheckoutUI = (props: any) => {
|
|
|
413
415
|
}, [])
|
|
414
416
|
|
|
415
417
|
useEffect(() => {
|
|
418
|
+
if (!isFocused) return
|
|
416
419
|
if (!cartState?.loading && (cartState?.error || typeof cartState?.cart === 'string')) {
|
|
417
420
|
const error = cartState?.error || typeof cartState.cart === 'string' && cartState.cart
|
|
418
421
|
if (error) {
|
|
@@ -420,7 +423,7 @@ const CheckoutUI = (props: any) => {
|
|
|
420
423
|
navigation.navigate('BusinessList')
|
|
421
424
|
}
|
|
422
425
|
}
|
|
423
|
-
}, [cartState?.error, cartState?.cart, cartState?.loading])
|
|
426
|
+
}, [cartState?.error, cartState?.cart, cartState?.loading, isFocused])
|
|
424
427
|
|
|
425
428
|
useEffect(() => {
|
|
426
429
|
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useLanguage } from 'ordering-components/native';
|
|
3
|
+
import { useTheme } from 'styled-components/native';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { OText } from '../../shared'
|
|
6
|
+
import { VerticalGiftCardOrdersLayout } from '../VerticalGiftCardOrdersLayout'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Container,
|
|
10
|
+
NoOrdersWrapper
|
|
11
|
+
} from './styles'
|
|
12
|
+
|
|
13
|
+
export const GiftCardOrdersList = (props: any) => {
|
|
14
|
+
const {
|
|
15
|
+
onNavigationRedirect
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
const [, t] = useLanguage();
|
|
20
|
+
const [isEmptyPending, setIsEmptyPending] = useState(false);
|
|
21
|
+
const [isEmptySent, setIsEmptySent] = useState(false);
|
|
22
|
+
const [isEmptyRedeemed, setIsEmptyRedeemed] = useState(false);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Container>
|
|
26
|
+
<VerticalGiftCardOrdersLayout
|
|
27
|
+
title={t('PENDING', 'Pending')}
|
|
28
|
+
defaultStatus='pending'
|
|
29
|
+
setIsEmpty={setIsEmptyPending}
|
|
30
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
{!isEmptyPending && (
|
|
34
|
+
<View
|
|
35
|
+
style={{
|
|
36
|
+
height: 8,
|
|
37
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
38
|
+
marginHorizontal: -40,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
<VerticalGiftCardOrdersLayout
|
|
44
|
+
title={t('SENT', 'Sent')}
|
|
45
|
+
defaultStatus='sent'
|
|
46
|
+
setIsEmpty={setIsEmptySent}
|
|
47
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
<VerticalGiftCardOrdersLayout
|
|
51
|
+
title={t('REDEEMED', 'Redeemed')}
|
|
52
|
+
defaultStatus='activated'
|
|
53
|
+
setIsEmpty={setIsEmptyRedeemed}
|
|
54
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
{isEmptyPending && isEmptySent && isEmptyRedeemed && (
|
|
58
|
+
<NoOrdersWrapper>
|
|
59
|
+
<OText size={16} color={theme.colors.textNormal}>{t('YOU_DONT_HAVE_CARDS', 'You don\'t have cards')}</OText>
|
|
60
|
+
</NoOrdersWrapper>
|
|
61
|
+
)}
|
|
62
|
+
</Container>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLanguage, useUtils, useEvent } from 'ordering-components/native';
|
|
3
|
+
import { useTheme } from 'styled-components/native';
|
|
4
|
+
import { View, StyleSheet } from 'react-native';
|
|
5
|
+
import {
|
|
6
|
+
Placeholder,
|
|
7
|
+
PlaceholderLine,
|
|
8
|
+
Fade
|
|
9
|
+
} from 'rn-placeholder';
|
|
10
|
+
import FastImage from 'react-native-fast-image';
|
|
11
|
+
import { OText } from '../../shared'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
CardContainer
|
|
15
|
+
} from './styles'
|
|
16
|
+
|
|
17
|
+
export const SingleGiftCard = (props: any) => {
|
|
18
|
+
const {
|
|
19
|
+
card,
|
|
20
|
+
isSkeleton,
|
|
21
|
+
onNavigationRedirect
|
|
22
|
+
} = props
|
|
23
|
+
|
|
24
|
+
const theme = useTheme()
|
|
25
|
+
const [, t] = useLanguage()
|
|
26
|
+
const [events] = useEvent()
|
|
27
|
+
const [{ parsePrice, optimizeImage, parseDate }] = useUtils()
|
|
28
|
+
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
logo: {
|
|
31
|
+
borderRadius: 8,
|
|
32
|
+
width: 64,
|
|
33
|
+
height: 64
|
|
34
|
+
},
|
|
35
|
+
innerContainer: {
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
marginBottom: 24
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const getGiftCardStatus = (status: string) => {
|
|
42
|
+
switch (status) {
|
|
43
|
+
case 'pending':
|
|
44
|
+
return t('PENDING', 'Pending')
|
|
45
|
+
case 'activated':
|
|
46
|
+
return t('REDEEMED', 'Redeemed')
|
|
47
|
+
default:
|
|
48
|
+
return status
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const handleClickGiftCardOrder = (card: any) => {
|
|
53
|
+
onNavigationRedirect?.('OrderDetails', { orderId: card.order_product?.order_id });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<CardContainer
|
|
58
|
+
activeOpacity={0.8}
|
|
59
|
+
onPress={() => handleClickGiftCardOrder(card)}
|
|
60
|
+
>
|
|
61
|
+
{isSkeleton ? (
|
|
62
|
+
<Placeholder style={{ marginBottom: 10 }} Animation={Fade}>
|
|
63
|
+
<View style={{ flexDirection: 'row' }}>
|
|
64
|
+
<View style={{ width: 64, marginRight: 14 }}>
|
|
65
|
+
<PlaceholderLine
|
|
66
|
+
width={100}
|
|
67
|
+
height={64}
|
|
68
|
+
style={{ marginRight: 10, marginBottom: 10 }}
|
|
69
|
+
/>
|
|
70
|
+
</View>
|
|
71
|
+
<Placeholder style={{ paddingTop: 5 }}>
|
|
72
|
+
<PlaceholderLine width={60} style={{ marginBottom: 6}} />
|
|
73
|
+
<PlaceholderLine width={40} style={{ marginBottom: 6 }} />
|
|
74
|
+
<PlaceholderLine width={20} style={{ marginBottom: 0 }} />
|
|
75
|
+
</Placeholder>
|
|
76
|
+
</View>
|
|
77
|
+
</Placeholder>
|
|
78
|
+
) : (
|
|
79
|
+
<View style={styles.innerContainer}>
|
|
80
|
+
<View>
|
|
81
|
+
<FastImage
|
|
82
|
+
style={styles.logo}
|
|
83
|
+
source={card?.order_product?.images ? {
|
|
84
|
+
uri: optimizeImage(card?.order_product?.images, 'h_86,c_limit')
|
|
85
|
+
} : theme?.images?.dummies?.businessLogo}
|
|
86
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
87
|
+
/>
|
|
88
|
+
</View>
|
|
89
|
+
<View style={{ flex: 1, marginLeft: 14 }}>
|
|
90
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
91
|
+
<OText size={12} lineHeight={18}>{card?.order_product?.name}</OText>
|
|
92
|
+
<OText size={12} lineHeight={18}>{parsePrice(card?.order_product?.price)}</OText>
|
|
93
|
+
</View>
|
|
94
|
+
<OText size={10} color={theme.colors.textSecondary} lineHeight={15}>{parseDate(card?.created_at)}</OText>
|
|
95
|
+
<OText size={10} color={theme.colors.primary}>{getGiftCardStatus(card?.status)}</OText>
|
|
96
|
+
</View>
|
|
97
|
+
</View>
|
|
98
|
+
)}
|
|
99
|
+
</CardContainer>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useLanguage, GiftCardOrdersList as GiftCardOrdersListController } from 'ordering-components/native';
|
|
3
|
+
import { useTheme } from 'styled-components/native';
|
|
4
|
+
import {
|
|
5
|
+
Placeholder,
|
|
6
|
+
PlaceholderLine,
|
|
7
|
+
Fade
|
|
8
|
+
} from 'rn-placeholder';
|
|
9
|
+
import { SingleGiftCard } from '../SingleGiftCard';
|
|
10
|
+
import { OButton, OText } from '../../shared';
|
|
11
|
+
import {
|
|
12
|
+
ProductsListContainer,
|
|
13
|
+
SingleGiftCardWrapper,
|
|
14
|
+
WrappButton
|
|
15
|
+
} from './styles'
|
|
16
|
+
|
|
17
|
+
const VerticalGiftCardOrdersLayoutUI = (props: any) => {
|
|
18
|
+
const {
|
|
19
|
+
giftCards,
|
|
20
|
+
paginationProps,
|
|
21
|
+
loadMoreOrders,
|
|
22
|
+
title,
|
|
23
|
+
setIsEmpty,
|
|
24
|
+
onNavigationRedirect
|
|
25
|
+
} = props
|
|
26
|
+
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const [, t] = useLanguage()
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (giftCards.loading) return
|
|
32
|
+
if (giftCards.list?.length === 0) setIsEmpty(true)
|
|
33
|
+
}, [giftCards])
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ProductsListContainer>
|
|
37
|
+
{
|
|
38
|
+
giftCards.loading ? (
|
|
39
|
+
<Placeholder Animation={Fade} style={{ marginVertical: 16 }}>
|
|
40
|
+
<PlaceholderLine width={30} height={16} />
|
|
41
|
+
</Placeholder>
|
|
42
|
+
) : giftCards.list?.length > 0 && (
|
|
43
|
+
<OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={24} style={{ marginTop: 24 }}>{title}</OText>
|
|
44
|
+
)}
|
|
45
|
+
{giftCards.list.map(card => (
|
|
46
|
+
<SingleGiftCardWrapper key={card.id}>
|
|
47
|
+
<SingleGiftCard
|
|
48
|
+
card={card}
|
|
49
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
50
|
+
/>
|
|
51
|
+
</SingleGiftCardWrapper>
|
|
52
|
+
))}
|
|
53
|
+
{giftCards.loading && (
|
|
54
|
+
[...Array(10).keys()].map(i => (
|
|
55
|
+
<SingleGiftCardWrapper key={i}>
|
|
56
|
+
<SingleGiftCard
|
|
57
|
+
isSkeleton
|
|
58
|
+
/>
|
|
59
|
+
</SingleGiftCardWrapper>
|
|
60
|
+
))
|
|
61
|
+
)}
|
|
62
|
+
{paginationProps.totalPages && paginationProps.currentPage < paginationProps.totalPages && (
|
|
63
|
+
<WrappButton>
|
|
64
|
+
<OButton
|
|
65
|
+
onClick={loadMoreOrders}
|
|
66
|
+
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
67
|
+
imgRightSrc={null}
|
|
68
|
+
textStyle={{ color: theme.colors.white }}
|
|
69
|
+
style={{ borderRadius: 7.6, shadowOpacity: 0 }}
|
|
70
|
+
/>
|
|
71
|
+
</WrappButton>
|
|
72
|
+
)}
|
|
73
|
+
</ProductsListContainer>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const VerticalGiftCardOrdersLayout = (props: any) => {
|
|
78
|
+
const giftCardsProps = {
|
|
79
|
+
...props,
|
|
80
|
+
UIComponent: VerticalGiftCardOrdersLayoutUI
|
|
81
|
+
}
|
|
82
|
+
return <GiftCardOrdersListController {...giftCardsProps} />
|
|
83
|
+
}
|
|
@@ -245,6 +245,14 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
245
245
|
setShowTitle(contentOffset.y > 30)
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
const handleGoBack = () => {
|
|
249
|
+
if (navigation?.canGoBack()) {
|
|
250
|
+
navigation.goBack()
|
|
251
|
+
} else {
|
|
252
|
+
navigation.navigate('BottomTab', { screen: 'Cart' })
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
248
256
|
useEffect(() => {
|
|
249
257
|
if (validationFields && validationFields?.fields?.checkout) {
|
|
250
258
|
checkValidationFields()
|
|
@@ -289,7 +297,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
289
297
|
<View style={styles.wrapperNavbar}>
|
|
290
298
|
<TopHeader>
|
|
291
299
|
<>
|
|
292
|
-
<TopActions onPress={() =>
|
|
300
|
+
<TopActions onPress={() => handleGoBack()}>
|
|
293
301
|
<IconAntDesign
|
|
294
302
|
name='arrowleft'
|
|
295
303
|
size={26}
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
|
|
|
2
2
|
import { useLanguage } from 'ordering-components/native';
|
|
3
3
|
import { View, StyleSheet, RefreshControl, Platform } from 'react-native';
|
|
4
4
|
import AntDesignIcon from 'react-native-vector-icons/AntDesign'
|
|
5
|
-
|
|
5
|
+
import { GiftCardOrdersList } from '../GiftCard/GiftCardOrdersList'
|
|
6
6
|
import { OrdersOption } from '../OrdersOption'
|
|
7
7
|
import { HeaderTitle, OButton, OText } from '../shared'
|
|
8
8
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
@@ -40,7 +40,8 @@ export const MyOrders = (props: any) => {
|
|
|
40
40
|
const MyOrdersMenu = [
|
|
41
41
|
{ key: 'orders', value: t('ORDERS', 'Orders'), disabled: false },
|
|
42
42
|
{ key: 'business', value: t('BUSINESS', 'Business'), disabled: hideBusinessTab },
|
|
43
|
-
{ key: 'products', value: t('PRODUCTS', 'Products'), disabled: hideProductsTab }
|
|
43
|
+
{ key: 'products', value: t('PRODUCTS', 'Products'), disabled: hideProductsTab },
|
|
44
|
+
{ key: 'giftCards', value: t('GIFT_CARD', 'Gift card'), disabled: false }
|
|
44
45
|
]
|
|
45
46
|
const goToBack = () => navigation?.canGoBack() && navigation.goBack()
|
|
46
47
|
|
|
@@ -215,7 +216,14 @@ export const MyOrders = (props: any) => {
|
|
|
215
216
|
setOrdersLength={setOrdersLength}
|
|
216
217
|
/>
|
|
217
218
|
)}
|
|
219
|
+
|
|
220
|
+
{selectedOption === 'giftCards' && (
|
|
221
|
+
<View style={{ paddingHorizontal: 20 }}>
|
|
222
|
+
<GiftCardOrdersList
|
|
223
|
+
onNavigationRedirect={props?.onNavigationRedirect}
|
|
224
|
+
/>
|
|
225
|
+
</View>
|
|
226
|
+
)}
|
|
218
227
|
</Container>
|
|
219
|
-
|
|
220
228
|
)
|
|
221
229
|
}
|
|
@@ -353,6 +353,7 @@ export const OrdersOption = (props: OrdersOptionParams) => {
|
|
|
353
353
|
const MyOrdersProps = {
|
|
354
354
|
...props,
|
|
355
355
|
UIComponent: OrdersOptionUI,
|
|
356
|
+
noGiftCardOrders: true,
|
|
356
357
|
orderStatus: getAllOrders
|
|
357
358
|
? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
|
|
358
359
|
: props.preOrders ? [13] : props.activeOrders
|
|
@@ -20,7 +20,7 @@ import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
|
|
|
20
20
|
import FontAwesome from 'react-native-vector-icons/FontAwesome'
|
|
21
21
|
import FastImage from 'react-native-fast-image'
|
|
22
22
|
import { OAlert } from '../../../../../src/components/shared'
|
|
23
|
-
|
|
23
|
+
import { WebsocketStatus } from '../WebsocketStatus'
|
|
24
24
|
import {
|
|
25
25
|
OIcon,
|
|
26
26
|
OText,
|
|
@@ -270,6 +270,7 @@ const ProfileListUI = (props: ProfileParams) => {
|
|
|
270
270
|
<View style={{ height: 17 }} />
|
|
271
271
|
</Actions>
|
|
272
272
|
</ListWrap>
|
|
273
|
+
<WebsocketStatus />
|
|
273
274
|
<OAlert
|
|
274
275
|
open={confirm.open}
|
|
275
276
|
title={confirm.title}
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
marginHorizontal: 15
|
|
70
|
+
}}
|
|
71
|
+
activeOpacity={0.6}
|
|
72
|
+
onPress={() => setOpenModal(true)}
|
|
73
|
+
>
|
|
74
|
+
<OText
|
|
75
|
+
style={{ color: theme.colors.backArrow, fontSize: 16, marginBottom: 0, lineHeight: 16 }}
|
|
76
|
+
>
|
|
77
|
+
{t('CONNECTION_STATUS', 'Status')}
|
|
78
|
+
</OText>
|
|
79
|
+
<MaterialIcon
|
|
80
|
+
name='circle'
|
|
81
|
+
size={12}
|
|
82
|
+
color={getStatusColor(socketStatus)}
|
|
83
|
+
style={{ marginLeft: 8 }}
|
|
84
|
+
/>
|
|
85
|
+
</TouchableOpacity>
|
|
86
|
+
|
|
87
|
+
<OModal
|
|
88
|
+
open={openModal}
|
|
89
|
+
onClose={() => setOpenModal(false)}
|
|
90
|
+
entireModal
|
|
91
|
+
customClose
|
|
92
|
+
>
|
|
93
|
+
<ModalContainer nestedScrollEnabled={true}>
|
|
94
|
+
<TouchableOpacity
|
|
95
|
+
onPress={() => setOpenModal(false)}
|
|
96
|
+
style={styles.btnBackArrow}
|
|
97
|
+
>
|
|
98
|
+
<OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
|
|
99
|
+
</TouchableOpacity>
|
|
100
|
+
<View>
|
|
101
|
+
<ModalTitle>{t('CONNECTION_STATUS', 'Connection status')}</ModalTitle>
|
|
102
|
+
<OText style={{ marginBottom: 20 }}>
|
|
103
|
+
{t('LAST_UPDATE', 'Last update')}: {parseDate(connectedDate)}
|
|
104
|
+
</OText>
|
|
105
|
+
<StatusItemWrapper>
|
|
106
|
+
<MaterialIcon
|
|
107
|
+
name='circle'
|
|
108
|
+
size={12}
|
|
109
|
+
color={getStatusColor(1)}
|
|
110
|
+
style={{ marginTop: 10, marginHorizontal: 8 }}
|
|
111
|
+
/>
|
|
112
|
+
<View style={{ marginLeft: 16 }}>
|
|
113
|
+
<StatusText>{t('OK', 'Ok')}</StatusText>
|
|
114
|
+
<OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_OK', 'The websocket works normally.')}</OText>
|
|
115
|
+
</View>
|
|
116
|
+
</StatusItemWrapper>
|
|
117
|
+
<StatusItemWrapper>
|
|
118
|
+
<MaterialIcon
|
|
119
|
+
name='circle'
|
|
120
|
+
size={12}
|
|
121
|
+
color={getStatusColor(0)}
|
|
122
|
+
style={{ marginTop: 10, marginHorizontal: 8 }}
|
|
123
|
+
/>
|
|
124
|
+
<View style={{ marginLeft: 16 }}>
|
|
125
|
+
<StatusText>{t('CONNECTING', 'Connecting')}</StatusText>
|
|
126
|
+
<OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_CONNECTING', 'The websocket is connecting.')}</OText>
|
|
127
|
+
</View>
|
|
128
|
+
</StatusItemWrapper>
|
|
129
|
+
<StatusItemWrapper>
|
|
130
|
+
<MaterialIcon
|
|
131
|
+
name='circle'
|
|
132
|
+
size={12}
|
|
133
|
+
color={getStatusColor(2)}
|
|
134
|
+
style={{ marginTop: 10, marginHorizontal: 8 }}
|
|
135
|
+
/>
|
|
136
|
+
<View style={{ marginLeft: 16 }}>
|
|
137
|
+
<StatusText>{t('DISCONNECTED', 'Disconnected')}</StatusText>
|
|
138
|
+
<OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_DISCONNECTED', 'The server is slow, please reload.')}</OText>
|
|
139
|
+
</View>
|
|
140
|
+
</StatusItemWrapper>
|
|
141
|
+
|
|
142
|
+
<View style={{ flexDirection: 'row', marginTop: 50 }}>
|
|
143
|
+
<OButton
|
|
144
|
+
onClick={() => setOpenModal(false)}
|
|
145
|
+
bgColor={theme.colors.white}
|
|
146
|
+
borderColor={theme.colors.primary}
|
|
147
|
+
textStyle={{ color: theme.colors.primary }}
|
|
148
|
+
style={{ borderRadius: 8, height: 48 }}
|
|
149
|
+
text={t('CLOSE', 'Close')}
|
|
150
|
+
/>
|
|
151
|
+
<OButton
|
|
152
|
+
onClick={() => RNRestart.Restart()}
|
|
153
|
+
borderColor={theme.colors.primary}
|
|
154
|
+
textStyle={{ color: theme.colors.white }}
|
|
155
|
+
style={{ borderRadius: 8, marginLeft: 16, height: 48 }}
|
|
156
|
+
text={t('UPDATE', 'Update')}
|
|
157
|
+
/>
|
|
158
|
+
</View>
|
|
159
|
+
</View>
|
|
160
|
+
</ModalContainer>
|
|
161
|
+
</OModal>
|
|
162
|
+
</Container>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const WebsocketStatus = (props: any) => {
|
|
167
|
+
const socketProps = {
|
|
168
|
+
...props,
|
|
169
|
+
UIComponent: SocketStatusUI
|
|
170
|
+
}
|
|
171
|
+
return <WebsocketStatusController {...socketProps} />
|
|
172
|
+
}
|
|
@@ -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
|
+
`
|