ordering-ui-react-native 0.15.17 → 0.15.18-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 +5 -3
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessTypeFilter/index.tsx +12 -2
- package/src/components/BusinessTypeFilter/styles.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +0 -1
- package/src/components/LanguageSelector/index.tsx +1 -0
- package/src/components/OrderDetails/index.tsx +26 -5
- package/src/components/PaymentOptions/index.tsx +9 -16
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/ProductForm/index.tsx +1 -1
- package/src/components/ProductForm/styles.tsx +1 -0
- package/src/components/StripeElementsForm/index.tsx +27 -48
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/config.json +0 -2
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/src/pages/Checkout.tsx +1 -1
- package/src/pages/Sessions.tsx +22 -0
- package/src/types/index.tsx +1 -9
- package/src/utils/index.tsx +68 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +56 -8
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +5 -0
- package/themes/business/src/components/Chat/index.tsx +38 -86
- package/themes/business/src/components/Home/index.tsx +128 -55
- package/themes/business/src/components/Home/styles.tsx +8 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
- package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +22 -13
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +150 -89
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
- package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
- package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
- package/themes/business/src/components/OrdersOption/index.tsx +54 -49
- package/themes/business/src/components/PreviousOrders/index.tsx +82 -23
- package/themes/business/src/types/index.tsx +2 -1
- 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/BusinessController/index.tsx +27 -6
- package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
- package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +48 -21
- package/themes/kiosk/src/components/Cart/index.tsx +98 -24
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
- package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
- package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
- package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +6 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
- package/themes/kiosk/src/components/Intro/index.tsx +13 -13
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
- 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/OrderDetails/index.tsx +136 -41
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
- package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
- package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +179 -0
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +56 -18
- package/themes/original/src/components/AppleLogin/index.tsx +117 -78
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
- package/themes/original/src/components/BusinessController/index.tsx +52 -22
- package/themes/original/src/components/BusinessController/styles.tsx +22 -0
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +4 -0
- package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
- package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
- package/themes/original/src/components/BusinessProductsList/index.tsx +129 -22
- package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +92 -37
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +48 -57
- package/themes/original/src/components/Cart/index.tsx +18 -14
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +42 -27
- package/themes/original/src/components/CouponControl/index.tsx +1 -0
- package/themes/original/src/components/DriverTips/index.tsx +1 -1
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
- package/themes/original/src/components/Help/index.tsx +21 -4
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrders/index.tsx +12 -1
- package/themes/original/src/components/LoginForm/index.tsx +73 -2
- package/themes/original/src/components/LoginForm/styles.tsx +6 -1
- package/themes/original/src/components/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/Messages/index.tsx +50 -45
- package/themes/original/src/components/Messages/styles.tsx +1 -3
- package/themes/original/src/components/MomentOption/index.tsx +10 -1
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +107 -111
- package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
- package/themes/original/src/components/OrderProgress/index.tsx +4 -4
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +2 -2
- package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
- package/themes/original/src/components/OrdersOption/index.tsx +25 -33
- package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +10 -4
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
- package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
- package/themes/original/src/components/ProductForm/index.tsx +40 -33
- package/themes/original/src/components/ProductForm/styles.tsx +2 -2
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +5 -3
- package/themes/original/src/components/Promotions/index.tsx +250 -0
- package/themes/original/src/components/Promotions/styles.tsx +60 -0
- package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
- package/themes/original/src/components/TaxInformation/index.tsx +17 -7
- package/themes/original/src/components/UpsellingProducts/index.tsx +87 -71
- package/themes/original/src/components/UserDetails/index.tsx +4 -95
- package/themes/original/src/components/UserFormDetails/index.tsx +32 -31
- package/themes/original/src/components/UserProfile/index.tsx +70 -20
- package/themes/original/src/components/UserProfileForm/index.tsx +28 -24
- package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
- package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +75 -8
- package/themes/original/src/components/Wallets/styles.tsx +21 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
- package/themes/original/src/components/shared/index.tsx +2 -0
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +71 -26
- package/themes/original/src/utils/index.tsx +12 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/StripeMethodForm/index.tsx +0 -168
|
@@ -32,8 +32,6 @@ import {
|
|
|
32
32
|
import { getIconCard, flatArray } from '../../utils';
|
|
33
33
|
|
|
34
34
|
const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
|
|
35
|
-
const methodsPay = ['google_pay', 'apple_pay']
|
|
36
|
-
const stripeDirectMethods = ['stripe_direct', ...methodsPay]
|
|
37
35
|
// const stripeRedirectOptions = [
|
|
38
36
|
// { name: 'Bancontact', value: 'bancontact' },
|
|
39
37
|
// { name: 'Alipay', value: 'alipay' },
|
|
@@ -56,8 +54,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
56
54
|
handlePaymethodClick,
|
|
57
55
|
handlePaymethodDataChange,
|
|
58
56
|
isOpenMethod,
|
|
59
|
-
handlePaymentMethodClickCustom
|
|
60
|
-
handlePlaceOrder
|
|
57
|
+
handlePaymentMethodClickCustom
|
|
61
58
|
} = props
|
|
62
59
|
|
|
63
60
|
const theme = useTheme();
|
|
@@ -125,16 +122,12 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
125
122
|
|
|
126
123
|
useEffect(() => {
|
|
127
124
|
if (props.paySelected && props.paySelected?.data) {
|
|
128
|
-
|
|
125
|
+
requestAnimationFrame(() => {
|
|
126
|
+
setPaymethodData && setPaymethodData(props.paySelected?.data)
|
|
127
|
+
})
|
|
129
128
|
}
|
|
130
129
|
}, [props.paySelected])
|
|
131
130
|
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
|
|
134
|
-
handlePlaceOrder()
|
|
135
|
-
}
|
|
136
|
-
}, [paymethodData, paymethodSelected])
|
|
137
|
-
|
|
138
131
|
const renderPaymethods = ({ item }: any) => {
|
|
139
132
|
return (
|
|
140
133
|
<TouchableOpacity
|
|
@@ -163,7 +156,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
163
156
|
)
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
const excludeIds: any = [32]; //exclude paypal & connect & redirect
|
|
159
|
+
const excludeIds: any = [32, 66]; //exclude paypal & connect & redirect
|
|
167
160
|
|
|
168
161
|
return (
|
|
169
162
|
<PMContainer>
|
|
@@ -296,11 +289,11 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
296
289
|
</KeyboardAvoidingView>
|
|
297
290
|
</OModal>
|
|
298
291
|
|
|
299
|
-
{/* Stripe direct
|
|
292
|
+
{/* Stripe direct */}
|
|
300
293
|
<OModal
|
|
301
294
|
entireModal
|
|
302
295
|
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
303
|
-
open={
|
|
296
|
+
open={isOpenMethod?.paymethod?.gateway === 'stripe_direct' && !paymethodData?.id}
|
|
304
297
|
onClose={() => handlePaymethodClick(null)}
|
|
305
298
|
>
|
|
306
299
|
<KeyboardAvoidingView
|
|
@@ -309,13 +302,10 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
309
302
|
enabled={Platform.OS === 'ios' ? true : false}
|
|
310
303
|
>
|
|
311
304
|
<StripeElementsForm
|
|
312
|
-
cart={cart}
|
|
313
|
-
paymethod={isOpenMethod?.paymethod?.gateway}
|
|
314
|
-
methodsPay={methodsPay}
|
|
315
305
|
businessId={props.businessId}
|
|
316
|
-
publicKey={isOpenMethod?.paymethod?.credentials?.publishable
|
|
306
|
+
publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
|
|
317
307
|
handleSource={handlePaymethodDataChange}
|
|
318
|
-
onCancel={() => handlePaymethodClick(
|
|
308
|
+
onCancel={() => handlePaymethodClick(false)}
|
|
319
309
|
/>
|
|
320
310
|
</KeyboardAvoidingView>
|
|
321
311
|
</OModal>
|
|
@@ -85,7 +85,11 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
85
85
|
order: {
|
|
86
86
|
id: order?.id,
|
|
87
87
|
business_id: order?.business_id,
|
|
88
|
-
logo: order
|
|
88
|
+
logo: order?.business?.logo,
|
|
89
|
+
driver: order?.driver,
|
|
90
|
+
products: order?.products,
|
|
91
|
+
review: order?.review,
|
|
92
|
+
user_review: order?.user_review
|
|
89
93
|
},
|
|
90
94
|
});
|
|
91
95
|
};
|
|
@@ -139,18 +143,20 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
139
143
|
</OText>
|
|
140
144
|
</Information>
|
|
141
145
|
<Status>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
{order.cart && (
|
|
147
|
+
<OButton
|
|
148
|
+
text={t('REORDER', 'Reorder')}
|
|
149
|
+
imgRightSrc={''}
|
|
150
|
+
textStyle={styles.buttonText}
|
|
151
|
+
style={
|
|
152
|
+
reorderLoading && order.id === reorderSelected
|
|
153
|
+
? styles.reorderLoading
|
|
154
|
+
: styles.reorderbutton
|
|
155
|
+
}
|
|
156
|
+
onClick={() => handleReorderClick(order.id)}
|
|
157
|
+
isLoading={reorderLoading && order.id === reorderSelected}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
154
160
|
{allowedOrderStatus.includes(parseInt(order?.status)) &&
|
|
155
161
|
!order.review && (
|
|
156
162
|
<TouchableOpacity
|
|
@@ -46,7 +46,6 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
|
|
|
46
46
|
import { NotFoundSource } from '../NotFoundSource';
|
|
47
47
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
48
48
|
import { useState } from 'react';
|
|
49
|
-
|
|
50
49
|
const windowHeight = Dimensions.get('window').height;
|
|
51
50
|
const windowWidth = Dimensions.get('window').width;
|
|
52
51
|
|
|
@@ -291,15 +290,23 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
291
290
|
if (img?.video) {
|
|
292
291
|
const keys = img?.video.split('/')
|
|
293
292
|
let _videoId = keys[keys.length - 1]
|
|
293
|
+
|
|
294
294
|
if (_videoId.includes('watch')) {
|
|
295
295
|
const __url = _videoId.split('=')[1]
|
|
296
296
|
_videoId = __url
|
|
297
|
-
}
|
|
298
|
-
if (_videoId.includes('?')) {
|
|
297
|
+
} else if (_videoId.includes('?')) {
|
|
299
298
|
const __url = _videoId.split('?')[0]
|
|
300
299
|
_videoId = __url
|
|
301
300
|
}
|
|
302
|
-
|
|
301
|
+
|
|
302
|
+
if (_videoId.search(/&/i) >= 0) {
|
|
303
|
+
_videoId = _videoId.split('&')[0]
|
|
304
|
+
} else if (_videoId.search(/\?/i) >= 0) {
|
|
305
|
+
_videoId = _videoId.split('?')[0]
|
|
306
|
+
}
|
|
307
|
+
if ((_videoId.length === 11)) {
|
|
308
|
+
videoList.push(_videoId)
|
|
309
|
+
}
|
|
303
310
|
}
|
|
304
311
|
}
|
|
305
312
|
}
|
|
@@ -319,28 +326,9 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
319
326
|
|
|
320
327
|
const ExtraOptions = ({ eID, options }: any) => (
|
|
321
328
|
<>
|
|
322
|
-
{
|
|
323
|
-
<TouchableOpacity
|
|
324
|
-
key={`eopt_all_00`}
|
|
325
|
-
onPress={() => setSelectedOpt(-1)}
|
|
326
|
-
style={[
|
|
327
|
-
styles.extraItem,
|
|
328
|
-
{
|
|
329
|
-
borderBottomColor:
|
|
330
|
-
selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
|
|
331
|
-
},
|
|
332
|
-
]}>
|
|
333
|
-
<OText
|
|
334
|
-
color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
|
|
335
|
-
size={selOpt == -1 ? 14 : 12}
|
|
336
|
-
weight={selOpt == -1 ? '600' : 'normal'}>
|
|
337
|
-
{t('INGREDIENTS', 'Ingredients')}
|
|
338
|
-
</OText>
|
|
339
|
-
</TouchableOpacity>
|
|
340
|
-
)}
|
|
341
|
-
{options.map(({ id, name, respect_to }: any) => (
|
|
329
|
+
{options.map(({ id, name, respect_to, suboptions }: any) => (
|
|
342
330
|
<React.Fragment key={`cont_key_${id}`}>
|
|
343
|
-
{respect_to == null && (
|
|
331
|
+
{respect_to == null && suboptions?.length > 0 && (
|
|
344
332
|
<TouchableOpacity
|
|
345
333
|
key={`eopt_key_${id}`}
|
|
346
334
|
onPress={() => setSelectedOpt(id)}
|
|
@@ -658,6 +646,25 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
658
646
|
{t('ALL', 'All')}
|
|
659
647
|
</OText>
|
|
660
648
|
</TouchableOpacity>
|
|
649
|
+
{product?.ingredients.length > 0 && (
|
|
650
|
+
<TouchableOpacity
|
|
651
|
+
key={`eopt_all_00`}
|
|
652
|
+
onPress={() => setSelectedOpt(-1)}
|
|
653
|
+
style={[
|
|
654
|
+
styles.extraItem,
|
|
655
|
+
{
|
|
656
|
+
borderBottomColor:
|
|
657
|
+
selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
|
|
658
|
+
},
|
|
659
|
+
]}>
|
|
660
|
+
<OText
|
|
661
|
+
color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
|
|
662
|
+
size={selOpt == -1 ? 14 : 12}
|
|
663
|
+
weight={selOpt == -1 ? '600' : 'normal'}>
|
|
664
|
+
{t('INGREDIENTS', 'Ingredients')}
|
|
665
|
+
</OText>
|
|
666
|
+
</TouchableOpacity>
|
|
667
|
+
)}
|
|
661
668
|
{product?.extras.map((extra: any) =>
|
|
662
669
|
<ExtraOptions key={extra.id} options={extra.options} />
|
|
663
670
|
)}
|
|
@@ -687,8 +694,8 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
687
694
|
</WrapperIngredients>
|
|
688
695
|
</View>
|
|
689
696
|
)}
|
|
690
|
-
{product?.extras.map((extra: any) =>
|
|
691
|
-
extra.options.map((option: any) => {
|
|
697
|
+
{product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
|
|
698
|
+
extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
|
|
692
699
|
const currentState =
|
|
693
700
|
productCart.options[`id:${option.id}`] || {};
|
|
694
701
|
return (
|
|
@@ -704,7 +711,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
704
711
|
backgroundColor: isError(option.id),
|
|
705
712
|
borderRadius: 7.6
|
|
706
713
|
}}>
|
|
707
|
-
{option.suboptions.map(
|
|
714
|
+
{option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
|
|
708
715
|
(suboption: any) => {
|
|
709
716
|
const currentState =
|
|
710
717
|
productCart.options[
|
|
@@ -772,7 +779,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
772
779
|
) : (
|
|
773
780
|
<>
|
|
774
781
|
{product?.extras.map((extra: any) =>
|
|
775
|
-
extra.options.map((option: any) => {
|
|
782
|
+
extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
|
|
776
783
|
if (
|
|
777
784
|
option.id == selOpt ||
|
|
778
785
|
(hasRespected(
|
|
@@ -797,7 +804,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
797
804
|
option.id,
|
|
798
805
|
),
|
|
799
806
|
}}>
|
|
800
|
-
{option.suboptions.map(
|
|
807
|
+
{option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
|
|
801
808
|
(suboption: any) => {
|
|
802
809
|
const currentState =
|
|
803
810
|
productCart.options[
|
|
@@ -991,14 +998,14 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
991
998
|
? t('UPDATE', 'Update')
|
|
992
999
|
: t('ADD', 'Add')
|
|
993
1000
|
}`}
|
|
994
|
-
isDisabled={isSoldOut || maxProductQuantity <= 0 || productCart?.quantity < product?.minimum_per_order || productCart?.quantity > product?.maximum_per_order}
|
|
1001
|
+
isDisabled={isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order))}
|
|
995
1002
|
textStyle={{
|
|
996
1003
|
color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
|
|
997
1004
|
fontSize: orderState.loading || editMode ? 10 : 14
|
|
998
1005
|
}}
|
|
999
1006
|
style={{
|
|
1000
|
-
backgroundColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || productCart?.quantity < product?.minimum_per_order || productCart?.quantity > product?.maximum_per_order ? theme.colors.lightGray : theme.colors.primary,
|
|
1001
|
-
borderColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || productCart?.quantity < product?.minimum_per_order || productCart?.quantity > product?.maximum_per_order ? theme.colors.white : theme.colors.primary,
|
|
1007
|
+
backgroundColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order)) ? theme.colors.lightGray : theme.colors.primary,
|
|
1008
|
+
borderColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order)) ? theme.colors.white : theme.colors.primary,
|
|
1002
1009
|
opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
|
|
1003
1010
|
borderRadius: 7.6,
|
|
1004
1011
|
height: 44,
|
|
@@ -6,9 +6,10 @@ export const WrapHeader = styled.View`
|
|
|
6
6
|
`
|
|
7
7
|
|
|
8
8
|
export const TopActions = styled.TouchableOpacity`
|
|
9
|
-
height:
|
|
9
|
+
height: 60px;
|
|
10
10
|
justify-content: center;
|
|
11
11
|
padding-horizontal: 30px;
|
|
12
|
+
width: 80px;
|
|
12
13
|
`;
|
|
13
14
|
|
|
14
15
|
export const TopHeader = styled.View`
|
|
@@ -48,7 +49,6 @@ export const ProductDescription = styled.View`
|
|
|
48
49
|
`
|
|
49
50
|
|
|
50
51
|
export const ProductEditions = styled.View`
|
|
51
|
-
|
|
52
52
|
`
|
|
53
53
|
|
|
54
54
|
export const SectionTitle = styled.View`
|
|
@@ -128,9 +128,11 @@ export const ProductOptionSubOptionUI = (props: any) => {
|
|
|
128
128
|
</>
|
|
129
129
|
)}
|
|
130
130
|
</PositionControl>
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
{price > 0 && (
|
|
132
|
+
<OText size={12} lineHeight={18} color={theme.colors.textSecondary}>
|
|
133
|
+
+ {parsePrice(price)}
|
|
134
|
+
</OText>
|
|
135
|
+
)}
|
|
134
136
|
</Container>
|
|
135
137
|
{showMessage && <OText size={10} mLeft={4} mRight={4} style={{ flex: 1, textAlign: 'center' }} color={theme.colors.primary}>{`${t('OPTIONS_MAX_LIMIT', 'Maximum options to choose')}: ${option?.max}`}</OText>}
|
|
136
138
|
</View>
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { PromotionsController, useLanguage, useUtils } from 'ordering-components/native'
|
|
3
|
+
import {
|
|
4
|
+
PromotionsContainer,
|
|
5
|
+
SingleOfferContainer,
|
|
6
|
+
OfferInformation,
|
|
7
|
+
SearchBarContainer,
|
|
8
|
+
SingleBusinessOffer,
|
|
9
|
+
AvailableBusinesses,
|
|
10
|
+
OfferData,
|
|
11
|
+
Code,
|
|
12
|
+
BusinessInfo
|
|
13
|
+
} from './styles'
|
|
14
|
+
import { SearchBar } from '../SearchBar'
|
|
15
|
+
import NavBar from '../NavBar'
|
|
16
|
+
import { useTheme } from 'styled-components/native';
|
|
17
|
+
import { OButton, OIcon, OModal, OText } from '../shared'
|
|
18
|
+
import { Placeholder, PlaceholderLine } from 'rn-placeholder'
|
|
19
|
+
import { NotFoundSource } from '../NotFoundSource'
|
|
20
|
+
import { View, StyleSheet, ScrollView, Platform, RefreshControl } from 'react-native'
|
|
21
|
+
import FastImage from 'react-native-fast-image'
|
|
22
|
+
import { PromotionParams } from '../../types'
|
|
23
|
+
import { Container } from '../../layouts/Container'
|
|
24
|
+
|
|
25
|
+
const PromotionsUI = (props: PromotionParams) => {
|
|
26
|
+
const {
|
|
27
|
+
navigation,
|
|
28
|
+
offersState,
|
|
29
|
+
handleSearchValue,
|
|
30
|
+
searchValue,
|
|
31
|
+
loadOffers,
|
|
32
|
+
offerSelected,
|
|
33
|
+
setOfferSelected
|
|
34
|
+
} = props
|
|
35
|
+
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
productStyle: {
|
|
40
|
+
width: 75,
|
|
41
|
+
height: 75,
|
|
42
|
+
borderRadius: 7.6
|
|
43
|
+
},
|
|
44
|
+
buttonStyle: {
|
|
45
|
+
width: 55,
|
|
46
|
+
height: 25,
|
|
47
|
+
paddingLeft: 0,
|
|
48
|
+
paddingRight: 0
|
|
49
|
+
},
|
|
50
|
+
offerTitle: {
|
|
51
|
+
fontSize: 12
|
|
52
|
+
},
|
|
53
|
+
offerDescription: {
|
|
54
|
+
color: '#909BA9',
|
|
55
|
+
fontSize: 10
|
|
56
|
+
},
|
|
57
|
+
offerExtraInfo: {
|
|
58
|
+
fontSize: 10
|
|
59
|
+
},
|
|
60
|
+
modalButtonStyle: {
|
|
61
|
+
width: 100,
|
|
62
|
+
height: 35,
|
|
63
|
+
paddingLeft: 0,
|
|
64
|
+
paddingRight: 0,
|
|
65
|
+
borderRadius: 7.6
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const [, t] = useLanguage()
|
|
70
|
+
const [{ parseDate, parsePrice, optimizeImage }] = useUtils()
|
|
71
|
+
const [openModal, setOpenModal] = useState(false)
|
|
72
|
+
const [refreshing] = useState(false);
|
|
73
|
+
|
|
74
|
+
const handleClickOffer = (offer: any) => {
|
|
75
|
+
setOpenModal(true)
|
|
76
|
+
setOfferSelected(offer)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const handleBusinessClick = (store: any) => {
|
|
80
|
+
setOpenModal(false)
|
|
81
|
+
navigation.navigate('Business', { store: store.slug })
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const handleOnRefresh = () => {
|
|
85
|
+
if (!offersState.loading) {
|
|
86
|
+
loadOffers();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const filteredOffers = offersState?.offers?.filter((offer: any) => offer.name.toLowerCase().includes(searchValue.toLowerCase()))
|
|
91
|
+
const targetString = offerSelected?.target === 1
|
|
92
|
+
? t('SUBTOTAL', 'Subtotal')
|
|
93
|
+
: offerSelected?.target === 2
|
|
94
|
+
? t('DELIVERY_FEE', 'Delivery fee')
|
|
95
|
+
: t('SERVICE_FEE', 'Service fee')
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Container
|
|
99
|
+
noPadding
|
|
100
|
+
refreshControl={
|
|
101
|
+
<RefreshControl
|
|
102
|
+
refreshing={refreshing}
|
|
103
|
+
onRefresh={() => handleOnRefresh()}
|
|
104
|
+
/>
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
<NavBar
|
|
108
|
+
title={t('PROMOTIONS', 'Promotions')}
|
|
109
|
+
titleAlign={'center'}
|
|
110
|
+
onActionLeft={() => navigation.goBack()}
|
|
111
|
+
showCall={false}
|
|
112
|
+
style={{ paddingVertical: Platform.OS === 'ios' ? 0 : 20, marginLeft: 20 }}
|
|
113
|
+
/>
|
|
114
|
+
<PromotionsContainer>
|
|
115
|
+
<SearchBarContainer>
|
|
116
|
+
<SearchBar
|
|
117
|
+
placeholder={t('SEARCH_OFFERS', 'Search offers')}
|
|
118
|
+
onSearch={handleSearchValue}
|
|
119
|
+
/>
|
|
120
|
+
</SearchBarContainer>
|
|
121
|
+
|
|
122
|
+
{offersState?.loading && (
|
|
123
|
+
<>
|
|
124
|
+
{[...Array(5).keys()].map((key, i) => (
|
|
125
|
+
<Placeholder key={i} style={{ flexDirection: 'row', marginBottom: 20 }}>
|
|
126
|
+
<PlaceholderLine height={10} width={45} />
|
|
127
|
+
<PlaceholderLine height={10} width={60} />
|
|
128
|
+
<PlaceholderLine height={10} width={75} />
|
|
129
|
+
</Placeholder>
|
|
130
|
+
))}
|
|
131
|
+
</>
|
|
132
|
+
)}
|
|
133
|
+
{((!offersState?.loading && filteredOffers?.length === 0) || offersState?.error) && (
|
|
134
|
+
<NotFoundSource
|
|
135
|
+
content={offersState?.error || t('NOT_FOUND_OFFERS', 'Not found offers')}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
<ScrollView>
|
|
139
|
+
{!offersState?.loading && offersState.offers?.length > 0 && filteredOffers?.map((offer: any) => (
|
|
140
|
+
<SingleOfferContainer key={offer.id}>
|
|
141
|
+
<OfferInformation>
|
|
142
|
+
<OText style={styles.offerTitle} numberOfLines={2}>{offer?.name}</OText>
|
|
143
|
+
{!!offer?.description && (
|
|
144
|
+
<OText style={styles.offerDescription} numberOfLines={2}>{offer?.description}</OText>
|
|
145
|
+
)}
|
|
146
|
+
<OText style={styles.offerExtraInfo}>
|
|
147
|
+
{t('EXPIRES', 'Expires')} {parseDate(offer?.end, { outputFormat: 'MMM DD, YYYY' })}
|
|
148
|
+
</OText>
|
|
149
|
+
<AvailableBusinesses>
|
|
150
|
+
<OText style={styles.offerExtraInfo} numberOfLines={1}>
|
|
151
|
+
{t('APPLY_FOR', 'Apply for')}:
|
|
152
|
+
{offer.businesses.map((business: any, i: number) => (
|
|
153
|
+
<React.Fragment key={i}>{' '}{business?.name}{i + 1 < offer.businesses?.length ? ',' : ''}</React.Fragment>
|
|
154
|
+
))}
|
|
155
|
+
</OText>
|
|
156
|
+
</AvailableBusinesses>
|
|
157
|
+
</OfferInformation>
|
|
158
|
+
<OButton
|
|
159
|
+
onClick={() => handleClickOffer(offer)}
|
|
160
|
+
text={t('VIEW', 'View')}
|
|
161
|
+
style={styles.buttonStyle}
|
|
162
|
+
textStyle={{ fontSize: 10, color: '#fff', flexWrap: 'nowrap' }}
|
|
163
|
+
/>
|
|
164
|
+
</SingleOfferContainer>
|
|
165
|
+
))}
|
|
166
|
+
</ScrollView>
|
|
167
|
+
<OModal
|
|
168
|
+
open={openModal}
|
|
169
|
+
onClose={() => setOpenModal(false)}
|
|
170
|
+
entireModal
|
|
171
|
+
|
|
172
|
+
title={``}
|
|
173
|
+
>
|
|
174
|
+
<View style={{ padding: 20 }}>
|
|
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
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export const Promotions = (props: PromotionParams) => {
|
|
242
|
+
const PromotionsProps = {
|
|
243
|
+
...props,
|
|
244
|
+
UIComponent: PromotionsUI
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<PromotionsController {...PromotionsProps} />
|
|
249
|
+
)
|
|
250
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const PromotionsContainer = styled.View`
|
|
4
|
+
width: 100%;
|
|
5
|
+
padding-left: 40px;
|
|
6
|
+
padding-right: 40px;
|
|
7
|
+
`
|
|
8
|
+
|
|
9
|
+
export const SingleOfferContainer = styled.View`
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
width: 100%;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
align-items: center;
|
|
14
|
+
margin-bottom: 20px;
|
|
15
|
+
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
export const OfferInformation = styled.View`
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
max-width: 75%;
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export const SearchBarContainer = styled.View`
|
|
24
|
+
display: flex;
|
|
25
|
+
width: 100%;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
margin-bottom: 20px;
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
export const SingleBusinessOffer = styled.View`
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
`
|
|
33
|
+
|
|
34
|
+
export const AvailableBusinesses = styled.View`
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
export const OfferData = styled.View`
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
`
|
|
44
|
+
|
|
45
|
+
export const Code = styled.View`
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
align-items: center;
|
|
49
|
+
margin-bottom: 10px;
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
export const ValueOfOffer = styled.View``
|
|
53
|
+
|
|
54
|
+
export const BusinessInfo = styled.View`
|
|
55
|
+
flex: 1;
|
|
56
|
+
flex-direction: row;
|
|
57
|
+
justify-content: space-between;
|
|
58
|
+
align-items: center;
|
|
59
|
+
margin-left: 10px;
|
|
60
|
+
`
|