ordering-ui-react-native 0.12.32 → 0.12.36

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 (34) hide show
  1. package/package.json +1 -1
  2. package/themes/business/src/components/OrderDetails/Delivery.tsx +206 -178
  3. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +344 -334
  4. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +83 -69
  5. package/themes/business/src/components/OrdersOption/index.tsx +122 -77
  6. package/themes/business/src/components/PreviousOrders/index.tsx +124 -73
  7. package/themes/business/src/components/PreviousOrders/styles.tsx +7 -0
  8. package/themes/business/src/components/ProductItemAccordion/index.tsx +26 -25
  9. package/themes/business/src/components/shared/OButton.tsx +0 -1
  10. package/themes/business/src/components/shared/OIcon.tsx +2 -0
  11. package/themes/business/src/types/index.tsx +5 -0
  12. package/themes/single-business/src/components/BusinessBasicInformation/index.tsx +1 -1
  13. package/themes/single-business/src/components/BusinessProductsListing/index.tsx +9 -8
  14. package/themes/single-business/src/components/BusinessesListing/index.tsx +307 -296
  15. package/themes/single-business/src/components/BusinessesListing/styles.tsx +41 -14
  16. package/themes/single-business/src/components/HelpAccountAndPayment/index.tsx +7 -6
  17. package/themes/single-business/src/components/HelpGuide/index.tsx +7 -6
  18. package/themes/single-business/src/components/HelpOrder/index.tsx +7 -6
  19. package/themes/single-business/src/components/LanguageSelector/index.tsx +87 -70
  20. package/themes/single-business/src/components/LoginForm/index.tsx +2 -2
  21. package/themes/single-business/src/components/OrderDetails/index.tsx +21 -21
  22. package/themes/single-business/src/components/ProductForm/index.tsx +682 -656
  23. package/themes/single-business/src/components/ProductForm/styles.tsx +1 -1
  24. package/themes/single-business/src/components/UserProfile/index.tsx +2 -2
  25. package/themes/single-business/src/components/shared/OIconButton.tsx +2 -2
  26. package/themes/single-business/src/components/shared/OInput.tsx +1 -0
  27. package/themes/single-business/src/components/shared/OLink.tsx +80 -0
  28. package/themes/single-business/src/components/shared/index.tsx +2 -0
  29. package/themes/single-business/src/types/index.tsx +3 -0
  30. package/themes/uber-eats/src/components/AddressList/index.tsx +1 -1
  31. package/themes/uber-eats/src/components/Messages/index.tsx +4 -4
  32. package/themes/uber-eats/src/components/shared/OButton.tsx +0 -1
  33. package/themes/uber-eats/src/components/shared/ODropDown.tsx +3 -2
  34. package/themes/uber-eats/src/components/shared/OIcon.tsx +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.12.32",
3
+ "version": "0.12.36",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -50,10 +50,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
50
50
  setDriverUpdateLocation,
51
51
  orderTitle,
52
52
  appTitle,
53
+ handleClickLogisticOrder
53
54
  } = props;
54
55
 
55
56
  const [, { showToast }] = useToast();
56
- const { order, loading, error } = props.order;
57
+ const { order } = props.order
57
58
  const theme = useTheme();
58
59
  const [, t] = useLanguage();
59
60
  const [session] = useSession();
@@ -71,6 +72,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
71
72
  key?: string | null;
72
73
  }>({ open: false, content: [], key: null });
73
74
 
75
+ const logisticOrderStatus = [4, 6, 7]
76
+
74
77
  const showFloatButtonsPickUp: any = {
75
78
  8: true,
76
79
  3: true,
@@ -143,7 +146,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
143
146
  if (openModalForMapView) {
144
147
  setOpenModalForMapView(false);
145
148
  }
146
- }, [loading]);
149
+ }, [order?.loading]);
147
150
 
148
151
  const handleCloseModal = () => {
149
152
  setOpenModalForBusiness(false);
@@ -153,6 +156,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
153
156
  navigation?.canGoBack() && navigation.goBack();
154
157
  };
155
158
 
159
+ const handleRejectLogisticOrder = () => {
160
+ handleClickLogisticOrder?.(2, order?.logistic_order_id)
161
+ handleArrowBack()
162
+ }
163
+
156
164
  useEffect(() => {
157
165
  if (order?.driver === null && session?.user?.level === 4) {
158
166
  setAlertState({
@@ -207,7 +215,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
207
215
  },
208
216
  });
209
217
 
210
- let locationMarker;
218
+ let locationMarker: any;
211
219
  let isToFollow = false;
212
220
  let isBusinessMarker = false;
213
221
 
@@ -235,10 +243,184 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
235
243
  );
236
244
  }
237
245
 
246
+ const OrderDetailsInformation = (_order: any, isOrderGroup: boolean) => {
247
+ const { order } = _order
248
+ return (
249
+ <>
250
+ <OrderDetailsContainer
251
+ keyboardShouldPersistTaps="handled"
252
+ showsVerticalScrollIndicator={false}
253
+ >
254
+ <>
255
+ <OrderContentComponent
256
+ order={order}
257
+ logisticOrderStatus={logisticOrderStatus}
258
+ isOrderGroup={isOrderGroup}
259
+ />
260
+ {(order?.status === 8 || order?.status === 18) && order?.delivery_type === 1 && (
261
+ <Pickup>
262
+ <OButton
263
+ style={styles.btnPickUp}
264
+ textStyle={{ color: theme.colors.primary }}
265
+ text={t('ARRIVED_TO_BUSINESS', 'Arrived to bussiness')}
266
+ onClick={() =>
267
+ handleChangeOrderStatus && handleChangeOrderStatus(3)
268
+ }
269
+ imgLeftStyle={{ tintColor: theme.colors.backArrow }}
270
+ />
271
+ </Pickup>
272
+ )}
273
+ {(order?.status === 3) && order?.delivery_type === 1 && (
274
+ <View style={{ paddingVertical: 20, marginBottom: 20 }}>
275
+ <OButton
276
+ style={styles.btnPickUp}
277
+ textStyle={{ color: theme.colors.white }}
278
+ text={t('ORDER_NOT_READY', 'Order not ready')}
279
+ onClick={() =>
280
+ handleViewActionOrder && handleViewActionOrder('notReady')
281
+ }
282
+ imgLeftStyle={{ tintColor: theme.colors.backArrow }}
283
+ bgColor={theme.colors.red}
284
+ />
285
+ </View>
286
+ )}
287
+ </>
288
+
289
+ <OModal
290
+ open={openModalForBusiness}
291
+ order={order}
292
+ title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id}`}
293
+ entireModal
294
+ onClose={() => handleCloseModal()}>
295
+ <Chat
296
+ type={
297
+ openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
298
+ }
299
+ orderId={order?.id}
300
+ messages={messages}
301
+ order={order}
302
+ setMessages={setMessages}
303
+ />
304
+ </OModal>
305
+
306
+ <OModal
307
+ open={openModalForAccept}
308
+ onClose={() => setOpenModalForAccept(false)}
309
+ entireModal
310
+ customClose>
311
+ <AcceptOrRejectOrder
312
+ handleUpdateOrder={handleChangeOrderStatus}
313
+ closeModal={setOpenModalForAccept}
314
+ customerCellphone={order?.customer?.cellphone}
315
+ loading={order?.loading}
316
+ action={actionOrder}
317
+ orderId={order?.id}
318
+ notShowCustomerPhone
319
+ actions={actions}
320
+ orderTitle={orderTitle}
321
+ appTitle={appTitle}
322
+ />
323
+ </OModal>
324
+
325
+ <OModal
326
+ open={openModalForMapView}
327
+ onClose={() => handleOpenMapView()}
328
+ entireModal
329
+ customClose>
330
+ <DriverMap
331
+ navigation={navigation}
332
+ order={order}
333
+ orderStatus={getOrderStatus(order?.status, t)?.value || ''}
334
+ location={locationMarker}
335
+ readOnly
336
+ updateDriverPosition={updateDriverPosition}
337
+ driverUpdateLocation={driverUpdateLocation}
338
+ setDriverUpdateLocation={setDriverUpdateLocation}
339
+ handleViewActionOrder={handleViewActionOrder}
340
+ isBusinessMarker={isBusinessMarker}
341
+ isToFollow={isToFollow}
342
+ showAcceptOrReject={
343
+ showFloatButtonsAcceptOrReject[order?.status]
344
+ }
345
+ handleOpenMapView={handleOpenMapView}
346
+ />
347
+ </OModal>
348
+
349
+ <View
350
+ style={{
351
+ height:
352
+ order?.status === 8 && order?.delivery_type === 1 ? 50 : 35,
353
+ }}
354
+ />
355
+ </OrderDetailsContainer>
356
+
357
+ {showFloatButtonsPickUp[order?.status] && (
358
+ <FloatingButton
359
+ disabled={order?.loading}
360
+ btnText={t('PICKUP_FAILED', 'Pickup failed')}
361
+ isSecondaryBtn={false}
362
+ secondButtonClick={() =>
363
+ handleChangeOrderStatus && handleChangeOrderStatus(9)
364
+ }
365
+ firstButtonClick={() =>
366
+ handleViewActionOrder && handleViewActionOrder('failed')
367
+ }
368
+ secondBtnText={t('PICKUP_COMPLETE', 'Pickup complete')}
369
+ secondButton={true}
370
+ firstColorCustom={theme.colors.red}
371
+ secondColorCustom={theme.colors.green}
372
+ widthButton={'45%'}
373
+ />
374
+ )}
375
+ {(order?.status === 9 || order?.status === 19) && (
376
+ <>
377
+ <FloatingButton
378
+ disabled={order?.loading}
379
+ btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
380
+ isSecondaryBtn={false}
381
+ secondButtonClick={() =>
382
+ handleChangeOrderStatus && handleChangeOrderStatus(11)
383
+ }
384
+ firstButtonClick={() =>
385
+ handleViewActionOrder && handleViewActionOrder('failed')
386
+ }
387
+ secondBtnText={t('DELIVERY_COMPLETE', 'Delivery complete')}
388
+ secondButton={true}
389
+ firstColorCustom={theme.colors.red}
390
+ secondColorCustom={theme.colors.green}
391
+ widthButton={'45%'}
392
+ />
393
+ </>
394
+ )}
395
+ {showFloatButtonsAcceptOrReject[order?.status] && (
396
+ <FloatingButton
397
+ btnText={t('REJECT', 'Reject')}
398
+ isSecondaryBtn={false}
399
+ secondButtonClick={() => order?.isLogistic && logisticOrderStatus.includes(order?.status) ? handleClickLogisticOrder?.(1, order?.logistic_order_id) : handleViewActionOrder('accept')}
400
+ firstButtonClick={() => order?.isLogistic && logisticOrderStatus.includes(order?.status) ? handleRejectLogisticOrder() : handleViewActionOrder('reject')}
401
+ secondBtnText={t('ACCEPT', 'Accept')}
402
+ secondButton={true}
403
+ firstColorCustom={theme.colors.red}
404
+ secondColorCustom={theme.colors.green}
405
+ widthButton={'45%'}
406
+ />
407
+ )}
408
+
409
+ <Alert
410
+ open={alertState.open}
411
+ onAccept={handleArrowBack}
412
+ onClose={handleArrowBack}
413
+ content={alertState.content}
414
+ title={t('WARNING', 'Warning')}
415
+ />
416
+ </>
417
+ )
418
+ }
419
+
238
420
  return (
239
421
  <>
240
422
  {(!order || Object.keys(order).length === 0) &&
241
- (error?.length < 1 || !error) && (
423
+ (order?.error?.length < 1 || !order?.error) && (
242
424
  <View style={{ flex: 1 }}>
243
425
  {[...Array(6)].map((item, i) => (
244
426
  <Placeholder key={i} Animation={Fade}>
@@ -255,7 +437,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
255
437
  </View>
256
438
  )}
257
439
 
258
- {(!!error || error) && (
440
+ {(!!order?.error || order?.error) && (
259
441
  <NotFoundSource
260
442
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
261
443
  content={
@@ -266,179 +448,25 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
266
448
  onClickButton={() => navigation.navigate('Orders')}
267
449
  />
268
450
  )}
269
- {order && Object.keys(order).length > 0 && (error?.length < 1 || !error) && (
270
- <View style={{ flex: 1 }}>
271
- <OrderHeaderComponent
272
- order={order}
273
- handleOpenMapView={handleOpenMapView}
274
- handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
275
- getOrderStatus={getOrderStatus}
276
- handleArrowBack={handleArrowBack}
277
- />
278
- <OrderDetailsContainer
279
- keyboardShouldPersistTaps="handled"
280
- showsVerticalScrollIndicator={false}
281
- >
282
- <>
283
- <OrderContentComponent order={order} />
284
- {(order?.status === 8 || order?.status === 18) && order?.delivery_type === 1 && (
285
- <Pickup>
286
- <OButton
287
- style={styles.btnPickUp}
288
- textStyle={{ color: theme.colors.primary }}
289
- text={t('ARRIVED_TO_BUSINESS', 'Arrived to bussiness')}
290
- onClick={() =>
291
- handleChangeOrderStatus && handleChangeOrderStatus(3)
292
- }
293
- imgLeftStyle={{ tintColor: theme.colors.backArrow }}
294
- />
295
- </Pickup>
296
- )}
297
- {(order?.status === 3) && order?.delivery_type === 1 && (
298
- <View style={{ paddingVertical: 20, marginBottom: 20 }}>
299
- <OButton
300
- style={styles.btnPickUp}
301
- textStyle={{ color: theme.colors.white }}
302
- text={t('ORDER_NOT_READY', 'Order not ready')}
303
- onClick={() =>
304
- handleViewActionOrder && handleViewActionOrder('notReady')
305
- }
306
- imgLeftStyle={{ tintColor: theme.colors.backArrow }}
307
- bgColor={theme.colors.red}
308
- />
309
- </View>
310
- )}
311
- </>
312
-
313
- <OModal
314
- open={openModalForBusiness}
315
- order={order}
316
- title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id}`}
317
- entireModal
318
- onClose={() => handleCloseModal()}>
319
- <Chat
320
- type={
321
- openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
322
- }
323
- orderId={order?.id}
324
- messages={messages}
325
- order={order}
326
- setMessages={setMessages}
327
- />
328
- </OModal>
329
-
330
- <OModal
331
- open={openModalForAccept}
332
- onClose={() => setOpenModalForAccept(false)}
333
- entireModal
334
- customClose>
335
- <AcceptOrRejectOrder
336
- handleUpdateOrder={handleChangeOrderStatus}
337
- closeModal={setOpenModalForAccept}
338
- customerCellphone={order?.customer?.cellphone}
339
- loading={loading}
340
- action={actionOrder}
341
- orderId={order?.id}
342
- notShowCustomerPhone
343
- actions={actions}
344
- orderTitle={orderTitle}
345
- appTitle={appTitle}
346
- />
347
- </OModal>
348
-
349
- <OModal
350
- open={openModalForMapView}
351
- onClose={() => handleOpenMapView()}
352
- entireModal
353
- customClose>
354
- <DriverMap
355
- navigation={navigation}
356
- order={order}
357
- orderStatus={getOrderStatus(order?.status, t)?.value || ''}
358
- location={locationMarker}
359
- readOnly
360
- updateDriverPosition={updateDriverPosition}
361
- driverUpdateLocation={driverUpdateLocation}
362
- setDriverUpdateLocation={setDriverUpdateLocation}
363
- handleViewActionOrder={handleViewActionOrder}
364
- isBusinessMarker={isBusinessMarker}
365
- isToFollow={isToFollow}
366
- showAcceptOrReject={
367
- showFloatButtonsAcceptOrReject[order?.status]
368
- }
369
- handleOpenMapView={handleOpenMapView}
370
- />
371
- </OModal>
372
-
373
- <View
374
- style={{
375
- height:
376
- order?.status === 8 && order?.delivery_type === 1 ? 50 : 35,
377
- }}
378
- />
379
- </OrderDetailsContainer>
380
-
381
- {showFloatButtonsPickUp[order?.status] && (
382
- <FloatingButton
383
- disabled={loading}
384
- btnText={t('PICKUP_FAILED', 'Pickup failed')}
385
- isSecondaryBtn={false}
386
- secondButtonClick={() =>
387
- handleChangeOrderStatus && handleChangeOrderStatus(9)
388
- }
389
- firstButtonClick={() =>
390
- handleViewActionOrder && handleViewActionOrder('pickupFailed')
391
- }
392
- secondBtnText={t('PICKUP_COMPLETE', 'Pickup complete')}
393
- secondButton={true}
394
- firstColorCustom={theme.colors.red}
395
- secondColorCustom={theme.colors.green}
396
- widthButton={'45%'}
397
- />
398
- )}
399
- {(order?.status === 9 || order?.status === 19) && (
400
- <>
401
- <FloatingButton
402
- disabled={loading}
403
- btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
404
- isSecondaryBtn={false}
405
- secondButtonClick={() =>
406
- handleChangeOrderStatus && handleChangeOrderStatus(11)
407
- }
408
- firstButtonClick={() =>
409
- handleViewActionOrder && handleViewActionOrder('deliveryFailed')
410
- }
411
- secondBtnText={t('DELIVERY_COMPLETE', 'Delivery complete')}
412
- secondButton={true}
413
- firstColorCustom={theme.colors.red}
414
- secondColorCustom={theme.colors.green}
415
- widthButton={'45%'}
416
- />
417
- </>
418
- )}
419
- {showFloatButtonsAcceptOrReject[order?.status] && (
420
- <FloatingButton
421
- btnText={t('REJECT', 'Reject')}
422
- isSecondaryBtn={false}
423
- secondButtonClick={() => handleViewActionOrder('accept')}
424
- firstButtonClick={() => handleViewActionOrder('reject')}
425
- secondBtnText={t('ACCEPT', 'Accept')}
426
- secondButton={true}
427
- firstColorCustom={theme.colors.red}
428
- secondColorCustom={theme.colors.green}
429
- widthButton={'45%'}
430
- />
431
- )}
432
-
433
- <Alert
434
- open={alertState.open}
435
- onAccept={handleArrowBack}
436
- onClose={handleArrowBack}
437
- content={alertState.content}
438
- title={t('WARNING', 'Warning')}
439
- />
440
- </View>
441
- )}
451
+ <View style={{ flex: 1 }}>
452
+ <OrderHeaderComponent
453
+ order={order}
454
+ handleOpenMapView={handleOpenMapView}
455
+ handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
456
+ getOrderStatus={getOrderStatus}
457
+ handleArrowBack={handleArrowBack}
458
+ logisticOrderStatus={logisticOrderStatus}
459
+ />
460
+ {order && Object.keys(order).length > 0 && (order?.error?.length < 1 || !order?.error) && (
461
+ <>
462
+ {order?.order_group && order?.order_group_id ? order?.order_group?.orders.map((order: any) => (
463
+ <OrderDetailsInformation order={order} />
464
+ )) : (
465
+ <OrderDetailsInformation order={order} />
466
+ )}
467
+ </>
468
+ )}
469
+ </View>
442
470
  </>
443
471
  );
444
472
  };