ordering-ui-react-native 0.15.29 → 0.15.30-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 (171) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/LoginForm/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +2 -2
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/SignupForm/index.tsx +3 -1
  14. package/src/components/SingleProductCard/index.tsx +16 -4
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/UpsellingProducts/index.tsx +1 -1
  17. package/src/components/UserProfileForm/index.tsx +63 -6
  18. package/src/components/UserProfileForm/styles.tsx +8 -0
  19. package/src/components/VerifyPhone/styles.tsx +1 -2
  20. package/src/components/shared/OModal.tsx +1 -1
  21. package/src/config.json +0 -2
  22. package/src/hooks/useCountdownTimer.tsx +26 -0
  23. package/src/navigators/HomeNavigator.tsx +6 -0
  24. package/src/pages/BusinessProductsList.tsx +1 -0
  25. package/src/pages/BusinessesListing.tsx +1 -1
  26. package/src/pages/Checkout.tsx +1 -1
  27. package/src/pages/Sessions.tsx +22 -0
  28. package/src/types/index.tsx +5 -11
  29. package/src/utils/index.tsx +68 -1
  30. package/themes/business/index.tsx +2 -0
  31. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  32. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  33. package/themes/business/src/components/Chat/index.tsx +38 -86
  34. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  35. package/themes/business/src/components/Home/index.tsx +128 -55
  36. package/themes/business/src/components/Home/styles.tsx +8 -1
  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 +79 -105
  41. package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
  42. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  43. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +151 -89
  44. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
  45. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  46. package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
  47. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  48. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  49. package/themes/business/src/components/OrdersOption/index.tsx +58 -51
  50. package/themes/business/src/components/PreviousOrders/index.tsx +75 -22
  51. package/themes/business/src/components/shared/OModal.tsx +1 -1
  52. package/themes/business/src/types/index.tsx +5 -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/Cart/index.tsx +98 -24
  57. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  58. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  59. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  60. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  61. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  62. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  63. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  64. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  65. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  66. package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
  67. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  68. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  69. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  70. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
  71. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  72. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  73. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  74. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  75. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  76. package/themes/kiosk/src/types/index.d.ts +2 -0
  77. package/themes/original/index.tsx +178 -1
  78. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  79. package/themes/original/src/components/AddressList/index.tsx +56 -18
  80. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  81. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  82. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  83. package/themes/original/src/components/BusinessController/index.tsx +52 -22
  84. package/themes/original/src/components/BusinessController/styles.tsx +22 -0
  85. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  86. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  87. package/themes/original/src/components/BusinessListingSearch/index.tsx +121 -7
  88. package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
  89. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  90. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  91. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  92. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  93. package/themes/original/src/components/BusinessProductsList/index.tsx +132 -35
  94. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  95. package/themes/original/src/components/BusinessProductsListing/index.tsx +118 -37
  96. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  97. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  98. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  99. package/themes/original/src/components/BusinessesListing/index.tsx +74 -70
  100. package/themes/original/src/components/Cart/index.tsx +21 -17
  101. package/themes/original/src/components/CartContent/index.tsx +2 -2
  102. package/themes/original/src/components/Checkout/index.tsx +59 -48
  103. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  104. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  105. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  106. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  107. package/themes/original/src/components/Help/index.tsx +21 -4
  108. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
  109. package/themes/original/src/components/Home/index.tsx +1 -1
  110. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  111. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  112. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  113. package/themes/original/src/components/LoginForm/index.tsx +394 -155
  114. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  115. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  116. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  117. package/themes/original/src/components/Messages/index.tsx +34 -25
  118. package/themes/original/src/components/Messages/styles.tsx +1 -3
  119. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  120. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  121. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  122. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  123. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  124. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  125. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  126. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  127. package/themes/original/src/components/OrdersOption/index.tsx +55 -58
  128. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  129. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  130. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  131. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  132. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  133. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  134. package/themes/original/src/components/PreviousOrders/index.tsx +16 -14
  135. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  136. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  137. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  138. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  139. package/themes/original/src/components/Promotions/index.tsx +250 -0
  140. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  141. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  142. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  143. package/themes/original/src/components/SearchBar/index.tsx +4 -1
  144. package/themes/original/src/components/Sessions/index.tsx +160 -0
  145. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  146. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  147. package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
  148. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  149. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -74
  150. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  151. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  152. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  153. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  154. package/themes/original/src/components/UserProfile/index.tsx +62 -14
  155. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  156. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  157. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  158. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  159. package/themes/original/src/components/Wallets/index.tsx +76 -9
  160. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  161. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  162. package/themes/original/src/components/shared/OModal.tsx +1 -1
  163. package/themes/original/src/components/shared/index.tsx +2 -0
  164. package/themes/original/src/config/constants.tsx +6 -6
  165. package/themes/original/src/types/index.tsx +68 -6
  166. package/themes/original/src/utils/index.tsx +28 -2
  167. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  168. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  169. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  170. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  171. package/src/components/StripeMethodForm/index.tsx +0 -174
@@ -6,9 +6,10 @@ export const WrapHeader = styled.View`
6
6
  `
7
7
 
8
8
  export const TopActions = styled.TouchableOpacity`
9
- height: 44px;
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`
@@ -40,7 +40,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
40
40
 
41
41
  const pickerStyle = StyleSheet.create({
42
42
  inputAndroid: {
43
- width: 27,
43
+ width: 34,
44
44
  textAlign: 'center',
45
45
  overflow: 'visible',
46
46
  fontSize: 12,
@@ -49,7 +49,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
49
49
  color: theme.colors.textNormal
50
50
  },
51
51
  inputIOS: {
52
- width: 27,
52
+ width: 34,
53
53
  textAlign: 'center',
54
54
  overflow: 'visible',
55
55
  fontSize: 12,
@@ -28,36 +28,40 @@ export const ProductOptionSubOptionUI = (props: any) => {
28
28
  toggleSelect,
29
29
  changePosition,
30
30
  disabled,
31
- error,
32
- scrollDown
31
+ setIsScrollAvailable
33
32
  } = props
34
33
 
34
+ const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
35
+ const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
36
+
35
37
  const theme = useTheme();
36
-
37
38
  const [, t] = useLanguage()
38
39
  const [{ parsePrice }] = useUtils()
39
40
  const [showMessage, setShowMessage] = useState(false)
41
+ const [isDirty, setIsDirty] = useState(false)
40
42
 
41
43
  const handleSuboptionClick = () => {
42
44
  toggleSelect()
43
-
44
- if (balance === option?.max - 1 && !state.selected) {
45
- scrollDown(option?.id)
46
- }
45
+ setIsDirty(true)
47
46
 
48
47
  if (balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1)) {
49
48
  setShowMessage(true)
50
49
  }
51
50
  }
52
51
 
52
+ useEffect(() => {
53
+ if (balance === option?.max && state?.selected && isDirty) {
54
+ setIsDirty(false)
55
+ setIsScrollAvailable(option?.id)
56
+ }
57
+ }, [state?.selected])
58
+
53
59
  useEffect(() => {
54
60
  if (!(balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1))) {
55
61
  setShowMessage(false)
56
62
  }
57
63
  }, [balance])
58
64
 
59
- const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
60
- const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
61
65
  return (
62
66
  <View>
63
67
  <Container onPress={() => handleSuboptionClick()}>
@@ -130,9 +134,11 @@ export const ProductOptionSubOptionUI = (props: any) => {
130
134
  </>
131
135
  )}
132
136
  </PositionControl>
133
- <OText size={12} lineHeight={18} color={theme.colors.textSecondary}>
134
- + {parsePrice(price)}
135
- </OText>
137
+ {price > 0 && (
138
+ <OText size={12} lineHeight={18} color={theme.colors.textSecondary}>
139
+ + {parsePrice(price)}
140
+ </OText>
141
+ )}
136
142
  </Container>
137
143
  {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>}
138
144
  </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
+ `
@@ -43,7 +43,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
43
43
  logoWrapper: {
44
44
  shadowColor: theme.colors.black,
45
45
  shadowRadius: 3,
46
- shadowOffset: {width: 1, height: 4},
46
+ shadowOffset: { width: 1, height: 4 },
47
47
  elevation: 3,
48
48
  borderRadius: 8,
49
49
  shadowOpacity: 0.1,
@@ -108,11 +108,11 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
108
108
  }
109
109
 
110
110
  const qualificationList = [
111
- { key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
111
+ { key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
112
112
  { key: 2, text: t('BAD', 'Bad'), percent: 0.25, parentStyle: { left: '25%' }, isInnerStyle: true, pointerColor: true },
113
113
  { key: 3, text: t('OKAY', 'Okay'), percent: 0.5, parentStyle: { left: '50%' }, isInnerStyle: true, pointerColor: true },
114
114
  { key: 4, text: t('GOOD', 'Good'), percent: 0.75, parentStyle: { left: '75%' }, isInnerStyle: true, pointerColor: true },
115
- { key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
115
+ { key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
116
116
  ]
117
117
 
118
118
  const commentsList = reviewCommentList('order')
@@ -137,7 +137,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
137
137
  return found
138
138
  }
139
139
 
140
- const handleContinueClick = () => {
140
+ const handleContinueClick = () => {
141
141
  if (!order?.review) {
142
142
  onSubmit()
143
143
  } else {
@@ -183,7 +183,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
183
183
  comments.map(comment => _comments += comment.content + '. ')
184
184
  }
185
185
  let _comment
186
- _comment = _comments + extraComment
186
+ _comment = _comments + extraComment
187
187
  setStars({ ...stars, comments: _comment })
188
188
  }, [comments, extraComment])
189
189
 
@@ -214,7 +214,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
214
214
  <OText color={theme.colors.primary}>{t('ORDER_REVIEWED', 'This order has been already reviewed')}</OText>
215
215
  </View>
216
216
  ) : (
217
- <View style={{flex: 1, justifyContent: 'flex-end'}}>
217
+ <View style={{ flex: 1, justifyContent: 'flex-end' }}>
218
218
  <FormReviews>
219
219
  <OText mBottom={13} color={theme.colors.textNormal}>{t('HOW_WAS_YOUR_ORDER', 'How was your order?')}</OText>
220
220
  <RatingBarContainer>
@@ -266,7 +266,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
266
266
  style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
267
267
  imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
268
268
  imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
269
- onClick={() => handleChangeComment(commentItem) }
269
+ onClick={() => handleChangeComment(commentItem)}
270
270
  />
271
271
  ))}
272
272
  </CommentsButtonGroup>
@@ -304,7 +304,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
304
304
  textStyle={{ color: theme.colors.white, paddingRight: 10 }}
305
305
  text={t('CONTINUE', 'Continue')}
306
306
  style={{ borderRadius: 8 }}
307
- imgRightSrc={theme.images.general.arrow_right}
307
+ imgRightSrc={theme.images.general.arrow_right}
308
308
  imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
309
309
  onClick={handleSubmit(handleContinueClick)}
310
310
  />
@@ -317,7 +317,8 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
317
317
  export const ReviewOrder = (props: ReviewOrderParams) => {
318
318
  const reviewOrderProps = {
319
319
  ...props,
320
- UIComponent: ReviewOrderUI
320
+ UIComponent: ReviewOrderUI,
321
+ defaultStar: 5
321
322
  }
322
323
  return <ReviewOrderController {...reviewOrderProps} />
323
324
  }
@@ -74,7 +74,7 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
74
74
  titleWrapStyle={{ paddingHorizontal: 0 }}
75
75
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
76
76
  />
77
- {order?.products.map((product: any) => (
77
+ {order?.products?.map((product: any) => (
78
78
  <SingleProductReview
79
79
  key={product.id}
80
80
  product={product}
@@ -20,7 +20,9 @@ export const SearchBar = (props: any) => {
20
20
  inputStyle,
21
21
  onPress,
22
22
  isDisabled,
23
- iconCustomRight
23
+ iconCustomRight,
24
+ onSubmitEditing,
25
+ blurOnSubmit
24
26
  } = props
25
27
 
26
28
  const theme = useTheme();
@@ -88,6 +90,7 @@ export const SearchBar = (props: any) => {
88
90
  inputStyle={{padding: 0, paddingTop: Platform.OS == 'android' ? 2 : 0, ...inputStyle}}
89
91
  onPress={() => onPress && onPress()}
90
92
  iconCustomRight={iconCustomRight}
93
+ onSubmitEditing={() => onSubmitEditing && onSubmitEditing()}
91
94
  />
92
95
  {isCancelButtonShow && (
93
96
  <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
+ }