ordering-ui-react-native 0.17.72 → 0.17.74

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.
Files changed (22) hide show
  1. package/package.json +1 -1
  2. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +1 -0
  3. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +2 -0
  4. package/themes/business/src/components/PreviousOrders/index.tsx +115 -8
  5. package/themes/business/src/components/PreviousOrders/styles.tsx +1 -1
  6. package/themes/business/src/components/shared/OLink.tsx +3 -2
  7. package/themes/original/src/components/Cart/index.tsx +1 -0
  8. package/themes/original/src/components/Checkout/index.tsx +95 -83
  9. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  10. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  11. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +96 -0
  12. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +6 -0
  13. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +178 -0
  14. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  15. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  16. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  17. package/themes/original/src/components/OrderDetails/index.tsx +175 -149
  18. package/themes/original/src/components/OrderSummary/index.tsx +6 -3
  19. package/themes/original/src/components/PaymentOptions/index.tsx +1 -1
  20. package/themes/original/src/components/ProductItemAccordion/index.tsx +4 -3
  21. package/themes/original/src/components/Wallets/index.tsx +13 -0
  22. package/themes/original/src/types/index.tsx +2 -1
@@ -0,0 +1,96 @@
1
+ import React from 'react'
2
+ import {
3
+ useLanguage,
4
+ PurchaseGiftCard as PurchaseGiftCardController
5
+ } from 'ordering-components/native'
6
+ import { StyleSheet, View, TouchableOpacity } from 'react-native'
7
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
8
+ import { useTheme } from 'styled-components/native';
9
+ import { OText, OButton, OIcon } from '../../shared';
10
+
11
+ import {
12
+ Container
13
+ } from './styles'
14
+
15
+ const PurchaseGiftCardUI = (props: any) => {
16
+ const {
17
+ productsListState,
18
+ selectedProduct,
19
+ setSelectedProduct,
20
+ handleAccept
21
+ } = props
22
+
23
+ const theme = useTheme()
24
+ const [, t] = useLanguage()
25
+
26
+ const style = StyleSheet.create({
27
+ itemStyle: {
28
+ flexDirection: 'row',
29
+ alignItems: 'center',
30
+ paddingVertical: 15,
31
+ borderBottomWidth: 1,
32
+ borderBottomColor: theme.colors.disabled
33
+ },
34
+ btnStyle: {
35
+ borderRadius: 7.6,
36
+ paddingLeft: 0,
37
+ paddingRight: 0,
38
+ height: 44,
39
+ marginTop: 50
40
+ }
41
+ })
42
+
43
+ return (
44
+ <Container>
45
+ <OText color={theme.colors.textNormal} weight='bold' size={20} mBottom={40}>{t('PURCHASE_GIFT_CARD', 'Purchase gift card')}</OText>
46
+ <OText color={theme.colors.textNormal} size={14}>{t('SELECT_ONE_OPTION', 'Select one option')}</OText>
47
+ <View>
48
+ {productsListState.loading && (
49
+ [...Array(5).keys()].map(i => (
50
+ <View key={i} style={style.itemStyle}>
51
+ <Placeholder
52
+ Animation={Fade}
53
+ >
54
+ <PlaceholderLine width={80} height={20} style={{ marginBottom: 0 }} />
55
+ </Placeholder>
56
+ </View>
57
+ ))
58
+ )}
59
+ {productsListState.products.map(product => (
60
+ <TouchableOpacity
61
+ key={product.id}
62
+ style={style.itemStyle}
63
+ onPress={() => setSelectedProduct(product)}
64
+ >
65
+ <View style={{ marginRight: 10 }}>
66
+ {selectedProduct?.id === product.id ? (
67
+ <OIcon src={theme.images.general.radio_act} color={theme.colors.primary} width={16} />
68
+ ) : (
69
+ <OIcon src={theme.images.general.radio_nor} color={theme.colors.disabled} width={16} />
70
+ )}
71
+ </View>
72
+ <OText color={theme.colors.textNormal} size={14}>{product.name}</OText>
73
+ </TouchableOpacity>
74
+ ))}
75
+ </View>
76
+ <OButton
77
+ onClick={() => handleAccept()}
78
+ text={t('ACCEPT', 'Accept')}
79
+ bgColor={theme.colors.primary}
80
+ borderColor={theme.colors.primary}
81
+ textStyle={{ color: 'white', fontSize: 13 }}
82
+ imgRightSrc={null}
83
+ style={style.btnStyle}
84
+ isDisabled={!selectedProduct}
85
+ />
86
+ </Container>
87
+ )
88
+ }
89
+
90
+ export const PurchaseGiftCard = (props: any) => {
91
+ const purchaseGiftCardProps = {
92
+ ...props,
93
+ UIComponent: PurchaseGiftCardUI
94
+ }
95
+ return <PurchaseGiftCardController {...purchaseGiftCardProps} />
96
+ }
@@ -0,0 +1,6 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ width: 100%;
5
+ padding-horizontal: 40px;
6
+ `
@@ -0,0 +1,178 @@
1
+ import React, { useEffect } from 'react'
2
+ import {
3
+ useLanguage, useUtils, RedeemGiftCard as RedeemGiftCardController
4
+ } from 'ordering-components/native'
5
+ import { useForm, Controller } from 'react-hook-form'
6
+ import { StyleSheet, View, Alert } from 'react-native';
7
+ import { useTheme } from 'styled-components/native';
8
+ import { OText, OButton, OInput } from '../../shared';
9
+
10
+ import {
11
+ Container,
12
+ FormController
13
+ } from './styles'
14
+
15
+ const RedeemGiftCardUI = (props: any) => {
16
+ const {
17
+ actionState,
18
+ redeemedGiftCard,
19
+ handleApply,
20
+ onClose,
21
+ setRedeemedGiftCard
22
+ } = props
23
+
24
+ const theme = useTheme()
25
+ const [, t] = useLanguage()
26
+ const { handleSubmit, control, errors } = useForm()
27
+ const [{ parsePrice }] = useUtils()
28
+
29
+ const style = StyleSheet.create({
30
+ btnStyle: {
31
+ borderRadius: 7.6,
32
+ height: 44,
33
+ marginTop: 20
34
+ },
35
+ inputStyle: {
36
+ borderWidth: 1,
37
+ borderColor: theme.colors.border,
38
+ borderRadius: 7.6,
39
+ },
40
+ })
41
+
42
+ const onSubmit = (values) => {
43
+ handleApply(values)
44
+ }
45
+
46
+ useEffect(() => {
47
+ if (Object.keys(errors).length > 0) {
48
+ const list = Object.values(errors)
49
+ let stringError = ''
50
+ list.map((item: any, i: number) => {
51
+ stringError += (i + 1) === list.length ? `- ${item.message}` : `- ${item.message}\n`
52
+ })
53
+ Alert.alert(
54
+ t('ERROR', 'Error'),
55
+ stringError,
56
+ [
57
+ { text: t('OK', 'oK'), onPress: () => {} }
58
+ ]
59
+ )
60
+ }
61
+ }, [errors])
62
+
63
+ useEffect(() => {
64
+ if (!actionState.error) return
65
+ let stringError = ''
66
+ if (typeof actionState.error === 'string') {
67
+ stringError = actionState.error
68
+ } else {
69
+ actionState.error.map(item => {
70
+ stringError += `- ${item}\n`
71
+ })
72
+ }
73
+ Alert.alert(
74
+ t('ERROR', 'Error'),
75
+ stringError,
76
+ [
77
+ { text: t('OK', 'oK'), onPress: () => {} }
78
+ ]
79
+ )
80
+ }, [actionState.error])
81
+
82
+ return (
83
+ <Container>
84
+ {!redeemedGiftCard ? (
85
+ <View>
86
+ <OText color={theme.colors.textNormal} weight='bold' size={20} mBottom={40}>{t('REDEEM_GIFT_CARD', 'Redeem a gift card')}</OText>
87
+ <FormController>
88
+ <OText color={theme.colors.textNormal} size={14} mBottom={10}>{t('GIFT_CARD_CODE', 'Gift card code')}</OText>
89
+ <Controller
90
+ control={control}
91
+ render={({ onChange, value }: any) => (
92
+ <OInput
93
+ placeholder='0000 0000'
94
+ value={value}
95
+ onChange={(val: any) => onChange(val)}
96
+ autoCapitalize='none'
97
+ autoCorrect={false}
98
+ blurOnSubmit={false}
99
+ style={style.inputStyle}
100
+ />
101
+ )}
102
+ name='code'
103
+ rules={{
104
+ required: t('VALIDATION_ERROR_REQUIRED', 'Code is required').replace('_attribute_', t('CODE', 'Code'))
105
+ }}
106
+ defaultValue=""
107
+ />
108
+ </FormController>
109
+ <FormController>
110
+ <OText color={theme.colors.textNormal} size={14} mBottom={10}>{t('PASSWORD', 'Password')}</OText>
111
+ <Controller
112
+ control={control}
113
+ render={({ onChange, value }: any) => (
114
+ <OInput
115
+ isSecured
116
+ placeholder={t('PASSWORD', 'Password')}
117
+ value={value}
118
+ onChange={(val: any) => onChange(val)}
119
+ autoCapitalize='none'
120
+ autoCompleteType='password'
121
+ autoCorrect={false}
122
+ blurOnSubmit={false}
123
+ style={style.inputStyle}
124
+ />
125
+ )}
126
+ name='password'
127
+ rules={{
128
+ required: t('VALIDATION_ERROR_REQUIRED', 'Password is required').replace('_attribute_', t('PASSWORD', 'Password'))
129
+ }}
130
+ defaultValue=""
131
+ />
132
+ </FormController>
133
+ <OButton
134
+ onClick={handleSubmit(onSubmit)}
135
+ text={actionState?.loading ? t('LOADING', 'Loading') : t('APPLY_TO_YOUR_BALANCE', 'Apply to your balance')}
136
+ bgColor={theme.colors.primary}
137
+ borderColor={theme.colors.primary}
138
+ textStyle={{ color: 'white', fontSize: 13 }}
139
+ imgRightSrc={null}
140
+ style={style.btnStyle}
141
+ isDisabled={actionState.loading}
142
+ />
143
+ </View>
144
+ ) : (
145
+ <>
146
+ <OText color={theme.colors.textNormal} weight='bold' size={20} mBottom={40}>{t('GIFT_CARD', 'Gift card')}</OText>
147
+ <View>
148
+ <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('TYPE', 'Type')}: {redeemedGiftCard?.type}</OText>
149
+ <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('AMOUNT', 'Amount')}: {parsePrice(redeemedGiftCard?.amount)}</OText>
150
+ <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('FROM', 'From')}: {redeemedGiftCard?.receiver?.name} {redeemedGiftCard?.receiver?.lastname}</OText>
151
+ <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('TITLE', 'Title')}: {redeemedGiftCard?.title}</OText>
152
+ <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('MESSAGES', 'Messages')}: {redeemedGiftCard?.message}</OText>
153
+ <OButton
154
+ onClick={() => {
155
+ setRedeemedGiftCard(null)
156
+ onClose()
157
+ }}
158
+ text={t('OK', 'Ok')}
159
+ bgColor={theme.colors.primary}
160
+ borderColor={theme.colors.primary}
161
+ textStyle={{ color: 'white', fontSize: 13 }}
162
+ imgRightSrc={null}
163
+ style={style.btnStyle}
164
+ />
165
+ </View>
166
+ </>
167
+ )}
168
+ </Container>
169
+ )
170
+ }
171
+
172
+ export const RedeemGiftCard = (props: any) => {
173
+ const redeemGiftCardProps = {
174
+ ...props,
175
+ UIComponent: RedeemGiftCardUI
176
+ }
177
+ return <RedeemGiftCardController {...redeemGiftCardProps} />
178
+ }
@@ -0,0 +1,8 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ padding-horizontal: 40px;
5
+ `
6
+ export const FormController = styled.View`
7
+ margin-bottom: 25px;
8
+ `
@@ -0,0 +1,165 @@
1
+ import React, { useEffect } from 'react'
2
+ import { StyleSheet, Platform, Alert } from 'react-native';
3
+ import { useLanguage, SendGiftCard as SendGiftCardController } from 'ordering-components/native';
4
+ import { useTheme } from 'styled-components/native';
5
+ import { OText, OButton, OInput } from '../../shared';
6
+ import { useForm, Controller } from 'react-hook-form'
7
+
8
+ import {
9
+ Container,
10
+ FormController
11
+ } from './styles'
12
+
13
+
14
+ const SendGiftCardUI = (props: any) => {
15
+ const {
16
+ actionState,
17
+ handleSendGiftCard
18
+ } = props
19
+
20
+ const theme = useTheme()
21
+ const [, t] = useLanguage()
22
+
23
+ const { handleSubmit, control, errors } = useForm()
24
+
25
+ const style = StyleSheet.create({
26
+ btnStyle: {
27
+ borderRadius: 7.6,
28
+ height: 44,
29
+ marginTop: 20
30
+ },
31
+ inputStyle: {
32
+ borderWidth: 1,
33
+ borderColor: theme.colors.border,
34
+ borderRadius: 7.6,
35
+ },
36
+ })
37
+
38
+ const onSubmit = (values) => {
39
+ handleSendGiftCard(values)
40
+ }
41
+
42
+ useEffect(() => {
43
+ if (Object.keys(errors).length > 0) {
44
+ const list = Object.values(errors)
45
+ let stringError = ''
46
+ list.map((item: any, i: number) => {
47
+ stringError += (i + 1) === list.length ? `- ${item.message}` : `- ${item.message}\n`
48
+ })
49
+ Alert.alert(
50
+ t('ERROR', 'Error'),
51
+ stringError,
52
+ [
53
+ { text: t('OK', 'oK'), onPress: () => {} }
54
+ ]
55
+ )
56
+ }
57
+ }, [errors])
58
+
59
+ return (
60
+ <Container>
61
+ <OText color={theme.colors.textNormal} size={20} mBottom={10} style={{ fontWeight: Platform.OS == 'ios' ? '600' : 'bold' }}>{t('GIFT_CARD_DETAILS', 'Gift Card details')}</OText>
62
+ <FormController>
63
+ <OText color={theme.colors.textNormal} size={14} mBottom={10}>{t('TO', 'To')}</OText>
64
+ <Controller
65
+ control={control}
66
+ render={({ onChange, value }: any) => (
67
+ <OInput
68
+ placeholder={t('ENTER_AN_EMAIL', 'Enter an email')}
69
+ value={value}
70
+ onChange={(val: any) => onChange(val)}
71
+ autoCompleteType='email'
72
+ autoCapitalize='none'
73
+ autoCorrect={false}
74
+ type='email-address'
75
+ blurOnSubmit={false}
76
+ style={style.inputStyle}
77
+ />
78
+ )}
79
+ name='email'
80
+ rules={{
81
+ required: t('VALIDATION_ERROR_REQUIRED', 'To email is required').replace('_attribute_', t('EMAIL', 'EMail'))
82
+ }}
83
+ defaultValue=""
84
+ />
85
+ </FormController>
86
+ <FormController>
87
+ <OText color={theme.colors.textNormal} size={14} mBottom={10}>{t('FROM', 'From')}</OText>
88
+ <Controller
89
+ control={control}
90
+ render={({ onChange, value }: any) => (
91
+ <OInput
92
+ placeholder={t('WRITE_YOUR_NAME', 'Write your name')}
93
+ value={value}
94
+ onChange={(val: any) => onChange(val)}
95
+ autoCapitalize='none'
96
+ autoCorrect={false}
97
+ blurOnSubmit={false}
98
+ style={style.inputStyle}
99
+ />
100
+ )}
101
+ name='user_name'
102
+ defaultValue=""
103
+ />
104
+ </FormController>
105
+ <FormController>
106
+ <OText color={theme.colors.textNormal} size={14} mBottom={10}>{t('TITLE', 'Title')}</OText>
107
+ <Controller
108
+ control={control}
109
+ render={({ onChange, value }: any) => (
110
+ <OInput
111
+ placeholder={t('TITLE', 'Title')}
112
+ value={value}
113
+ onChange={(val: any) => onChange(val)}
114
+ autoCapitalize='none'
115
+ autoCorrect={false}
116
+ blurOnSubmit={false}
117
+ style={style.inputStyle}
118
+ />
119
+ )}
120
+ name='title'
121
+ defaultValue=""
122
+ />
123
+ </FormController>
124
+ <FormController>
125
+ <OText color={theme.colors.textNormal} size={14} mBottom={10}>{t('MESSAGES', 'Messages')}</OText>
126
+ <Controller
127
+ control={control}
128
+ render={({ onChange, value }: any) => (
129
+ <OInput
130
+ multiline
131
+ placeholder={t('TYPE_YOUR_MESSAGE_HERE', 'Type your message here')}
132
+ value={value}
133
+ onChange={(val: any) => onChange(val)}
134
+ autoCapitalize='none'
135
+ autoCorrect={false}
136
+ blurOnSubmit={false}
137
+ style={{ ...style.inputStyle, height: 100, alignItems: 'flex-start', }}
138
+ />
139
+ )}
140
+ name='message'
141
+ defaultValue=""
142
+ />
143
+ </FormController>
144
+ <OButton
145
+ onClick={handleSubmit(onSubmit)}
146
+ text={actionState?.loading ? t('LOADING', 'Loading') : t('SEND_GIFT_CARD', 'Send gift card')}
147
+ bgColor={theme.colors.primary}
148
+ borderColor={theme.colors.primary}
149
+ textStyle={{ color: 'white', fontSize: 13 }}
150
+ imgRightSrc={null}
151
+ style={style.btnStyle}
152
+ isDisabled={actionState.loading}
153
+ />
154
+ </Container>
155
+ )
156
+ }
157
+
158
+ export const SendGiftCard = (props: any) => {
159
+ const sendGiftCardProps = {
160
+ ...props,
161
+ showToastMsg: true,
162
+ UIComponent: SendGiftCardUI
163
+ }
164
+ return <SendGiftCardController {...sendGiftCardProps} />
165
+ }
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ padding-horizontal: 40px;
5
+ margin-bottom: 30px;
6
+ `
7
+ export const FormController = styled.View`
8
+ margin-bottom: 25px;
9
+ `