ordering-ui-react-native 0.12.36 → 0.12.37

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.12.36",
3
+ "version": "0.12.37",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -40,12 +40,14 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
40
40
  const [time, setTime] = useState('');
41
41
  const [comments, setComments] = useState('');
42
42
  const [isKeyboardShow, setIsKeyboardShow] = useState(false);
43
- const phoneNumber = customerCellphone;
44
- let codeNumberPhone, numberPhone, numberToShow;
45
43
  const { top, bottom } = useSafeAreaInsets()
46
- const titleOrder = t(orderTitle[action].key, orderTitle[action].text)
47
- const buttonText = t(orderTitle[action].btnKey, orderTitle[action].btnText)
44
+
45
+ let codeNumberPhone, numberPhone, numberToShow;
46
+ const phoneNumber = customerCellphone;
47
+ const titleOrder = t(orderTitle[action]?.key, orderTitle[action]?.text)
48
+ const buttonText = t(orderTitle[action]?.btnKey, orderTitle[action]?.btnText)
48
49
  const showTextArea = ['reject', 'deliveryFailed', 'pickupFailed', 'notReady'].includes(action)
50
+
49
51
  const handleFocus = () => {
50
52
  viewRef?.current?.measure((x: any, y: any) => {
51
53
  scrollViewRef?.current?.scrollTo({ x: 0, y });
@@ -210,7 +212,6 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
210
212
  }
211
213
 
212
214
  bodyToSend.id = orderId;
213
-
214
215
  handleUpdateOrder && handleUpdateOrder(bodyToSend.status, bodyToSend);
215
216
  };
216
217
 
@@ -48,8 +48,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
48
48
  isFromCheckout,
49
49
  driverLocation,
50
50
  actions,
51
- titleAccept,
52
- titleReject,
51
+ orderTitle,
53
52
  appTitle,
54
53
  } = props;
55
54
 
@@ -607,8 +606,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
607
606
  orderId={order?.id}
608
607
  notShowCustomerPhone={false}
609
608
  actions={actions}
610
- titleAccept={titleAccept}
611
- titleReject={titleReject}
609
+ orderTitle={orderTitle}
612
610
  appTitle={appTitle}
613
611
  />
614
612
  </OModal>
@@ -128,6 +128,36 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
128
128
  setOpenModalForAccept(true);
129
129
  };
130
130
 
131
+ const handleCloseModal = () => {
132
+ setOpenModalForBusiness(false);
133
+ };
134
+
135
+ const handleArrowBack: any = () => {
136
+ navigation?.canGoBack() && navigation.goBack();
137
+ };
138
+
139
+ const handleRejectLogisticOrder = () => {
140
+ handleClickLogisticOrder?.(2, order?.logistic_order_id)
141
+ handleArrowBack()
142
+ }
143
+
144
+ const locations = [
145
+ {
146
+ ...order?.business?.location,
147
+ title: order?.business?.name,
148
+ icon: order?.business?.logo || theme.images.dummies.businessLogo,
149
+ type: 'Business',
150
+ },
151
+ {
152
+ ...order?.customer?.location,
153
+ title: order?.customer?.name,
154
+ icon:
155
+ order?.customer?.photo ||
156
+ 'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
157
+ type: 'Customer',
158
+ },
159
+ ];
160
+
131
161
  useEffect(() => {
132
162
  if (permissions.locationStatus !== 'granted' && openModalForMapView) {
133
163
  setOpenModalForMapView(false);
@@ -146,20 +176,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
146
176
  if (openModalForMapView) {
147
177
  setOpenModalForMapView(false);
148
178
  }
149
- }, [order?.loading]);
150
-
151
- const handleCloseModal = () => {
152
- setOpenModalForBusiness(false);
153
- };
154
-
155
- const handleArrowBack: any = () => {
156
- navigation?.canGoBack() && navigation.goBack();
157
- };
158
-
159
- const handleRejectLogisticOrder = () => {
160
- handleClickLogisticOrder?.(2, order?.logistic_order_id)
161
- handleArrowBack()
162
- }
179
+ }, [props.order?.loading]);
163
180
 
164
181
  useEffect(() => {
165
182
  if (order?.driver === null && session?.user?.level === 4) {
@@ -176,23 +193,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
176
193
  }
177
194
  }, [order?.driver]);
178
195
 
179
- const locations = [
180
- {
181
- ...order?.business?.location,
182
- title: order?.business?.name,
183
- icon: order?.business?.logo || theme.images.dummies.businessLogo,
184
- type: 'Business',
185
- },
186
- {
187
- ...order?.customer?.location,
188
- title: order?.customer?.name,
189
- icon:
190
- order?.customer?.photo ||
191
- 'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
192
- type: 'Customer',
193
- },
194
- ];
195
-
196
196
  useEffect(() => {
197
197
  if (driverLocation) {
198
198
  locations[0] = driverLocation;
@@ -312,7 +312,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
312
312
  handleUpdateOrder={handleChangeOrderStatus}
313
313
  closeModal={setOpenModalForAccept}
314
314
  customerCellphone={order?.customer?.cellphone}
315
- loading={order?.loading}
315
+ loading={props.order?.loading}
316
316
  action={actionOrder}
317
317
  orderId={order?.id}
318
318
  notShowCustomerPhone
@@ -356,14 +356,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
356
356
 
357
357
  {showFloatButtonsPickUp[order?.status] && (
358
358
  <FloatingButton
359
- disabled={order?.loading}
359
+ disabled={props.order?.loading}
360
360
  btnText={t('PICKUP_FAILED', 'Pickup failed')}
361
361
  isSecondaryBtn={false}
362
362
  secondButtonClick={() =>
363
363
  handleChangeOrderStatus && handleChangeOrderStatus(9)
364
364
  }
365
365
  firstButtonClick={() =>
366
- handleViewActionOrder && handleViewActionOrder('failed')
366
+ handleViewActionOrder && handleViewActionOrder('pickupFailed')
367
367
  }
368
368
  secondBtnText={t('PICKUP_COMPLETE', 'Pickup complete')}
369
369
  secondButton={true}
@@ -375,14 +375,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
375
375
  {(order?.status === 9 || order?.status === 19) && (
376
376
  <>
377
377
  <FloatingButton
378
- disabled={order?.loading}
378
+ disabled={props.order?.loading}
379
379
  btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
380
380
  isSecondaryBtn={false}
381
381
  secondButtonClick={() =>
382
382
  handleChangeOrderStatus && handleChangeOrderStatus(11)
383
383
  }
384
384
  firstButtonClick={() =>
385
- handleViewActionOrder && handleViewActionOrder('failed')
385
+ handleViewActionOrder && handleViewActionOrder('deliveryFailed')
386
386
  }
387
387
  secondBtnText={t('DELIVERY_COMPLETE', 'Delivery complete')}
388
388
  secondButton={true}
@@ -405,14 +405,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
405
405
  widthButton={'45%'}
406
406
  />
407
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
408
  </>
417
409
  )
418
410
  }
@@ -420,7 +412,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
420
412
  return (
421
413
  <>
422
414
  {(!order || Object.keys(order).length === 0) &&
423
- (order?.error?.length < 1 || !order?.error) && (
415
+ (props.order?.error?.length < 1 || !props.order?.error) && (
424
416
  <View style={{ flex: 1 }}>
425
417
  {[...Array(6)].map((item, i) => (
426
418
  <Placeholder key={i} Animation={Fade}>
@@ -437,7 +429,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
437
429
  </View>
438
430
  )}
439
431
 
440
- {(!!order?.error || order?.error) && (
432
+ {(!!props.order?.error || props.order?.error) && (
441
433
  <NotFoundSource
442
434
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
443
435
  content={
@@ -457,7 +449,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
457
449
  handleArrowBack={handleArrowBack}
458
450
  logisticOrderStatus={logisticOrderStatus}
459
451
  />
460
- {order && Object.keys(order).length > 0 && (order?.error?.length < 1 || !order?.error) && (
452
+ {order && Object.keys(order).length > 0 && (props.order?.error?.length < 1 || !props.order?.error) && (
461
453
  <>
462
454
  {order?.order_group && order?.order_group_id ? order?.order_group?.orders.map((order: any) => (
463
455
  <OrderDetailsInformation order={order} />
@@ -467,6 +459,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
467
459
  </>
468
460
  )}
469
461
  </View>
462
+ {alertState?.open && (
463
+ <Alert
464
+ open={alertState.open}
465
+ onAccept={handleArrowBack}
466
+ onClose={handleArrowBack}
467
+ content={alertState.content}
468
+ title={t('WARNING', 'Warning')}
469
+ />
470
+ )}
470
471
  </>
471
472
  );
472
473
  };