ordering-ui-react-native 0.12.34 → 0.12.38

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 (23) hide show
  1. package/package.json +1 -1
  2. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +6 -5
  3. package/themes/business/src/components/OrderDetails/Business.tsx +2 -4
  4. package/themes/business/src/components/OrderDetails/Delivery.tsx +111 -108
  5. package/themes/business/src/types/index.tsx +3 -3
  6. package/themes/single-business/src/components/BusinessBasicInformation/index.tsx +1 -1
  7. package/themes/single-business/src/components/BusinessProductsListing/index.tsx +9 -8
  8. package/themes/single-business/src/components/BusinessesListing/index.tsx +307 -296
  9. package/themes/single-business/src/components/BusinessesListing/styles.tsx +41 -14
  10. package/themes/single-business/src/components/HelpAccountAndPayment/index.tsx +7 -6
  11. package/themes/single-business/src/components/HelpGuide/index.tsx +7 -6
  12. package/themes/single-business/src/components/HelpOrder/index.tsx +7 -6
  13. package/themes/single-business/src/components/LanguageSelector/index.tsx +87 -70
  14. package/themes/single-business/src/components/LoginForm/index.tsx +2 -2
  15. package/themes/single-business/src/components/OrderDetails/index.tsx +21 -21
  16. package/themes/single-business/src/components/ProductForm/index.tsx +682 -656
  17. package/themes/single-business/src/components/ProductForm/styles.tsx +1 -1
  18. package/themes/single-business/src/components/UserProfile/index.tsx +2 -2
  19. package/themes/single-business/src/components/shared/OIconButton.tsx +2 -2
  20. package/themes/single-business/src/components/shared/OInput.tsx +1 -0
  21. package/themes/single-business/src/components/shared/OLink.tsx +80 -0
  22. package/themes/single-business/src/components/shared/index.tsx +2 -0
  23. package/themes/single-business/src/types/index.tsx +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.12.34",
3
+ "version": "0.12.38",
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;
@@ -270,7 +270,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
270
270
  />
271
271
  </Pickup>
272
272
  )}
273
- {(order?.status === 3) && order?.delivery_type === 1 && (
273
+ {order?.status === 3 && order?.delivery_type === 1 && (
274
274
  <View style={{ paddingVertical: 20, marginBottom: 20 }}>
275
275
  <OButton
276
276
  style={styles.btnPickUp}
@@ -285,67 +285,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
285
285
  </View>
286
286
  )}
287
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
288
  <View
350
289
  style={{
351
290
  height:
@@ -356,14 +295,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
356
295
 
357
296
  {showFloatButtonsPickUp[order?.status] && (
358
297
  <FloatingButton
359
- disabled={order?.loading}
298
+ disabled={props.order?.loading}
360
299
  btnText={t('PICKUP_FAILED', 'Pickup failed')}
361
300
  isSecondaryBtn={false}
362
301
  secondButtonClick={() =>
363
302
  handleChangeOrderStatus && handleChangeOrderStatus(9)
364
303
  }
365
304
  firstButtonClick={() =>
366
- handleViewActionOrder && handleViewActionOrder('failed')
305
+ handleViewActionOrder && handleViewActionOrder('pickupFailed')
367
306
  }
368
307
  secondBtnText={t('PICKUP_COMPLETE', 'Pickup complete')}
369
308
  secondButton={true}
@@ -375,14 +314,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
375
314
  {(order?.status === 9 || order?.status === 19) && (
376
315
  <>
377
316
  <FloatingButton
378
- disabled={order?.loading}
317
+ disabled={props.order?.loading}
379
318
  btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
380
319
  isSecondaryBtn={false}
381
320
  secondButtonClick={() =>
382
321
  handleChangeOrderStatus && handleChangeOrderStatus(11)
383
322
  }
384
323
  firstButtonClick={() =>
385
- handleViewActionOrder && handleViewActionOrder('failed')
324
+ handleViewActionOrder && handleViewActionOrder('deliveryFailed')
386
325
  }
387
326
  secondBtnText={t('DELIVERY_COMPLETE', 'Delivery complete')}
388
327
  secondButton={true}
@@ -405,14 +344,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
405
344
  widthButton={'45%'}
406
345
  />
407
346
  )}
408
-
409
- <Alert
410
- open={alertState.open}
411
- onAccept={handleArrowBack}
412
- onClose={handleArrowBack}
413
- content={alertState.content}
414
- title={t('WARNING', 'Warning')}
415
- />
416
347
  </>
417
348
  )
418
349
  }
@@ -420,7 +351,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
420
351
  return (
421
352
  <>
422
353
  {(!order || Object.keys(order).length === 0) &&
423
- (order?.error?.length < 1 || !order?.error) && (
354
+ (props.order?.error?.length < 1 || !props.order?.error) && (
424
355
  <View style={{ flex: 1 }}>
425
356
  {[...Array(6)].map((item, i) => (
426
357
  <Placeholder key={i} Animation={Fade}>
@@ -437,7 +368,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
437
368
  </View>
438
369
  )}
439
370
 
440
- {(!!order?.error || order?.error) && (
371
+ {(!!props.order?.error || props.order?.error) && (
441
372
  <NotFoundSource
442
373
  btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
443
374
  content={
@@ -457,7 +388,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
457
388
  handleArrowBack={handleArrowBack}
458
389
  logisticOrderStatus={logisticOrderStatus}
459
390
  />
460
- {order && Object.keys(order).length > 0 && (order?.error?.length < 1 || !order?.error) && (
391
+ {order && Object.keys(order).length > 0 && (props.order?.error?.length < 1 || !props.order?.error) && (
461
392
  <>
462
393
  {order?.order_group && order?.order_group_id ? order?.order_group?.orders.map((order: any) => (
463
394
  <OrderDetailsInformation order={order} />
@@ -466,7 +397,79 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
466
397
  )}
467
398
  </>
468
399
  )}
400
+ {openModalForMapView && (
401
+ <OModal
402
+ open={openModalForMapView}
403
+ onClose={() => handleOpenMapView()}
404
+ entireModal
405
+ customClose>
406
+ <DriverMap
407
+ navigation={navigation}
408
+ order={order}
409
+ orderStatus={getOrderStatus(order?.status, t)?.value || ''}
410
+ location={locationMarker}
411
+ readOnly
412
+ updateDriverPosition={updateDriverPosition}
413
+ driverUpdateLocation={driverUpdateLocation}
414
+ setDriverUpdateLocation={setDriverUpdateLocation}
415
+ handleViewActionOrder={handleViewActionOrder}
416
+ isBusinessMarker={isBusinessMarker}
417
+ isToFollow={isToFollow}
418
+ showAcceptOrReject={
419
+ showFloatButtonsAcceptOrReject[order?.status]
420
+ }
421
+ handleOpenMapView={handleOpenMapView}
422
+ />
423
+ </OModal>
424
+ )}
425
+ {openModalForBusiness && (
426
+ <OModal
427
+ open={openModalForBusiness}
428
+ order={order}
429
+ title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id}`}
430
+ entireModal
431
+ onClose={() => handleCloseModal()}>
432
+ <Chat
433
+ type={
434
+ openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
435
+ }
436
+ orderId={order?.id}
437
+ messages={messages}
438
+ order={order}
439
+ setMessages={setMessages}
440
+ />
441
+ </OModal>
442
+ )}
443
+ {openModalForAccept && (
444
+ <OModal
445
+ open={openModalForAccept}
446
+ onClose={() => setOpenModalForAccept(false)}
447
+ entireModal
448
+ customClose>
449
+ <AcceptOrRejectOrder
450
+ handleUpdateOrder={handleChangeOrderStatus}
451
+ closeModal={setOpenModalForAccept}
452
+ customerCellphone={order?.customer?.cellphone}
453
+ loading={props.order?.loading}
454
+ action={actionOrder}
455
+ orderId={order?.id}
456
+ notShowCustomerPhone
457
+ actions={actions}
458
+ orderTitle={orderTitle}
459
+ appTitle={appTitle}
460
+ />
461
+ </OModal>
462
+ )}
469
463
  </View>
464
+ {alertState?.open && (
465
+ <Alert
466
+ open={alertState.open}
467
+ onAccept={handleArrowBack}
468
+ onClose={handleArrowBack}
469
+ content={alertState.content}
470
+ title={t('WARNING', 'Warning')}
471
+ />
472
+ )}
470
473
  </>
471
474
  );
472
475
  };
@@ -526,9 +526,9 @@ export interface TagsParams {
526
526
  interface actions {
527
527
  accept: string;
528
528
  reject: string;
529
- pickupFailed: string;
530
- deliveryFailed: string;
531
- notReady: string;
529
+ pickupFailed?: string;
530
+ deliveryFailed?: string;
531
+ notReady?: string;
532
532
  }
533
533
 
534
534
  interface textTranslate {
@@ -79,7 +79,7 @@ export const BusinessBasicInformation = (
79
79
  onPress={() => auth
80
80
  ? navigation.navigate('AddressList', { isGoBack: true, isFromProductsList: true })
81
81
  : navigation.navigate('AddressForm', { address: orderState.options?.address })}
82
- style={{marginTop: !auth ? 36 : top > 0 ? 0 : 20}}
82
+ style={{marginTop: (!auth || props.isFranchiseApp) ? 36 : top > 0 ? 0 : 20}}
83
83
  activeOpacity={0.8}
84
84
  >
85
85
  <OIcon src={theme.images.general.pin} width={16} color={theme.colors.textSecondary} />
@@ -28,6 +28,7 @@ import { ProductForm } from '../ProductForm'
28
28
  // import { UpsellingProducts } from '../UpsellingProducts'
29
29
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
30
30
  import { _setStoreData } from '../../providers/StoreUtil';
31
+ import NavBar from '../NavBar';
31
32
 
32
33
  const PIXELS_TO_SCROLL = 1000
33
34
 
@@ -180,15 +181,14 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
180
181
  scrollEventThrottle={16}
181
182
  >
182
183
  <WrapHeader>
183
- {!auth &&
184
+ {(!auth || props.isFranchiseApp) && !loading &&
184
185
  <TopHeader style={{top: top}}>
185
- <OButton
186
- imgLeftSrc={theme.images.general.arrow_left}
187
- imgRightSrc={null}
188
- style={styles.btnBackArrow}
189
- onClick={() => navigation?.canGoBack() && navigation.goBack()}
190
- imgLeftStyle={{ tintColor: theme.colors.white }}
191
- />
186
+ <NavBar
187
+ style={{ paddingBottom: 0, marginLeft: 20, backgroundColor: 'transparent' }}
188
+ btnStyle={{ backgroundColor: 'transparent' }}
189
+ leftImageStyle={{ tintColor: theme.colors.white }}
190
+ onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
191
+ />
192
192
  </TopHeader>
193
193
  }
194
194
  <BusinessBasicInformation
@@ -197,6 +197,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
197
197
  openBusinessInformation={openBusinessInformation}
198
198
  header={header}
199
199
  logo={logo}
200
+ isFranchiseApp={props.isFranchiseApp}
200
201
  />
201
202
  </WrapHeader>
202
203
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />