ordering-ui-react-native 0.12.14 → 0.12.18
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 +1 -1
- package/src/components/AddressList/index.tsx +3 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
- package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
- package/themes/business/src/components/OrdersOption/index.tsx +19 -15
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
- package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
- package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
- package/themes/business/src/components 2/Chat/index.tsx +1152 -0
- package/themes/business/src/components 2/Chat/styles.tsx +12 -0
- package/themes/business/src/components 2/Contacts/index.tsx +299 -0
- package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
- package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
- package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
- package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
- package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
- package/themes/business/src/components 2/Home/index.tsx +111 -0
- package/themes/business/src/components 2/Home/styles.tsx +27 -0
- package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
- package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
- package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
- package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
- package/themes/business/src/components 2/MapView/index.tsx +317 -0
- package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
- package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
- package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
- package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
- package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
- package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
- package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
- package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
- package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
- package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
- package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
- package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
- package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
- package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
- package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
- package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
- package/themes/business/src/components 2/StoresList/index.tsx +208 -0
- package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
- package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
- package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
- package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
- package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
- package/themes/business/src/components 2/shared/OButton.tsx +149 -0
- package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
- package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
- package/themes/business/src/components 2/shared/OFab.tsx +54 -0
- package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
- package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
- package/themes/business/src/components 2/shared/OInput.tsx +144 -0
- package/themes/business/src/components 2/shared/OLink.tsx +76 -0
- package/themes/business/src/components 2/shared/OModal.tsx +275 -0
- package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
- package/themes/business/src/components 2/shared/OText.tsx +55 -0
- package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
- package/themes/business/src/components 2/shared/OToast.tsx +92 -0
- package/themes/business/src/components 2/shared/index.tsx +27 -0
- package/themes/business/src/types/index.tsx +4 -1
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
- package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
- package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
- package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
- package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
- package/themes/original/src/components/OrderProgress/index.tsx +32 -18
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { OText, OIconButton } from '../shared';
|
|
3
|
+
import { StyleSheet, View, Platform, Alert } from 'react-native';
|
|
4
|
+
import {
|
|
5
|
+
Content,
|
|
6
|
+
OrderCustomer,
|
|
7
|
+
OrderHeader,
|
|
8
|
+
OrderContent,
|
|
9
|
+
OrderBusiness,
|
|
10
|
+
OrderProducts,
|
|
11
|
+
Table,
|
|
12
|
+
OrderBill,
|
|
13
|
+
Total,
|
|
14
|
+
Action,
|
|
15
|
+
ContentInfo,
|
|
16
|
+
} from './styles';
|
|
17
|
+
import { useUtils, useLanguage, useConfig } from 'ordering-components/native';
|
|
18
|
+
import { verifyDecimals, getProductPrice } from '../../utils';
|
|
19
|
+
import { FloatingButton } from '../FloatingButton';
|
|
20
|
+
import RNHTMLtoPDF from 'react-native-html-to-pdf';
|
|
21
|
+
import RNPrint from 'react-native-print';
|
|
22
|
+
import { useTheme } from 'styled-components/native';
|
|
23
|
+
|
|
24
|
+
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
25
|
+
|
|
26
|
+
export const OrderSummary = ({ order, navigation, orderStatus }: any) => {
|
|
27
|
+
const handleArrowBack: any = () => {
|
|
28
|
+
navigation?.canGoBack() && navigation.goBack();
|
|
29
|
+
};
|
|
30
|
+
const [{ parsePrice, parseNumber, parseDate }] = useUtils();
|
|
31
|
+
const [, t] = useLanguage();
|
|
32
|
+
const [{ configs }] = useConfig();
|
|
33
|
+
const [state, setState] = useState({
|
|
34
|
+
selectedPrinter: { url: undefined },
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
|
|
38
|
+
if (name !== 'No') {
|
|
39
|
+
const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
|
|
40
|
+
return pos
|
|
41
|
+
? `${quantity} x ${name} ${pos} +${parsePrice(price)}\n`
|
|
42
|
+
: `${quantity} x ${name} +${parsePrice(price)}\n`;
|
|
43
|
+
} else {
|
|
44
|
+
return 'No\n';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getSuboptions = (suboptions: any) => {
|
|
49
|
+
const array: any = []
|
|
50
|
+
suboptions?.length > 0 &&
|
|
51
|
+
suboptions?.map((suboption: any) => {
|
|
52
|
+
const string = ` ${getFormattedSubOptionName(suboption)}<br/>`
|
|
53
|
+
array.push(string)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return array.join('')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const getOptions = (options: any, productComment: string = '') => {
|
|
60
|
+
const array: any = [];
|
|
61
|
+
|
|
62
|
+
options?.length &&
|
|
63
|
+
options?.map((option: any) => {
|
|
64
|
+
const string =
|
|
65
|
+
` ${option.name}<br/>${getSuboptions(option.suboptions)}`;
|
|
66
|
+
|
|
67
|
+
array.push(string)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
if (productComment) {
|
|
71
|
+
array.push(`${t('COMMENT', 'Comment')}<br/> ${productComment}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return array.join('')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const theme = useTheme();
|
|
78
|
+
const percentTip =
|
|
79
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
80
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
81
|
+
verifyDecimals(order?.summary?.driver_tip, parseNumber);
|
|
82
|
+
|
|
83
|
+
const orderSummary = () => {
|
|
84
|
+
return `
|
|
85
|
+
<div>
|
|
86
|
+
<h1>${t('ORDER_NO', 'Order No.')} ${order.id}</h1>
|
|
87
|
+
<p style="font-size: 27px">
|
|
88
|
+
|
|
89
|
+
${orderStatus} </br>
|
|
90
|
+
|
|
91
|
+
${t('DELIVERY_TYPE', 'Delivery Type')}: ${
|
|
92
|
+
deliveryStatus[order?.delivery_type]
|
|
93
|
+
}
|
|
94
|
+
</br>
|
|
95
|
+
${t('DELIVERY_DATE', 'Delivery Date')}: ${
|
|
96
|
+
order?.delivery_datetime_utc
|
|
97
|
+
? parseDate(order?.delivery_datetime_utc)
|
|
98
|
+
: parseDate(order?.delivery_datetime, { utc: false })
|
|
99
|
+
}
|
|
100
|
+
</br>
|
|
101
|
+
${t('PAYMENT_METHOD')}: ${order?.paymethod?.name}
|
|
102
|
+
</p>
|
|
103
|
+
|
|
104
|
+
<h1>${t('CUSTOMER_DETAILS', 'Customer details')}</h1>
|
|
105
|
+
<p style="font-size: 27px"> ${t('FULL_NAME', 'Full Name')}: ${
|
|
106
|
+
order?.customer?.name
|
|
107
|
+
} ${order?.customer?.middle_name} ${order?.customer?.lastname} ${
|
|
108
|
+
order?.customer?.second_lastname
|
|
109
|
+
}
|
|
110
|
+
</br>
|
|
111
|
+
${t('EMAIL', 'Email')}: ${order?.customer?.email}
|
|
112
|
+
</br>
|
|
113
|
+
${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}
|
|
114
|
+
</br>
|
|
115
|
+
${
|
|
116
|
+
!!order?.customer?.phone
|
|
117
|
+
? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${
|
|
118
|
+
order?.customer?.phone
|
|
119
|
+
} </br>`
|
|
120
|
+
: ''
|
|
121
|
+
}
|
|
122
|
+
${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}
|
|
123
|
+
</br>
|
|
124
|
+
${
|
|
125
|
+
!!order?.customer?.internal_number
|
|
126
|
+
? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${
|
|
127
|
+
order?.customer?.internal_number
|
|
128
|
+
} </br>`
|
|
129
|
+
: ''
|
|
130
|
+
}
|
|
131
|
+
${t('ZIPCODE', 'Zipcode')}: ${order?.customer.zipcode}
|
|
132
|
+
</p>
|
|
133
|
+
|
|
134
|
+
<h1>${t('BUSINESS_DETAILS', 'Business details')}</h1>
|
|
135
|
+
<p style="font-size: 27px">
|
|
136
|
+
${order?.business?.name}
|
|
137
|
+
</br>
|
|
138
|
+
${order?.business?.email}
|
|
139
|
+
</br>
|
|
140
|
+
${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}
|
|
141
|
+
</br>
|
|
142
|
+
${
|
|
143
|
+
!!order?.business?.phone
|
|
144
|
+
? `${t('BUSINESS_PHONE', 'Business Phone')}: ${
|
|
145
|
+
order?.business?.phone
|
|
146
|
+
} </br>`
|
|
147
|
+
: ''
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
${t('ADDRESS', 'Address')}: ${order?.business?.address}
|
|
151
|
+
</br>
|
|
152
|
+
${
|
|
153
|
+
!!order?.business?.address_notes
|
|
154
|
+
? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${
|
|
155
|
+
order?.business?.address_notes
|
|
156
|
+
} `
|
|
157
|
+
: ''
|
|
158
|
+
}
|
|
159
|
+
</p>
|
|
160
|
+
<h1> ${t('ORDER_DETAILS', 'Order Details')}</h1>
|
|
161
|
+
|
|
162
|
+
${order?.products.length &&
|
|
163
|
+
order?.products.map(
|
|
164
|
+
(product: any, i: number) =>
|
|
165
|
+
`<div style="display: flex;flexDirection:row;flex-wrap:wrap">
|
|
166
|
+
<div style="display:flex;width:100%">
|
|
167
|
+
<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
|
|
168
|
+
${product?.quantity} ${product?.name}
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
|
|
172
|
+
${parsePrice(product.total ?? getProductPrice(product))}
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div style="font-size: 26px;width:100%">
|
|
177
|
+
<div style="width:90%;display:flex;justifyContent:center;margin:auto;">
|
|
178
|
+
${getOptions(product.options, product.comment)}
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</div>`
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
<div style="display: flex;">
|
|
185
|
+
|
|
186
|
+
<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
|
|
187
|
+
${t('SUBTOTAL', 'Subtotal')}
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">
|
|
191
|
+
${parsePrice(
|
|
192
|
+
order.tax_type === 1
|
|
193
|
+
? order?.summary?.subtotal + order?.summary?.tax ?? 0
|
|
194
|
+
: order?.summary?.subtotal ?? 0,
|
|
195
|
+
)}
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div style="display: flex">
|
|
201
|
+
${
|
|
202
|
+
order?.summary?.discount > 0
|
|
203
|
+
? order?.offer_type === 1
|
|
204
|
+
? `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%">
|
|
205
|
+
${t('DISCOUNT', 'Discount')} (${verifyDecimals(
|
|
206
|
+
order?.offer_rate,
|
|
207
|
+
parsePrice,
|
|
208
|
+
)}%)
|
|
209
|
+
</div>`
|
|
210
|
+
: `<div style="display:flex; justify-content: flex-start; font-size: 26px; width: 70%"> ${t(
|
|
211
|
+
'DISCOUNT',
|
|
212
|
+
'Discount',
|
|
213
|
+
)}
|
|
214
|
+
</div>`
|
|
215
|
+
: ''
|
|
216
|
+
}
|
|
217
|
+
${
|
|
218
|
+
order?.summary?.discount > 0
|
|
219
|
+
? `<div style="display:flex; justify-content: flex-end; font-size: 26px; width: 30%">- ${parsePrice(
|
|
220
|
+
order?.summary?.discount,
|
|
221
|
+
)}
|
|
222
|
+
</div>`
|
|
223
|
+
: ''
|
|
224
|
+
}
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
${
|
|
228
|
+
order?.tax_type !== 1
|
|
229
|
+
? `<div style="font-size: 25px">
|
|
230
|
+
${t('TAX', 'Tax')}
|
|
231
|
+
${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%
|
|
232
|
+
${parsePrice(order?.summary?.tax ?? 0)}
|
|
233
|
+
${t('TAX', 'Tax')}
|
|
234
|
+
${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%
|
|
235
|
+
</div>`
|
|
236
|
+
: ''
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
${
|
|
240
|
+
order?.summary?.delivery_price > 0
|
|
241
|
+
? `<div style="font-size: 25px;"> ${t(
|
|
242
|
+
'DELIVERY_FEE',
|
|
243
|
+
'Delivery Fee',
|
|
244
|
+
)}
|
|
245
|
+
</div>`
|
|
246
|
+
: ''
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
<div style="display: flex">
|
|
250
|
+
|
|
251
|
+
<div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
|
|
252
|
+
${t('DRIVER_TIP', 'Driver tip')}
|
|
253
|
+
${percentTip ? `(${percentTip}%)` : ''}
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
|
|
257
|
+
${parsePrice(order?.summary?.driver_tip ?? 0)}
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div style="display: flex">
|
|
263
|
+
|
|
264
|
+
<div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start">
|
|
265
|
+
${t('SERVICE_FEE', 'Service Fee')}
|
|
266
|
+
(${verifyDecimals(order?.summary?.service_fee, parseNumber)}%)
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
|
|
270
|
+
${parsePrice(order?.summary?.service_fee ?? 0)}
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<div style="display: flex">
|
|
276
|
+
|
|
277
|
+
<div style="font-size: 26px; width: 70%; display: flex; justify-content: flex-start; font-weight: bold">
|
|
278
|
+
${t('TOTAL', 'Total')}
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<div style="font-size: 26px; width: 30%; display: flex; justify-content: flex-end">
|
|
282
|
+
${parsePrice(order?.summary?.total ?? 0)}
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
</div>`;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const deliveryStatus: any = {
|
|
291
|
+
1: t('DELIVERY', 'Delivery'),
|
|
292
|
+
2: t('PICK_UP', 'Pick up'),
|
|
293
|
+
3: t('EAT_IN', 'Eat In'),
|
|
294
|
+
4: t('CURBSIDE', 'Curbside'),
|
|
295
|
+
5: t('DRIVER_THRU', 'Driver thru'),
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// @NOTE iOS Only
|
|
299
|
+
const selectPrinter = async () => {
|
|
300
|
+
const selectedPrinter = await RNPrint.selectPrinter({ x: '100', y: '100' });
|
|
301
|
+
setState({ selectedPrinter });
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// @NOTE iOS Only
|
|
305
|
+
const silentPrint = async () => {
|
|
306
|
+
if (!state?.selectedPrinter) {
|
|
307
|
+
Alert.alert('Must Select Printer First');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const jobName = await RNPrint.print({
|
|
311
|
+
printerURL: state?.selectedPrinter?.url,
|
|
312
|
+
html: orderSummary(),
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const printPDF = async () => {
|
|
317
|
+
const results = await RNHTMLtoPDF.convert({
|
|
318
|
+
html: orderSummary(),
|
|
319
|
+
fileName: 'test',
|
|
320
|
+
base64: true,
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
await RNPrint.print({
|
|
324
|
+
filePath: results.filePath || '',
|
|
325
|
+
jobName: `${t('ORDER_NO', `Order no. ${order.id}`)}`,
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const styles = StyleSheet.create({
|
|
330
|
+
btnBackArrow: {
|
|
331
|
+
maxWidth: 40,
|
|
332
|
+
height: 25,
|
|
333
|
+
},
|
|
334
|
+
textBold: {
|
|
335
|
+
fontWeight: '600',
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<>
|
|
341
|
+
<Content>
|
|
342
|
+
<OrderContent>
|
|
343
|
+
<OrderHeader>
|
|
344
|
+
<OIconButton
|
|
345
|
+
icon={theme.images.general.arrow_left}
|
|
346
|
+
iconStyle={{ width: 20, height: 20 }}
|
|
347
|
+
borderColor={theme.colors.clear}
|
|
348
|
+
style={{ maxWidth: 40, justifyContent: 'flex-end' }}
|
|
349
|
+
onClick={() => handleArrowBack()}
|
|
350
|
+
/>
|
|
351
|
+
<OText
|
|
352
|
+
style={{ marginBottom: 5 }}
|
|
353
|
+
size={15}
|
|
354
|
+
color={theme.colors.textGray}
|
|
355
|
+
weight="600">
|
|
356
|
+
{t('INVOICE_ORDER_NO', 'Order No.')} {order.id}
|
|
357
|
+
</OText>
|
|
358
|
+
|
|
359
|
+
<OText
|
|
360
|
+
style={{ marginBottom: 5 }}
|
|
361
|
+
size={15}
|
|
362
|
+
color={theme.colors.textGray}>
|
|
363
|
+
{`${orderStatus}`}
|
|
364
|
+
</OText>
|
|
365
|
+
|
|
366
|
+
<OText style={{ marginBottom: 5 }}>
|
|
367
|
+
{`${t('DELIVERY_TYPE', 'Delivery Type')}: ${
|
|
368
|
+
deliveryStatus[order?.delivery_type]
|
|
369
|
+
}`}
|
|
370
|
+
</OText>
|
|
371
|
+
|
|
372
|
+
<OText style={{ marginBottom: 5 }}>
|
|
373
|
+
{`${t('DELIVERY_DATE', 'Delivery Date')}: ${
|
|
374
|
+
order?.delivery_datetime_utc
|
|
375
|
+
? parseDate(order?.delivery_datetime_utc)
|
|
376
|
+
: parseDate(order?.delivery_datetime, { utc: false })
|
|
377
|
+
}`}
|
|
378
|
+
</OText>
|
|
379
|
+
|
|
380
|
+
<OText style={{ marginBottom: 5 }}>{`${t('PAYMENT_METHOD')}: ${t(
|
|
381
|
+
order?.paymethod?.name.toUpperCase(),
|
|
382
|
+
order?.paymethod?.name,
|
|
383
|
+
)}`}</OText>
|
|
384
|
+
</OrderHeader>
|
|
385
|
+
|
|
386
|
+
<OrderCustomer>
|
|
387
|
+
<OText
|
|
388
|
+
style={{ marginBottom: 5 }}
|
|
389
|
+
size={16}
|
|
390
|
+
weight="600"
|
|
391
|
+
color={theme.colors.textGray}>
|
|
392
|
+
{t('CUSTOMER_DETAILS', 'Customer details')}
|
|
393
|
+
</OText>
|
|
394
|
+
|
|
395
|
+
<OText
|
|
396
|
+
style={{ marginBottom: 5 }}
|
|
397
|
+
size={14}
|
|
398
|
+
numberOfLines={2}
|
|
399
|
+
adjustsFontSizeToFit
|
|
400
|
+
ellipsizeMode="tail"
|
|
401
|
+
color={theme.colors.textGray}>
|
|
402
|
+
{`${t('FULL_NAME', 'Full Name')}: ${order?.customer?.name} ${
|
|
403
|
+
order?.customer?.middle_name
|
|
404
|
+
} ${order?.customer?.lastname} ${
|
|
405
|
+
order?.customer?.second_lastname
|
|
406
|
+
}`}
|
|
407
|
+
</OText>
|
|
408
|
+
|
|
409
|
+
<OText
|
|
410
|
+
style={{ marginBottom: 5 }}
|
|
411
|
+
size={14}
|
|
412
|
+
numberOfLines={2}
|
|
413
|
+
adjustsFontSizeToFit
|
|
414
|
+
ellipsizeMode="tail"
|
|
415
|
+
color={theme.colors.textGray}>
|
|
416
|
+
{`${t('EMAIL', 'Email')}: ${order?.customer?.email}`}
|
|
417
|
+
</OText>
|
|
418
|
+
|
|
419
|
+
<OText
|
|
420
|
+
style={{ marginBottom: 5 }}
|
|
421
|
+
size={14}
|
|
422
|
+
numberOfLines={2}
|
|
423
|
+
adjustsFontSizeToFit
|
|
424
|
+
ellipsizeMode="tail"
|
|
425
|
+
color={theme.colors.textGray}>
|
|
426
|
+
{`${t('MOBILE_PHONE', 'Mobile Phone')}: ${
|
|
427
|
+
order?.customer?.cellphone
|
|
428
|
+
}`}
|
|
429
|
+
</OText>
|
|
430
|
+
|
|
431
|
+
{!!order?.customer?.phone && (
|
|
432
|
+
<OText
|
|
433
|
+
style={{ marginBottom: 5 }}
|
|
434
|
+
size={14}
|
|
435
|
+
numberOfLines={2}
|
|
436
|
+
adjustsFontSizeToFit
|
|
437
|
+
ellipsizeMode="tail"
|
|
438
|
+
color={theme.colors.textGray}>
|
|
439
|
+
{`${t('MOBILE_PHONE', 'Mobile Phone')}: ${
|
|
440
|
+
order?.customer?.phone
|
|
441
|
+
}`}
|
|
442
|
+
</OText>
|
|
443
|
+
)}
|
|
444
|
+
|
|
445
|
+
<OText
|
|
446
|
+
style={{ marginBottom: 5 }}
|
|
447
|
+
size={14}
|
|
448
|
+
numberOfLines={2}
|
|
449
|
+
adjustsFontSizeToFit
|
|
450
|
+
ellipsizeMode="tail"
|
|
451
|
+
color={theme.colors.textGray}>
|
|
452
|
+
{`${t('ADDRESS', 'Address')}: ${order?.customer?.address}`}
|
|
453
|
+
</OText>
|
|
454
|
+
|
|
455
|
+
{!!order?.customer?.internal_number && (
|
|
456
|
+
<OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
|
|
457
|
+
{t('INTERNAL_NUMBER', 'Internal Number')}{' '}
|
|
458
|
+
{order?.customer?.internal_number}
|
|
459
|
+
</OText>
|
|
460
|
+
)}
|
|
461
|
+
|
|
462
|
+
{order?.customer?.address_notes && (
|
|
463
|
+
<OText style={{ marginBottom: 5 }}>
|
|
464
|
+
{`${t('NOTES', 'Notes')}: ${order?.customer?.address_notes}`}
|
|
465
|
+
</OText>
|
|
466
|
+
)}
|
|
467
|
+
|
|
468
|
+
{!!order?.customer.zipcode && (
|
|
469
|
+
<OText numberOfLines={1} mBottom={4} ellipsizeMode="tail">
|
|
470
|
+
{t('ZIPCODE', 'Zipcode')}: {order?.customer?.zipcode}
|
|
471
|
+
</OText>
|
|
472
|
+
)}
|
|
473
|
+
</OrderCustomer>
|
|
474
|
+
|
|
475
|
+
<OrderBusiness>
|
|
476
|
+
<OText
|
|
477
|
+
style={{ marginBottom: 5 }}
|
|
478
|
+
size={16}
|
|
479
|
+
weight="600"
|
|
480
|
+
color={theme.colors.textGray}>
|
|
481
|
+
{t('BUSINESS_DETAILS', 'Business details')}
|
|
482
|
+
</OText>
|
|
483
|
+
|
|
484
|
+
<OText
|
|
485
|
+
style={{ marginBottom: 5 }}
|
|
486
|
+
size={14}
|
|
487
|
+
numberOfLines={2}
|
|
488
|
+
adjustsFontSizeToFit
|
|
489
|
+
ellipsizeMode="tail"
|
|
490
|
+
color={theme.colors.textGray}>
|
|
491
|
+
{order?.business?.name}
|
|
492
|
+
</OText>
|
|
493
|
+
|
|
494
|
+
<OText
|
|
495
|
+
style={{ marginBottom: 5 }}
|
|
496
|
+
size={14}
|
|
497
|
+
numberOfLines={2}
|
|
498
|
+
adjustsFontSizeToFit
|
|
499
|
+
ellipsizeMode="tail"
|
|
500
|
+
color={theme.colors.textGray}>
|
|
501
|
+
{order?.business?.email}
|
|
502
|
+
</OText>
|
|
503
|
+
|
|
504
|
+
{!!order?.business?.cellphone && (
|
|
505
|
+
<OText
|
|
506
|
+
style={{ marginBottom: 5 }}
|
|
507
|
+
size={14}
|
|
508
|
+
numberOfLines={2}
|
|
509
|
+
ellipsizeMode="tail"
|
|
510
|
+
color={theme.colors.textGray}>
|
|
511
|
+
{`${t('BUSINESS_PHONE', 'Business Phone')}: ${
|
|
512
|
+
order?.business?.cellphone
|
|
513
|
+
}`}
|
|
514
|
+
</OText>
|
|
515
|
+
)}
|
|
516
|
+
|
|
517
|
+
{!!order?.business?.phone && (
|
|
518
|
+
<OText
|
|
519
|
+
style={{ marginBottom: 5 }}
|
|
520
|
+
size={14}
|
|
521
|
+
numberOfLines={2}
|
|
522
|
+
ellipsizeMode="tail"
|
|
523
|
+
color={theme.colors.textGray}>
|
|
524
|
+
{`${t('BUSINESS_PHONE', 'Business Phone')}: ${
|
|
525
|
+
order?.business?.phone
|
|
526
|
+
}`}
|
|
527
|
+
</OText>
|
|
528
|
+
)}
|
|
529
|
+
|
|
530
|
+
{!!order?.business?.address && (
|
|
531
|
+
<OText
|
|
532
|
+
style={{ marginBottom: 5 }}
|
|
533
|
+
size={14}
|
|
534
|
+
adjustsFontSizeToFit
|
|
535
|
+
ellipsizeMode="tail"
|
|
536
|
+
color={theme.colors.textGray}>
|
|
537
|
+
{`${t('ADDRESS', 'Address')}: ${order?.business?.address}`}
|
|
538
|
+
</OText>
|
|
539
|
+
)}
|
|
540
|
+
|
|
541
|
+
{!!order?.business?.address_notes && (
|
|
542
|
+
<OText
|
|
543
|
+
style={{ marginBottom: 5 }}
|
|
544
|
+
size={14}
|
|
545
|
+
adjustsFontSizeToFit
|
|
546
|
+
ellipsizeMode="tail"
|
|
547
|
+
color={theme.colors.textGray}>
|
|
548
|
+
{`${t('SPECIAL_ADDRESS', 'Special Address')}: ${
|
|
549
|
+
order?.business?.address_notes
|
|
550
|
+
}`}
|
|
551
|
+
</OText>
|
|
552
|
+
)}
|
|
553
|
+
</OrderBusiness>
|
|
554
|
+
|
|
555
|
+
<OrderProducts>
|
|
556
|
+
<OText
|
|
557
|
+
style={{ marginBottom: 5 }}
|
|
558
|
+
size={16}
|
|
559
|
+
weight="600"
|
|
560
|
+
color={theme.colors.textGray}>
|
|
561
|
+
{t('ORDER_DETAILS', 'Order Details')}
|
|
562
|
+
</OText>
|
|
563
|
+
|
|
564
|
+
{order?.products.length &&
|
|
565
|
+
order?.products.map((product: any, i: number) => (
|
|
566
|
+
<View key={i}>
|
|
567
|
+
<ContentInfo>
|
|
568
|
+
<ProductItemAccordion
|
|
569
|
+
key={product?.id || i}
|
|
570
|
+
product={product}
|
|
571
|
+
isClickableEvent
|
|
572
|
+
/>
|
|
573
|
+
</ContentInfo>
|
|
574
|
+
</View>
|
|
575
|
+
))}
|
|
576
|
+
</OrderProducts>
|
|
577
|
+
|
|
578
|
+
<OrderBill>
|
|
579
|
+
<Table>
|
|
580
|
+
<OText style={{ marginBottom: 5 }}>
|
|
581
|
+
{t('SUBTOTAL', 'Subtotal')}
|
|
582
|
+
</OText>
|
|
583
|
+
|
|
584
|
+
<OText style={{ marginBottom: 5 }}>
|
|
585
|
+
{parsePrice(
|
|
586
|
+
order.tax_type === 1
|
|
587
|
+
? order?.summary?.subtotal + order?.summary?.tax ?? 0
|
|
588
|
+
: order?.summary?.subtotal ?? 0,
|
|
589
|
+
)}
|
|
590
|
+
</OText>
|
|
591
|
+
</Table>
|
|
592
|
+
|
|
593
|
+
{order?.tax_type !== 1 && (
|
|
594
|
+
<Table>
|
|
595
|
+
<OText style={{ marginBottom: 5 }}>
|
|
596
|
+
{t('TAX', 'Tax')}
|
|
597
|
+
{`(${verifyDecimals(
|
|
598
|
+
order?.summary?.tax_rate,
|
|
599
|
+
parseNumber,
|
|
600
|
+
)}%)`}
|
|
601
|
+
</OText>
|
|
602
|
+
|
|
603
|
+
<OText style={{ marginBottom: 5 }}>
|
|
604
|
+
{parsePrice(order?.summary?.tax ?? 0)}
|
|
605
|
+
</OText>
|
|
606
|
+
</Table>
|
|
607
|
+
)}
|
|
608
|
+
|
|
609
|
+
{order?.summary?.discount > 0 && (
|
|
610
|
+
<Table>
|
|
611
|
+
{order?.offer_type === 1 ? (
|
|
612
|
+
<OText style={{ marginBottom: 5 }}>
|
|
613
|
+
<OText>{t('DISCOUNT', 'Discount')}</OText>
|
|
614
|
+
|
|
615
|
+
<OText>
|
|
616
|
+
{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}
|
|
617
|
+
</OText>
|
|
618
|
+
</OText>
|
|
619
|
+
) : (
|
|
620
|
+
<OText style={{ marginBottom: 5 }}>
|
|
621
|
+
{t('DISCOUNT', 'Discount')}
|
|
622
|
+
</OText>
|
|
623
|
+
)}
|
|
624
|
+
|
|
625
|
+
<OText style={{ marginBottom: 5 }}>
|
|
626
|
+
- {parsePrice(order?.summary?.discount)}
|
|
627
|
+
</OText>
|
|
628
|
+
</Table>
|
|
629
|
+
)}
|
|
630
|
+
|
|
631
|
+
{order?.summary?.delivery_price > 0 && (
|
|
632
|
+
<Table>
|
|
633
|
+
<OText style={{ marginBottom: 5 }}>
|
|
634
|
+
{t('DELIVERY_FEE', 'Delivery Fee')}
|
|
635
|
+
</OText>
|
|
636
|
+
|
|
637
|
+
<OText>{parsePrice(order?.summary?.delivery_price)}</OText>
|
|
638
|
+
</Table>
|
|
639
|
+
)}
|
|
640
|
+
|
|
641
|
+
<Table>
|
|
642
|
+
<OText style={{ marginBottom: 5 }}>
|
|
643
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
644
|
+
{order?.summary?.driver_tip > 0 &&
|
|
645
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
646
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
647
|
+
`(${verifyDecimals(
|
|
648
|
+
order?.summary?.driver_tip,
|
|
649
|
+
parseNumber,
|
|
650
|
+
)}%)`}
|
|
651
|
+
</OText>
|
|
652
|
+
|
|
653
|
+
<OText style={{ marginBottom: 5 }}>
|
|
654
|
+
{parsePrice(order?.summary?.driver_tip ?? 0)}
|
|
655
|
+
</OText>
|
|
656
|
+
</Table>
|
|
657
|
+
|
|
658
|
+
{order?.summary?.service_fee > 0 && (
|
|
659
|
+
<Table>
|
|
660
|
+
<OText style={{ marginBottom: 5 }}>
|
|
661
|
+
{t('SERVICE_FEE', 'Service Fee')}
|
|
662
|
+
{`(${verifyDecimals(
|
|
663
|
+
order?.summary?.service_fee,
|
|
664
|
+
parseNumber,
|
|
665
|
+
)}%)`}
|
|
666
|
+
</OText>
|
|
667
|
+
|
|
668
|
+
<OText style={{ marginBottom: 5 }}>
|
|
669
|
+
{parsePrice(order?.summary?.service_fee)}
|
|
670
|
+
</OText>
|
|
671
|
+
</Table>
|
|
672
|
+
)}
|
|
673
|
+
|
|
674
|
+
<Total>
|
|
675
|
+
<Table>
|
|
676
|
+
<OText style={styles.textBold}>{t('TOTAL', 'Total')}</OText>
|
|
677
|
+
<OText style={styles.textBold} color={theme.colors.primary}>
|
|
678
|
+
{parsePrice(order?.summary?.total ?? 0)}
|
|
679
|
+
</OText>
|
|
680
|
+
</Table>
|
|
681
|
+
</Total>
|
|
682
|
+
</OrderBill>
|
|
683
|
+
</OrderContent>
|
|
684
|
+
<View style={{ height: 40 }} />
|
|
685
|
+
</Content>
|
|
686
|
+
|
|
687
|
+
<View style={{ marginBottom: 0 }}>
|
|
688
|
+
<FloatingButton
|
|
689
|
+
firstButtonClick={() =>
|
|
690
|
+
Platform.OS === 'ios' ? silentPrint() : printPDF()
|
|
691
|
+
}
|
|
692
|
+
btnText={t('PRINT', 'Print')}
|
|
693
|
+
color={theme.colors.green}
|
|
694
|
+
widthButton={'100%'}
|
|
695
|
+
isPadding
|
|
696
|
+
/>
|
|
697
|
+
</View>
|
|
698
|
+
</>
|
|
699
|
+
);
|
|
700
|
+
};
|