ordering-ui-react-native 0.23.91 → 0.23.93

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.91",
3
+ "version": "0.23.93",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -38,7 +38,6 @@ import { OrderHeaderComponent } from './OrderHeaderComponent';
38
38
  import { OrderContentComponent } from './OrderContentComponent';
39
39
  import { _retrieveStoreData } from '../../providers/StoreUtil'
40
40
  import { usePrinterCommands } from './usePrinterCommands'
41
- import Alert from '../../../../../src/providers/AlertProvider'
42
41
 
43
42
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
44
43
  const {
@@ -78,7 +77,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
78
77
  const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
79
78
  const [printerSettings, setPrinterSettings] = useState<any>('')
80
79
  const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
81
- const [alertState, setAlertState] = useState<any>({ open: false, title: '', content: [] })
82
80
 
83
81
  const orderToComplete = [4, 20, 21]
84
82
  const orderToReady = [7, 14]
@@ -317,11 +315,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
317
315
  setUnreadAlert({ ...unreadAlert, business: false });
318
316
  };
319
317
 
320
- const handleViewActionOrder = (action: string, options?: any) => {
318
+ const handleViewActionOrder = async (action: string, options?: any) => {
321
319
  if (openModalForMapView) {
322
320
  setOpenModalForMapView(false);
323
321
  }
324
- if (options?.alert) {
322
+ if (options?.forceUpdateStatus) {
325
323
  let bodyToSend: any = {};
326
324
  const orderStatus: any = {
327
325
  acceptByBusiness: {
@@ -333,25 +331,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
333
331
  bodyToSend = orderStatus[actions.accept];
334
332
  }
335
333
  bodyToSend.id = order?.id;
336
- setAlertState({
337
- open: true,
338
- content: options?.content,
339
- title: t('ORDER_STATUS', 'Order status'),
340
- onAccept: async () => {
341
- setAlertState({
342
- open: false,
343
- content: []
344
- })
345
- const order = await handleChangeOrderStatus(bodyToSend?.status, bodyToSend)
346
- if (order?.id) {
347
- setActionOrder(action);
348
- setOpenModalForAccept(true);
349
- } else {
350
- showToast(ToastType.Error, t('FAILED_TO_UPDATE_ORDER', 'Failed to update order'), 5000)
351
- }
352
- }
353
- })
354
- return
334
+ const _order = await handleChangeOrderStatus(bodyToSend?.status, bodyToSend)
335
+ if (!_order?.id) {
336
+ showToast(ToastType.Error, t('FAILED_TO_UPDATE_ORDER', 'Failed to update order'), 5000)
337
+ return
338
+ }
355
339
  }
356
340
  setActionOrder(action);
357
341
  setOpenModalForAccept(true);
@@ -400,14 +384,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
400
384
  navigation?.canGoBack() && navigation.goBack();
401
385
  };
402
386
 
403
- const closeAlert = () => {
404
- setAlertState({
405
- open: false,
406
- title: '',
407
- content: []
408
- })
409
- }
410
-
411
387
  useEffect(() => {
412
388
  if (messagesReadList?.length) {
413
389
  openModalForBusiness
@@ -698,7 +674,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
698
674
  <FloatingButton
699
675
  btnText={t('REJECT', 'Reject')}
700
676
  isSecondaryBtn={false}
701
- secondButtonClick={() => handleViewActionOrder('accept', { alert: true, content: t('DO_YOU_WANT_ACCEPT_ORDER', 'Do you want to accept the order?') })}
677
+ secondButtonClick={() => handleViewActionOrder('accept', { forceUpdateStatus: true })}
702
678
  firstButtonClick={() => handleViewActionOrder('reject')}
703
679
  secondBtnText={t('ACCEPT', 'Accept')}
704
680
  secondButton={true}
@@ -740,14 +716,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
740
716
  )}
741
717
  </View>
742
718
  )}
743
- <Alert
744
- open={alertState.open}
745
- content={alertState.content}
746
- title={alertState.title || ''}
747
- onAccept={alertState.onAccept}
748
- onClose={closeAlert}
749
- onCancel={closeAlert}
750
- />
751
719
  </>
752
720
  );
753
721
  };
@@ -40,6 +40,8 @@ function BusinessControllerPropsAreEqual(prevProps: any, nextProps: any) {
40
40
  prevProps.isBusinessOpen === nextProps.isBusinessOpen
41
41
  }
42
42
 
43
+ const deliveryTypes = [1, 7]
44
+
43
45
  export const BusinessControllerUI = React.memo((props: BusinessControllerParams) => {
44
46
  const {
45
47
  business,
@@ -321,14 +323,14 @@ export const BusinessControllerUI = React.memo((props: BusinessControllerParams)
321
323
  </View>
322
324
  ) : (
323
325
  <View style={styles.bullet}>
324
- {orderState?.options?.type === 1 && !hideBusinessFee && (
326
+ {deliveryTypes.includes(orderState?.options?.type) && !hideBusinessFee && (
325
327
  <OText size={textSize} color={theme.colors.textSecondary}>
326
328
  {`${t('DELIVERY_FEE', 'Delivery fee')} ${parsePrice(businessDeliveryPrice ?? business?.delivery_price) + ' \u2022 '}`}
327
329
  </OText>
328
330
  )}
329
331
  {!hideBusinessTime && (
330
332
  <OText size={textSize} color={theme.colors.textSecondary}>{`${convertHoursToMinutes(
331
- orderState?.options?.type === 1
333
+ deliveryTypes.includes(orderState?.options?.type)
332
334
  ? (businessDeliveryTime ?? business?.delivery_time)
333
335
  : (businessPickupTime ?? business?.pickup_time),
334
336
  )} \u2022 `}</OText>