ordering-ui-react-native 0.16.74 → 0.16.75-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 +6 -5
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/ActiveOrders/styles.tsx +8 -14
- package/src/components/BusinessInformation/index.tsx +19 -4
- package/src/components/BusinessInformation/styles.tsx +2 -2
- package/src/components/BusinessProductsList/index.tsx +10 -10
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +2 -1
- package/src/components/LanguageSelector/index.tsx +21 -16
- package/src/components/Messages/index.tsx +2 -2
- package/src/components/OrderCreating/index.tsx +2 -2
- package/src/components/OrdersOption/index.tsx +54 -56
- package/src/components/PaymentOptions/index.tsx +298 -345
- package/src/components/PaymentOptionsWebView/index.tsx +119 -120
- package/src/components/SingleProductReview/index.tsx +7 -4
- package/src/components/StripeElementsForm/index.tsx +25 -16
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +4 -4
- package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
- package/src/utils/index.tsx +2 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
- package/themes/business/src/components/BusinessController/index.tsx +2 -2
- package/themes/business/src/components/Chat/index.tsx +31 -31
- package/themes/business/src/components/DriverMap/index.tsx +7 -5
- package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
- package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/business/src/components/LoginForm/index.tsx +332 -140
- package/themes/business/src/components/LoginForm/styles.tsx +10 -0
- package/themes/business/src/components/MapView/index.tsx +14 -3
- package/themes/business/src/components/MessagesOption/index.tsx +11 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +31 -41
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +70 -43
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
- package/themes/business/src/components/OrdersOption/index.tsx +63 -73
- package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
- package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
- package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
- package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
- package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
- package/themes/business/src/components/PreviousOrders/index.tsx +440 -245
- package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
- package/themes/business/src/components/ProductItemAccordion/index.tsx +24 -5
- package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
- package/themes/business/src/components/shared/ODropDown.tsx +42 -8
- package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
- package/themes/business/src/components/shared/OLink.tsx +33 -13
- package/themes/business/src/components/shared/OText.tsx +8 -2
- package/themes/business/src/types/index.tsx +29 -3
- package/themes/business/src/utils/index.tsx +26 -0
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
- package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
- package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +545 -112
- package/themes/kiosk/src/components/LoginForm/styles.tsx +18 -0
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PhoneInputNumber/index.tsx +1 -0
- package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
- package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
- package/themes/kiosk/src/layouts/Container.tsx +7 -1
- package/themes/kiosk/src/types/index.d.ts +15 -0
- package/themes/kiosk/src/utils/index.tsx +15 -0
- package/themes/original/index.tsx +6 -0
- package/themes/original/src/components/AddressDetails/index.tsx +10 -8
- package/themes/original/src/components/AddressForm/index.tsx +155 -139
- package/themes/original/src/components/AddressList/index.tsx +18 -18
- package/themes/original/src/components/AddressList/styles.tsx +4 -2
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +47 -22
- package/themes/original/src/components/BusinessController/index.tsx +101 -70
- package/themes/original/src/components/BusinessController/styles.tsx +14 -9
- package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
- package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +104 -155
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +26 -52
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +562 -493
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +13 -12
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +82 -69
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
- package/themes/original/src/components/BusinessesListing/index.tsx +7 -6
- package/themes/original/src/components/Cart/index.tsx +76 -42
- package/themes/original/src/components/CartContent/index.tsx +80 -18
- package/themes/original/src/components/CartContent/styles.tsx +11 -1
- package/themes/original/src/components/Checkout/index.tsx +102 -108
- package/themes/original/src/components/Checkout/styles.tsx +4 -3
- package/themes/original/src/components/CitiesControl/index.tsx +89 -0
- package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
- package/themes/original/src/components/DriverTips/index.tsx +47 -37
- package/themes/original/src/components/DriverTips/styles.tsx +2 -1
- package/themes/original/src/components/Favorite/index.tsx +7 -4
- package/themes/original/src/components/Favorite/styles.tsx +1 -1
- package/themes/original/src/components/FavoriteList/index.tsx +70 -80
- package/themes/original/src/components/FloatingButton/index.tsx +1 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +20 -19
- package/themes/original/src/components/GPSButton/styles.ts +3 -3
- package/themes/original/src/components/GoogleMap/index.tsx +10 -1
- package/themes/original/src/components/Help/index.tsx +8 -8
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +14 -20
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +6 -0
- package/themes/original/src/components/HelpGuide/index.tsx +13 -12
- package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
- package/themes/original/src/components/HelpOrder/index.tsx +12 -20
- package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
- package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
- package/themes/original/src/components/LastOrder/index.tsx +1 -34
- package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
- package/themes/original/src/components/LoginForm/index.tsx +98 -41
- package/themes/original/src/components/LottieAnimation/index.tsx +78 -0
- package/themes/original/src/components/MessageListing/index.tsx +7 -40
- package/themes/original/src/components/Messages/index.tsx +42 -26
- package/themes/original/src/components/MomentOption/index.tsx +23 -14
- package/themes/original/src/components/MultiCart/index.tsx +50 -0
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
- package/themes/original/src/components/MultiCheckout/index.tsx +158 -77
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +85 -34
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
- package/themes/original/src/components/MyOrders/index.tsx +66 -17
- package/themes/original/src/components/NavBar/index.tsx +7 -6
- package/themes/original/src/components/NetworkError/index.tsx +5 -3
- package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
- package/themes/original/src/components/Notifications/index.tsx +144 -0
- package/themes/original/src/components/Notifications/styles.tsx +20 -0
- package/themes/original/src/components/OrderDetails/index.tsx +108 -218
- package/themes/original/src/components/OrderDetails/styles.tsx +10 -1
- package/themes/original/src/components/OrderItAgain/index.tsx +46 -43
- package/themes/original/src/components/OrderProgress/index.tsx +81 -105
- package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
- package/themes/original/src/components/OrderSummary/index.tsx +2 -2
- package/themes/original/src/components/OrderTypeSelector/index.tsx +13 -6
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +93 -97
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
- package/themes/original/src/components/OrdersOption/index.tsx +86 -92
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +1 -2
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PlaceSpot/index.tsx +16 -6
- package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
- package/themes/original/src/components/ProductForm/index.tsx +240 -254
- package/themes/original/src/components/ProductForm/styles.tsx +5 -8
- package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -10
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +1 -2
- package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -49
- package/themes/original/src/components/ProfessionalProfile/index.tsx +20 -9
- package/themes/original/src/components/Promotions/index.tsx +234 -220
- package/themes/original/src/components/Promotions/styles.tsx +7 -2
- package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
- package/themes/original/src/components/ReviewOrder/index.tsx +43 -11
- package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
- package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
- package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
- package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
- package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
- package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
- package/themes/original/src/components/ServiceForm/index.tsx +360 -265
- package/themes/original/src/components/Sessions/index.tsx +11 -8
- package/themes/original/src/components/Sessions/styles.tsx +5 -0
- package/themes/original/src/components/SignupForm/index.tsx +150 -100
- package/themes/original/src/components/SingleOrderCard/index.tsx +125 -56
- package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
- package/themes/original/src/components/SingleProductCard/index.tsx +116 -79
- package/themes/original/src/components/SingleProductCard/styles.tsx +14 -13
- package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
- package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
- package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +13 -2
- package/themes/original/src/components/UpsellingProducts/index.tsx +244 -215
- package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
- package/themes/original/src/components/UserDetails/index.tsx +5 -3
- package/themes/original/src/components/UserFormDetails/index.tsx +50 -54
- package/themes/original/src/components/UserProfile/index.tsx +58 -35
- package/themes/original/src/components/UserProfile/styles.ts +17 -0
- package/themes/original/src/components/UserProfileForm/index.tsx +21 -28
- package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
- package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
- package/themes/original/src/components/Wallets/index.tsx +177 -164
- package/themes/original/src/components/Wallets/styles.tsx +12 -8
- package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
- package/themes/original/src/components/shared/OBottomPopup.tsx +6 -4
- package/themes/original/src/components/shared/OButton.tsx +9 -4
- package/themes/original/src/components/shared/OIcon.tsx +8 -1
- package/themes/original/src/components/shared/OInput.tsx +10 -1
- package/themes/original/src/layouts/Container.tsx +13 -9
- package/themes/original/src/types/index.tsx +41 -6
- package/themes/original/src/utils/index.tsx +322 -58
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { ScrollView, TouchableOpacity, View, StyleSheet
|
|
3
|
-
import {
|
|
2
|
+
import { ScrollView, TouchableOpacity, View, StyleSheet } from 'react-native'
|
|
3
|
+
import { useLanguage } from 'ordering-components/native'
|
|
4
4
|
import { useTheme } from 'styled-components/native'
|
|
5
|
-
import
|
|
6
|
-
import { OIcon, OText, OModal } from '../shared'
|
|
5
|
+
import { OText, OModal } from '../shared'
|
|
7
6
|
import { ProfessionalProfile } from '../ProfessionalProfile'
|
|
8
7
|
import { ProfessionalFilterParams } from '../../types'
|
|
8
|
+
import { SingleProfessionalCard } from './SingleProfessionalCard'
|
|
9
9
|
|
|
10
10
|
export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
11
11
|
const {
|
|
12
12
|
professionals,
|
|
13
13
|
professionalSelected,
|
|
14
|
-
handleChangeProfessionalSelected
|
|
14
|
+
handleChangeProfessionalSelected,
|
|
15
|
+
handleUpdateProfessionals
|
|
15
16
|
} = props
|
|
16
17
|
|
|
17
18
|
const theme = useTheme()
|
|
18
|
-
const [{ optimizeImage }] = useUtils()
|
|
19
19
|
const [, t] = useLanguage()
|
|
20
20
|
const [open, setOpen] = useState(false)
|
|
21
21
|
const [currentProfessional, setCurrentProfessional] = useState(null)
|
|
@@ -30,6 +30,11 @@ export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
|
30
30
|
setOpen(false)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const onUpdateProfessionals = (id, changes) => {
|
|
34
|
+
const updatedProfessional = professionals.find(professional => professional.id === id)
|
|
35
|
+
handleUpdateProfessionals({ ...updatedProfessional, ...changes })
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
const styles = StyleSheet.create({
|
|
34
39
|
professionalItem: {
|
|
35
40
|
flexDirection: 'row',
|
|
@@ -39,12 +44,7 @@ export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
|
39
44
|
borderWidth: 1,
|
|
40
45
|
marginRight: 12,
|
|
41
46
|
minHeight: 64
|
|
42
|
-
}
|
|
43
|
-
photoStyle: {
|
|
44
|
-
width: 42,
|
|
45
|
-
height: 42,
|
|
46
|
-
borderRadius: 7.6
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
return (
|
|
@@ -73,43 +73,14 @@ export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
|
73
73
|
</OText>
|
|
74
74
|
</View>
|
|
75
75
|
</TouchableOpacity>
|
|
76
|
-
{professionals.map((professional: any
|
|
77
|
-
<
|
|
78
|
-
key={
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
borderColor: (professional?.id === professionalSelected?.id)
|
|
85
|
-
? theme.colors.primary
|
|
86
|
-
: theme.colors.border
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
89
|
-
{professional?.photo ? (
|
|
90
|
-
<FastImage
|
|
91
|
-
style={styles.photoStyle}
|
|
92
|
-
source={{
|
|
93
|
-
uri: optimizeImage(professional?.photo, 'h_250,c_limit'),
|
|
94
|
-
priority: FastImage.priority.normal,
|
|
95
|
-
}}
|
|
96
|
-
resizeMode={FastImage.resizeMode.cover}
|
|
97
|
-
/>
|
|
98
|
-
) : (
|
|
99
|
-
<OIcon
|
|
100
|
-
src={theme?.images?.dummies?.product}
|
|
101
|
-
style={styles.photoStyle}
|
|
102
|
-
/>
|
|
103
|
-
)}
|
|
104
|
-
<OText
|
|
105
|
-
size={12}
|
|
106
|
-
style={{ marginLeft: 12 }}
|
|
107
|
-
weight={'400'}
|
|
108
|
-
>
|
|
109
|
-
{professional?.name} {professional?.lastname}
|
|
110
|
-
</OText>
|
|
111
|
-
</View>
|
|
112
|
-
</TouchableOpacity>
|
|
76
|
+
{professionals.map((professional: any) => (
|
|
77
|
+
<SingleProfessionalCard
|
|
78
|
+
key={professional.id}
|
|
79
|
+
professional={professional}
|
|
80
|
+
active={professional?.id === professionalSelected?.id}
|
|
81
|
+
handleProfessionalClick={handleOpenProfile}
|
|
82
|
+
handleUpdateProfessionals={onUpdateProfessionals}
|
|
83
|
+
/>
|
|
113
84
|
))}
|
|
114
85
|
</ScrollView>
|
|
115
86
|
<OModal
|
|
@@ -6,7 +6,7 @@ import CalendarPicker from 'react-native-calendar-picker'
|
|
|
6
6
|
import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
7
7
|
import moment from 'moment'
|
|
8
8
|
import SelectDropdown from 'react-native-select-dropdown'
|
|
9
|
-
import { OButton, OText } from '../shared'
|
|
9
|
+
import { OButton, OText, OIcon } from '../shared'
|
|
10
10
|
import IconAntDesign from 'react-native-vector-icons/AntDesign'
|
|
11
11
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
12
|
import { ProfessionalProfileParams } from '../../types'
|
|
@@ -58,6 +58,9 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
|
|
|
58
58
|
height: 40,
|
|
59
59
|
marginBottom: 30
|
|
60
60
|
},
|
|
61
|
+
photoStyle: {
|
|
62
|
+
alignSelf: 'center'
|
|
63
|
+
}
|
|
61
64
|
})
|
|
62
65
|
|
|
63
66
|
const onDateChange = (date: any) => {
|
|
@@ -144,20 +147,28 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
|
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
useEffect(() => {
|
|
147
|
-
if (selectDate === null) return
|
|
150
|
+
if (selectDate === null || !professional?.schedule) return
|
|
148
151
|
const _times = getTimes(selectDate, professional)
|
|
149
152
|
setTimeList(_times)
|
|
150
153
|
}, [selectDate, professional])
|
|
151
154
|
|
|
152
155
|
return (
|
|
153
156
|
<Container>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
{!!professional?.photo ? (
|
|
158
|
+
<ProfessionalPhoto
|
|
159
|
+
source={{
|
|
160
|
+
uri: professional?.photo
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
) : (
|
|
164
|
+
<OIcon
|
|
165
|
+
src={theme.images.general.user}
|
|
166
|
+
style={styles.photoStyle}
|
|
167
|
+
cover={false}
|
|
168
|
+
width={200}
|
|
169
|
+
height={200}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
161
172
|
<InfoWrapper>
|
|
162
173
|
<OText
|
|
163
174
|
size={20}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
2
|
import { PromotionsController, useLanguage, useUtils } from 'ordering-components/native'
|
|
3
|
+
import FastImage from 'react-native-fast-image'
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
PromotionsContainer,
|
|
6
|
+
SingleOfferContainer,
|
|
7
|
+
OfferInformation,
|
|
8
|
+
SearchBarContainer,
|
|
9
|
+
SingleBusinessOffer,
|
|
10
|
+
AvailableBusinesses,
|
|
11
|
+
OfferData,
|
|
12
|
+
Code,
|
|
13
|
+
BusinessInfo,
|
|
14
|
+
WrapperSingleOffer
|
|
13
15
|
} from './styles'
|
|
14
16
|
import { SearchBar } from '../SearchBar'
|
|
15
17
|
import NavBar from '../NavBar'
|
|
@@ -17,234 +19,246 @@ import { useTheme } from 'styled-components/native';
|
|
|
17
19
|
import { OButton, OIcon, OModal, OText } from '../shared'
|
|
18
20
|
import { Placeholder, PlaceholderLine } from 'rn-placeholder'
|
|
19
21
|
import { NotFoundSource } from '../NotFoundSource'
|
|
20
|
-
import { View, StyleSheet, ScrollView,
|
|
21
|
-
import FastImage from 'react-native-fast-image'
|
|
22
|
+
import { View, StyleSheet, ScrollView, RefreshControl } from 'react-native'
|
|
22
23
|
import { PromotionParams } from '../../types'
|
|
23
24
|
import { Container } from '../../layouts/Container'
|
|
24
25
|
|
|
25
26
|
const PromotionsUI = (props: PromotionParams) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
const {
|
|
28
|
+
navigation,
|
|
29
|
+
offersState,
|
|
30
|
+
handleSearchValue,
|
|
31
|
+
searchValue,
|
|
32
|
+
loadOffers,
|
|
33
|
+
offerSelected,
|
|
34
|
+
setOfferSelected
|
|
35
|
+
} = props
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
const theme = useTheme();
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
productStyle: {
|
|
41
|
+
width: 75,
|
|
42
|
+
height: 75,
|
|
43
|
+
borderRadius: 7.6
|
|
44
|
+
},
|
|
45
|
+
buttonStyle: {
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: 35,
|
|
48
|
+
paddingLeft: 0,
|
|
49
|
+
paddingRight: 0,
|
|
50
|
+
borderRadius: 8
|
|
51
|
+
},
|
|
52
|
+
offerTitle: {
|
|
53
|
+
fontSize: 14
|
|
54
|
+
},
|
|
55
|
+
offerDescription: {
|
|
56
|
+
color: '#909BA9',
|
|
57
|
+
fontSize: 12
|
|
58
|
+
},
|
|
59
|
+
offerExtraInfo: {
|
|
60
|
+
fontSize: 12
|
|
61
|
+
},
|
|
62
|
+
modalButtonStyle: {
|
|
63
|
+
width: 100,
|
|
64
|
+
height: 35,
|
|
65
|
+
paddingLeft: 0,
|
|
66
|
+
paddingRight: 0,
|
|
67
|
+
borderRadius: 7.6
|
|
68
|
+
}
|
|
69
|
+
});
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const [, t] = useLanguage()
|
|
72
|
+
const [{ parseDate, parsePrice, optimizeImage }] = useUtils()
|
|
73
|
+
const [openModal, setOpenModal] = useState(false)
|
|
74
|
+
const [refreshing] = useState(false);
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const handleClickOffer = (offer: any) => {
|
|
77
|
+
setOpenModal(true)
|
|
78
|
+
setOfferSelected(offer)
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const handleBusinessClick = (store: any) => {
|
|
82
|
+
setOpenModal(false)
|
|
83
|
+
navigation.navigate('Business', { store: store.slug })
|
|
84
|
+
}
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
86
|
+
const handleOnRefresh = () => {
|
|
87
|
+
if (!offersState.loading) {
|
|
88
|
+
loadOffers();
|
|
88
89
|
}
|
|
90
|
+
}
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
const filteredOffers = offersState?.offers?.filter((offer: any) => offer.name.toLowerCase().includes(searchValue.toLowerCase()))
|
|
93
|
+
const targetString = offerSelected?.target === 1
|
|
94
|
+
? t('SUBTOTAL', 'Subtotal')
|
|
95
|
+
: offerSelected?.target === 2
|
|
96
|
+
? t('DELIVERY_FEE', 'Delivery fee')
|
|
97
|
+
: t('SERVICE_FEE', 'Service fee')
|
|
96
98
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
return (
|
|
100
|
+
<Container
|
|
101
|
+
noPadding
|
|
102
|
+
pt={20}
|
|
103
|
+
refreshControl={
|
|
104
|
+
<RefreshControl
|
|
105
|
+
refreshing={refreshing}
|
|
106
|
+
onRefresh={() => handleOnRefresh()}
|
|
107
|
+
/>
|
|
108
|
+
}
|
|
109
|
+
>
|
|
110
|
+
<NavBar
|
|
111
|
+
title={t('PROMOTIONS', 'Promotions')}
|
|
112
|
+
titleAlign={'center'}
|
|
113
|
+
onActionLeft={() => navigation.goBack()}
|
|
114
|
+
showCall={false}
|
|
115
|
+
style={{ paddingVertical: 0, marginLeft: 20 }}
|
|
116
|
+
/>
|
|
117
|
+
<PromotionsContainer>
|
|
118
|
+
<SearchBarContainer>
|
|
119
|
+
<SearchBar
|
|
120
|
+
placeholder={t('SEARCH_OFFERS', 'Search offers')}
|
|
121
|
+
onSearch={handleSearchValue}
|
|
122
|
+
/>
|
|
123
|
+
</SearchBarContainer>
|
|
124
|
+
|
|
125
|
+
{offersState?.loading && (
|
|
126
|
+
<>
|
|
127
|
+
{[...Array(5).keys()].map((key, i) => (
|
|
128
|
+
<Placeholder key={i} style={{ flexDirection: 'row', marginBottom: 20 }}>
|
|
129
|
+
<PlaceholderLine height={10} width={45} />
|
|
130
|
+
<PlaceholderLine height={10} width={60} />
|
|
131
|
+
<PlaceholderLine height={10} width={75} />
|
|
132
|
+
</Placeholder>
|
|
133
|
+
))}
|
|
134
|
+
</>
|
|
135
|
+
)}
|
|
136
|
+
{((!offersState?.loading && filteredOffers?.length === 0) || offersState?.error) && (
|
|
137
|
+
<NotFoundSource
|
|
138
|
+
content={offersState?.error || t('NOT_FOUND_OFFERS', 'Not found offers')}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
<ScrollView>
|
|
142
|
+
{!offersState?.loading && offersState.offers?.length > 0 && filteredOffers?.map((offer: any) => (
|
|
143
|
+
<WrapperSingleOffer key={offer.id}>
|
|
144
|
+
<SingleOfferContainer>
|
|
145
|
+
<FastImage
|
|
146
|
+
style={{ height: 80, width: 80, aspectRatio: 3 / 2, borderRadius: 8 }}
|
|
147
|
+
source={typeof offer?.image !== 'number' ? {
|
|
148
|
+
uri: optimizeImage(offer?.image, 'h_1024,c_limit'),
|
|
149
|
+
priority: FastImage.priority.normal,
|
|
150
|
+
} : theme.images?.dummies?.businessLogo}
|
|
104
151
|
/>
|
|
105
|
-
|
|
152
|
+
<OfferInformation>
|
|
153
|
+
<OText style={styles.offerTitle} numberOfLines={2}>{offer?.name}</OText>
|
|
154
|
+
{!!offer?.description && (
|
|
155
|
+
<OText style={styles.offerDescription} numberOfLines={2}>{offer?.description}</OText>
|
|
156
|
+
)}
|
|
157
|
+
<OText style={styles.offerExtraInfo}>
|
|
158
|
+
{t('EXPIRES', 'Expires')} {parseDate(offer?.end, { outputFormat: 'MMM DD, YYYY' })}
|
|
159
|
+
</OText>
|
|
160
|
+
<AvailableBusinesses>
|
|
161
|
+
<OText style={styles.offerExtraInfo} numberOfLines={1}>
|
|
162
|
+
{t('APPLY_FOR', 'Apply for')}:
|
|
163
|
+
{offer.businesses.map((business: any, i: number) => (
|
|
164
|
+
<React.Fragment key={i}>{' '}{business?.name}{i + 1 < offer.businesses?.length ? ',' : ''}</React.Fragment>
|
|
165
|
+
))}
|
|
166
|
+
</OText>
|
|
167
|
+
</AvailableBusinesses>
|
|
168
|
+
</OfferInformation>
|
|
169
|
+
</SingleOfferContainer>
|
|
170
|
+
<OButton
|
|
171
|
+
onClick={() => handleClickOffer(offer)}
|
|
172
|
+
text={t('VIEW', 'View')}
|
|
173
|
+
style={styles.buttonStyle}
|
|
174
|
+
textStyle={{ fontSize: 14, color: '#fff', flexWrap: 'nowrap' }}
|
|
175
|
+
/>
|
|
176
|
+
</WrapperSingleOffer>
|
|
177
|
+
))}
|
|
178
|
+
</ScrollView>
|
|
179
|
+
<OModal
|
|
180
|
+
open={openModal}
|
|
181
|
+
entireModal
|
|
182
|
+
title={``}
|
|
183
|
+
onClose={() => setOpenModal(false)}
|
|
106
184
|
>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
</
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
<OText style={{ alignSelf: 'center', fontWeight: '700' }} mBottom={20}>
|
|
176
|
-
{offerSelected?.name} / {t('VALUE_OF_OFFER', 'Value of offer')}: {offerSelected?.rate_type === 1 ? `${offerSelected?.rate}%` : `${parsePrice(offerSelected?.rate)}`}
|
|
177
|
-
</OText>
|
|
178
|
-
<OfferData>
|
|
179
|
-
{offerSelected?.type === 2 && (
|
|
180
|
-
<Code>
|
|
181
|
-
<OText>{t('YOUR_CODE', 'Your code')}</OText>
|
|
182
|
-
<OText color={theme.colors.primary}>{offerSelected.coupon}</OText>
|
|
183
|
-
</Code>
|
|
184
|
-
)}
|
|
185
|
-
<OText>{t('APPLIES_TO', 'Applies to')}: {targetString}</OText>
|
|
186
|
-
{offerSelected?.auto && (
|
|
187
|
-
<OText>{t('OFFER_AUTOMATIC', 'This offer applies automatic')}</OText>
|
|
188
|
-
)}
|
|
189
|
-
{!!offerSelected?.minimum && (
|
|
190
|
-
<OText>{t('MINIMUM_PURCHASE_FOR_OFFER', 'Minimum purchase for use this offer')}: {parsePrice(offerSelected?.minimum)}</OText>
|
|
191
|
-
)}
|
|
192
|
-
{!!offerSelected?.max_discount && (
|
|
193
|
-
<OText>{t('MAX_DISCOUNT_ALLOWED', 'Max discount allowed')}: {parsePrice(offerSelected?.max_discount)}</OText>
|
|
194
|
-
)}
|
|
195
|
-
{!!offerSelected?.description && (
|
|
196
|
-
<OText>{offerSelected?.description}</OText>
|
|
197
|
-
)}
|
|
198
|
-
</OfferData>
|
|
199
|
-
<OText style={{ marginTop: 10, marginBottom: 10 }}>
|
|
200
|
-
{t('AVAILABLE_BUSINESSES_FOR_OFFER', 'Available businesses for this offer')}:
|
|
201
|
-
</OText>
|
|
202
|
-
<ScrollView style={{ height: '75%' }}>
|
|
203
|
-
{offerSelected?.businesses?.map((business: any) => {
|
|
204
|
-
return (
|
|
205
|
-
<SingleBusinessOffer key={business.id}>
|
|
206
|
-
{business?.logo ? (
|
|
207
|
-
<FastImage
|
|
208
|
-
style={styles.productStyle}
|
|
209
|
-
source={{
|
|
210
|
-
uri: optimizeImage(business?.logo, 'h_250,c_limit'),
|
|
211
|
-
priority: FastImage.priority.normal,
|
|
212
|
-
}}
|
|
213
|
-
resizeMode={FastImage.resizeMode.cover}
|
|
214
|
-
/>
|
|
215
|
-
) : (
|
|
216
|
-
<OIcon
|
|
217
|
-
src={theme?.images?.dummies?.product}
|
|
218
|
-
style={styles.productStyle}
|
|
219
|
-
/>
|
|
220
|
-
)}
|
|
221
|
-
<BusinessInfo>
|
|
222
|
-
<OText style={{ maxWidth: '60%' }}>{business.name}</OText>
|
|
223
|
-
<OButton
|
|
224
|
-
onClick={() => handleBusinessClick(business)}
|
|
225
|
-
text={t('GO_TO_BUSINESSS', 'Go to business')}
|
|
226
|
-
style={styles.modalButtonStyle}
|
|
227
|
-
textStyle={{ fontSize: 10, color: '#fff' }}
|
|
228
|
-
/>
|
|
229
|
-
</BusinessInfo>
|
|
230
|
-
</SingleBusinessOffer>
|
|
231
|
-
)
|
|
232
|
-
})}
|
|
233
|
-
</ScrollView>
|
|
234
|
-
</View>
|
|
235
|
-
</OModal>
|
|
236
|
-
</PromotionsContainer>
|
|
237
|
-
</Container>
|
|
238
|
-
)
|
|
185
|
+
<View style={{ padding: 20 }}>
|
|
186
|
+
<OText style={{ alignSelf: 'center', fontWeight: '700' }} mBottom={20}>
|
|
187
|
+
{offerSelected?.name} / {t('VALUE_OF_OFFER', 'Value of offer')}: {offerSelected?.rate_type === 1 ? `${offerSelected?.rate}%` : `${parsePrice(offerSelected?.rate)}`}
|
|
188
|
+
</OText>
|
|
189
|
+
<OfferData>
|
|
190
|
+
{offerSelected?.type === 2 && (
|
|
191
|
+
<Code>
|
|
192
|
+
<OText>{t('YOUR_CODE', 'Your code')}</OText>
|
|
193
|
+
<OText color={theme.colors.primary}>{offerSelected.coupon}</OText>
|
|
194
|
+
</Code>
|
|
195
|
+
)}
|
|
196
|
+
<OText>{t('APPLIES_TO', 'Applies to')}: {targetString}</OText>
|
|
197
|
+
{offerSelected?.auto && (
|
|
198
|
+
<OText>{t('OFFER_AUTOMATIC', 'This offer applies automatic')}</OText>
|
|
199
|
+
)}
|
|
200
|
+
{!!offerSelected?.minimum && (
|
|
201
|
+
<OText>{t('MINIMUM_PURCHASE_FOR_OFFER', 'Minimum purchase for use this offer')}: {parsePrice(offerSelected?.minimum)}</OText>
|
|
202
|
+
)}
|
|
203
|
+
{!!offerSelected?.max_discount && (
|
|
204
|
+
<OText>{t('MAX_DISCOUNT_ALLOWED', 'Max discount allowed')}: {parsePrice(offerSelected?.max_discount)}</OText>
|
|
205
|
+
)}
|
|
206
|
+
{!!offerSelected?.description && (
|
|
207
|
+
<OText>{offerSelected?.description}</OText>
|
|
208
|
+
)}
|
|
209
|
+
</OfferData>
|
|
210
|
+
<OText style={{ marginTop: 10, marginBottom: 10 }}>
|
|
211
|
+
{t('AVAILABLE_BUSINESSES_FOR_OFFER', 'Available businesses for this offer')}:
|
|
212
|
+
</OText>
|
|
213
|
+
<ScrollView
|
|
214
|
+
showsVerticalScrollIndicator={false}
|
|
215
|
+
style={{ height: '75%' }}
|
|
216
|
+
>
|
|
217
|
+
{offerSelected?.businesses?.map((business: any) => {
|
|
218
|
+
return (
|
|
219
|
+
<SingleBusinessOffer key={business.id}>
|
|
220
|
+
{business?.logo ? (
|
|
221
|
+
<FastImage
|
|
222
|
+
style={styles.productStyle}
|
|
223
|
+
source={{
|
|
224
|
+
uri: optimizeImage(business?.logo, 'h_250,c_limit'),
|
|
225
|
+
priority: FastImage.priority.normal,
|
|
226
|
+
}}
|
|
227
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
228
|
+
/>
|
|
229
|
+
) : (
|
|
230
|
+
<OIcon
|
|
231
|
+
src={theme?.images?.dummies?.product}
|
|
232
|
+
style={styles.productStyle}
|
|
233
|
+
/>
|
|
234
|
+
)}
|
|
235
|
+
<BusinessInfo>
|
|
236
|
+
<OText style={{ maxWidth: '60%' }}>{business.name}</OText>
|
|
237
|
+
<OButton
|
|
238
|
+
onClick={() => handleBusinessClick(business)}
|
|
239
|
+
text={t('GO_TO_BUSINESSS', 'Go to business')}
|
|
240
|
+
style={styles.modalButtonStyle}
|
|
241
|
+
textStyle={{ fontSize: 10, color: '#fff' }}
|
|
242
|
+
/>
|
|
243
|
+
</BusinessInfo>
|
|
244
|
+
</SingleBusinessOffer>
|
|
245
|
+
)
|
|
246
|
+
})}
|
|
247
|
+
</ScrollView>
|
|
248
|
+
</View>
|
|
249
|
+
</OModal>
|
|
250
|
+
</PromotionsContainer>
|
|
251
|
+
</Container>
|
|
252
|
+
)
|
|
239
253
|
}
|
|
240
254
|
|
|
241
255
|
export const Promotions = (props: PromotionParams) => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
256
|
+
const PromotionsProps = {
|
|
257
|
+
...props,
|
|
258
|
+
UIComponent: PromotionsUI
|
|
259
|
+
}
|
|
246
260
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
261
|
+
return (
|
|
262
|
+
<PromotionsController {...PromotionsProps} />
|
|
263
|
+
)
|
|
250
264
|
}
|