ordering-ui-react-native 0.21.0-release → 0.21.1-release
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/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/MyOrders/index.tsx +11 -3
- package/themes/original/src/components/OrderProgress/index.tsx +7 -1
- package/themes/original/src/components/OrdersOption/index.tsx +1 -0
- package/themes/original/src/components/shared/OButton.tsx +5 -5
package/package.json
CHANGED
|
@@ -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
|
+
}
|
|
@@ -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';
|
|
@@ -41,7 +41,8 @@ export const MyOrders = (props: any) => {
|
|
|
41
41
|
const MyOrdersMenu = [
|
|
42
42
|
{ key: 'orders', value: t('ORDERS', 'Orders'), disabled: false },
|
|
43
43
|
{ key: 'business', value: t('BUSINESS', 'Business'), disabled: hideBusinessTab },
|
|
44
|
-
{ key: 'products', value: t('PRODUCTS', 'Products'), disabled: hideProductsTab }
|
|
44
|
+
{ key: 'products', value: t('PRODUCTS', 'Products'), disabled: hideProductsTab },
|
|
45
|
+
{ key: 'giftCards', value: t('GIFT_CARD', 'Gift card'), disabled: false }
|
|
45
46
|
]
|
|
46
47
|
const goToBack = () => navigation?.canGoBack() && navigation.goBack()
|
|
47
48
|
|
|
@@ -202,7 +203,14 @@ export const MyOrders = (props: any) => {
|
|
|
202
203
|
setOrdersLength={setOrdersLength}
|
|
203
204
|
/>
|
|
204
205
|
)}
|
|
206
|
+
|
|
207
|
+
{selectedOption === 'giftCards' && (
|
|
208
|
+
<View style={{ paddingHorizontal: 20 }}>
|
|
209
|
+
<GiftCardOrdersList
|
|
210
|
+
onNavigationRedirect={props?.onNavigationRedirect}
|
|
211
|
+
/>
|
|
212
|
+
</View>
|
|
213
|
+
)}
|
|
205
214
|
</Container>
|
|
206
|
-
|
|
207
215
|
)
|
|
208
216
|
}
|
|
@@ -220,7 +220,13 @@ export const OrderProgress = (props: any) => {
|
|
|
220
220
|
'delivery_type',
|
|
221
221
|
'delivery_datetime_utc',
|
|
222
222
|
'delivery_datetime',
|
|
223
|
-
'reporting_data'
|
|
223
|
+
'reporting_data',
|
|
224
|
+
'eta_current_status_time',
|
|
225
|
+
'eta_previous_status_times',
|
|
226
|
+
'eta_time',
|
|
227
|
+
'delivered_in',
|
|
228
|
+
'prepared_in',
|
|
229
|
+
'eta_drive_time'
|
|
224
230
|
],
|
|
225
231
|
noGiftCardOrders: true
|
|
226
232
|
}
|
|
@@ -350,6 +350,7 @@ export const OrdersOption = (props: OrdersOptionParams) => {
|
|
|
350
350
|
const MyOrdersProps = {
|
|
351
351
|
...props,
|
|
352
352
|
UIComponent: OrdersOptionUI,
|
|
353
|
+
noGiftCardOrders: true,
|
|
353
354
|
orderStatus: getAllOrders
|
|
354
355
|
? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
|
|
355
356
|
: props.preOrders ? [13] : props.activeOrders
|
|
@@ -27,9 +27,9 @@ const StyledButton = styled.View<Props>`
|
|
|
27
27
|
padding-left: 20px;
|
|
28
28
|
padding-right: 20px;
|
|
29
29
|
position: relative;
|
|
30
|
-
${(props: any) => props?.
|
|
31
|
-
border-radius: ${props?.
|
|
32
|
-
|
|
30
|
+
${(props: any) => props?.borderRadius && css`
|
|
31
|
+
border-radius: ${typeof props?.borderRadius === 'string' ? props?.borderRadius : `${props?.borderRadius}px`};
|
|
32
|
+
`}
|
|
33
33
|
`
|
|
34
34
|
const StyledButtonDisabled = styled(StyledButton)`
|
|
35
35
|
background-color: ${(props: any) => props.theme.colors.disabled};
|
|
@@ -119,7 +119,7 @@ const OButton = (props: Props): React.ReactElement => {
|
|
|
119
119
|
style={{ width: props.isCircle ? 52 : props.style?.width, ...props.parentStyle }}
|
|
120
120
|
disabled={props.isDisabledWithSameStyles}
|
|
121
121
|
>
|
|
122
|
-
<StyledButton style={
|
|
122
|
+
<StyledButton style={{ ...props.style, backgroundColor: theme?.general?.components?.buttons?.color ?? props.bgColor, borderColor: theme?.general?.components?.buttons?.color ?? props.borderColor, borderRadius: parseInt(theme?.general?.components?.buttons?.borderRadius) || props.style?.borderRadius }}>
|
|
123
123
|
{props.icon ? (
|
|
124
124
|
<props.icon {...props.iconProps} />
|
|
125
125
|
) : null}
|
|
@@ -127,7 +127,7 @@ const OButton = (props: Props): React.ReactElement => {
|
|
|
127
127
|
<OIcon style={props.imgLeftStyle} src={props.imgLeftSrc} color={theme.colors.textNormal} />
|
|
128
128
|
) : null}
|
|
129
129
|
{props.text ? (
|
|
130
|
-
<StyledText style={props.textStyle}>{props.text}</StyledText>
|
|
130
|
+
<StyledText style={{ ...props.textStyle, color: theme?.general?.components?.buttons?.buttonTextColor ?? props?.textStyle?.color }}>{props.text}</StyledText>
|
|
131
131
|
) : null}
|
|
132
132
|
{props.imgRightSrc ? (
|
|
133
133
|
<EndImage style={props.imgRightStyle} source={props.imgRightSrc} />
|