ordering-ui-react-native 0.19.6-testing → 0.19.7-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 +6 -5
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessInformation/index.tsx +10 -9
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OToast.tsx +3 -2
- package/src/utils/index.tsx +2 -2
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
- package/themes/business/src/components/BusinessController/index.tsx +19 -17
- package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
- package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
- package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
- package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
- package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
- package/themes/business/src/components/Chat/index.tsx +41 -13
- package/themes/business/src/components/DriverMap/index.tsx +4 -2
- package/themes/business/src/components/DriverSchedule/index.tsx +5 -5
- package/themes/business/src/components/FloatingButton/index.tsx +34 -31
- package/themes/business/src/components/MapView/index.tsx +11 -7
- package/themes/business/src/components/MessagesOption/index.tsx +22 -94
- package/themes/business/src/components/NewOrderNotification/index.tsx +121 -103
- package/themes/business/src/components/OrderDetails/Delivery.tsx +19 -10
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +88 -51
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +26 -6
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
- package/themes/business/src/components/OrderSummary/index.tsx +27 -13
- package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
- package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
- package/themes/business/src/components/OrdersOption/index.tsx +83 -37
- package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +24 -31
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
- package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
- package/themes/business/src/components/PreviousOrders/index.tsx +192 -220
- package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/SearchBar/index.tsx +2 -1
- package/themes/business/src/components/StoresList/index.tsx +5 -3
- package/themes/business/src/components/UserProfileForm/index.tsx +26 -10
- package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
- package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
- package/themes/business/src/types/index.tsx +10 -0
- 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 +6 -0
- package/themes/kiosk/src/components/LoginForm/index.tsx +124 -96
- 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/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +7 -3
- package/themes/original/src/components/AddressForm/index.tsx +2 -2
- package/themes/original/src/components/AddressForm/styles.tsx +1 -1
- package/themes/original/src/components/AddressList/index.tsx +4 -7
- package/themes/original/src/components/AddressList/styles.tsx +4 -4
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +3 -3
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
- package/themes/original/src/components/BusinessController/index.tsx +9 -6
- package/themes/original/src/components/BusinessController/styles.tsx +8 -7
- package/themes/original/src/components/BusinessInformation/index.tsx +35 -3
- package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
- package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
- package/themes/original/src/components/BusinessListingSearch/index.tsx +56 -361
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
- package/themes/original/src/components/BusinessPreorder/index.tsx +3 -4
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsList/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +43 -19
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +3 -4
- package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +29 -402
- 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 +27 -8
- package/themes/original/src/components/CartContent/index.tsx +61 -39
- package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +199 -55
- package/themes/original/src/components/Checkout/styles.tsx +17 -0
- package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
- package/themes/original/src/components/DatePicker/index.tsx +17 -0
- package/themes/original/src/components/DatePicker/styles.tsx +20 -0
- package/themes/original/src/components/Favorite/index.tsx +4 -9
- package/themes/original/src/components/Favorite/styles.tsx +0 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
- package/themes/original/src/components/GPSButton/index.tsx +1 -1
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
- package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
- package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
- package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
- package/themes/original/src/components/GoogleMap/index.tsx +50 -5
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
- package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrder/index.tsx +2 -1
- package/themes/original/src/components/LastOrders/index.tsx +2 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +53 -47
- package/themes/original/src/components/LoginForm/index.tsx +6 -1
- package/themes/original/src/components/Messages/index.tsx +9 -4
- package/themes/original/src/components/Messages/styles.tsx +1 -1
- package/themes/original/src/components/MomentOption/index.tsx +4 -4
- package/themes/original/src/components/MomentSelector/index.tsx +1 -1
- package/themes/original/src/components/MultiCart/index.tsx +1 -1
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +13 -4
- package/themes/original/src/components/MultiCheckout/index.tsx +226 -52
- package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +19 -14
- package/themes/original/src/components/MyOrders/index.tsx +5 -5
- package/themes/original/src/components/NavBar/index.tsx +3 -1
- package/themes/original/src/components/NetworkError/index.tsx +2 -3
- package/themes/original/src/components/NetworkError/styles.tsx +2 -2
- package/themes/original/src/components/Notifications/index.tsx +4 -8
- package/themes/original/src/components/Notifications/styles.tsx +0 -1
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +7 -3
- package/themes/original/src/components/OrderDetails/index.tsx +716 -667
- package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
- package/themes/original/src/components/OrderProgress/index.tsx +7 -7
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
- package/themes/original/src/components/OrderSummary/index.tsx +5 -3
- package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
- package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
- package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
- package/themes/original/src/components/OrdersOption/index.tsx +4 -3
- package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
- package/themes/original/src/components/PageBanner/index.tsx +3 -0
- package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
- package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +75 -33
- package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -1
- package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
- package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
- package/themes/original/src/components/ProductForm/index.tsx +81 -167
- package/themes/original/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/ProductItemAccordion/index.tsx +5 -0
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +120 -79
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
- package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
- package/themes/original/src/components/Promotions/index.tsx +4 -4
- package/themes/original/src/components/Promotions/styles.tsx +0 -2
- package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
- package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
- package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
- package/themes/original/src/components/ServiceForm/index.tsx +2 -2
- package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
- package/themes/original/src/components/SingleOrderCard/index.tsx +4 -3
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +23 -8
- package/themes/original/src/components/StripeElementsForm/index.tsx +5 -3
- package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
- package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
- package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
- package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
- package/themes/original/src/components/UserFormDetails/index.tsx +53 -7
- package/themes/original/src/components/UserProfile/index.tsx +1 -1
- package/themes/original/src/components/UserProfileForm/index.tsx +30 -36
- package/themes/original/src/components/UserVerification/index.tsx +55 -50
- package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
- package/themes/original/src/components/Wallets/index.tsx +8 -9
- package/themes/original/src/components/Wallets/styles.tsx +1 -1
- package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
- package/themes/original/src/components/shared/OInput.tsx +1 -4
- package/themes/original/src/components/shared/OModal.tsx +12 -14
- package/themes/original/src/layouts/Container.tsx +5 -3
- package/themes/original/src/types/index.tsx +10 -2
- package/themes/original/src/utils/index.tsx +124 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/navigators/BottomNavigator.tsx +0 -117
- package/src/navigators/CheckoutNavigator.tsx +0 -66
- package/src/navigators/HomeNavigator.tsx +0 -202
- package/src/navigators/NavigationRef.tsx +0 -7
- package/src/navigators/RootNavigator.tsx +0 -269
- package/src/pages/Account.tsx +0 -34
- package/src/pages/AddressForm.tsx +0 -62
- package/src/pages/AddressList.tsx +0 -24
- package/src/pages/BusinessProductsList.tsx +0 -81
- package/src/pages/BusinessesListing.tsx +0 -43
- package/src/pages/CartList.tsx +0 -49
- package/src/pages/Checkout.tsx +0 -101
- package/src/pages/ForgotPassword.tsx +0 -24
- package/src/pages/Help.tsx +0 -23
- package/src/pages/HelpAccountAndPayment.tsx +0 -23
- package/src/pages/HelpGuide.tsx +0 -23
- package/src/pages/HelpOrder.tsx +0 -23
- package/src/pages/Home.tsx +0 -36
- package/src/pages/IntroductoryTutorial.tsx +0 -170
- package/src/pages/Login.tsx +0 -47
- package/src/pages/MomentOption.tsx +0 -30
- package/src/pages/MultiCheckout.tsx +0 -31
- package/src/pages/MultiOrdersDetails.tsx +0 -27
- package/src/pages/MyOrders.tsx +0 -40
- package/src/pages/NetworkError.tsx +0 -24
- package/src/pages/NotFound.tsx +0 -22
- package/src/pages/OrderDetails.tsx +0 -25
- package/src/pages/ProductDetails.tsx +0 -55
- package/src/pages/Profile.tsx +0 -36
- package/src/pages/ReviewDriver.tsx +0 -30
- package/src/pages/ReviewOrder.tsx +0 -32
- package/src/pages/ReviewProducts.tsx +0 -30
- package/src/pages/Sessions.tsx +0 -22
- package/src/pages/Signup.tsx +0 -53
- package/src/pages/SpinnerLoader.tsx +0 -10
- package/src/pages/Splash.tsx +0 -21
|
@@ -2,20 +2,18 @@ import React, { useState, useEffect } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
Pressable,
|
|
5
|
-
StyleSheet
|
|
6
|
-
Dimensions,
|
|
7
|
-
ScrollView,
|
|
8
|
-
RefreshControl,
|
|
5
|
+
StyleSheet
|
|
9
6
|
} from 'react-native';
|
|
10
7
|
import { Contacts, useLanguage } from 'ordering-components/native';
|
|
11
8
|
import { useTheme } from 'styled-components/native';
|
|
12
|
-
import {
|
|
13
|
-
import { OText, OButton } from '../shared';
|
|
9
|
+
import { OText } from '../shared';
|
|
14
10
|
import { NotFoundSource } from '../NotFoundSource';
|
|
15
11
|
import { PreviousMessages } from '../PreviousMessages';
|
|
16
12
|
import { FiltersTab, TabsContainer, TagsContainer, Tag } from './styles';
|
|
17
13
|
import { MessagesOptionParams } from '../../types';
|
|
18
14
|
import { useDeviceOrientation } from '../../../../../src/hooks/DeviceOrientation';
|
|
15
|
+
import { WebsocketStatus } from '../WebsocketStatus'
|
|
16
|
+
|
|
19
17
|
const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
20
18
|
const {
|
|
21
19
|
orders,
|
|
@@ -65,12 +63,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
|
65
63
|
),
|
|
66
64
|
);
|
|
67
65
|
|
|
68
|
-
const [orientation, setOrientation] = useState(
|
|
69
|
-
Dimensions.get('window').width < Dimensions.get('window').height
|
|
70
|
-
? 'Portrait'
|
|
71
|
-
: 'Landscape',
|
|
72
|
-
);
|
|
73
|
-
|
|
74
66
|
const getTagFilter = (key: number) => {
|
|
75
67
|
return tags.find(value => value.key === key)?.text;
|
|
76
68
|
};
|
|
@@ -114,14 +106,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
|
114
106
|
);
|
|
115
107
|
}, [orders]);
|
|
116
108
|
|
|
117
|
-
Dimensions.addEventListener('change', ({ window: { width, height } }) => {
|
|
118
|
-
if (width < height) {
|
|
119
|
-
setOrientation('Portrait');
|
|
120
|
-
} else {
|
|
121
|
-
setOrientation('Landscape');
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
109
|
const styles = StyleSheet.create({
|
|
126
110
|
header: {
|
|
127
111
|
marginBottom: 25,
|
|
@@ -180,7 +164,7 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
|
180
164
|
<View style={styles.header}>
|
|
181
165
|
<OText style={styles.title}>{t('MESSAGES', 'Messages')}</OText>
|
|
182
166
|
</View>
|
|
183
|
-
|
|
167
|
+
<WebsocketStatus />
|
|
184
168
|
<FiltersTab>
|
|
185
169
|
<TabsContainer width={dimensions.width - 42}>
|
|
186
170
|
{tabs.map((tab: any) => (
|
|
@@ -242,35 +226,28 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
|
242
226
|
!error
|
|
243
227
|
? t('NO_RESULTS_FOUND', 'Sorry, no results found')
|
|
244
228
|
: error[0]?.message ||
|
|
245
|
-
|
|
246
|
-
|
|
229
|
+
error[0] ||
|
|
230
|
+
t('NETWORK_ERROR', 'Network Error')
|
|
247
231
|
}
|
|
248
232
|
image={theme.images.general.notFound}
|
|
249
233
|
conditioned={false}
|
|
250
234
|
/>
|
|
251
235
|
)}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
{
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
setOrders={setOrders}
|
|
268
|
-
messages={messages}
|
|
269
|
-
onNavigationRedirect={onNavigationRedirect}
|
|
270
|
-
/>
|
|
271
|
-
)}
|
|
272
|
-
|
|
273
|
-
{/* {!reload &&
|
|
236
|
+
<PreviousMessages
|
|
237
|
+
orders={values}
|
|
238
|
+
messages={messages}
|
|
239
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
240
|
+
getOrders={getOrders}
|
|
241
|
+
pagination={pagination}
|
|
242
|
+
loading={loading}
|
|
243
|
+
reload={reload}
|
|
244
|
+
tabs={tabs}
|
|
245
|
+
tabsFilter={tabsFilter}
|
|
246
|
+
setOrders={setOrders}
|
|
247
|
+
loadMore={loadMore}
|
|
248
|
+
error={error}
|
|
249
|
+
/>
|
|
250
|
+
{/* {!reload &&
|
|
274
251
|
!error &&
|
|
275
252
|
orders.length > 0 &&
|
|
276
253
|
JSON.stringify(tabsFilter) === JSON.stringify(tabs[1].tags) && (
|
|
@@ -283,55 +260,6 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
|
|
|
283
260
|
onNavigationRedirect={onNavigationRedirect}
|
|
284
261
|
/>
|
|
285
262
|
)} */}
|
|
286
|
-
|
|
287
|
-
{(loading || reload) && (
|
|
288
|
-
<>
|
|
289
|
-
<View>
|
|
290
|
-
{[...Array(5)].map((item, i) => (
|
|
291
|
-
<Placeholder key={i} Animation={Fade}>
|
|
292
|
-
<View
|
|
293
|
-
style={{
|
|
294
|
-
width: '100%',
|
|
295
|
-
flexDirection: 'row',
|
|
296
|
-
marginBottom: 10,
|
|
297
|
-
}}>
|
|
298
|
-
<PlaceholderLine
|
|
299
|
-
width={orientation === 'Portrait' ? 22 : 11}
|
|
300
|
-
height={74}
|
|
301
|
-
style={{
|
|
302
|
-
marginRight: 20,
|
|
303
|
-
marginBottom: 20,
|
|
304
|
-
borderRadius: 7.6,
|
|
305
|
-
}}
|
|
306
|
-
/>
|
|
307
|
-
<Placeholder>
|
|
308
|
-
<PlaceholderLine width={30} style={{ marginTop: 5 }} />
|
|
309
|
-
<PlaceholderLine width={50} />
|
|
310
|
-
<PlaceholderLine width={20} />
|
|
311
|
-
</Placeholder>
|
|
312
|
-
</View>
|
|
313
|
-
</Placeholder>
|
|
314
|
-
))}
|
|
315
|
-
</View>
|
|
316
|
-
</>
|
|
317
|
-
)}
|
|
318
|
-
|
|
319
|
-
{pagination?.totalPages &&
|
|
320
|
-
!loading &&
|
|
321
|
-
!reload &&
|
|
322
|
-
JSON.stringify(tabsFilter) === JSON.stringify(tabs[0].tags) &&
|
|
323
|
-
pagination?.currentPage < pagination?.totalPages && (
|
|
324
|
-
<OButton
|
|
325
|
-
onClick={() => loadMore && loadMore()}
|
|
326
|
-
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
327
|
-
imgRightSrc={null}
|
|
328
|
-
textStyle={styles.loadButtonText}
|
|
329
|
-
style={styles.loadButton}
|
|
330
|
-
bgColor={theme.colors.primary}
|
|
331
|
-
borderColor={theme.colors.primary}
|
|
332
|
-
/>
|
|
333
|
-
)}
|
|
334
|
-
</ScrollView>
|
|
335
263
|
</>
|
|
336
264
|
);
|
|
337
265
|
};
|
|
@@ -1,80 +1,102 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
View,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Dimensions,
|
|
7
|
+
TouchableOpacity
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { useTheme } from 'styled-components/native'
|
|
1
10
|
import moment from 'moment'
|
|
2
|
-
import { NewOrderNotification as NewOrderNotificationController, useApi, useEvent, useLanguage, useSession } from 'ordering-components/native'
|
|
3
|
-
import React, { useEffect, useState } from 'react'
|
|
4
|
-
import { Dimensions, Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
5
|
-
import Sound from 'react-native-sound'
|
|
6
11
|
import Icon from 'react-native-vector-icons/Feather'
|
|
7
|
-
import
|
|
12
|
+
import SoundPlayer from 'react-native-sound-player'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
NewOrderNotification as NewOrderNotificationController,
|
|
16
|
+
useApi,
|
|
17
|
+
useEvent,
|
|
18
|
+
useLanguage,
|
|
19
|
+
useSession
|
|
20
|
+
} from 'ordering-components/native'
|
|
8
21
|
|
|
9
|
-
import { useLocation } from '../../hooks/useLocation'
|
|
10
22
|
import { OIcon, OText } from '../shared'
|
|
11
23
|
import { NotificationContainer } from './styles'
|
|
24
|
+
import { useLocation } from '../../hooks/useLocation'
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
Sound.setMode('Default')
|
|
15
|
-
|
|
26
|
+
const DELAY_SOUND = 2500 // 2 sec
|
|
16
27
|
const windowWidth = Dimensions.get('screen').width
|
|
17
28
|
|
|
18
|
-
const
|
|
29
|
+
const SoundPlayerComponent = (props: any) => {
|
|
30
|
+
const { evtList, currentEvent, handleCloseEvents } = props
|
|
19
31
|
|
|
20
|
-
const NewOrderNotificationUI = (props: any) => {
|
|
21
|
-
const { isBusinessApp } = props
|
|
22
|
-
const [events] = useEvent()
|
|
23
32
|
const theme = useTheme()
|
|
24
|
-
const [,
|
|
25
|
-
const [{ user, token }] = useSession()
|
|
26
|
-
const [ordering] = useApi()
|
|
27
|
-
const { getCurrentLocation } = useLocation();
|
|
28
|
-
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
33
|
+
const [count, setCount] = useState(0);
|
|
29
34
|
|
|
30
|
-
const
|
|
31
|
-
1: {
|
|
32
|
-
event: 'messages',
|
|
33
|
-
message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
|
|
34
|
-
message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
|
|
35
|
-
},
|
|
36
|
-
2: {
|
|
37
|
-
event: 'order_added',
|
|
38
|
-
message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
|
|
39
|
-
message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
|
|
40
|
-
},
|
|
41
|
-
3: {
|
|
42
|
-
event: 'order_updated',
|
|
43
|
-
message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
|
|
44
|
-
message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
|
|
45
|
-
},
|
|
46
|
-
}
|
|
35
|
+
const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const id = setInterval(() => setCount(count + 1), 2500)
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
const playSound = async () => {
|
|
41
|
+
SoundPlayer.playUrl(URL_SOUND)
|
|
42
|
+
await new Promise(resolve => setTimeout(resolve, DELAY_SOUND))
|
|
43
|
+
SoundPlayer.stop()
|
|
44
|
+
}
|
|
52
45
|
|
|
53
|
-
|
|
54
|
-
notificationSound.stop()
|
|
55
|
-
setCurrentEvent(null)
|
|
56
|
-
clearInterval(_timeout)
|
|
57
|
-
}
|
|
46
|
+
playSound()
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (times === 3) {
|
|
63
|
-
times = 0
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
return
|
|
48
|
+
return () => {
|
|
49
|
+
SoundPlayer.stop()
|
|
50
|
+
clearInterval(id);
|
|
67
51
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
}, [count])
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Modal
|
|
56
|
+
animationType='slide'
|
|
57
|
+
transparent={true}
|
|
58
|
+
visible={!!currentEvent?.orderId}
|
|
59
|
+
>
|
|
60
|
+
<NotificationContainer>
|
|
61
|
+
<View style={styles.modalView}>
|
|
62
|
+
<TouchableOpacity
|
|
63
|
+
style={styles.wrapperIcon}
|
|
64
|
+
onPress={() => handleCloseEvents()}
|
|
65
|
+
>
|
|
66
|
+
<Icon name="x" size={30} />
|
|
67
|
+
</TouchableOpacity>
|
|
68
|
+
<OText
|
|
69
|
+
size={18}
|
|
70
|
+
color={theme.colors.textGray}
|
|
71
|
+
weight={600}
|
|
72
|
+
>
|
|
73
|
+
{evtList(currentEvent)[currentEvent?.evt]?.message}
|
|
74
|
+
</OText>
|
|
75
|
+
<OIcon
|
|
76
|
+
src={theme.images.general.newOrder}
|
|
77
|
+
width={250}
|
|
78
|
+
height={200}
|
|
79
|
+
/>
|
|
80
|
+
<OText
|
|
81
|
+
color={theme.colors.textGray}
|
|
82
|
+
mBottom={15}
|
|
83
|
+
>
|
|
84
|
+
{evtList(currentEvent)[currentEvent?.evt]?.message2}
|
|
85
|
+
</OText>
|
|
86
|
+
</View>
|
|
87
|
+
</NotificationContainer>
|
|
88
|
+
</Modal>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const NewOrderNotificationUI = (props: any) => {
|
|
93
|
+
const { isBusinessApp, evtList } = props
|
|
94
|
+
|
|
95
|
+
const [events] = useEvent()
|
|
96
|
+
const [{ user, token }] = useSession()
|
|
97
|
+
const [ordering] = useApi()
|
|
98
|
+
const { getCurrentLocation } = useLocation()
|
|
99
|
+
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
78
100
|
|
|
79
101
|
const handleEventNotification = async (evtType: number, value: any) => {
|
|
80
102
|
if (value?.driver) {
|
|
@@ -91,14 +113,18 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
91
113
|
const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
|
|
92
114
|
const assignedSecondsDiff = duration.asSeconds()
|
|
93
115
|
if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
|
|
94
|
-
|
|
116
|
+
setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
|
|
95
117
|
}
|
|
96
118
|
}
|
|
97
|
-
if (evtType === 3 || value.author_id === user.id) return
|
|
98
|
-
|
|
119
|
+
if ((evtType === 3 && (value.status !== 8 || !value?.driver) && !value.uuid) || value?.author_id === user.id) return
|
|
120
|
+
setCurrentEvent({
|
|
99
121
|
evt: evtType,
|
|
100
|
-
orderId: value?.driver
|
|
101
|
-
|
|
122
|
+
orderId: value?.driver
|
|
123
|
+
? value?.order_id ?? value?.id
|
|
124
|
+
: evtList(currentEvent)[evtType].event === 'messages'
|
|
125
|
+
? value?.order?.id
|
|
126
|
+
: value?.order_id ?? value?.id
|
|
127
|
+
})
|
|
102
128
|
}
|
|
103
129
|
|
|
104
130
|
useEffect(() => {
|
|
@@ -118,48 +144,21 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
118
144
|
}, [])
|
|
119
145
|
|
|
120
146
|
useEffect(() => {
|
|
121
|
-
return () =>
|
|
147
|
+
return () => setCurrentEvent(null)
|
|
122
148
|
}, [])
|
|
123
149
|
|
|
124
150
|
return (
|
|
125
151
|
<>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<TouchableOpacity
|
|
134
|
-
style={styles.wrapperIcon}
|
|
135
|
-
onPress={() => handleCloseEvents()}
|
|
136
|
-
>
|
|
137
|
-
<Icon name="x" size={30} />
|
|
138
|
-
</TouchableOpacity>
|
|
139
|
-
<OText
|
|
140
|
-
size={18}
|
|
141
|
-
color={theme.colors.textGray}
|
|
142
|
-
weight={600}
|
|
143
|
-
>
|
|
144
|
-
{evtList[currentEvent?.evt]?.message}
|
|
145
|
-
</OText>
|
|
146
|
-
<OIcon
|
|
147
|
-
src={theme.images.general.newOrder}
|
|
148
|
-
width={250}
|
|
149
|
-
height={200}
|
|
150
|
-
/>
|
|
151
|
-
<OText
|
|
152
|
-
color={theme.colors.textGray}
|
|
153
|
-
mBottom={15}
|
|
154
|
-
>
|
|
155
|
-
{evtList[currentEvent?.evt]?.message2}
|
|
156
|
-
</OText>
|
|
157
|
-
</View>
|
|
158
|
-
</NotificationContainer>
|
|
159
|
-
</Modal>
|
|
152
|
+
{!!currentEvent ? (
|
|
153
|
+
<SoundPlayerComponent
|
|
154
|
+
evtList={evtList}
|
|
155
|
+
currentEvent={currentEvent}
|
|
156
|
+
handleCloseEvents={() => setCurrentEvent(null)}
|
|
157
|
+
/>
|
|
158
|
+
) : null}
|
|
160
159
|
</>
|
|
161
160
|
)
|
|
162
|
-
}
|
|
161
|
+
};
|
|
163
162
|
|
|
164
163
|
const styles = StyleSheet.create({
|
|
165
164
|
modalView: {
|
|
@@ -179,9 +178,28 @@ const styles = StyleSheet.create({
|
|
|
179
178
|
})
|
|
180
179
|
|
|
181
180
|
export const NewOrderNotification = (props: any) => {
|
|
181
|
+
const [, t] = useLanguage()
|
|
182
|
+
|
|
182
183
|
const newOrderNotificationProps = {
|
|
183
184
|
...props,
|
|
184
|
-
UIComponent: NewOrderNotificationUI
|
|
185
|
+
UIComponent: NewOrderNotificationUI,
|
|
186
|
+
evtList: (currentEvent: any) => ({
|
|
187
|
+
1: {
|
|
188
|
+
event: 'messages',
|
|
189
|
+
message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
|
|
190
|
+
message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
|
|
191
|
+
},
|
|
192
|
+
2: {
|
|
193
|
+
event: 'order_added',
|
|
194
|
+
message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
|
|
195
|
+
message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
|
|
196
|
+
},
|
|
197
|
+
3: {
|
|
198
|
+
event: 'order_updated',
|
|
199
|
+
message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
|
|
200
|
+
message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
|
|
201
|
+
},
|
|
202
|
+
})
|
|
185
203
|
};
|
|
186
204
|
|
|
187
205
|
return <NewOrderNotificationController {...newOrderNotificationProps} />;
|
|
@@ -61,9 +61,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
61
61
|
const [, { showToast }] = useToast();
|
|
62
62
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
63
63
|
const [{ configs }] = useConfig();
|
|
64
|
+
|
|
64
65
|
const { order } = props.order
|
|
65
66
|
|
|
66
67
|
const isAllowedDriverRejectOrder = configs?.allow_driver_reject_order?.value === '1'
|
|
68
|
+
const isHideRejectButtons = configs?.reject_orders_enabled && configs?.reject_orders_enabled?.value !== '1'
|
|
67
69
|
const theme = useTheme();
|
|
68
70
|
const [, t] = useLanguage();
|
|
69
71
|
const [session] = useSession();
|
|
@@ -88,9 +90,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
88
90
|
const logisticOrderStatus = [4, 6, 7]
|
|
89
91
|
|
|
90
92
|
const showFloatButtonsPickUp: any = {
|
|
91
|
-
8:
|
|
93
|
+
8: !isHideRejectButtons,
|
|
92
94
|
3: true,
|
|
93
|
-
18:
|
|
95
|
+
18: !isHideRejectButtons,
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
const showFloatButtonsAcceptOrReject: any = {
|
|
@@ -113,6 +115,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
113
115
|
readMessages && readMessages();
|
|
114
116
|
};
|
|
115
117
|
|
|
118
|
+
const goToPermissionPage = () => {
|
|
119
|
+
navigation.navigate('RequestPermissions')
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
const handleOpenMapView = async () => {
|
|
117
123
|
if (!isGrantedPermissions) {
|
|
118
124
|
navigation.navigate('RequestPermissions')
|
|
@@ -387,7 +393,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
387
393
|
}, [props.order?.loading]);
|
|
388
394
|
|
|
389
395
|
useEffect(() => {
|
|
390
|
-
if (
|
|
396
|
+
if (order?.driver_id === null && session?.user?.level === 4) {
|
|
391
397
|
setAlertState({
|
|
392
398
|
open: true,
|
|
393
399
|
content: [
|
|
@@ -476,13 +482,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
476
482
|
textStyle={{ color: theme.colors.primary }}
|
|
477
483
|
text={t('ARRIVED_TO_BUSINESS', 'Arrived to bussiness')}
|
|
478
484
|
onClick={() =>
|
|
479
|
-
handleChangeOrderStatus && handleChangeOrderStatus(3)
|
|
485
|
+
handleChangeOrderStatus && isGrantedPermissions ? handleChangeOrderStatus(3) : goToPermissionPage()
|
|
480
486
|
}
|
|
481
487
|
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
482
488
|
/>
|
|
483
489
|
</Pickup>
|
|
484
490
|
)}
|
|
485
|
-
{order?.status === 3 && order?.delivery_type === 1 && (
|
|
491
|
+
{order?.status === 3 && order?.delivery_type === 1 && !isHideRejectButtons && (
|
|
486
492
|
<View style={{ paddingVertical: 20, marginBottom: 20 }}>
|
|
487
493
|
<OButton
|
|
488
494
|
style={styles.btnPickUp}
|
|
@@ -568,7 +574,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
568
574
|
btnText={t('PICKUP_FAILED', 'Pickup failed')}
|
|
569
575
|
isSecondaryBtn={false}
|
|
570
576
|
secondButtonClick={() =>
|
|
571
|
-
handleChangeOrderStatus && handleChangeOrderStatus(9)
|
|
577
|
+
handleChangeOrderStatus && isGrantedPermissions ? handleChangeOrderStatus(9) : goToPermissionPage()
|
|
572
578
|
}
|
|
573
579
|
firstButtonClick={() =>
|
|
574
580
|
handleViewActionOrder && handleViewActionOrder('pickupFailed')
|
|
@@ -577,7 +583,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
577
583
|
secondButton={true}
|
|
578
584
|
firstColorCustom={theme.colors.red}
|
|
579
585
|
secondColorCustom={theme.colors.green}
|
|
580
|
-
widthButton={'45%'}
|
|
586
|
+
widthButton={isHideRejectButtons ? '100%': '45%'}
|
|
587
|
+
isHideRejectButtons={isHideRejectButtons}
|
|
581
588
|
/>
|
|
582
589
|
)}
|
|
583
590
|
{(validStatusComplete.includes(order?.status)) && (
|
|
@@ -587,7 +594,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
587
594
|
btnText={t('DELIVERY_FAILED', 'Delivery Failed')}
|
|
588
595
|
isSecondaryBtn={false}
|
|
589
596
|
secondButtonClick={() =>
|
|
590
|
-
handleChangeOrderStatus && handleChangeOrderStatus(11)
|
|
597
|
+
handleChangeOrderStatus && isGrantedPermissions ? handleChangeOrderStatus(11) : goToPermissionPage()
|
|
591
598
|
}
|
|
592
599
|
firstButtonClick={() =>
|
|
593
600
|
handleViewActionOrder && handleViewActionOrder('deliveryFailed')
|
|
@@ -596,7 +603,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
596
603
|
secondButton={true}
|
|
597
604
|
firstColorCustom={theme.colors.red}
|
|
598
605
|
secondColorCustom={theme.colors.green}
|
|
599
|
-
widthButton={'45%'}
|
|
606
|
+
widthButton={isHideRejectButtons ? '100%': '45%'}
|
|
607
|
+
isHideRejectButtons={isHideRejectButtons}
|
|
600
608
|
/>
|
|
601
609
|
</>
|
|
602
610
|
)}
|
|
@@ -610,7 +618,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
610
618
|
secondButton={true}
|
|
611
619
|
firstColorCustom={theme.colors.red}
|
|
612
620
|
secondColorCustom={theme.colors.green}
|
|
613
|
-
widthButton={'45%'}
|
|
621
|
+
widthButton={isHideRejectButtons ? '100%': '45%'}
|
|
622
|
+
isHideRejectButtons={isHideRejectButtons}
|
|
614
623
|
/>
|
|
615
624
|
)}
|
|
616
625
|
</>
|