ordering-ui-react-native 0.15.57 → 0.15.58-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.
Files changed (182) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessController/index.tsx +16 -8
  5. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +23 -2
  8. package/src/components/DriverTips/index.tsx +11 -6
  9. package/src/components/LanguageSelector/index.tsx +7 -2
  10. package/src/components/LoginForm/index.tsx +120 -30
  11. package/src/components/LoginForm/styles.tsx +6 -0
  12. package/src/components/OrderDetails/index.tsx +7 -21
  13. package/src/components/PaymentOptions/index.tsx +67 -50
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/SignupForm/index.tsx +145 -61
  16. package/src/components/SingleProductCard/index.tsx +16 -4
  17. package/src/components/StripeMethodForm/index.tsx +1 -2
  18. package/src/components/UpsellingProducts/index.tsx +1 -1
  19. package/src/components/UserProfileForm/index.tsx +63 -6
  20. package/src/components/UserProfileForm/styles.tsx +8 -0
  21. package/src/components/VerifyPhone/styles.tsx +1 -2
  22. package/src/components/shared/OModal.tsx +1 -1
  23. package/src/hooks/useCountdownTimer.tsx +26 -0
  24. package/src/navigators/CheckoutNavigator.tsx +6 -0
  25. package/src/navigators/HomeNavigator.tsx +12 -0
  26. package/src/pages/BusinessesListing.tsx +1 -1
  27. package/src/pages/MultiCheckout.tsx +31 -0
  28. package/src/pages/MultiOrdersDetails.tsx +27 -0
  29. package/src/pages/Sessions.tsx +22 -0
  30. package/src/theme.json +0 -1
  31. package/src/types/index.tsx +18 -11
  32. package/src/utils/index.tsx +68 -1
  33. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  34. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  35. package/themes/business/src/components/Chat/index.tsx +42 -90
  36. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  37. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  38. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  39. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  40. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  41. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  42. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  43. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +41 -7
  44. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  45. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  46. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  47. package/themes/business/src/components/PreviousOrders/index.tsx +2 -2
  48. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  49. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  50. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  51. package/themes/business/src/components/shared/OModal.tsx +1 -1
  52. package/themes/business/src/types/index.tsx +6 -1
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  57. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  58. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  59. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  60. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  61. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  62. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  63. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  64. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  65. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  66. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  67. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  68. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  69. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  70. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  71. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  72. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  73. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  74. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  75. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  76. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  77. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  78. package/themes/kiosk/src/types/index.d.ts +1 -0
  79. package/themes/original/index.tsx +22 -8
  80. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  81. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  82. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  83. package/themes/original/src/components/AddressList/index.tsx +30 -18
  84. package/themes/original/src/components/AppleLogin/index.tsx +9 -13
  85. package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
  86. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  87. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  88. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  89. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  90. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  91. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  92. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  93. package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
  94. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  95. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  96. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  97. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  98. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -53
  99. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  100. package/themes/original/src/components/BusinessProductsListing/index.tsx +105 -22
  101. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  102. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  103. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  104. package/themes/original/src/components/BusinessesListing/index.tsx +126 -65
  105. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  106. package/themes/original/src/components/Cart/index.tsx +60 -41
  107. package/themes/original/src/components/Checkout/index.tsx +48 -32
  108. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  109. package/themes/original/src/components/Favorite/index.tsx +92 -0
  110. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  111. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  112. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  113. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  114. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  115. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  116. package/themes/original/src/components/Help/index.tsx +21 -4
  117. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  118. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  119. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  120. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  121. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  122. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  123. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  124. package/themes/original/src/components/Messages/index.tsx +1 -1
  125. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  126. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  127. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  128. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  129. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  130. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  131. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  132. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  133. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  134. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  135. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  136. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  137. package/themes/original/src/components/OrderDetails/index.tsx +135 -49
  138. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  139. package/themes/original/src/components/OrderSummary/index.tsx +2 -2
  140. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  141. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  142. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  143. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  144. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  145. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  146. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  147. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  148. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  149. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  150. package/themes/original/src/components/PaymentOptions/index.tsx +57 -36
  151. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  152. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  153. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  154. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  155. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  156. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  157. package/themes/original/src/components/Promotions/index.tsx +151 -133
  158. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  159. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  160. package/themes/original/src/components/Sessions/index.tsx +160 -0
  161. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  162. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  163. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  164. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  165. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  166. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  167. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  168. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  169. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  170. package/themes/original/src/components/UserFormDetails/index.tsx +25 -26
  171. package/themes/original/src/components/UserProfile/index.tsx +52 -5
  172. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  173. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  174. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  175. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  176. package/themes/original/src/components/Wallets/index.tsx +76 -9
  177. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  178. package/themes/original/src/components/shared/OModal.tsx +4 -2
  179. package/themes/original/src/types/index.tsx +189 -35
  180. package/themes/original/src/utils/index.tsx +85 -2
  181. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  182. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react'
2
- import { PromotionsController, useLanguage, useUtils, useEvent } from 'ordering-components/native'
2
+ import { PromotionsController, useLanguage, useUtils } from 'ordering-components/native'
3
3
  import {
4
4
  PromotionsContainer,
5
5
  SingleOfferContainer,
@@ -17,15 +17,18 @@ import { useTheme } from 'styled-components/native';
17
17
  import { OButton, OIcon, OModal, OText } from '../shared'
18
18
  import { Placeholder, PlaceholderLine } from 'rn-placeholder'
19
19
  import { NotFoundSource } from '../NotFoundSource'
20
- import { View, StyleSheet, ScrollView } from 'react-native'
20
+ import { View, StyleSheet, ScrollView, Platform, RefreshControl } from 'react-native'
21
21
  import FastImage from 'react-native-fast-image'
22
22
  import { PromotionParams } from '../../types'
23
- const PromotionsUI = (props : PromotionParams) => {
23
+ import { Container } from '../../layouts/Container'
24
+
25
+ const PromotionsUI = (props: PromotionParams) => {
24
26
  const {
25
27
  navigation,
26
28
  offersState,
27
29
  handleSearchValue,
28
30
  searchValue,
31
+ loadOffers,
29
32
  offerSelected,
30
33
  setOfferSelected
31
34
  } = props
@@ -65,20 +68,26 @@ const PromotionsUI = (props : PromotionParams) => {
65
68
 
66
69
  const [, t] = useLanguage()
67
70
  const [{ parseDate, parsePrice, optimizeImage }] = useUtils()
68
- const [events] = useEvent()
69
71
  const [openModal, setOpenModal] = useState(false)
72
+ const [refreshing] = useState(false);
70
73
 
71
- const handleClickOffer = (offer : any) => {
74
+ const handleClickOffer = (offer: any) => {
72
75
  setOpenModal(true)
73
76
  setOfferSelected(offer)
74
77
  }
75
78
 
76
- const handleBusinessClick = (business : any) => {
77
- events.emit('go_to_page', { page: 'business', params: { store: business.slug } })
79
+ const handleBusinessClick = (store: any) => {
80
+ setOpenModal(false)
81
+ navigation.navigate('Business', { store: store.slug })
78
82
  }
79
83
 
80
- const filteredOffers = offersState?.offers?.filter((offer : any) => offer.name.toLowerCase().includes(searchValue.toLowerCase()))
84
+ const handleOnRefresh = () => {
85
+ if (!offersState.loading) {
86
+ loadOffers();
87
+ }
88
+ }
81
89
 
90
+ const filteredOffers = offersState?.offers?.filter((offer: any) => offer.name.toLowerCase().includes(searchValue.toLowerCase()))
82
91
  const targetString = offerSelected?.target === 1
83
92
  ? t('SUBTOTAL', 'Subtotal')
84
93
  : offerSelected?.target === 2
@@ -86,141 +95,150 @@ const PromotionsUI = (props : PromotionParams) => {
86
95
  : t('SERVICE_FEE', 'Service fee')
87
96
 
88
97
  return (
89
- <PromotionsContainer>
98
+ <Container
99
+ noPadding
100
+ refreshControl={
101
+ <RefreshControl
102
+ refreshing={refreshing}
103
+ onRefresh={() => handleOnRefresh()}
104
+ />
105
+ }
106
+ >
90
107
  <NavBar
91
- onActionLeft={() => navigation.goBack()}
92
- btnStyle={{ paddingLeft: 0 }}
93
- paddingTop={20}
94
- style={{ paddingBottom: 0, flexDirection: 'column', alignItems: 'flex-start' }}
95
108
  title={t('PROMOTIONS', 'Promotions')}
96
109
  titleAlign={'center'}
97
- titleStyle={{ fontSize: 16, marginRight: 0, marginLeft: 0, marginBottom: 10 }}
98
- titleWrapStyle={{ paddingHorizontal: 0 }}
110
+ onActionLeft={() => navigation.goBack()}
111
+ showCall={false}
112
+ style={{ paddingVertical: Platform.OS === 'ios' ? 0 : 20, marginLeft: 20 }}
99
113
  />
100
- <SearchBarContainer>
101
- <SearchBar
102
- placeholder={t('SEARCH_OFFERS', 'Search offers')}
103
- onSearch={handleSearchValue}
104
- />
105
- </SearchBarContainer>
114
+ <PromotionsContainer>
115
+ <SearchBarContainer>
116
+ <SearchBar
117
+ placeholder={t('SEARCH_OFFERS', 'Search offers')}
118
+ onSearch={handleSearchValue}
119
+ />
120
+ </SearchBarContainer>
106
121
 
107
- {offersState?.loading && (
108
- <>
109
- {[...Array(5).keys()].map((key, i) => (
110
- <Placeholder key={i} style={{ flexDirection: 'row', marginBottom: 20 }}>
111
- <PlaceholderLine height={10} width={45} />
112
- <PlaceholderLine height={10} width={60} />
113
- <PlaceholderLine height={10} width={75} />
114
- </Placeholder>
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>
115
165
  ))}
116
- </>
117
- )}
118
- {((!offersState?.loading && filteredOffers?.length === 0) || offersState?.error) && (
119
- <NotFoundSource
120
- content={offersState?.error || t('NOT_FOUND_OFFERS', 'Not found offers')}
121
- />
122
- )}
123
- <ScrollView>
124
- {!offersState?.loading && offersState.offers?.length > 0 && filteredOffers?.map((offer : any) => (
125
- <SingleOfferContainer key={offer.id}>
126
- <OfferInformation>
127
- <OText style={styles.offerTitle}>{offer?.name}</OText>
128
- {offer?.description && (
129
- <OText style={styles.offerDescription}>{offer?.description}</OText>
130
- )}
131
- <OText style={styles.offerExtraInfo}>
132
- {t('EXPIRES', 'Expires')} {parseDate(offer?.end, { outputFormat: 'MMM DD, YYYY' })}
133
- </OText>
134
- <AvailableBusinesses>
135
- <OText style={styles.offerExtraInfo}>{t('APPLY_FOR', 'Apply for')}:</OText>
136
- {offer.businesses.map((business: any, i: number) => (
137
- <OText style={styles.offerExtraInfo} key={business?.id}>{' '}{business?.name}{i + 1 < offer.businesses?.length ? ',' : ''}</OText>
138
- ))}
139
- </AvailableBusinesses>
140
- </OfferInformation>
141
- <OButton
142
- onClick={() => handleClickOffer(offer)}
143
- text={t('VIEW', 'View')}
144
- style={styles.buttonStyle}
145
- textStyle={{ fontSize: 10, color: '#fff', flexWrap: 'nowrap' }}
146
- />
147
- </SingleOfferContainer>
148
- ))}
149
- </ScrollView>
150
- <OModal
151
- open={openModal}
152
- onClose={() => setOpenModal(false)}
153
- entireModal
166
+ </ScrollView>
167
+ <OModal
168
+ open={openModal}
169
+ onClose={() => setOpenModal(false)}
170
+ entireModal
154
171
 
155
- title={``}
156
- >
157
- <View style={{ padding: 20 }}>
158
- <OText style={{ alignSelf: 'center', fontWeight: '700' }} mBottom={20}>
159
- {offerSelected?.name} / {t('VALUE_OF_OFFER', 'Value of offer')}: {offerSelected?.rate_type === 1 ? `${offerSelected?.rate}%` : `${parsePrice(offerSelected?.rate)}`}
160
- </OText>
161
- <OfferData>
162
- {offerSelected?.type === 2 && (
163
- <Code>
164
- <OText>{t('YOUR_CODE', 'Your code')}</OText>
165
- <OText color={theme.colors.primary}>{offerSelected.coupon}</OText>
166
- </Code>
167
- )}
168
- <OText>{t('APPLIES_TO', 'Applies to')}: {targetString}</OText>
169
- {offerSelected?.auto && (
170
- <OText>{t('OFFER_AUTOMATIC', 'This offer applies automatic')}</OText>
171
- )}
172
- {offerSelected?.minimum && (
173
- <OText>{t('MINIMUM_PURCHASE_FOR_OFFER', 'Minimum purshase for use this offer')}: {parsePrice(offerSelected?.minimum)}</OText>
174
- )}
175
- {offerSelected?.max_discount && (
176
- <OText>{t('MAX_DISCOUNT_ALLOWED', 'Max discount allowed')}: {parsePrice(offerSelected?.max_discount)}</OText>
177
- )}
178
- {offerSelected?.description && (
179
- <OText>{offerSelected?.description}</OText>
180
- )}
181
- </OfferData>
182
- <OText style={{ marginTop: 10, marginBottom: 10 }}>
183
- {t('AVAILABLE_BUSINESSES_FOR_OFFER', 'Available businesses for this offer')}:
184
- </OText>
185
- <ScrollView style={{height: '75%'}}>
186
- {offerSelected?.businesses?.map((business : any) => {
187
- return (
188
- <SingleBusinessOffer key={business.id}>
189
- {business?.logo ? (
190
- <FastImage
191
- style={styles.productStyle}
192
- source={{
193
- uri: optimizeImage(business?.logo, 'h_250,c_limit'),
194
- priority: FastImage.priority.normal,
195
- }}
196
- resizeMode={FastImage.resizeMode.cover}
197
- />
198
- ) : (
199
- <OIcon
200
- src={theme?.images?.dummies?.product}
201
- style={styles.productStyle}
202
- />
203
- )}
204
- <BusinessInfo>
205
- <OText>{business.name}</OText>
206
- <OButton
207
- onClick={() => handleBusinessClick(business)}
208
- text={t('GO_TO_BUSINESSS', 'Go to business')}
209
- style={styles.modalButtonStyle}
210
- textStyle={{ fontSize: 10, color: '#fff' }}
211
- />
212
- </BusinessInfo>
213
- </SingleBusinessOffer>
214
- )
215
- })}
216
- </ScrollView>
217
- </View>
218
- </OModal>
219
- </PromotionsContainer>
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>
220
238
  )
221
239
  }
222
240
 
223
- export const Promotions = (props : PromotionParams) => {
241
+ export const Promotions = (props: PromotionParams) => {
224
242
  const PromotionsProps = {
225
243
  ...props,
226
244
  UIComponent: PromotionsUI
@@ -2,12 +2,13 @@ import styled, { css } from 'styled-components/native'
2
2
 
3
3
  export const PromotionsContainer = styled.View`
4
4
  width: 100%;
5
+ padding-left: 40px;
6
+ padding-right: 40px;
5
7
  `
6
8
 
7
9
  export const SingleOfferContainer = styled.View`
8
10
  flex-direction: row;
9
11
  width: 100%;
10
- height: 80px;
11
12
  justify-content: space-between;
12
13
  align-items: center;
13
14
  margin-bottom: 20px;
@@ -24,15 +25,6 @@ export const SearchBarContainer = styled.View`
24
25
  width: 100%;
25
26
  justify-content: flex-start;
26
27
  margin-bottom: 20px;
27
- .search-bar {
28
- justify-content: flex-start;
29
- input {
30
- width: 100%;
31
- }
32
- }
33
- .clear {
34
- right: 0;
35
- }
36
28
  `
37
29
 
38
30
  export const SingleBusinessOffer = styled.View`
@@ -48,11 +40,6 @@ export const OfferData = styled.View`
48
40
  display: flex;
49
41
  align-items: center;
50
42
  flex-direction: column;
51
- p{
52
- color: #909BA9;
53
- margin: 3px;
54
- font-size: 14px;
55
- }
56
43
  `
57
44
 
58
45
  export const Code = styled.View`
@@ -62,14 +49,7 @@ export const Code = styled.View`
62
49
  margin-bottom: 10px;
63
50
  `
64
51
 
65
- export const ValueOfOffer = styled.View`
66
- p{
67
- font-size: 16px;
68
- }
69
- span{
70
- font-size: 20px;
71
- }
72
- `
52
+ export const ValueOfOffer = styled.View``
73
53
 
74
54
  export const BusinessInfo = styled.View`
75
55
  flex: 1;
@@ -20,7 +20,12 @@ export const SearchBar = (props: any) => {
20
20
  inputStyle,
21
21
  onPress,
22
22
  isDisabled,
23
- iconCustomRight
23
+ iconCustomRight,
24
+ onSubmitEditing,
25
+ blurOnSubmit,
26
+ inputContainerStyles,
27
+ containerStyles,
28
+ hideIcon
24
29
  } = props
25
30
 
26
31
  const theme = useTheme();
@@ -75,19 +80,20 @@ export const SearchBar = (props: any) => {
75
80
  }
76
81
 
77
82
  return (
78
- <Pressable style={[styles.container, { height: height }]}>
83
+ <Pressable style={[styles.container, containerStyles, { height: height }]}>
79
84
  <OInput
80
85
  value={searchValue}
81
86
  onChange={onChangeSearch}
82
- style={styles.inputStyle}
87
+ style={{...styles.inputStyle, ...inputContainerStyles}}
83
88
  placeholder={placeholder}
84
- icon={theme.images.general.search}
89
+ icon={!hideIcon && theme.images.general.search}
85
90
  isDisabled={isDisabled}
86
91
  iconStyle={{ width: 12 }}
87
92
  returnKeyType='done'
88
93
  inputStyle={{padding: 0, paddingTop: Platform.OS == 'android' ? 2 : 0, ...inputStyle}}
89
94
  onPress={() => onPress && onPress()}
90
95
  iconCustomRight={iconCustomRight}
96
+ onSubmitEditing={() => onSubmitEditing && onSubmitEditing()}
91
97
  />
92
98
  {isCancelButtonShow && (
93
99
  <OButton
@@ -0,0 +1,160 @@
1
+ import React, { useState } from 'react'
2
+ import { View, TouchableOpacity } from 'react-native'
3
+ import { useLanguage, useSession, useUtils, Sessions as SessionsController } from 'ordering-components/native'
4
+ import NavBar from '../NavBar'
5
+ import { SessionsParams } from '../../types'
6
+ import { OAlert } from '../../../../../src/components/shared'
7
+ import { OButton, OIcon, OText } from '../shared'
8
+ import { useTheme } from 'styled-components/native'
9
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
10
+ import AntIcon from 'react-native-vector-icons/AntDesign'
11
+
12
+ import {
13
+ SessionsWrapper,
14
+ SessionItem,
15
+ DurationWrapper
16
+ } from './styles'
17
+
18
+ export const SessionsUI = (props: SessionsParams) => {
19
+ const {
20
+ navigation,
21
+ sessionsList,
22
+ actionState,
23
+ handleDeleteSession,
24
+ handleDeleteAllSessions
25
+ } = props
26
+
27
+ const [, t] = useLanguage()
28
+ const [{ user }] = useSession()
29
+ const [{ parseDate }] = useUtils()
30
+ const theme = useTheme()
31
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
32
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
33
+
34
+ const onDeleteSession = (session: any) => {
35
+ setConfirm({
36
+ open: true,
37
+ title: t('WEB_APPNAME', 'Ordering'),
38
+ content: [t('QUESTION_DELETE_SESSION', 'Are you sure to delete this session?')],
39
+ handleOnAccept: () => {
40
+ handleDeleteSession(session)
41
+ setConfirm({ ...confirm, open: false })
42
+ }
43
+ })
44
+ }
45
+
46
+ const onDeleteAllSessions = (isOldUser: any, deleteCurrent: any) => {
47
+ setConfirm({
48
+ open: true,
49
+ title: t('WEB_APPNAME', 'Ordering'),
50
+ content:
51
+ isOldUser
52
+ ? [t('QUESTION_ENABLE_ALL_SESSIONS', 'Are you sure to enable all sessions?')]
53
+ : deleteCurrent
54
+ ? [t('QUESTION_DELETE_ALL_SESSIONS', 'Are you sure that you want to delete all sessions?')]
55
+ : [t('QUESTION_DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Are you sure that you want to delete all sessions except current?')],
56
+ handleOnAccept: () => {
57
+ handleDeleteAllSessions(deleteCurrent)
58
+ setConfirm({ ...confirm, open: false })
59
+ }
60
+ })
61
+ }
62
+
63
+ return (
64
+ <>
65
+ <NavBar
66
+ title={t('SESSIONS', 'Sessions')}
67
+ titleAlign={'center'}
68
+ onActionLeft={goToBack}
69
+ showCall={false}
70
+ paddingTop={10}
71
+ btnStyle={{ paddingLeft: 0 }}
72
+ />
73
+ {user?.session_strategy === 'jwt_session' ? (
74
+ <>
75
+ {sessionsList.loading ? (
76
+ [...Array(5).keys()].map(i => (
77
+ <SessionItem key={i}>
78
+ <Placeholder Animation={Fade}>
79
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
80
+ <View style={{ flex: 1}}>
81
+ <PlaceholderLine width={40} />
82
+ <PlaceholderLine width={40} />
83
+ </View>
84
+ <PlaceholderLine width={5}/>
85
+ </View>
86
+ </Placeholder>
87
+ </SessionItem>
88
+ ))
89
+ ) : (
90
+ sessionsList.sessions.length > 0 ? (
91
+ <SessionsWrapper>
92
+ {sessionsList.sessions.map((session: any) => (
93
+ <SessionItem key={session.id}>
94
+ <DurationWrapper>
95
+ <OText>{parseDate(session.created_at)}</OText>
96
+ <OText>{parseDate(session.valid_thru)}</OText>
97
+ </DurationWrapper>
98
+ {session.current && (
99
+ <OText mLeft={15} style={{ flex: 1 }}>({t('CURRENT', 'Current')})</OText>
100
+ )}
101
+ <TouchableOpacity
102
+ onPress={() => onDeleteSession(session)}
103
+ >
104
+ <AntIcon name='close' size={16} color={theme.colors.red} />
105
+ </TouchableOpacity>
106
+ </SessionItem>
107
+ ))}
108
+ <OButton
109
+ text={t('DELETE_ALL_SESSIONS', 'Delete all sessions')}
110
+ isDisabled={actionState.loading}
111
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
112
+ onClick={() => onDeleteAllSessions(false, true)}
113
+ style={{ borderRadius: 7.6, marginTop: 30 }}
114
+ />
115
+ <OButton
116
+ text={t('DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Delete all sessions except current')}
117
+ isDisabled={actionState.loading}
118
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
119
+ onClick={() => onDeleteAllSessions(false, false)}
120
+ style={{ borderRadius: 7.6, marginTop: 20 }}
121
+ />
122
+ </SessionsWrapper>
123
+ ) : (
124
+ <OText>{t('YOU_DONT_HAVE_ANY_SESSIONS', 'You don\'t have any sessions')}</OText>
125
+ )
126
+ )}
127
+ </>
128
+ ) : (
129
+ <View>
130
+ <OText>
131
+ {t('YOU_DONT_HAVE_ENABLED_THE_SESSIONS', 'You don\'t have enabled the sessions, please active them to have a better control of your sessions.')}
132
+ </OText>
133
+ <OButton
134
+ text={t('ACTIVE_SESSIONS', 'Active sessions')}
135
+ isDisabled={actionState.loading}
136
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
137
+ onClick={() => onDeleteAllSessions(true, false)}
138
+ style={{ borderRadius: 7.6, marginTop: 20 }}
139
+ />
140
+ </View>
141
+ )}
142
+ <OAlert
143
+ open={confirm.open}
144
+ title={confirm.title}
145
+ content={confirm.content}
146
+ onAccept={confirm.handleOnAccept}
147
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
148
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
149
+ />
150
+ </>
151
+ )
152
+ }
153
+
154
+ export const Sessions = (props: SessionsParams) => {
155
+ const sessionsProps = {
156
+ ...props,
157
+ UIComponent: SessionsUI
158
+ }
159
+ return <SessionsController {...sessionsProps} />
160
+ }
@@ -0,0 +1,15 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const SessionsWrapper = styled.View`
4
+ `
5
+ export const SessionItem = styled.View`
6
+ flex-direction: row;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ padding-vertical: 15px;
10
+ border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
11
+ border-bottom-width: 1px;
12
+ `
13
+ export const DurationWrapper = styled.View`
14
+ /* flex-direction: row; */
15
+ `