ordering-ui-react-native 0.21.19 → 0.21.20-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 +7 -6
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/PaymentOptionsWebView/index.tsx +1 -0
- package/src/components/StripeMethodForm/index.tsx +4 -4
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/types/index.tsx +2 -1
- package/src/utils/index.tsx +2 -2
- package/themes/business/index.tsx +4 -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 -3
- package/themes/business/src/components/FloatingButton/index.tsx +34 -31
- package/themes/business/src/components/Home/index.tsx +5 -1
- package/themes/business/src/components/LanguageSelector/index.tsx +4 -2
- package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
- 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 +163 -113
- package/themes/business/src/components/OrderDetails/Business.tsx +50 -2
- package/themes/business/src/components/OrderDetails/Delivery.tsx +23 -11
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +60 -53
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +54 -23
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
- package/themes/business/src/components/OrderSummary/index.tsx +240 -76
- 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 +125 -48
- package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
- 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 +41 -38
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
- package/themes/business/src/components/PreviousOrders/index.tsx +194 -220
- package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +279 -0
- package/themes/business/src/components/PrinterSettings/styles.tsx +17 -0
- package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
- 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/Sessions/index.tsx +187 -0
- package/themes/business/src/components/Sessions/styles.tsx +20 -0
- package/themes/business/src/components/StoresList/index.tsx +5 -3
- package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
- package/themes/business/src/components/UserProfileForm/index.tsx +98 -43
- package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
- package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
- package/themes/business/src/components/shared/OInput.tsx +2 -0
- package/themes/business/src/hooks/useLocation.tsx +5 -4
- package/themes/business/src/types/index.tsx +21 -1
- package/themes/business/src/utils/index.tsx +5 -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 +7 -4
- 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 +9 -4
- package/themes/original/src/components/AddressDetails/index.tsx +20 -10
- package/themes/original/src/components/AddressForm/index.tsx +10 -6
- 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/AnalyticsSegment/index.tsx +6 -6
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
- package/themes/original/src/components/BusinessController/index.tsx +20 -12
- package/themes/original/src/components/BusinessController/styles.tsx +8 -7
- 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 +2 -3
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +51 -20
- 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 +24 -404
- 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 +32 -9
- package/themes/original/src/components/CartContent/index.tsx +96 -58
- package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +190 -66
- 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 +33 -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/GiftCardOrdersList/index.tsx +64 -0
- package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
- 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/GiftCard/SingleGiftCard/index.tsx +101 -0
- package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
- package/themes/original/src/components/GoogleMap/index.tsx +6 -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 +2 -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 +4 -16
- 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 -3
- package/themes/original/src/components/MultiCart/index.tsx +1 -1
- package/themes/original/src/components/MultiCheckout/index.tsx +208 -21
- package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
- package/themes/original/src/components/MyOrders/index.tsx +24 -29
- 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 +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +716 -668
- package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
- package/themes/original/src/components/OrderProgress/index.tsx +28 -6
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
- package/themes/original/src/components/OrderSummary/index.tsx +3 -1
- 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 +3 -5
- 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 +72 -6
- 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 +74 -165
- package/themes/original/src/components/ProductItemAccordion/index.tsx +54 -44
- package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +123 -82
- package/themes/original/src/components/ProductOptionSubOption/styles.tsx +6 -1
- 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 +5 -4
- package/themes/original/src/components/SingleProductCard/index.tsx +2 -2
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +17 -36
- package/themes/original/src/components/StripeElementsForm/index.tsx +72 -59
- package/themes/original/src/components/StripeElementsForm/naked.tsx +47 -0
- 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 +54 -8
- package/themes/original/src/components/UserFormDetails/styles.tsx +7 -0
- package/themes/original/src/components/UserProfile/index.tsx +3 -2
- package/themes/original/src/components/UserProfileForm/index.tsx +30 -36
- 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/WebsocketStatus/index.tsx +172 -0
- package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
- package/themes/original/src/components/shared/OButton.tsx +5 -5
- 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 +1 -0
- 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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { useConfig, useUtils, useLanguage} from 'ordering-components/native'
|
|
2
|
+
|
|
3
|
+
import { verifyDecimals, getProductPrice } from '../../utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook to create commands for star micronics printer using PassPRNT library
|
|
7
|
+
* @returns array of strings
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const usePrinterCommands = () => {
|
|
11
|
+
const [, t] = useLanguage()
|
|
12
|
+
const [{ configs }] = useConfig();
|
|
13
|
+
const [{ parsePrice, parseNumber, parseDate }] = useUtils();
|
|
14
|
+
|
|
15
|
+
const deliveryStatus: any = {
|
|
16
|
+
1: t('DELIVERY', 'Delivery'),
|
|
17
|
+
2: t('PICK_UP', 'Pick up'),
|
|
18
|
+
3: t('EAT_IN', 'Eat In'),
|
|
19
|
+
4: t('CURBSIDE', 'Curbside'),
|
|
20
|
+
5: t('DRIVER_THRU', 'Driver thru'),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const walletName: any = {
|
|
24
|
+
cash: {
|
|
25
|
+
name: t('CASH_WALLET', 'Cash Wallet')
|
|
26
|
+
},
|
|
27
|
+
credit_point: {
|
|
28
|
+
name: t('POINTS_WALLET', 'Points Wallet')
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const percentTip = (order: any) =>
|
|
33
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
34
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
35
|
+
verifyDecimals(order?.summary?.driver_tip, parseNumber);
|
|
36
|
+
|
|
37
|
+
const handlePaymethodsListString = (order: any) => {
|
|
38
|
+
const paymethodsList = order?.payment_events?.filter((item: any) => item.event === 'payment').map((paymethod: any) => {
|
|
39
|
+
return paymethod?.wallet_event
|
|
40
|
+
? walletName[paymethod?.wallet_event?.wallet?.type]?.name
|
|
41
|
+
: paymethod?.paymethod?.gateway && paymethod?.paymethod?.gateway === 'cash' && order?.cash > 0
|
|
42
|
+
? `${t(paymethod?.paymethod?.gateway?.toUpperCase(), paymethod?.paymethod?.name)} (${t('CASH_CHANGE_OF', 'Change of :amount:').replace(':amount:', parsePrice(order?.cash))})`
|
|
43
|
+
: paymethod?.paymethod?.gateway
|
|
44
|
+
? t(paymethod?.paymethod?.gateway?.toUpperCase(), paymethod?.paymethod?.name)
|
|
45
|
+
: t(order?.paymethod?.gateway?.toUpperCase(), order?.paymethod?.name)
|
|
46
|
+
})
|
|
47
|
+
return paymethodsList.join(', ')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const paymethodsLength = (order: any) => order?.payment_events?.filter((item: any) => item.event === 'payment')?.length
|
|
51
|
+
|
|
52
|
+
const customerName = (order: any) => `${order?.customer?.name ?? ''} ${order?.customer?.middle_name ?? ''} ${order?.customer?.lastname ?? ''} ${order?.customer?.second_lastname ?? ''}`?.replace(' ', ' ')?.trim() ?? ''
|
|
53
|
+
|
|
54
|
+
const deliveryDate = (order: any) => {
|
|
55
|
+
const dateString = order?.delivery_datetime_utc ?? order?.delivery_datetime
|
|
56
|
+
const currentDate = new Date();
|
|
57
|
+
const receivedDate: any = new Date(order?.delivery_datetime);
|
|
58
|
+
|
|
59
|
+
const formattedDate = receivedDate <= currentDate
|
|
60
|
+
? `${t('ASAP_ABBREVIATION', 'ASAP')}(${parseDate(dateString, { utc: !!order?.delivery_datetime_utc })})`
|
|
61
|
+
: parseDate(dateString, { utc: !!order?.delivery_datetime_utc })
|
|
62
|
+
return formattedDate
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const generateProductsText = (order: any, { endLine }: any) => {
|
|
66
|
+
const list: any = []
|
|
67
|
+
|
|
68
|
+
if (order?.products.length) {
|
|
69
|
+
order?.products.map((product: any) => {
|
|
70
|
+
list.push(`${product?.quantity} ${product?.name} \t ${parsePrice(product.total ?? getProductPrice(product))}${endLine}`)
|
|
71
|
+
|
|
72
|
+
if (product?.ingredients?.length) {
|
|
73
|
+
list.push({ text: `\t ${t('INGREDIENTS', 'Ingredients')}:${endLine}`, props: { fontSize: 10 } })
|
|
74
|
+
product?.ingredients?.map((ingredient: any) => {
|
|
75
|
+
list.push({ text: `\t ${t('NO', 'No')} ${ingredient.name}${endLine}` , fontSize: 10 })
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
product.options?.map((option: any) => {
|
|
80
|
+
list.push({ text: `\t ${option.name}${endLine}`, props: { fontSize: 10 } })
|
|
81
|
+
|
|
82
|
+
option.suboptions?.map((suboption: any) => {
|
|
83
|
+
const { quantity, name, position, price } = suboption
|
|
84
|
+
const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : ''
|
|
85
|
+
const string = name !== 'No'
|
|
86
|
+
? pos
|
|
87
|
+
? `${quantity} x ${name} ${pos} +${parsePrice(price)}`
|
|
88
|
+
: `${quantity} x ${name} +${parsePrice(price)}`
|
|
89
|
+
: 'No'
|
|
90
|
+
|
|
91
|
+
list.push({ text: `\t\t ${string}${endLine}`, props: { fontSize: 10 } })
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
if (product.comment) {
|
|
96
|
+
list.push({ text: `\t ${t('COMMENT', 'Comment')}${endLine}`, props: { fontSize: 10 } })
|
|
97
|
+
list.push({ text: `\t\t ${product.comment}${endLine}`, props: { fontSize: 10 } })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
list.push('_separator_')
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return list
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const paymethodsList = (order: any, { endLine }: any) => {
|
|
108
|
+
const list: any = []
|
|
109
|
+
|
|
110
|
+
if (order?.payment_events?.length > 0) {
|
|
111
|
+
order?.payment_events.map((event: any) => {
|
|
112
|
+
const payment = event?.wallet_event
|
|
113
|
+
? walletName[event?.wallet_event?.wallet?.type]?.name
|
|
114
|
+
: t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)
|
|
115
|
+
|
|
116
|
+
const amount = (event?.paymethod?.gateway === 'cash' && order?.cash)
|
|
117
|
+
? parsePrice(order?.cash, { currency: order?.currency })
|
|
118
|
+
: `-${parsePrice(event?.amount, { currency: order?.currency })}`
|
|
119
|
+
|
|
120
|
+
list.push(`${payment} \t ${amount}${endLine}`)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return list
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const replaceChars = (string: string) => {
|
|
128
|
+
const accents: any = {
|
|
129
|
+
'á': 'a',
|
|
130
|
+
'é': 'e',
|
|
131
|
+
'í': 'i',
|
|
132
|
+
'ó': 'o',
|
|
133
|
+
'ú': 'u',
|
|
134
|
+
'Á': 'A',
|
|
135
|
+
'É': 'E',
|
|
136
|
+
'Í': 'I',
|
|
137
|
+
'Ó': 'O',
|
|
138
|
+
'Ú': 'U',
|
|
139
|
+
'ü': 'u',
|
|
140
|
+
'Ü': 'U',
|
|
141
|
+
'ñ': 'n',
|
|
142
|
+
'Ñ': 'N',
|
|
143
|
+
"'": '',
|
|
144
|
+
"’": '',
|
|
145
|
+
"`": '',
|
|
146
|
+
};
|
|
147
|
+
return string.replace(/[áéíóúÁÉÍÓÚüÜñÑ'’`]/g, (match: any) => accents[match])
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const generateCommands = (order: any, printMode: string = 'append') => {
|
|
151
|
+
let commands: any = [];
|
|
152
|
+
|
|
153
|
+
const isAppendMode = printMode === 'append'
|
|
154
|
+
const jumpLine = isAppendMode ? '\n' : ' '
|
|
155
|
+
const endLine = isAppendMode ? '\n' : ''
|
|
156
|
+
|
|
157
|
+
const textProps = { fontSize: 12 }
|
|
158
|
+
|
|
159
|
+
const appends: any = [
|
|
160
|
+
{ text: `${t('ORDER_NO', 'Order No.')} ${order.id}${endLine}`, props: { fontSize: 16 } },
|
|
161
|
+
jumpLine,
|
|
162
|
+
`${order.orderStatus}${endLine}`,
|
|
163
|
+
{ text: `${t('ORDER_TYPE', 'Order Type')}: ${deliveryStatus[order?.delivery_type]}${endLine}`, props: { fontSize: 14 } },
|
|
164
|
+
{ text: `${t(`PAYMENT_METHOD${paymethodsLength(order) > 1 ? 'S' : ''}`, `Payment method${paymethodsLength(order) > 1 ? 's' : ''}`)}: ${handlePaymethodsListString(order)}${endLine}`, props: { fontSize: 14 } },
|
|
165
|
+
`${!!order?.delivery_option ? `${t('DELIVERY_PREFERENCE', 'Delivery Preference')}: ${t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}${endLine}` : ''}`,
|
|
166
|
+
`${t('DELIVERY_DATE', 'Delivery Date')}: ${deliveryDate(order)}${endLine}`,
|
|
167
|
+
'_separator_',
|
|
168
|
+
{ text: `${t('CUSTOMER_DETAILS', 'Customer details')}${endLine}`, props: { fontSize: 14 } },
|
|
169
|
+
`${t('FULL_NAME', 'Full Name')}: ${customerName(order)}${endLine}`,
|
|
170
|
+
`${t('EMAIL', 'Email')}: ${order?.customer?.email}${endLine}`,
|
|
171
|
+
`${!!order?.customer?.cellphone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}${endLine}` : ''}`,
|
|
172
|
+
`${!!order?.customer?.phone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.phone}${endLine}` : ''}`,
|
|
173
|
+
`${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}${endLine}`,
|
|
174
|
+
`${!!order?.customer?.internal_number ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number}${endLine}` : ''}`,
|
|
175
|
+
`${!!order?.customer?.zipcode ? `${t('ZIPCODE', 'Zipcode')}: ${order?.customer?.zipcode}${endLine}` : ''}`,
|
|
176
|
+
'_separator_',
|
|
177
|
+
{ text: `${t('BUSINESS_DETAILS', 'Business details')}${endLine}`, props: { fontSize: 14 } },
|
|
178
|
+
`${order?.business?.name}${endLine}`,
|
|
179
|
+
`${order?.business?.email}${endLine}`,
|
|
180
|
+
`${!!order?.business?.cellphone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}${endLine}` : ''}`,
|
|
181
|
+
`${!!order?.business?.phone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone}${endLine}` : ''}`,
|
|
182
|
+
`${t('ADDRESS', 'Address')}: ${order?.business?.address}${endLine}`,
|
|
183
|
+
`${!!order?.business?.address_notes ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes}${endLine}` : ''}`,
|
|
184
|
+
'_separator_',
|
|
185
|
+
{ text: `${t('ORDER_DETAILS', 'Order Details')}${endLine}`, props: { fontSize: 14 } },
|
|
186
|
+
`${!!order?.comment ? `${t('ORDER_COMMENT', 'Order Comment')}: ${order?.comment}${endLine}` : ''}`,
|
|
187
|
+
...generateProductsText(order, { endLine }),
|
|
188
|
+
`${t('SUBTOTAL', 'Subtotal')} \t\t ${parsePrice(order.tax_type === 1 ? (order?.summary?.subtotal + order?.summary?.tax) ?? 0 : order?.summary?.subtotal ?? 0)}${endLine}`,
|
|
189
|
+
`${order?.summary?.discount > 0 ? `${order?.offer_type === 1 ? `${t('DISCOUNT', 'Discount')} (${verifyDecimals(order?.offer_rate, parsePrice)}%)${endLine}` : t('DISCOUNT', 'Discount')} \t\t ${parsePrice(order?.summary?.discount)}${endLine}` : ''}`,
|
|
190
|
+
`${order?.tax_type !== 1 ? `${t('TAX', 'Tax')} (${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%) \t\t ${parsePrice(order?.summary?.tax ?? 0)}${endLine}` : ''}`,
|
|
191
|
+
`${order?.summary?.delivery_price > 0 && order.delivery_type !== 2 ? `${t('DELIVERY_FEE', 'Delivery Fee')} \t\t ${parsePrice(order?.summary?.delivery_price ?? 0)}${endLine}` : ''}`,
|
|
192
|
+
`${(order?.summary?.driver_tip > 0 || order?.driver_tip > 0) && order.delivery_type !== 2 ? `${t('DRIVER_TIP', 'Driver tip')} ${percentTip(order) ? `(${percentTip(order)}%)` : ''} \t\t ${parsePrice(order?.summary?.driver_tip ?? 0)}${endLine}` : ''}`,
|
|
193
|
+
`${order?.summary?.service_fee > 0 ? `${t('SERVICE_FEE', 'Service Fee')} (${verifyDecimals(order?.summary?.service_fee, parseNumber)}%) \t\t ${parsePrice(order?.summary?.service_fee ?? 0)}${endLine}` : ''}`,
|
|
194
|
+
'_separator_',
|
|
195
|
+
`${t('TOTAL', 'Total')} \t\t ${parsePrice(order?.summary?.total ?? 0)}${endLine}`,
|
|
196
|
+
jumpLine,
|
|
197
|
+
`${order?.payment_events?.length > 0 ? `${t('PAYMENTS', 'Payments')}${endLine}` : ''}`,
|
|
198
|
+
...paymethodsList(order, { endLine }),
|
|
199
|
+
jumpLine,
|
|
200
|
+
jumpLine,
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
commands = [
|
|
204
|
+
...commands,
|
|
205
|
+
...appends.map((append: any) => {
|
|
206
|
+
return append === '_separator_'
|
|
207
|
+
? { [printMode]: `---------------------------------------${endLine}` }
|
|
208
|
+
: {
|
|
209
|
+
[printMode]: replaceChars(append?.text ?? append),
|
|
210
|
+
...textProps,
|
|
211
|
+
...append?.props
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
return commands
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return { generateCommands }
|
|
220
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
useLanguage,
|
|
11
11
|
OrderDetails as OrderDetailsConTableoller,
|
|
12
12
|
useSession,
|
|
13
|
+
useConfig
|
|
13
14
|
} from 'ordering-components/native';
|
|
14
15
|
|
|
15
16
|
//Components
|
|
@@ -34,6 +35,8 @@ export const OrderDetailsLogisticUI = (props: OrderDetailsLogisticParams) => {
|
|
|
34
35
|
const theme = useTheme();
|
|
35
36
|
const [, t] = useLanguage();
|
|
36
37
|
const [session] = useSession();
|
|
38
|
+
const [{ configs }] = useConfig();
|
|
39
|
+
|
|
37
40
|
const [alertState, setAlertState] = useState<{
|
|
38
41
|
open: boolean;
|
|
39
42
|
content: Array<string>;
|
|
@@ -41,6 +44,7 @@ export const OrderDetailsLogisticUI = (props: OrderDetailsLogisticParams) => {
|
|
|
41
44
|
}>({ open: false, content: [], key: null });
|
|
42
45
|
|
|
43
46
|
const logisticOrderStatus = [4, 6, 7]
|
|
47
|
+
const isHideRejectButtons = configs?.reject_orders_enabled && configs?.reject_orders_enabled?.value !== '1'
|
|
44
48
|
|
|
45
49
|
const showFloatButtonsAcceptOrReject: any = {
|
|
46
50
|
0: true,
|
|
@@ -166,7 +170,8 @@ export const OrderDetailsLogisticUI = (props: OrderDetailsLogisticParams) => {
|
|
|
166
170
|
secondButton={true}
|
|
167
171
|
firstColorCustom={theme.colors.red}
|
|
168
172
|
secondColorCustom={theme.colors.green}
|
|
169
|
-
widthButton={'45%'}
|
|
173
|
+
widthButton={isHideRejectButtons ? '100%': '45%'}
|
|
174
|
+
isHideRejectButtons={isHideRejectButtons}
|
|
170
175
|
/>
|
|
171
176
|
)}
|
|
172
177
|
</>
|