ordering-ui-react-native 0.21.41-test → 0.21.41
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 -3
- package/themes/business/index.tsx +0 -5
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -1
- package/themes/business/src/components/FloatingButton/index.tsx +34 -31
- package/themes/business/src/components/OrderDetails/Delivery.tsx +11 -6
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +12 -0
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
- package/themes/business/src/components/OrderSummary/index.tsx +3 -10
- package/themes/business/src/components/OrdersOption/index.tsx +2 -0
- package/themes/business/src/components/PreviousOrders/OrderList.tsx +17 -12
- package/themes/business/src/components/PreviousOrders/index.tsx +77 -65
- package/themes/kiosk/src/components/LoginForm/index.tsx +7 -4
- package/themes/original/src/components/BusinessInformation/index.tsx +0 -1
- 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 +22 -402
- package/themes/original/src/components/Checkout/index.tsx +5 -1
- package/themes/original/src/components/GiftCard/RedeemGiftCard/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/MultiCheckout/index.tsx +138 -16
- package/themes/original/src/components/OrderProgress/index.tsx +2 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
- package/themes/original/src/components/ProductForm/index.tsx +1 -1
- package/themes/business/src/components/StarPrinter/SearchPrinter.tsx +0 -94
- package/themes/business/src/components/StarPrinter/index.tsx +0 -156
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
ToastType,
|
|
11
11
|
MultiCheckout as MultiCheckoutController
|
|
12
12
|
} from 'ordering-components/native'
|
|
13
|
-
import { View, StyleSheet, Platform } from 'react-native'
|
|
13
|
+
import { View, StyleSheet, Platform, ScrollView } from 'react-native'
|
|
14
14
|
import { useTheme } from 'styled-components/native';
|
|
15
15
|
import { Container } from '../../layouts/Container';
|
|
16
16
|
import NavBar from '../NavBar';
|
|
17
|
-
import { OText, OIcon, OModal } from '../shared';
|
|
17
|
+
import { OText, OIcon, OModal, OButton } from '../shared';
|
|
18
18
|
import { getTypesText } from '../../utils';
|
|
19
19
|
import { UserDetails } from '../UserDetails'
|
|
20
20
|
import { AddressDetails } from '../AddressDetails'
|
|
@@ -26,6 +26,8 @@ import { DriverTips } from '../DriverTips'
|
|
|
26
26
|
import { CouponControl } from '../CouponControl';
|
|
27
27
|
import { DriverTipsContainer } from '../Cart/styles'
|
|
28
28
|
import { OSTable, OSCoupon } from '../OrderSummary/styles';
|
|
29
|
+
import { SignupForm } from '../SignupForm'
|
|
30
|
+
import { LoginForm } from '../LoginForm'
|
|
29
31
|
|
|
30
32
|
import {
|
|
31
33
|
ChContainer,
|
|
@@ -74,7 +76,11 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
74
76
|
paddingLeft: 40,
|
|
75
77
|
paddingRight: 40
|
|
76
78
|
},
|
|
77
|
-
wrapperNavbar: { paddingHorizontal: 40 }
|
|
79
|
+
wrapperNavbar: { paddingHorizontal: 40 },
|
|
80
|
+
detailWrapper: {
|
|
81
|
+
paddingHorizontal: 40,
|
|
82
|
+
width: '100%'
|
|
83
|
+
},
|
|
78
84
|
})
|
|
79
85
|
|
|
80
86
|
const [, { showToast }] = useToast();
|
|
@@ -83,7 +89,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
83
89
|
const [{ parsePrice, parseDate }] = useUtils();
|
|
84
90
|
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
85
91
|
const [validationFields] = useValidationFields();
|
|
86
|
-
const [{ user }] = useSession()
|
|
92
|
+
const [{ user }, { login }] = useSession()
|
|
87
93
|
|
|
88
94
|
const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
89
95
|
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
@@ -134,6 +140,11 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
134
140
|
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
135
141
|
const [userErrors, setUserErrors] = useState<any>([]);
|
|
136
142
|
const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
|
|
143
|
+
const [allowedGuest, setAllowedGuest] = useState(false)
|
|
144
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
145
|
+
const [requiredFields, setRequiredFields] = useState<any>([])
|
|
146
|
+
const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
|
|
147
|
+
const [openModal, setOpenModal] = useState({ login: false, signup: false, isGuest: false })
|
|
137
148
|
const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
|
|
138
149
|
const methodsPay = ['global_google_pay', 'global_apple_pay']
|
|
139
150
|
const isDisablePlaceOrderButton = cartGroup?.loading || (!(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) && cartGroup?.result?.balance > 0) ||
|
|
@@ -151,11 +162,12 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
151
162
|
setUserErrors([])
|
|
152
163
|
const errors = []
|
|
153
164
|
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
165
|
+
const _requiredFields: any = []
|
|
154
166
|
|
|
155
167
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
156
168
|
if (field?.required && !notFields.includes(field.code)) {
|
|
157
169
|
if (!user[field?.code]) {
|
|
158
|
-
|
|
170
|
+
_requiredFields.push(field?.code)
|
|
159
171
|
}
|
|
160
172
|
}
|
|
161
173
|
})
|
|
@@ -166,8 +178,9 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
166
178
|
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
167
179
|
configs?.verification_phone_required?.value === '1')
|
|
168
180
|
) {
|
|
169
|
-
|
|
181
|
+
_requiredFields.push('cellphone')
|
|
170
182
|
}
|
|
183
|
+
setRequiredFields(_requiredFields)
|
|
171
184
|
|
|
172
185
|
if (phoneUpdate) {
|
|
173
186
|
errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
|
|
@@ -181,10 +194,19 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
181
194
|
}
|
|
182
195
|
|
|
183
196
|
const handlePlaceOrder = (confirmPayment?: any) => {
|
|
184
|
-
if (
|
|
197
|
+
if (stripePaymethods.includes(paymethodSelected?.gateway) && user?.guest_id) {
|
|
198
|
+
setOpenModal({ ...openModal, signup: true, isGuest: true })
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!userErrors.length && (!requiredFields?.length || allowedGuest)) {
|
|
185
203
|
handleGroupPlaceOrder && handleGroupPlaceOrder(confirmPayment)
|
|
186
204
|
return
|
|
187
205
|
}
|
|
206
|
+
if (requiredFields?.length) {
|
|
207
|
+
setIsOpen(true)
|
|
208
|
+
return
|
|
209
|
+
}
|
|
188
210
|
let stringError = ''
|
|
189
211
|
Object.values(userErrors).map((item: any, i: number) => {
|
|
190
212
|
stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
@@ -193,6 +215,24 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
193
215
|
setIsUserDetailsEdit(true)
|
|
194
216
|
}
|
|
195
217
|
|
|
218
|
+
const handlePlaceOrderAsGuest = () => {
|
|
219
|
+
setIsOpen(false)
|
|
220
|
+
handleGroupPlaceOrder && handleGroupPlaceOrder()
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const handleSuccessSignup = (user: any) => {
|
|
224
|
+
login({
|
|
225
|
+
user,
|
|
226
|
+
token: user?.session?.access_token
|
|
227
|
+
})
|
|
228
|
+
openModal?.isGuest && handlePlaceOrderAsGuest()
|
|
229
|
+
setOpenModal({ ...openModal, signup: false, isGuest: false })
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const handleSuccessLogin = (user: any) => {
|
|
233
|
+
if (user) setOpenModal({ ...openModal, login: false })
|
|
234
|
+
}
|
|
235
|
+
|
|
196
236
|
useEffect(() => {
|
|
197
237
|
if (validationFields && validationFields?.fields?.checkout) {
|
|
198
238
|
checkValidationFields()
|
|
@@ -285,15 +325,45 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
285
325
|
|
|
286
326
|
<ChSection>
|
|
287
327
|
<ChUserDetails>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
328
|
+
{(user?.guest_id && !allowedGuest) ? (
|
|
329
|
+
<View>
|
|
330
|
+
<OText size={14} numberOfLines={1} ellipsizeMode='tail' color={theme.colors.textNormal}>
|
|
331
|
+
{t('CUSTOMER_DETAILS', 'Customer details')}
|
|
332
|
+
</OText>
|
|
333
|
+
<OButton
|
|
334
|
+
text={t('SIGN_UP', 'Sign up')}
|
|
335
|
+
textStyle={{ color: theme.colors.white }}
|
|
336
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
337
|
+
onClick={() => setOpenModal({ ...openModal, signup: true })}
|
|
338
|
+
/>
|
|
339
|
+
<OButton
|
|
340
|
+
text={t('LOGIN', 'Login')}
|
|
341
|
+
textStyle={{ color: theme.colors.primary }}
|
|
342
|
+
bgColor={theme.colors.white}
|
|
343
|
+
borderColor={theme.colors.primary}
|
|
344
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
345
|
+
onClick={() => setOpenModal({ ...openModal, login: true })}
|
|
346
|
+
/>
|
|
347
|
+
<OButton
|
|
348
|
+
text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
|
|
349
|
+
textStyle={{ color: theme.colors.black }}
|
|
350
|
+
bgColor={theme.colors.white}
|
|
351
|
+
borderColor={theme.colors.black}
|
|
352
|
+
style={{ borderRadius: 7.6, marginTop: 20 }}
|
|
353
|
+
onClick={() => setAllowedGuest(true)}
|
|
354
|
+
/>
|
|
355
|
+
</View>
|
|
356
|
+
) : (
|
|
357
|
+
<UserDetails
|
|
358
|
+
isUserDetailsEdit={isUserDetailsEdit}
|
|
359
|
+
useValidationFields
|
|
360
|
+
useDefualtSessionManager
|
|
361
|
+
useSessionUser
|
|
362
|
+
isCheckout
|
|
363
|
+
phoneUpdate={phoneUpdate}
|
|
364
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
365
|
+
/>
|
|
366
|
+
)}
|
|
297
367
|
</ChUserDetails>
|
|
298
368
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40 }} />
|
|
299
369
|
</ChSection>
|
|
@@ -484,6 +554,58 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
484
554
|
</OText>
|
|
485
555
|
)}
|
|
486
556
|
</ChContainer>
|
|
557
|
+
<OModal
|
|
558
|
+
open={openModal.signup}
|
|
559
|
+
onClose={() => setOpenModal({ ...openModal, signup: false, isGuest: false })}
|
|
560
|
+
>
|
|
561
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
562
|
+
<SignupForm
|
|
563
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
564
|
+
isGuest
|
|
565
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
566
|
+
useSignupByEmail
|
|
567
|
+
useChekoutFileds
|
|
568
|
+
/>
|
|
569
|
+
</ScrollView>
|
|
570
|
+
</OModal>
|
|
571
|
+
<OModal
|
|
572
|
+
open={openModal.login}
|
|
573
|
+
onClose={() => setOpenModal({ ...openModal, login: false })}
|
|
574
|
+
>
|
|
575
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%' }}>
|
|
576
|
+
<LoginForm
|
|
577
|
+
handleSuccessLogin={handleSuccessLogin}
|
|
578
|
+
isGuest
|
|
579
|
+
loginButtonText={t('LOGIN', 'Login')}
|
|
580
|
+
loginButtonBackground={theme.colors.primary}
|
|
581
|
+
/>
|
|
582
|
+
</ScrollView>
|
|
583
|
+
</OModal>
|
|
584
|
+
<OModal
|
|
585
|
+
open={isOpen}
|
|
586
|
+
onClose={() => setIsOpen(false)}
|
|
587
|
+
>
|
|
588
|
+
<View style={styles.detailWrapper}>
|
|
589
|
+
<UserDetails
|
|
590
|
+
isUserDetailsEdit
|
|
591
|
+
useValidationFields
|
|
592
|
+
useDefualtSessionManager
|
|
593
|
+
useSessionUser
|
|
594
|
+
isCheckout
|
|
595
|
+
isEdit
|
|
596
|
+
phoneUpdate={phoneUpdate}
|
|
597
|
+
togglePhoneUpdate={togglePhoneUpdate}
|
|
598
|
+
requiredFields={requiredFields}
|
|
599
|
+
hideUpdateButton
|
|
600
|
+
handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
|
|
601
|
+
onClose={() => {
|
|
602
|
+
setIsOpen(false)
|
|
603
|
+
handlePlaceOrder()
|
|
604
|
+
}}
|
|
605
|
+
setIsOpen={setIsOpen}
|
|
606
|
+
/>
|
|
607
|
+
</View>
|
|
608
|
+
</OModal>
|
|
487
609
|
</Container>
|
|
488
610
|
|
|
489
611
|
<FloatingButton
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useLanguage,
|
|
12
12
|
ToastType,
|
|
13
13
|
useToast,
|
|
14
|
+
useSession
|
|
14
15
|
} from 'ordering-components/native';
|
|
15
16
|
import { useTheme } from 'styled-components/native';
|
|
16
17
|
import { PaymentOptionCash } from '../PaymentOptionCash';
|
|
@@ -78,6 +79,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
78
79
|
|
|
79
80
|
const theme = useTheme();
|
|
80
81
|
const [, { showToast }] = useToast();
|
|
82
|
+
const [{ user }] = useSession()
|
|
81
83
|
const { confirmApplePayPayment } = useApplePay()
|
|
82
84
|
|
|
83
85
|
const getPayIcon = (method: string) => {
|
|
@@ -120,7 +122,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
120
122
|
const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
|
|
121
123
|
|
|
122
124
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
123
|
-
if (cart?.balance > 0) {
|
|
125
|
+
if (cart?.balance > 0 || !!user?.guest_id) {
|
|
124
126
|
if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
|
|
125
127
|
openUserModal && openUserModal(true)
|
|
126
128
|
setPaymethodClicked({
|
|
@@ -505,7 +505,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
505
505
|
<TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
|
|
506
506
|
{actionStatus?.loading ? (
|
|
507
507
|
<Placeholder Animation={Fade}>
|
|
508
|
-
<PlaceholderLine
|
|
508
|
+
<PlaceholderLine height={20} />
|
|
509
509
|
</Placeholder>
|
|
510
510
|
) : (
|
|
511
511
|
<OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('AS_GUEST_USER', 'As guest user')}</OText>
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { OIconButton } from 'ordering-ui-react-native/themes/business/src/components/shared';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
View,
|
|
5
|
-
Text,
|
|
6
|
-
Button,
|
|
7
|
-
FlatList,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
InterfaceType,
|
|
12
|
-
StarDeviceDiscoveryManager,
|
|
13
|
-
StarDeviceDiscoveryManagerFactory,
|
|
14
|
-
StarPrinter
|
|
15
|
-
} from 'react-native-star-io10';
|
|
16
|
-
import { useTheme } from 'styled-components';
|
|
17
|
-
|
|
18
|
-
export const SearchStarPrinter = ({ navigation }: any) => {
|
|
19
|
-
|
|
20
|
-
const theme = useTheme();
|
|
21
|
-
let _manager: StarDeviceDiscoveryManager;
|
|
22
|
-
|
|
23
|
-
const [state, setState] = useState({
|
|
24
|
-
bluetoonabled: true,
|
|
25
|
-
printers: [],
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
let _onPressDiscoveryButton = async () => {
|
|
29
|
-
setState({
|
|
30
|
-
...state,
|
|
31
|
-
printers: [],
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
await _manager?.stopDiscovery()
|
|
36
|
-
|
|
37
|
-
var interfaceTypes: Array<InterfaceType> = []
|
|
38
|
-
if (state.bluetoonabled) {
|
|
39
|
-
interfaceTypes.push(InterfaceType.Bluetooth);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
_manager = await StarDeviceDiscoveryManagerFactory.create(interfaceTypes);
|
|
43
|
-
_manager.discoveryTime = 10000;
|
|
44
|
-
|
|
45
|
-
_manager.onPrinterFound = (printer: StarPrinter) => {
|
|
46
|
-
const printers = state.printers;
|
|
47
|
-
printers.push(printer);
|
|
48
|
-
setState({
|
|
49
|
-
...state,
|
|
50
|
-
printers: printers
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
console.log(`Found printer: ${printer.connectionSettings.identifier}.`);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
_manager.onDiscoveryFinished = () => {
|
|
57
|
-
console.log(`Discovery finished.`);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
await _manager.startDiscovery();
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
console.log(`Error: ${String(error)}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const handleArrowBack: any = () => {
|
|
68
|
-
navigation?.canGoBack() && navigation.goBack();
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<View style={{ margin: 50 }}>
|
|
73
|
-
<OIconButton
|
|
74
|
-
icon={theme.images.general.arrow_left}
|
|
75
|
-
iconStyle={{ width: 20, height: 20 }}
|
|
76
|
-
borderColor={theme.colors.clear}
|
|
77
|
-
style={{ maxWidth: 40, justifyContent: 'flex-end' }}
|
|
78
|
-
onClick={() => handleArrowBack()}
|
|
79
|
-
/>
|
|
80
|
-
<View
|
|
81
|
-
style={{ width: 100, marginTop: 30 }}>
|
|
82
|
-
<Button
|
|
83
|
-
title="Discovery"
|
|
84
|
-
onPress={_onPressDiscoveryButton}
|
|
85
|
-
/>
|
|
86
|
-
</View>
|
|
87
|
-
<FlatList
|
|
88
|
-
style={{ marginTop: 30 }}
|
|
89
|
-
data={state.printers}
|
|
90
|
-
renderItem={({ item }) => <Text>{item.connectionSettings.interfaceType} : {item.connectionSettings.identifier}</Text>}
|
|
91
|
-
keyExtractor={(item, index) => index.toString()} />
|
|
92
|
-
</View>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
InterfaceType,
|
|
4
|
-
StarConnectionSettings,
|
|
5
|
-
StarXpandCommand,
|
|
6
|
-
StarPrinter
|
|
7
|
-
} from 'react-native-star-io10';
|
|
8
|
-
import { Picker } from '@react-native-picker/picker';
|
|
9
|
-
import {
|
|
10
|
-
View,
|
|
11
|
-
Text,
|
|
12
|
-
Button,
|
|
13
|
-
TextInput,
|
|
14
|
-
} from 'react-native';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export const HandleStarPrinter = ({ navigation }: any) => {
|
|
18
|
-
|
|
19
|
-
const [printState, setPrintState] = useState({
|
|
20
|
-
interfaceType: InterfaceType.Bluetooth,
|
|
21
|
-
identifier: '',
|
|
22
|
-
imageBase64: ''
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const _onPressPrintButton = async () => {
|
|
26
|
-
|
|
27
|
-
let settings = new StarConnectionSettings();
|
|
28
|
-
settings.interfaceType = printState.interfaceType;
|
|
29
|
-
settings.identifier = printState.identifier;
|
|
30
|
-
|
|
31
|
-
let printer = new StarPrinter(settings);
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
let builder = new StarXpandCommand.StarXpandCommandBuilder();
|
|
35
|
-
builder.addDocument(new StarXpandCommand.DocumentBuilder()
|
|
36
|
-
.addPrinter(new StarXpandCommand.PrinterBuilder()
|
|
37
|
-
.actionPrintImage(new StarXpandCommand.Printer.ImageParameter("logo_01.png", 406))
|
|
38
|
-
.styleInternationalCharacter(StarXpandCommand.Printer.InternationalCharacterType.Usa)
|
|
39
|
-
.styleCharacterSpace(0)
|
|
40
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
41
|
-
.actionPrintText("Star Clothing Boutique\n" +
|
|
42
|
-
"123 Star Road\n" +
|
|
43
|
-
"City, State 12345\n" +
|
|
44
|
-
"\n")
|
|
45
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Left)
|
|
46
|
-
.actionPrintText("Date:MM/DD/YYYY Time:HH:MM PM\n" +
|
|
47
|
-
"--------------------------------\n" +
|
|
48
|
-
"\n")
|
|
49
|
-
.actionPrintText("SKU Description Total\n" +
|
|
50
|
-
"300678566 PLAIN T-SHIRT 10.99\n" +
|
|
51
|
-
"300692003 BLACK DENIM 29.99\n" +
|
|
52
|
-
"300651148 BLUE DENIM 29.99\n" +
|
|
53
|
-
"300642980 STRIPED DRESS 49.99\n" +
|
|
54
|
-
"300638471 BLACK BOOTS 35.99\n" +
|
|
55
|
-
"\n" +
|
|
56
|
-
"Subtotal 156.95\n" +
|
|
57
|
-
"Tax 0.00\n" +
|
|
58
|
-
"--------------------------------\n")
|
|
59
|
-
.actionPrintText("Total ")
|
|
60
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
61
|
-
.styleMagnification(new StarXpandCommand.MagnificationParameter(2, 2))
|
|
62
|
-
.actionPrintText(" $156.95\n")
|
|
63
|
-
)
|
|
64
|
-
.actionPrintText("--------------------------------\n" +
|
|
65
|
-
"\n" +
|
|
66
|
-
"Charge\n" +
|
|
67
|
-
"156.95\n" +
|
|
68
|
-
"Visa XXXX-XXXX-XXXX-0123\n" +
|
|
69
|
-
"\n")
|
|
70
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
71
|
-
.styleInvert(true)
|
|
72
|
-
.actionPrintText("Refunds and Exchanges\n")
|
|
73
|
-
)
|
|
74
|
-
.actionPrintText("Within ")
|
|
75
|
-
.add(new StarXpandCommand.PrinterBuilder()
|
|
76
|
-
.styleUnderLine(true)
|
|
77
|
-
.actionPrintText("30 days")
|
|
78
|
-
)
|
|
79
|
-
.actionPrintText(" with receipt\n")
|
|
80
|
-
.actionPrintText("And tags attached\n" +
|
|
81
|
-
"\n")
|
|
82
|
-
.styleAlignment(StarXpandCommand.Printer.Alignment.Center)
|
|
83
|
-
.actionPrintBarcode(new StarXpandCommand.Printer.BarcodeParameter('0123456',
|
|
84
|
-
StarXpandCommand.Printer.BarcodeSymbology.Jan8)
|
|
85
|
-
.setBarDots(3)
|
|
86
|
-
.setBarRatioLevel(StarXpandCommand.Printer.BarcodeBarRatioLevel.Level0)
|
|
87
|
-
.setHeight(5)
|
|
88
|
-
.setPrintHri(true))
|
|
89
|
-
.actionFeedLine(1)
|
|
90
|
-
.actionPrintQRCode(new StarXpandCommand.Printer.QRCodeParameter('Hello World.\n')
|
|
91
|
-
.setModel(StarXpandCommand.Printer.QRCodeModel.Model2)
|
|
92
|
-
.setLevel(StarXpandCommand.Printer.QRCodeLevel.L)
|
|
93
|
-
.setCellSize(8))
|
|
94
|
-
.actionCut(StarXpandCommand.Printer.CutType.Partial)
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
let commands = await builder.getCommands();
|
|
99
|
-
|
|
100
|
-
await printer.open();
|
|
101
|
-
await printer.print(commands);
|
|
102
|
-
|
|
103
|
-
console.log(`Success`);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
console.log(`Error: ${String(error)}`);
|
|
107
|
-
}
|
|
108
|
-
finally {
|
|
109
|
-
await printer.close();
|
|
110
|
-
await printer.dispose();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const onSearchPrint = () => {
|
|
115
|
-
navigation.navigate('SearchStarPrinter')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<View style={{ margin: 50 }}>
|
|
120
|
-
<View style={{ flexDirection: 'row' }}>
|
|
121
|
-
<Text style={{ width: 100 }}>Interface</Text>
|
|
122
|
-
<Picker
|
|
123
|
-
style={{ width: 200, marginLeft: 20, justifyContent: 'center' }}
|
|
124
|
-
selectedValue={printState.interfaceType}
|
|
125
|
-
onValueChange={(value) => {
|
|
126
|
-
setPrintState({ interfaceType: value });
|
|
127
|
-
}}>
|
|
128
|
-
<Picker.Item label='Bluetooth' value={InterfaceType.Bluetooth} />
|
|
129
|
-
</Picker>
|
|
130
|
-
</View>
|
|
131
|
-
<View style={{ flexDirection: 'row', marginTop: 30 }}>
|
|
132
|
-
<Text style={{ width: 100 }}>Identifier</Text>
|
|
133
|
-
<TextInput
|
|
134
|
-
style={{ width: 200, marginLeft: 20 }}
|
|
135
|
-
value={printState.identifier}
|
|
136
|
-
onChangeText={(value) => {
|
|
137
|
-
setPrintState({ identifier: value });
|
|
138
|
-
}}
|
|
139
|
-
/>
|
|
140
|
-
</View>
|
|
141
|
-
<View style={{ width: 100, marginTop: 20 }}>
|
|
142
|
-
<Button
|
|
143
|
-
title="Search Printer"
|
|
144
|
-
onPress={onSearchPrint}
|
|
145
|
-
/>
|
|
146
|
-
</View>
|
|
147
|
-
<View style={{ width: 100, marginTop: 20 }}>
|
|
148
|
-
<Button
|
|
149
|
-
title="Print"
|
|
150
|
-
onPress={_onPressPrintButton}
|
|
151
|
-
/>
|
|
152
|
-
</View>
|
|
153
|
-
</View>
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
|
-
|