ordering-ui-react-native 0.22.56 → 0.22.57-release
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 +5 -7
- package/src/DeliveryApp.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +40 -39
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/context/OfflineActions/index.tsx +236 -0
- package/src/providers/AlertProvider.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/BusinessController/index.tsx +8 -3
- package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
- package/themes/business/src/components/Chat/index.tsx +15 -3
- package/themes/business/src/components/DriverMap/index.tsx +44 -33
- package/themes/business/src/components/FloatingButton/index.tsx +3 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/business/src/components/LoginForm/index.tsx +123 -98
- package/themes/business/src/components/LogoutButton/index.tsx +13 -4
- package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
- package/themes/business/src/components/MapView/index.tsx +68 -142
- package/themes/business/src/components/NewOrderNotification/index.tsx +25 -14
- package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
- package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
- package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
- package/themes/business/src/components/OrderSummary/index.tsx +271 -176
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +345 -231
- package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +30 -18
- package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
- package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
- package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
- package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
- package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
- package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/config/currency.tsx +1010 -0
- package/themes/business/src/hooks/useLocation.tsx +16 -12
- package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
- package/themes/business/src/types/index.tsx +34 -7
- package/themes/business/src/utils/index.tsx +28 -3
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +223 -219
- package/themes/original/src/components/AddressForm/index.tsx +19 -8
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
- package/themes/original/src/components/BusinessController/index.tsx +4 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +10 -4
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
- package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
- package/themes/original/src/components/BusinessPreorder/index.tsx +34 -15
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
- package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +48 -13
- package/themes/original/src/components/CartContent/index.tsx +2 -3
- package/themes/original/src/components/Checkout/index.tsx +130 -89
- package/themes/original/src/components/Favorite/index.tsx +1 -5
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +1 -2
- package/themes/original/src/components/GoogleMap/index.tsx +39 -18
- package/themes/original/src/components/Help/functions.tsx +76 -0
- package/themes/original/src/components/Help/index.tsx +74 -29
- package/themes/original/src/components/Help/styles.tsx +4 -1
- package/themes/original/src/components/HelpOptions/index.tsx +44 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +35 -16
- package/themes/original/src/components/LoginForm/index.tsx +12 -5
- package/themes/original/src/components/MessageListing/index.tsx +1 -1
- package/themes/original/src/components/Messages/index.tsx +20 -13
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +72 -51
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCheckout/index.tsx +76 -35
- package/themes/original/src/components/MyOrders/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +6 -2
- package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
- package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
- package/themes/original/src/components/OrderDetails/index.tsx +44 -19
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +4 -3
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
- package/themes/original/src/components/OrdersOption/index.tsx +3 -6
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/ProductForm/ActionButton.tsx +6 -10
- package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
- package/themes/original/src/components/ServiceForm/index.tsx +1 -1
- package/themes/original/src/components/SignupForm/index.tsx +41 -24
- package/themes/original/src/components/SingleOrderCard/index.tsx +7 -4
- package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +9 -4
- package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
- package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
- package/themes/original/src/components/UserProfile/index.tsx +9 -1
- package/themes/original/src/components/UserVerification/index.tsx +18 -5
- package/themes/original/src/components/shared/OAlert.tsx +2 -1
- package/themes/original/src/components/shared/OButton.tsx +2 -2
- package/themes/original/src/components/shared/OInput.tsx +4 -8
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/types/index.tsx +699 -689
- package/themes/original/src/utils/index.tsx +29 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
- package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
- package/themes/original/src/components/HelpGuide/index.tsx +0 -68
- package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
- package/themes/original/src/components/HelpOrder/index.tsx +0 -71
- package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ordering-ui-react-native",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.57-release",
|
|
4
4
|
"description": "Reusable components made in react native",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"author": "ordering.inc",
|
|
@@ -51,14 +51,13 @@
|
|
|
51
51
|
"@react-navigation/stack": "^5.9.3",
|
|
52
52
|
"@segment/analytics-react-native": "2.1.11",
|
|
53
53
|
"@segment/sovran-react-native": "0.2.6",
|
|
54
|
-
"@
|
|
55
|
-
"@stripe/stripe-react-native": "0.23.0",
|
|
54
|
+
"@stripe/stripe-react-native": "0.23.0",
|
|
56
55
|
"@types/react-native-loading-spinner-overlay": "^0.5.2",
|
|
57
56
|
"@types/react-native-snap-carousel": "^3.8.4",
|
|
58
57
|
"@types/styled-components": "^5.1.3",
|
|
59
58
|
"axios": "^0.21.0",
|
|
60
59
|
"moment": "^2.29.1",
|
|
61
|
-
"ordering-components": "github:Ordering-Inc/ordering-components#
|
|
60
|
+
"ordering-components": "github:Ordering-Inc/ordering-components#release",
|
|
62
61
|
"patch-package": "^6.4.7",
|
|
63
62
|
"postinstall-postinstall": "^2.1.0",
|
|
64
63
|
"prop-types": "^15.7.2",
|
|
@@ -86,12 +85,12 @@
|
|
|
86
85
|
"react-native-gesture-handler": "^1.8.0",
|
|
87
86
|
"react-native-get-random-values": "1.8.0",
|
|
88
87
|
"react-native-gifted-chat": "^0.16.3",
|
|
89
|
-
"react-native-google-places-autocomplete": "
|
|
88
|
+
"react-native-google-places-autocomplete": "2.1.3",
|
|
90
89
|
"react-native-html-to-pdf": "^0.10.0",
|
|
91
90
|
"react-native-image-picker": "^4.0.6",
|
|
92
91
|
"react-native-intersection-observer": "^0.0.9",
|
|
93
92
|
"react-native-lightbox": "^0.8.1",
|
|
94
|
-
"react-native-linear-gradient": "
|
|
93
|
+
"react-native-linear-gradient": "2.7.3",
|
|
95
94
|
"react-native-loading-spinner-overlay": "^2.0.0",
|
|
96
95
|
"react-native-map-link": "^2.8.2",
|
|
97
96
|
"react-native-maps": "^0.28.0",
|
|
@@ -102,7 +101,6 @@
|
|
|
102
101
|
"react-native-phone-number-input": "^2.0.0",
|
|
103
102
|
"react-native-picker-select": "^8.0.4",
|
|
104
103
|
"react-native-print": "^0.9.0",
|
|
105
|
-
"react-native-reanimated": "^1.13.1",
|
|
106
104
|
"react-native-recaptcha-that-works": "^1.2.0",
|
|
107
105
|
"react-native-restart": "^0.0.22",
|
|
108
106
|
"react-native-safe-area-context": "^3.1.8",
|
package/src/DeliveryApp.tsx
CHANGED
|
@@ -191,7 +191,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
191
191
|
{isFarAway && (
|
|
192
192
|
<FarAwayMessage style={styles.farAwayMsg}>
|
|
193
193
|
<Ionicons name='md-warning-outline' style={styles.iconStyle} />
|
|
194
|
-
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', '
|
|
194
|
+
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
|
|
195
195
|
</FarAwayMessage>
|
|
196
196
|
)}
|
|
197
197
|
</OrderControlContainer>
|
|
@@ -295,6 +295,7 @@ const CheckoutUI = (props: any) => {
|
|
|
295
295
|
</Placeholder>
|
|
296
296
|
) : (
|
|
297
297
|
<AddressDetails
|
|
298
|
+
cart={cart}
|
|
298
299
|
navigation={navigation}
|
|
299
300
|
location={businessDetails?.business?.location}
|
|
300
301
|
businessLogo={businessDetails?.business?.logo}
|
|
@@ -598,14 +599,14 @@ const CheckoutUI = (props: any) => {
|
|
|
598
599
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
599
600
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
600
601
|
(Number(cart?.driver_tip) <= 0) && (
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
602
|
+
<OText
|
|
603
|
+
style={{ textAlign: 'center' }}
|
|
604
|
+
color={theme.colors.error}
|
|
605
|
+
size={14}
|
|
606
|
+
>
|
|
607
|
+
{t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
|
|
608
|
+
</OText>
|
|
609
|
+
)}
|
|
609
610
|
</ChErrors>
|
|
610
611
|
</ChSection>
|
|
611
612
|
)}
|
|
@@ -617,15 +618,15 @@ const CheckoutUI = (props: any) => {
|
|
|
617
618
|
<FloatingButton
|
|
618
619
|
handleClick={() => handlePlaceOrder()}
|
|
619
620
|
isSecondaryBtn={loading || !cart?.valid || !paymethodSelected || placing || errorCash || cart?.subtotal_to_calculate < cart?.minimum || paymethodSelected?.gateway === 'paypal' ||
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
621
|
+
(options.type === 1 &&
|
|
622
|
+
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
623
|
+
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
624
|
+
(Number(cart?.driver_tip) <= 0))}
|
|
624
625
|
disabled={loading || !cart?.valid || !paymethodSelected || placing || errorCash || cart?.subtotal_to_calculate < cart?.minimum || paymethodSelected?.gateway === 'paypal' ||
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
626
|
+
(options.type === 1 &&
|
|
627
|
+
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
628
|
+
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
629
|
+
(Number(cart?.driver_tip) <= 0))}
|
|
629
630
|
btnText={cart?.subtotal_to_calculate >= cart?.minimum
|
|
630
631
|
? (
|
|
631
632
|
placing
|
|
@@ -641,31 +642,31 @@ const CheckoutUI = (props: any) => {
|
|
|
641
642
|
</>
|
|
642
643
|
)}
|
|
643
644
|
{webviewPaymethod?.gateway === 'paypal' && showGateway.open && (
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
645
|
+
<PaymentOptionsWebView
|
|
646
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
647
|
+
uri={`${ordering.root}/html/paypal_react_native`}
|
|
648
|
+
user={user}
|
|
649
|
+
token={token}
|
|
650
|
+
cart={cart}
|
|
651
|
+
currency={currency}
|
|
652
|
+
webviewPaymethod={webviewPaymethod}
|
|
653
|
+
setShowGateway={setShowGateway}
|
|
654
|
+
setOpenOrderCreating={setOpenOrderCreating}
|
|
655
|
+
/>
|
|
655
656
|
)}
|
|
656
657
|
{webviewPaymethod?.gateway === 'square' && showGateway.open && (
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
658
|
+
<PaymentOptionsWebView
|
|
659
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
660
|
+
uri={`https://test-square-f50f7.web.app`}
|
|
661
|
+
user={user}
|
|
662
|
+
token={token}
|
|
663
|
+
cart={cart}
|
|
664
|
+
currency={currency}
|
|
665
|
+
webviewPaymethod={webviewPaymethod}
|
|
666
|
+
setShowGateway={setShowGateway}
|
|
667
|
+
setOpenOrderCreating={setOpenOrderCreating}
|
|
668
|
+
locationId={'L1NGAY5M6KJRX'}
|
|
669
|
+
/>
|
|
669
670
|
)}
|
|
670
671
|
{openOrderCreating && (
|
|
671
672
|
<View style={{ zIndex: 9999, height: '100%', width: '100%', position: 'absolute', backgroundColor: 'white' }}>
|
|
@@ -2,7 +2,7 @@ import styled from 'styled-components/native';
|
|
|
2
2
|
|
|
3
3
|
export const Container = styled.View`
|
|
4
4
|
width: 100%;
|
|
5
|
-
padding: 0
|
|
5
|
+
padding: 0 30px;
|
|
6
6
|
`
|
|
7
7
|
|
|
8
8
|
export const CountDownContainer = styled.View`
|
|
@@ -20,7 +20,6 @@ export const ResendSection = styled.View`
|
|
|
20
20
|
display: flex;
|
|
21
21
|
flex-direction: row;
|
|
22
22
|
justify-content: center;
|
|
23
|
-
flex-wrap: wrap;
|
|
24
23
|
`
|
|
25
24
|
|
|
26
25
|
export const WrappCountdown = styled.View`
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import React, { useState, createContext, useEffect, useContext } from 'react';
|
|
2
|
+
import { useApi, useSession, useEvent, useWebsocket } from 'ordering-components/native'
|
|
3
|
+
import { useNetInfo } from '@react-native-community/netinfo';
|
|
4
|
+
|
|
5
|
+
import { _retrieveStoreData, _setStoreData, _removeStoreData } from '../../providers/StoreUtil'
|
|
6
|
+
|
|
7
|
+
type State = {
|
|
8
|
+
isNetConnected: boolean | null
|
|
9
|
+
isCombinedTabs: boolean | null
|
|
10
|
+
canSaveChangesOffline: boolean | null
|
|
11
|
+
actions: { [key: string]: any }
|
|
12
|
+
orders: { [key: string]: any } | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type Functions = {
|
|
16
|
+
applyOffAction: (changes: any) => any
|
|
17
|
+
registerOffOrder: (order: any) => any
|
|
18
|
+
setState: React.Dispatch<React.SetStateAction<State>>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const defaultState = {
|
|
22
|
+
isNetConnected: null,
|
|
23
|
+
isCombinedTabs: null,
|
|
24
|
+
canSaveChangesOffline: false,
|
|
25
|
+
actions: {},
|
|
26
|
+
orders: null,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export const OfflineActionsContext = createContext<[State, Functions]>([
|
|
31
|
+
defaultState,
|
|
32
|
+
{
|
|
33
|
+
applyOffAction: () => {},
|
|
34
|
+
registerOffOrder: () => {},
|
|
35
|
+
setState: () => {}
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
export const OfflineActionsProvider = (props: any) => {
|
|
40
|
+
const netInfo = useNetInfo()
|
|
41
|
+
const [ordering] = useApi()
|
|
42
|
+
const [{ token }] = useSession()
|
|
43
|
+
const [events] = useEvent()
|
|
44
|
+
const socket = useWebsocket()
|
|
45
|
+
|
|
46
|
+
const [state, setState] = useState<State>({
|
|
47
|
+
isNetConnected: netInfo.isConnected,
|
|
48
|
+
isCombinedTabs: false,
|
|
49
|
+
canSaveChangesOffline: false,
|
|
50
|
+
actions: [],
|
|
51
|
+
orders: null
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const getStatusById = (id: number) => {
|
|
55
|
+
if (!id && id !== 0) return
|
|
56
|
+
const active = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21]
|
|
57
|
+
const pending = [0, 13]
|
|
58
|
+
const inProgress = [3, 4, 7, 8, 9, 14, 18, 19, 20, 21]
|
|
59
|
+
const completed = [1, 11, 15]
|
|
60
|
+
|
|
61
|
+
const status = pending.includes(id)
|
|
62
|
+
? 'pending'
|
|
63
|
+
: inProgress.includes(id)
|
|
64
|
+
? 'inProgress'
|
|
65
|
+
: completed.includes(id)
|
|
66
|
+
? 'completed'
|
|
67
|
+
: 'cancelled'
|
|
68
|
+
|
|
69
|
+
const combinedStatus = active.includes(id)
|
|
70
|
+
? 'active'
|
|
71
|
+
: completed.includes(id)
|
|
72
|
+
? 'completed'
|
|
73
|
+
: 'cancelled'
|
|
74
|
+
|
|
75
|
+
return state.isCombinedTabs ? combinedStatus : status
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const applyOffAction = async (changes: any) => {
|
|
79
|
+
if (state.canSaveChangesOffline === false) return false
|
|
80
|
+
|
|
81
|
+
let _actions: any = state.actions?.[changes?.data?.orderId] ?? []
|
|
82
|
+
|
|
83
|
+
if (state.actions?.[changes?.data?.orderId]) {
|
|
84
|
+
_actions.push(changes)
|
|
85
|
+
} else {
|
|
86
|
+
_actions = [changes]
|
|
87
|
+
}
|
|
88
|
+
const actions = { ...state.actions, [changes?.data?.orderId]: _actions }
|
|
89
|
+
|
|
90
|
+
setState(state => ({ ...state, actions }))
|
|
91
|
+
await _setStoreData('offline_actions_array', actions)
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const registerOffOrder = async (order: any) => {
|
|
96
|
+
if (!order) return
|
|
97
|
+
|
|
98
|
+
const oldStatusString = getStatusById(order?.oldStatus)
|
|
99
|
+
const newStatusString = getStatusById(order?.status)
|
|
100
|
+
|
|
101
|
+
const orderStatuses: any = [oldStatusString]
|
|
102
|
+
oldStatusString !== newStatusString && orderStatuses.push(newStatusString)
|
|
103
|
+
|
|
104
|
+
const ordersStoraged: any = {}
|
|
105
|
+
for (const status of orderStatuses) {
|
|
106
|
+
ordersStoraged[status] = await _retrieveStoreData(`${status}_orders`)
|
|
107
|
+
|
|
108
|
+
if (ordersStoraged[status]) {
|
|
109
|
+
if (orderStatuses.length === 1) {
|
|
110
|
+
ordersStoraged[status] = [
|
|
111
|
+
...ordersStoraged[status].filter((_order: any) => _order.id !== order.id),
|
|
112
|
+
order
|
|
113
|
+
].sort((a: any, b: any) => b.id - a.id)
|
|
114
|
+
} else if (orderStatuses.length === 2) {
|
|
115
|
+
if (status === oldStatusString) {
|
|
116
|
+
ordersStoraged[status] = ordersStoraged[status]
|
|
117
|
+
.filter((_order: any) => _order.id !== order.id)
|
|
118
|
+
.sort((a: any, b: any) => b.id - a.id)
|
|
119
|
+
}
|
|
120
|
+
if (status === newStatusString) {
|
|
121
|
+
ordersStoraged[status] = [
|
|
122
|
+
...ordersStoraged[status],
|
|
123
|
+
order
|
|
124
|
+
].sort((a: any, b: any) => b.id - a.id)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
await _setStoreData(`${status}_orders`, ordersStoraged[status]);
|
|
128
|
+
} else {
|
|
129
|
+
ordersStoraged[status] = [order]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (Object.keys(ordersStoraged).length) {
|
|
133
|
+
setState(state => ({ ...state, orders: ordersStoraged }))
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const syncChanges = async (changes: any) => {
|
|
138
|
+
const ordersIdUpdated: any = []
|
|
139
|
+
|
|
140
|
+
Object.keys(changes).forEach(async (orderId) => {
|
|
141
|
+
const arr = changes[orderId]
|
|
142
|
+
|
|
143
|
+
const [lastChange, ...restOfChanges] = arr.reverse();
|
|
144
|
+
|
|
145
|
+
if (restOfChanges.length > 0) {
|
|
146
|
+
const ordersString = restOfChanges
|
|
147
|
+
.map((obj: any) => (
|
|
148
|
+
Object.entries(obj?.data?.body).map(([clave, valor]) => `${clave}: '${valor}'`).join(', ')
|
|
149
|
+
))
|
|
150
|
+
.join(', ')
|
|
151
|
+
handleSendMessage({ message: ordersString, orderId })
|
|
152
|
+
}
|
|
153
|
+
const id = await updateOrderStatus({ orderId, body: lastChange?.data?.body })
|
|
154
|
+
id && ordersIdUpdated.push(id);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
ordersIdUpdated.length && events.emit('offline_order_updated', ordersIdUpdated)
|
|
158
|
+
await _removeStoreData('offline_actions_array');
|
|
159
|
+
setState(state => ({ ...state, actions: [] }));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const actionsFromStorage = async (isConnected: boolean) => {
|
|
163
|
+
setState(state => ({ ...state, isNetConnected: isConnected }))
|
|
164
|
+
const storedActions = await _retrieveStoreData('offline_actions_array');
|
|
165
|
+
|
|
166
|
+
if (isConnected && Object.keys(storedActions)?.length) {
|
|
167
|
+
syncChanges(storedActions)
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Object.keys(storedActions)?.length && setState(state => ({ ...state, actions: storedActions }));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (netInfo.isConnected === null || state.canSaveChangesOffline === false) return
|
|
176
|
+
actionsFromStorage(netInfo.isConnected)
|
|
177
|
+
}, [netInfo.isConnected])
|
|
178
|
+
|
|
179
|
+
const functions: any = {
|
|
180
|
+
applyOffAction,
|
|
181
|
+
registerOffOrder,
|
|
182
|
+
setState
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const updateOrderStatus = async (offlineData: any) => {
|
|
186
|
+
try {
|
|
187
|
+
const { content: { result: order, error } } = await ordering
|
|
188
|
+
.setAccessToken(token)
|
|
189
|
+
.orders(offlineData?.orderId)
|
|
190
|
+
.save(offlineData?.body)
|
|
191
|
+
|
|
192
|
+
return error ? null : order?.id
|
|
193
|
+
} catch {
|
|
194
|
+
return null
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const handleSendMessage = async (offlineData: any) => {
|
|
199
|
+
try {
|
|
200
|
+
const _canRead = [0, 2, 3, 4]
|
|
201
|
+
const body = {
|
|
202
|
+
comment: offlineData?.message,
|
|
203
|
+
type: 2,
|
|
204
|
+
can_see: _canRead.join(',')
|
|
205
|
+
}
|
|
206
|
+
const response = await fetch(`${ordering.root}/orders/${offlineData?.orderId}/messages`, {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
headers: {
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
Authorization: `Bearer ${token}`,
|
|
211
|
+
'X-App-X': ordering.appId,
|
|
212
|
+
'X-Socket-Id-X': socket?.getId()
|
|
213
|
+
},
|
|
214
|
+
body: JSON.stringify(body)
|
|
215
|
+
})
|
|
216
|
+
const { error, result } = await response.json()
|
|
217
|
+
} catch {
|
|
218
|
+
return null
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const eventsDictiorary: any = {
|
|
223
|
+
evt_off_change_order_status: updateOrderStatus
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<OfflineActionsContext.Provider value={[{ ...state, isNetConnected: netInfo.isConnected }, functions]}>
|
|
228
|
+
{props.children}
|
|
229
|
+
</OfflineActionsContext.Provider>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export const useOfflineActions = () => {
|
|
234
|
+
const actionsManager = useContext(OfflineActionsContext)
|
|
235
|
+
return actionsManager || [defaultState, {}]
|
|
236
|
+
}
|
|
@@ -8,7 +8,8 @@ interface Props {
|
|
|
8
8
|
title: string,
|
|
9
9
|
content: Array<string>,
|
|
10
10
|
onClose: () => void,
|
|
11
|
-
onAccept: () => void
|
|
11
|
+
onAccept: () => void,
|
|
12
|
+
onCancel: () => void
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const Alert = (props: Props) => {
|
|
@@ -38,6 +39,7 @@ const Alert = (props: Props) => {
|
|
|
38
39
|
confirmText={t('ACCEPT', 'Accept')}
|
|
39
40
|
confirmButtonColor={theme.colors.primary}
|
|
40
41
|
onCancelPressed={() => onClose()}
|
|
42
|
+
showCancelButton={!!props.onCancel}
|
|
41
43
|
onConfirmPressed={() => onAccept()}
|
|
42
44
|
/>
|
|
43
45
|
)
|
|
@@ -31,6 +31,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
31
31
|
notShowCustomerPhone,
|
|
32
32
|
orderTitle,
|
|
33
33
|
appTitle,
|
|
34
|
+
isLoadingOrder
|
|
34
35
|
} = props;
|
|
35
36
|
|
|
36
37
|
const [, t] = useLanguage();
|
|
@@ -277,7 +278,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
bodyToSend.id = orderId;
|
|
280
|
-
handleUpdateOrder
|
|
281
|
+
handleUpdateOrder?.(bodyToSend.status, bodyToSend);
|
|
281
282
|
};
|
|
282
283
|
|
|
283
284
|
useEffect(() => {
|
|
@@ -427,13 +428,15 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
427
428
|
{action === 'accept' && (
|
|
428
429
|
<View style={{ height: 300, justifyContent: 'center' }}>
|
|
429
430
|
<Timer onPress={() => openTimerIOnput()}>
|
|
430
|
-
<OText weight="600"
|
|
431
|
+
<OText weight="600" size={55}>
|
|
431
432
|
{hour}
|
|
432
433
|
</OText>
|
|
433
|
-
{hour.length > 0 && <OText size={55}>:</OText>}
|
|
434
|
-
<OText weight="600"
|
|
434
|
+
{hour.length > 0 && <OText size={55} style={{ marginBottom: 10 }}>:</OText>}
|
|
435
|
+
<OText weight="600" size={55}>
|
|
435
436
|
{min}
|
|
436
437
|
</OText>
|
|
438
|
+
{time?.length > 2 && <OText style={{ position: 'absolute', bottom: 60, left: 55 }}>{t('HOURS', 'Hours')}</OText>}
|
|
439
|
+
<OText style={{ position: 'absolute', bottom: 60, right: time?.length > 2 ? 55 : 95 }}>{t('MINUTES', 'Minutes')}</OText>
|
|
437
440
|
</Timer>
|
|
438
441
|
</View>
|
|
439
442
|
)}
|
|
@@ -517,7 +520,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
517
520
|
...styles.bottomParent,
|
|
518
521
|
marginBottom: Platform.OS === 'ios'
|
|
519
522
|
? 30 : (keyboardState.height === 0)
|
|
520
|
-
? isPage ? 0 :
|
|
523
|
+
? isPage ? 0 : 40
|
|
521
524
|
: keyboardState.height - (isPage ? 20 : -10)
|
|
522
525
|
}}
|
|
523
526
|
>
|
|
@@ -529,7 +532,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
529
532
|
style={{ borderRadius: 7, height: 45 }}
|
|
530
533
|
parentStyle={{ width: '100%' }}
|
|
531
534
|
textStyle={{ color: '#FFF', fontSize: 18 }}
|
|
532
|
-
isDisabled={showTextArea && !comments}
|
|
535
|
+
isDisabled={(showTextArea && !comments) || isLoadingOrder}
|
|
533
536
|
onClick={() => handleAcceptOrReject()}
|
|
534
537
|
/>
|
|
535
538
|
</View>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { StyleSheet, View, ActivityIndicator, TouchableOpacity } from 'react-native';
|
|
3
|
+
import FastImage from 'react-native-fast-image'
|
|
3
4
|
import ToggleSwitch from 'toggle-switch-react-native';
|
|
4
5
|
import { useTheme } from 'styled-components/native';
|
|
5
6
|
import {
|
|
@@ -99,10 +100,14 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
99
100
|
onPress={() => navigation && business?.slug && navigation.navigate('BusinessProductListing', { slug: business?.slug })}
|
|
100
101
|
>
|
|
101
102
|
<Logo style={styles.logo}>
|
|
102
|
-
<
|
|
103
|
-
url={optimizeImage(business?.logo, 'h_300,c_limit')}
|
|
104
|
-
src={!business?.logo && theme?.images?.dummies?.businessLogo}
|
|
103
|
+
<FastImage
|
|
105
104
|
style={styles.icon}
|
|
105
|
+
source={business?.logo?.includes('https') ? {
|
|
106
|
+
uri: business?.logo,
|
|
107
|
+
priority: FastImage.priority.high,
|
|
108
|
+
cache: FastImage.cacheControl.immutable
|
|
109
|
+
} : business?.logo ?? theme?.images?.dummies?.businessLogo}
|
|
110
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
106
111
|
/>
|
|
107
112
|
</Logo>
|
|
108
113
|
<Information>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { View, StyleSheet, ScrollView, Dimensions, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, ScrollView, Dimensions, TouchableOpacity, Platform } from 'react-native';
|
|
3
3
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import { SearchBar } from '../SearchBar';
|
|
@@ -115,7 +115,7 @@ const BusinessProductListUI = (props: any) => {
|
|
|
115
115
|
<ScrollView
|
|
116
116
|
showsVerticalScrollIndicator={false}
|
|
117
117
|
style={styles.container}>
|
|
118
|
-
{!loading &&
|
|
118
|
+
{!loading && categories?.length === 0 && (
|
|
119
119
|
<NotFoundSource
|
|
120
120
|
content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
|
|
121
121
|
image={theme.images.general.notFound}
|
|
@@ -190,6 +190,7 @@ export const BusinessProductList = (props: any) => {
|
|
|
190
190
|
const businessProductListProps = {
|
|
191
191
|
...props,
|
|
192
192
|
UIComponent: BusinessProductListUI,
|
|
193
|
+
isIos: Platform.OS === 'ios'
|
|
193
194
|
};
|
|
194
195
|
|
|
195
196
|
return <StoreProductList {...businessProductListProps} />;
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
useSession,
|
|
37
37
|
useUtils,
|
|
38
38
|
useLanguage,
|
|
39
|
+
useConfig
|
|
39
40
|
} from 'ordering-components/native';
|
|
40
41
|
import { Header, TitleHeader, Wrapper, QuickMessageContainer } from './styles';
|
|
41
42
|
import { OIcon, OIconButton, OText, OButton } from '../shared';
|
|
@@ -68,8 +69,9 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
68
69
|
const [, t] = useLanguage();
|
|
69
70
|
const [, { showToast }] = useToast();
|
|
70
71
|
const theme = useTheme();
|
|
72
|
+
const [{ configs }] = useConfig();
|
|
71
73
|
const [messageList, setMessageList] = useState<any>([])
|
|
72
|
-
const previousStatus = [1, 2, 5, 6, 10, 11, 12, 16, 17]
|
|
74
|
+
const previousStatus = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
|
|
73
75
|
const chatDisabled = previousStatus.includes(order?.status)
|
|
74
76
|
|
|
75
77
|
const ORDER_STATUS: any = {
|
|
@@ -96,7 +98,10 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
96
98
|
20: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Order customer almost arrived to business'),
|
|
97
99
|
21: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Order customer arrived to business'),
|
|
98
100
|
22: t('ORDER_LOOKING_FOR_DRIVER', 'Order looking for driver'),
|
|
99
|
-
23: t('ORDER_DRIVER_ON_WAY', 'Driver on way')
|
|
101
|
+
23: t('ORDER_DRIVER_ON_WAY', 'Driver on way'),
|
|
102
|
+
24: t('ORDER_DRIVER_WAITING_FOR_ORDER', 'Driver waiting for order'),
|
|
103
|
+
25: t('ORDER_ACCEPTED_BY_DRIVER_COMPANY', 'Accepted by driver company'),
|
|
104
|
+
26: t('ORDER_DRIVER_ARRIVED_CUSTOMER', 'Driver arrived to customer')
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
const getLogisticTag = (status: any) => {
|
|
@@ -498,6 +503,7 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
498
503
|
|
|
499
504
|
const firstMessage = {
|
|
500
505
|
_id: 0,
|
|
506
|
+
type: 0,
|
|
501
507
|
text: console,
|
|
502
508
|
createdAt: parseDate(order?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
|
|
503
509
|
system: true,
|
|
@@ -517,6 +523,7 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
517
523
|
text: message.type === 1 ? messageConsole(message) : message.comment,
|
|
518
524
|
createdAt: message.type !== 0 && parseDate(message?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
|
|
519
525
|
image: message.source,
|
|
526
|
+
type: message.type,
|
|
520
527
|
system: message.type === 1,
|
|
521
528
|
user: {
|
|
522
529
|
_id: message.author?.id,
|
|
@@ -537,7 +544,12 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
537
544
|
newMessages = [...newMessages, newMessage];
|
|
538
545
|
}
|
|
539
546
|
});
|
|
540
|
-
|
|
547
|
+
let _arrayMessages = [...newMessages.reverse()]
|
|
548
|
+
|
|
549
|
+
if (configs?.order_logbook_enabled?.value === '0' && user?.level === 4) {
|
|
550
|
+
_arrayMessages = _arrayMessages.filter(msg => msg.type !== 1 && msg.type !== 0)
|
|
551
|
+
}
|
|
552
|
+
setFormattedMessages(_arrayMessages);
|
|
541
553
|
}, [messages?.messages?.length]);
|
|
542
554
|
|
|
543
555
|
useEffect(() => {
|