ordering-ui-react-native 0.23.96 → 0.23.97

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.23.96",
3
+ "version": "0.23.97",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -35,9 +35,7 @@ import { MessageListing } from './src/components/MessageListing';
35
35
  import { Messages } from './src/components/Messages';
36
36
  import { MyOrders } from './src/components/MyOrders';
37
37
  import { Help } from './src/components/Help';
38
- import { HelpAccountAndPayment } from './src/components/HelpAccountAndPayment';
39
- import { HelpGuide } from './src/components/HelpGuide';
40
- import { HelpOrder } from './src/components/HelpOrder';
38
+ import { HelpOptions } from './src/components/HelpOptions';
41
39
  import { NetworkError } from './src/components/NetworkError';
42
40
  import { NotFoundSource } from './src/components/NotFoundSource';
43
41
  import { OrderTypeSelector } from './src/components/OrderTypeSelector';
@@ -113,49 +111,49 @@ import { orderTypeList, getTraduction, verifyDecimals, getOrderStatus, getOrderS
113
111
  import Alert from './src/providers/AlertProvider'
114
112
 
115
113
  import {
116
- LoginParams,
117
- ProfileParams,
118
- AddressListParams,
119
- AddressFormParams,
120
- SignupParams,
121
- PhoneInputParams,
122
- LanguageSelectorParams,
123
- BusinessesListingParams,
124
- HighestRatedBusinessesParams,
125
- BusinessTypeFilterParams,
126
- BusinessControllerParams,
127
- BusinessProductsListingParams,
128
- BusinessBasicInformationParams,
129
- BusinessProductsCategoriesParams,
130
- BusinessProductsListParams,
131
- SingleProductCardParams,
132
- BusinessInformationParams,
133
- BusinessReviewsParams,
134
- SearchBarParams,
135
- NotFoundSourceParams,
136
- OrdersOptionParams,
137
- ActiveOrdersParams,
138
- PreviousOrdersParams,
139
- OrderDetailsParams,
140
- ReviewDriverParams
114
+ LoginParams,
115
+ ProfileParams,
116
+ AddressListParams,
117
+ AddressFormParams,
118
+ SignupParams,
119
+ PhoneInputParams,
120
+ LanguageSelectorParams,
121
+ BusinessesListingParams,
122
+ HighestRatedBusinessesParams,
123
+ BusinessTypeFilterParams,
124
+ BusinessControllerParams,
125
+ BusinessProductsListingParams,
126
+ BusinessBasicInformationParams,
127
+ BusinessProductsCategoriesParams,
128
+ BusinessProductsListParams,
129
+ SingleProductCardParams,
130
+ BusinessInformationParams,
131
+ BusinessReviewsParams,
132
+ SearchBarParams,
133
+ NotFoundSourceParams,
134
+ OrdersOptionParams,
135
+ ActiveOrdersParams,
136
+ PreviousOrdersParams,
137
+ OrderDetailsParams,
138
+ ReviewDriverParams
141
139
  } from './src/types';
142
140
 
143
141
  import { Toast } from './src/components/shared/OToast';
144
142
  import {
145
- OText,
146
- OButton,
147
- OInput,
148
- ODropDown,
149
- OIcon,
150
- OIconText,
151
- OIconButton,
152
- OTextarea,
153
- OToggle,
154
- OKeyButton,
155
- OAlert,
156
- OModal,
157
- OBottomPopup,
158
- HeaderTitle
143
+ OText,
144
+ OButton,
145
+ OInput,
146
+ ODropDown,
147
+ OIcon,
148
+ OIconText,
149
+ OIconButton,
150
+ OTextarea,
151
+ OToggle,
152
+ OKeyButton,
153
+ OAlert,
154
+ OModal,
155
+ OBottomPopup,
156
+ HeaderTitle
159
157
  } from './src/components/shared';
160
158
 
161
159
  import { Container } from './src/layouts/Container';
@@ -163,198 +161,196 @@ import { SafeAreaContainer } from './src/layouts/SafeAreaContainer';
163
161
  import { FloatingBottomContainer } from './src/layouts/FloatingBottomContainer';
164
162
 
165
163
  import {
166
- _retrieveStoreData,
167
- _setStoreData,
168
- _removeStoreData,
169
- _clearStoreData
164
+ _retrieveStoreData,
165
+ _setStoreData,
166
+ _removeStoreData,
167
+ _clearStoreData
170
168
  } from './src/providers/StoreUtil';
171
169
 
172
170
  export {
173
- AddressForm,
174
- AddressDetails,
175
- AnalyticsSegment,
176
- Home as HomeView,
177
- SignupForm,
178
- LoginForm,
179
- ActiveOrders,
180
- AddressList,
181
- AppleLogin,
182
- BusinessesListing,
183
- BusinessProductsListing,
184
- CartContent,
185
- BusinessCart,
186
- Checkout,
187
- Favorite,
188
- FavoriteList,
171
+ AddressForm,
172
+ AddressDetails,
173
+ AnalyticsSegment,
174
+ Home as HomeView,
175
+ SignupForm,
176
+ LoginForm,
177
+ ActiveOrders,
178
+ AddressList,
179
+ AppleLogin,
180
+ BusinessesListing,
181
+ BusinessProductsListing,
182
+ CartContent,
183
+ BusinessCart,
184
+ Checkout,
185
+ Favorite,
186
+ FavoriteList,
189
187
  GPSButton,
190
- ForgotPasswordForm,
191
- MomentOption,
192
- OrdersOption,
193
- OrderDetails,
194
- OrderProgress,
195
- BusinessPreorder,
196
- NotificationsList,
197
- UserProfileForm,
198
- ReviewOrder,
199
- ReviewProducts,
200
- ReviewDriver,
201
- BusinessMenuList,
202
- UserProfile,
203
- MessageListing,
204
- Messages,
205
- Help,
206
- HelpAccountAndPayment,
207
- HelpGuide,
208
- HelpOrder,
209
- MultiCheckout,
210
- MultiOrdersDetails,
211
- NetworkError,
212
- NotFoundSource,
213
- OrderTypeSelector,
214
- Wallets,
215
- PaymentOptionWallet,
216
- ProductForm,
217
- UpsellingProducts,
218
- UserVerification,
219
- BusinessListingSearch,
220
- BusinessBasicInformation,
221
- BusinessProductsCategories,
222
- BusinessProductsList,
223
- FloatingButton,
224
- SearchBar,
225
- LastOrders,
226
- BusinessTypeFilter,
227
- BusinessController,
228
- BusinessFeaturedController,
229
- HighestRatedBusinesses,
230
- PaymentOptions,
231
- DriverTips,
232
- UserDetails,
233
- OrderSummary,
234
- OrderItAgain,
235
- CartStoresListing,
236
- PaymentOptionsWebView,
237
- GoogleMap,
238
- SingleProductCard,
239
- SingleOrderCard,
240
- UpsellingRedirect,
241
- ProductItemAccordion,
242
- ScheduleAccordion,
243
- BusinessItemAccordion,
244
- CouponControl,
245
- TaxInformation,
246
- PlaceSpot,
247
- ProfessionalFilter,
248
- ServiceForm,
249
- ProfessionalProfile,
250
- MomentSelector,
251
- Cart,
252
- LanguageSelector,
253
- PhoneInputNumber,
254
- FacebookLogin,
255
- VerifyPhone,
256
- GoogleLogin,
257
- PreviousOrders,
258
- PaymentOptionCash,
259
- StripeElementsForm,
260
- StripeCardsList,
261
- ProductIngredient,
262
- ProductOption,
263
- ProductOptionSubOption,
188
+ ForgotPasswordForm,
189
+ MomentOption,
190
+ OrdersOption,
191
+ OrderDetails,
192
+ OrderProgress,
193
+ BusinessPreorder,
194
+ NotificationsList,
195
+ UserProfileForm,
196
+ ReviewOrder,
197
+ ReviewProducts,
198
+ ReviewDriver,
199
+ BusinessMenuList,
200
+ UserProfile,
201
+ MessageListing,
202
+ Messages,
203
+ Help,
204
+ HelpOptions,
205
+ MultiCheckout,
206
+ MultiOrdersDetails,
207
+ NetworkError,
208
+ NotFoundSource,
209
+ OrderTypeSelector,
210
+ Wallets,
211
+ PaymentOptionWallet,
212
+ ProductForm,
213
+ UpsellingProducts,
214
+ UserVerification,
215
+ BusinessListingSearch,
216
+ BusinessBasicInformation,
217
+ BusinessProductsCategories,
218
+ BusinessProductsList,
219
+ FloatingButton,
220
+ SearchBar,
221
+ LastOrders,
222
+ BusinessTypeFilter,
223
+ BusinessController,
224
+ BusinessFeaturedController,
225
+ HighestRatedBusinesses,
226
+ PaymentOptions,
227
+ DriverTips,
228
+ UserDetails,
229
+ OrderSummary,
230
+ OrderItAgain,
231
+ CartStoresListing,
232
+ PaymentOptionsWebView,
233
+ GoogleMap,
234
+ SingleProductCard,
235
+ SingleOrderCard,
236
+ UpsellingRedirect,
237
+ ProductItemAccordion,
238
+ ScheduleAccordion,
239
+ BusinessItemAccordion,
240
+ CouponControl,
241
+ TaxInformation,
242
+ PlaceSpot,
243
+ ProfessionalFilter,
244
+ ServiceForm,
245
+ ProfessionalProfile,
246
+ MomentSelector,
247
+ Cart,
248
+ LanguageSelector,
249
+ PhoneInputNumber,
250
+ FacebookLogin,
251
+ VerifyPhone,
252
+ GoogleLogin,
253
+ PreviousOrders,
254
+ PaymentOptionCash,
255
+ StripeElementsForm,
256
+ StripeCardsList,
257
+ ProductIngredient,
258
+ ProductOption,
259
+ ProductOptionSubOption,
264
260
  SendGiftCard,
265
- Sessions,
266
- SingleProductReview,
267
- LogoutButton,
268
- UserFormDetailsUI,
269
- WalletTransactionItem,
270
- Promotions,
271
- PageBanner,
272
- MyOrders,
273
- MultiCart,
274
- WebsocketStatus,
275
- ORDER_TYPES,
276
- USER_TYPE,
261
+ Sessions,
262
+ SingleProductReview,
263
+ LogoutButton,
264
+ UserFormDetailsUI,
265
+ WalletTransactionItem,
266
+ Promotions,
267
+ PageBanner,
268
+ MyOrders,
269
+ MultiCart,
270
+ WebsocketStatus,
271
+ ORDER_TYPES,
272
+ USER_TYPE,
277
273
 
278
- OSBill,
279
- OSTable,
280
- OSCoupon,
281
- OSTotal,
282
- OSRow,
274
+ OSBill,
275
+ OSTable,
276
+ OSCoupon,
277
+ OSTotal,
278
+ OSRow,
283
279
 
284
- FormInput,
285
- FormSide,
286
- ButtonsWrapper,
287
- LoginWith,
288
- OTab,
289
- OTabs,
280
+ FormInput,
281
+ FormSide,
282
+ ButtonsWrapper,
283
+ LoginWith,
284
+ OTab,
285
+ OTabs,
290
286
 
291
- OSItem,
292
- OSItemContent,
293
- OSItemActions,
287
+ OSItem,
288
+ OSItemContent,
289
+ OSItemActions,
294
290
 
295
- Alert,
291
+ Alert,
296
292
 
297
- //Types
298
- LoginParams,
299
- ProfileParams,
300
- AddressListParams,
301
- AddressFormParams,
302
- SignupParams,
303
- PhoneInputParams,
304
- LanguageSelectorParams,
305
- BusinessesListingParams,
306
- HighestRatedBusinessesParams,
307
- BusinessTypeFilterParams,
308
- BusinessControllerParams,
309
- BusinessProductsListingParams,
310
- BusinessBasicInformationParams,
311
- BusinessProductsCategoriesParams,
312
- BusinessProductsListParams,
313
- SingleProductCardParams,
314
- BusinessInformationParams,
315
- BusinessReviewsParams,
316
- SearchBarParams,
317
- NotFoundSourceParams,
318
- OrdersOptionParams,
319
- ActiveOrdersParams,
320
- PreviousOrdersParams,
321
- OrderDetailsParams,
322
- ReviewDriverParams,
293
+ //Types
294
+ LoginParams,
295
+ ProfileParams,
296
+ AddressListParams,
297
+ AddressFormParams,
298
+ SignupParams,
299
+ PhoneInputParams,
300
+ LanguageSelectorParams,
301
+ BusinessesListingParams,
302
+ HighestRatedBusinessesParams,
303
+ BusinessTypeFilterParams,
304
+ BusinessControllerParams,
305
+ BusinessProductsListingParams,
306
+ BusinessBasicInformationParams,
307
+ BusinessProductsCategoriesParams,
308
+ BusinessProductsListParams,
309
+ SingleProductCardParams,
310
+ BusinessInformationParams,
311
+ BusinessReviewsParams,
312
+ SearchBarParams,
313
+ NotFoundSourceParams,
314
+ OrdersOptionParams,
315
+ ActiveOrdersParams,
316
+ PreviousOrdersParams,
317
+ OrderDetailsParams,
318
+ ReviewDriverParams,
323
319
 
324
- // OComponents
325
- Toast,
326
- OText,
327
- OButton,
328
- OInput,
329
- ODropDown,
330
- OIcon,
331
- OIconText,
332
- OIconButton,
333
- OTextarea,
334
- OToggle,
335
- OKeyButton,
336
- OAlert,
337
- OModal,
338
- OBottomPopup,
339
- HeaderTitle,
320
+ // OComponents
321
+ Toast,
322
+ OText,
323
+ OButton,
324
+ OInput,
325
+ ODropDown,
326
+ OIcon,
327
+ OIconText,
328
+ OIconButton,
329
+ OTextarea,
330
+ OToggle,
331
+ OKeyButton,
332
+ OAlert,
333
+ OModal,
334
+ OBottomPopup,
335
+ HeaderTitle,
340
336
 
341
- // layout
342
- Container,
343
- SafeAreaContainer,
344
- FloatingBottomContainer,
345
- NavBar,
337
+ // layout
338
+ Container,
339
+ SafeAreaContainer,
340
+ FloatingBottomContainer,
341
+ NavBar,
346
342
 
347
- // utils
348
- _retrieveStoreData,
349
- _setStoreData,
350
- _removeStoreData,
351
- _clearStoreData,
352
- orderTypeList,
343
+ // utils
344
+ _retrieveStoreData,
345
+ _setStoreData,
346
+ _removeStoreData,
347
+ _clearStoreData,
348
+ orderTypeList,
353
349
  getTraduction,
354
350
  verifyDecimals,
355
351
  getOrderStatus,
356
352
  getOrderStatuPickUp,
357
353
 
358
- // Date Picker
359
- DatePickerUI
354
+ // Date Picker
355
+ DatePickerUI
360
356
  }
@@ -0,0 +1,76 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import { useApi } from 'ordering-components/native'
4
+
5
+ /**
6
+ * Component to manage login behavior without UI component
7
+ */
8
+ export const CmsContent = (props: any) => {
9
+ const { UIComponent } = props
10
+
11
+ /**
12
+ * Array to save the body of the page
13
+ */
14
+ const [ordering] = useApi()
15
+ const [cmsState, setCmsState] = useState({ items: [], pages: [], loading: true, error: null })
16
+
17
+ /**
18
+ * Method used to get the page by slug
19
+ */
20
+ const getPages = async () => {
21
+ setCmsState({ ...cmsState, loading: true })
22
+ try {
23
+ const propsToFetch = ['name', 'enabled']
24
+ let pages: any = []
25
+ const { content: { error, result } } = await ordering.pages().select(propsToFetch).get()
26
+ if (!error) {
27
+ const promises = result.map((item: any) => getPage(item.id));
28
+ pages = await Promise.all(promises)
29
+ }
30
+ setCmsState({
31
+ ...cmsState,
32
+ loading: false,
33
+ error: error ? typeof result === 'string' ? result : result[0] : null,
34
+ items: error ? [] : result.filter((i: any) => i.enabled).map((item: any) => ({ id: item.id, name: item.name })),
35
+ pages
36
+ })
37
+ } catch (err: any) {
38
+ setCmsState({
39
+ ...cmsState,
40
+ loading: false,
41
+ error: err?.message ?? err
42
+ })
43
+ }
44
+ }
45
+
46
+ const getPage = async (id: number) => {
47
+ try {
48
+ const { content: { error, result } } = await ordering.pages(id).get()
49
+ return error ? null : { id, body: result?.body }
50
+ } catch {
51
+ return null
52
+ }
53
+ }
54
+
55
+ useEffect(() => {
56
+ getPages()
57
+ }, [])
58
+
59
+ return (
60
+ <>
61
+ {UIComponent && (
62
+ <UIComponent
63
+ {...props}
64
+ cmsState={cmsState}
65
+ />
66
+ )}
67
+ </>
68
+ )
69
+ }
70
+
71
+ CmsContent.propTypes = {
72
+ /**
73
+ * UI Component, this must be containt all graphic elements and use parent props
74
+ */
75
+ UIComponent: PropTypes.elementType
76
+ }
@@ -1,27 +1,48 @@
1
1
  import React, { useState } from 'react'
2
- import { useTheme } from 'styled-components/native';
3
- import { Platform, RefreshControl } from 'react-native'
4
- import { HelpParams } from '../../types'
2
+ import { Platform, RefreshControl, View } from 'react-native'
3
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
4
+ import { useTheme } from 'styled-components/native'
5
5
  import { useLanguage } from 'ordering-components/native'
6
+
7
+ import { HelpParams } from '../../types'
8
+ import { CmsContent } from './functions'
9
+ import { HelpSubItem, LastOrdersContainer } from './styles'
10
+ import { Container } from '../../layouts/Container'
11
+
12
+ import { OText, OIcon } from '../shared'
13
+ import { NotFoundSource } from '../NotFoundSource'
6
14
  import NavBar from '../NavBar'
7
- import { OText } from '../shared'
8
15
  import { LastOrders } from '../LastOrders'
9
- import { Container } from '../../layouts/Container'
10
16
 
11
- import {
12
- HelpSubItem,
13
- LastOrdersContainer
14
- } from './styles'
17
+ const HelpUI = (props: HelpParams) => {
18
+ const { cmsState, navigation } = props
19
+
20
+ const { items, loading, error, pages } = cmsState
15
21
 
16
- export const Help = (props: HelpParams) => {
17
- const {
18
- navigation
19
- } = props
20
22
  const [, t] = useLanguage()
21
23
  const theme = useTheme()
22
- const [refreshing] = useState(false);
24
+
25
+ const [refreshing] = useState(false)
23
26
  const [refresh, setRefresh] = useState(false)
24
27
 
28
+ const HelpItem = ({ item }: any) => {
29
+ const currentItem = pages.find((p: any) => p.id === item.id)
30
+ return (
31
+ <HelpSubItem
32
+ activeOpacity={0.7}
33
+ onPress={() => onRedirect('HelpOptions', { item: currentItem })}
34
+ >
35
+ <OText size={14} style={{ width: '90%' }}>
36
+ {item.name}
37
+ </OText>
38
+ <OIcon
39
+ width={15}
40
+ src={theme.images.general.chevron_right}
41
+ />
42
+ </HelpSubItem>
43
+ )
44
+ }
45
+
25
46
  const goToBack = () => navigation?.canGoBack() && navigation.goBack()
26
47
  const onRedirect = (route: string, params?: any) => {
27
48
  navigation.navigate(route, params)
@@ -49,22 +70,36 @@ export const Help = (props: HelpParams) => {
49
70
  showCall={false}
50
71
  btnStyle={{ paddingLeft: 0 }}
51
72
  />
52
- <HelpSubItem
53
- onPress={() => onRedirect('HelpOrder')}
73
+ <OText
74
+ size={20}
75
+ weight={'bold'}
76
+ style={{ marginBottom: 20 }}
54
77
  >
55
- <OText size={14}>{t('HELP_WITH_ORDER', 'Help with an order')}</OText>
56
- </HelpSubItem>
57
- <HelpSubItem
58
- onPress={() => onRedirect('HelpAccountAndPayment')}
59
- >
60
- <OText size={14}>{t('ACCOUNT_PAYMENT_OPTIONS', 'Account and Payment Options')}</OText>
61
- </HelpSubItem>
62
- <HelpSubItem
63
- onPress={() => onRedirect('HelpGuide')}
64
- >
65
- <OText size={14}>{t('GUIDE_TO_ORDERING', 'Guide to Ordering')}</OText>
66
- </HelpSubItem>
67
-
78
+ {t('ALL_THE_THEMES', 'All the themes')}
79
+ </OText>
80
+ {!loading && !error && items.map((item: any) => (
81
+ <HelpItem
82
+ key={item.id}
83
+ item={item}
84
+ />
85
+ ))}
86
+ {loading && (
87
+ <Placeholder Animation={Fade}>
88
+ <View style={{ flexDirection: 'column' }}>
89
+ {[...Array(5)].map((_, i) => (
90
+ <HelpSubItem key={i}>
91
+ <PlaceholderLine key={i} height={30} width={90} noMargin />
92
+ </HelpSubItem>
93
+ ))}
94
+ </View>
95
+ </Placeholder>
96
+ )}
97
+ {!loading && !!error && (
98
+ <NotFoundSource
99
+ simple
100
+ content={error}
101
+ />
102
+ )}
68
103
  <LastOrdersContainer>
69
104
  <OText size={18} weight={600}>{t('LAST_ORDERS', 'Last Orders')}</OText>
70
105
  <LastOrders {...props} onRedirect={onRedirect} refresh={refresh} setRefresh={setRefresh} />
@@ -72,3 +107,13 @@ export const Help = (props: HelpParams) => {
72
107
  </Container>
73
108
  )
74
109
  }
110
+
111
+ export const Help = (props: HelpParams) => {
112
+ const helpProps = {
113
+ ...props,
114
+ UIComponent: HelpUI
115
+ }
116
+ return (
117
+ <CmsContent {...helpProps} />
118
+ )
119
+ }