ordering-ui-react-native 0.22.41 → 0.22.42-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 -8
- package/src/DeliveryApp.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +40 -39
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/context/OfflineActions/index.tsx +236 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/BusinessController/index.tsx +8 -3
- package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
- package/themes/business/src/components/Chat/index.tsx +15 -3
- package/themes/business/src/components/DriverMap/index.tsx +44 -33
- package/themes/business/src/components/FloatingButton/index.tsx +3 -2
- package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
- package/themes/business/src/components/LoginForm/index.tsx +123 -98
- package/themes/business/src/components/LogoutButton/index.tsx +14 -5
- package/themes/business/src/components/MapView/index.tsx +42 -22
- package/themes/business/src/components/NewOrderNotification/index.tsx +38 -19
- package/themes/business/src/components/OrderDetails/Business.tsx +34 -16
- package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
- package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
- package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
- package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
- package/themes/business/src/components/OrderSummary/index.tsx +6 -4
- package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
- package/themes/business/src/components/OrdersOption/index.tsx +332 -231
- package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
- package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
- package/themes/business/src/components/PreviousOrders/OrderItem.tsx +29 -18
- package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
- package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
- package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
- package/themes/business/src/components/PrinterEdition/index.tsx +310 -97
- package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
- package/themes/business/src/components/PrinterSettings/index.tsx +101 -90
- package/themes/business/src/components/PrinterSettings/styles.tsx +9 -0
- package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
- package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
- package/themes/business/src/components/StoresList/index.tsx +2 -2
- package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
- package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
- package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
- package/themes/business/src/components/shared/OTextarea.tsx +8 -9
- package/themes/business/src/config/currency.tsx +1010 -0
- package/themes/business/src/hooks/useLocation.tsx +16 -12
- package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
- package/themes/business/src/types/index.tsx +22 -7
- package/themes/business/src/utils/index.tsx +28 -3
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/original/index.tsx +11 -0
- package/themes/original/src/components/AddressForm/index.tsx +25 -17
- package/themes/original/src/components/AddressList/index.tsx +8 -7
- package/themes/original/src/components/AppleLogin/index.tsx +4 -4
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +14 -6
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
- package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
- package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
- package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
- package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
- package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
- package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
- package/themes/original/src/components/Cart/index.tsx +49 -15
- package/themes/original/src/components/CartContent/index.tsx +2 -4
- package/themes/original/src/components/Checkout/index.tsx +127 -79
- package/themes/original/src/components/CitiesControl/index.tsx +0 -3
- package/themes/original/src/components/CouponControl/index.tsx +1 -3
- package/themes/original/src/components/DriverTips/index.tsx +1 -3
- package/themes/original/src/components/Favorite/index.tsx +1 -5
- package/themes/original/src/components/FavoriteList/index.tsx +0 -1
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
- package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
- package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
- package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
- package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
- package/themes/original/src/components/GoogleMap/index.tsx +39 -18
- package/themes/original/src/components/Help/index.tsx +2 -0
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +35 -19
- package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
- package/themes/original/src/components/LoginForm/index.tsx +13 -10
- package/themes/original/src/components/MessageListing/index.tsx +2 -1
- package/themes/original/src/components/Messages/index.tsx +20 -13
- package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
- package/themes/original/src/components/MomentOption/index.tsx +80 -52
- package/themes/original/src/components/MomentSelector/index.tsx +5 -2
- package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -4
- package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
- package/themes/original/src/components/MyOrders/index.tsx +2 -2
- package/themes/original/src/components/NavBar/index.tsx +7 -4
- package/themes/original/src/components/NetworkError/index.tsx +0 -5
- package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
- package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
- package/themes/original/src/components/OrderDetails/index.tsx +44 -21
- package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
- package/themes/original/src/components/OrderProgress/index.tsx +4 -3
- package/themes/original/src/components/OrderSummary/index.tsx +32 -11
- package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
- package/themes/original/src/components/OrdersOption/index.tsx +3 -6
- package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
- package/themes/original/src/components/PaymentOptions/index.tsx +462 -461
- package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
- package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
- package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
- package/themes/original/src/components/ProductForm/ActionButton.tsx +7 -12
- package/themes/original/src/components/ProductForm/index.tsx +107 -102
- package/themes/original/src/components/ProductItemAccordion/index.tsx +30 -38
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
- package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
- package/themes/original/src/components/Promotions/index.tsx +2 -2
- package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
- package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
- package/themes/original/src/components/ServiceForm/index.tsx +52 -54
- package/themes/original/src/components/Sessions/index.tsx +3 -3
- package/themes/original/src/components/SignupForm/index.tsx +44 -32
- package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
- package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
- package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
- package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
- package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
- package/themes/original/src/components/StripeElementsForm/index.tsx +8 -4
- package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
- package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
- package/themes/original/src/components/TaxInformation/index.tsx +3 -2
- package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +8 -5
- package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
- package/themes/original/src/components/UserDetails/index.tsx +17 -16
- package/themes/original/src/components/UserFormDetails/index.tsx +102 -74
- package/themes/original/src/components/UserProfile/index.tsx +9 -1
- package/themes/original/src/components/UserVerification/index.tsx +15 -4
- package/themes/original/src/components/Wallets/index.tsx +6 -3
- package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
- package/themes/original/src/components/shared/OAlert.tsx +2 -1
- package/themes/original/src/components/shared/OButton.tsx +5 -4
- package/themes/original/src/components/shared/OInput.tsx +4 -8
- package/themes/original/src/components/shared/OModal.tsx +7 -2
- package/themes/original/src/types/index.tsx +12 -4
- package/themes/original/src/utils/index.tsx +29 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { StarPRNT } from 'react-native-star-prnt';
|
|
3
|
+
import { ActivityIndicator, Dimensions, SafeAreaView, StyleSheet, View } from 'react-native';
|
|
4
|
+
import SelectDropdown from 'react-native-select-dropdown'
|
|
3
5
|
import { useLanguage } from 'ordering-components/native'
|
|
4
6
|
import { useTheme } from 'styled-components/native'
|
|
5
7
|
import { useForm, Controller } from 'react-hook-form';
|
|
@@ -17,23 +19,38 @@ import {
|
|
|
17
19
|
} from './styles'
|
|
18
20
|
|
|
19
21
|
import { Container } from '../../layouts/Container'
|
|
20
|
-
import { OText, OInput, OIcon } from '../shared'
|
|
22
|
+
import { OText, OInput, OIcon, OButton } from '../shared'
|
|
23
|
+
|
|
24
|
+
import { PRINTERS } from './printerList'
|
|
25
|
+
import { MessageAlert } from './MessageAlert'
|
|
26
|
+
|
|
27
|
+
const printerList = PRINTERS.map(printer => ({
|
|
28
|
+
...printer,
|
|
29
|
+
ip: '',
|
|
30
|
+
type: 1,
|
|
31
|
+
nickname: printer.model,
|
|
32
|
+
portName1: `BT:${printer.model.split(' ')[0]}`,
|
|
33
|
+
bt: `BT:${printer.model.split(' ')[0]}`
|
|
34
|
+
}))
|
|
21
35
|
|
|
22
36
|
export const PrinterEdition = (props: any) => {
|
|
23
|
-
const {
|
|
24
|
-
printer,
|
|
25
|
-
onClose
|
|
26
|
-
} = props
|
|
37
|
+
const { printer, onClose } = props
|
|
27
38
|
|
|
28
|
-
const
|
|
39
|
+
const HEIGHT_SCREEN = Dimensions.get('window').height
|
|
29
40
|
const [, t] = useLanguage()
|
|
30
41
|
const theme = useTheme()
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
const watchIp = watch('ip')
|
|
34
|
-
const isErrorIp = !/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i.test(watchIp)
|
|
42
|
+
const { control, setValue, watch } = useForm()
|
|
35
43
|
|
|
36
44
|
const [currentPrinter, setCurrentPrinter] = useState(printer)
|
|
45
|
+
const [discoverPort, setDiscoverPort] = useState({ loading: false, msg: null })
|
|
46
|
+
|
|
47
|
+
const watchIp = watch('ip')
|
|
48
|
+
const watchBt = watch('bt')
|
|
49
|
+
const watchNickname = watch('nickname')
|
|
50
|
+
const errorIP = !/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i.test(watchIp)
|
|
51
|
+
const errorBT = !/^[^\n]*$/i.test(watchBt) || !watchBt
|
|
52
|
+
const isErrorInput = currentPrinter?.type === 2 ? errorIP : errorBT
|
|
53
|
+
const isErrorNickname = watchNickname && !/^[^\n]*$/i.test(watchNickname)
|
|
37
54
|
|
|
38
55
|
const styles = StyleSheet.create({
|
|
39
56
|
icons: {
|
|
@@ -46,27 +63,74 @@ export const PrinterEdition = (props: any) => {
|
|
|
46
63
|
paddingRight: 10
|
|
47
64
|
},
|
|
48
65
|
inputStyle: {
|
|
49
|
-
height: 40,
|
|
50
66
|
borderWidth: 1,
|
|
51
67
|
borderRadius: 8,
|
|
68
|
+
color: theme.colors.arrowColor,
|
|
69
|
+
borderColor: theme.colors.inputSignup,
|
|
70
|
+
backgroundColor: theme.colors.transparent,
|
|
71
|
+
minHeight: 50,
|
|
72
|
+
maxHeight: 50
|
|
73
|
+
},
|
|
74
|
+
savePrinterBtnText: {
|
|
75
|
+
color: theme.colors.white,
|
|
76
|
+
fontSize: 18,
|
|
77
|
+
},
|
|
78
|
+
savePrinterBtn: {
|
|
79
|
+
height: 44,
|
|
80
|
+
borderRadius: 8,
|
|
81
|
+
marginHorizontal: 20
|
|
52
82
|
}
|
|
53
83
|
})
|
|
54
84
|
|
|
55
85
|
const handleChangePrinter = (values: any) => {
|
|
56
86
|
props.handleChangePrinter({
|
|
57
87
|
...values,
|
|
58
|
-
|
|
88
|
+
index: currentPrinter?.index ?? null,
|
|
89
|
+
type: currentPrinter?.type,
|
|
90
|
+
ip: currentPrinter?.ip,
|
|
91
|
+
item: currentPrinter
|
|
59
92
|
})
|
|
60
93
|
}
|
|
61
94
|
|
|
62
|
-
const
|
|
63
|
-
|
|
95
|
+
const portDiscovery = async () => {
|
|
96
|
+
try {
|
|
97
|
+
setDiscoverPort({ ...discoverPort, loading: true })
|
|
98
|
+
let printers = await StarPRNT.portDiscovery('Bluetooth');
|
|
99
|
+
|
|
100
|
+
if (printers?.length) {
|
|
101
|
+
setValue('bt', printers[0]?.portName)
|
|
102
|
+
setCurrentPrinter({
|
|
103
|
+
...currentPrinter,
|
|
104
|
+
['bt']: printers[0]?.portName
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
setDiscoverPort({
|
|
109
|
+
...discoverPort,
|
|
110
|
+
loading: false,
|
|
111
|
+
msg: !printers?.length
|
|
112
|
+
? t('NO_PRINTERS_FOUND', 'No printers found')
|
|
113
|
+
: null
|
|
114
|
+
})
|
|
115
|
+
}, 1000);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
setValue('bt', currentPrinter?.portName)
|
|
118
|
+
setCurrentPrinter({
|
|
119
|
+
...currentPrinter,
|
|
120
|
+
['bt']: currentPrinter?.portName
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const onSubmit = () => {
|
|
126
|
+
handleChangePrinter({ edit: !!printer, isAdd: !printer })
|
|
64
127
|
onClose && onClose()
|
|
65
128
|
}
|
|
66
129
|
|
|
67
130
|
useEffect(() => {
|
|
68
|
-
console.log(currentPrinter, isErrorIp)
|
|
69
131
|
currentPrinter?.ip && setValue('ip', currentPrinter?.ip)
|
|
132
|
+
currentPrinter?.bt && setValue('bt', currentPrinter?.bt)
|
|
133
|
+
currentPrinter?.nickname && setValue('nickname', currentPrinter?.nickname)
|
|
70
134
|
}, [currentPrinter?.type])
|
|
71
135
|
|
|
72
136
|
useEffect(() => {
|
|
@@ -74,7 +138,8 @@ export const PrinterEdition = (props: any) => {
|
|
|
74
138
|
}, [printer])
|
|
75
139
|
|
|
76
140
|
return (
|
|
77
|
-
<
|
|
141
|
+
<SafeAreaView style={{ flex: 1, marginBottom: 20 }}>
|
|
142
|
+
<Container>
|
|
78
143
|
<ContainerEdition>
|
|
79
144
|
<BackArrowWrapper>
|
|
80
145
|
<BackArrow activeOpacity={1} onPress={() => onClose()}>
|
|
@@ -99,120 +164,268 @@ export const PrinterEdition = (props: any) => {
|
|
|
99
164
|
size={22}
|
|
100
165
|
style={{ paddingTop: 0 }}
|
|
101
166
|
>
|
|
102
|
-
{
|
|
167
|
+
{t('PRINTER_CONFIGURE', 'Printer Configure')}
|
|
103
168
|
</OText>
|
|
104
169
|
</WrapperHeader>
|
|
105
170
|
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
171
|
+
<SelectDropdown
|
|
172
|
+
data={printerList}
|
|
173
|
+
defaultValueByIndex={printerList.findIndex(p => p.model === currentPrinter?.model)}
|
|
174
|
+
dropdownOverlayColor='transparent'
|
|
175
|
+
defaultButtonText={t('SELECT_PRINTER', 'Select printer')}
|
|
176
|
+
buttonTextAfterSelection={item => item.model}
|
|
177
|
+
rowTextForSelection={item => item.model}
|
|
178
|
+
renderDropdownIcon={() => dropDownIcon()}
|
|
179
|
+
buttonStyle={{
|
|
180
|
+
width: '100%',
|
|
181
|
+
backgroundColor: theme.colors.primary,
|
|
182
|
+
borderRadius: 8,
|
|
183
|
+
flexDirection: 'row-reverse',
|
|
184
|
+
justifyContent: 'space-between',
|
|
185
|
+
alignItems: 'center',
|
|
186
|
+
height: 44,
|
|
187
|
+
marginTop: 20,
|
|
188
|
+
}}
|
|
189
|
+
buttonTextStyle={{
|
|
190
|
+
color: theme.colors.white,
|
|
191
|
+
fontSize: 18,
|
|
192
|
+
textAlign: 'left',
|
|
193
|
+
marginHorizontal: 0
|
|
194
|
+
}}
|
|
195
|
+
dropdownStyle={{
|
|
196
|
+
borderRadius: 8,
|
|
197
|
+
borderColor: theme.colors.primary,
|
|
198
|
+
maxHeight: HEIGHT_SCREEN * 0.3
|
|
199
|
+
}}
|
|
200
|
+
rowStyle={{
|
|
201
|
+
borderBottomColor: theme.colors.disabled,
|
|
202
|
+
backgroundColor: theme.colors.gray100,
|
|
203
|
+
height: 40,
|
|
204
|
+
flexDirection: 'column',
|
|
205
|
+
alignItems: 'flex-start',
|
|
206
|
+
paddingTop: 8,
|
|
207
|
+
paddingHorizontal: 14,
|
|
208
|
+
width: '100%'
|
|
209
|
+
}}
|
|
210
|
+
rowTextStyle={{
|
|
211
|
+
marginHorizontal: 0,
|
|
212
|
+
fontSize: 14,
|
|
213
|
+
}}
|
|
214
|
+
onSelect={item => setCurrentPrinter(item)}
|
|
215
|
+
/>
|
|
216
|
+
{!!currentPrinter && (
|
|
217
|
+
<WrapperIcons>
|
|
129
218
|
<OText
|
|
130
|
-
size={
|
|
131
|
-
style={{ paddingTop: 0 }}
|
|
219
|
+
size={20}
|
|
220
|
+
style={{ paddingTop: 0, marginBottom: 10 }}
|
|
132
221
|
>
|
|
133
|
-
{t('
|
|
222
|
+
{`${t('PRINTER_NICKNAME', 'Nickname')}:`}
|
|
134
223
|
</OText>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
224
|
+
<Controller
|
|
225
|
+
control={control}
|
|
226
|
+
name={'nickname'}
|
|
227
|
+
rules={{
|
|
228
|
+
pattern: {
|
|
229
|
+
value: /^[a-zA-Z0-9\s]+$/i,
|
|
230
|
+
message: t('INVALID_ERROR_PRINTER_NICKNAME', 'Invalid Nickname')
|
|
231
|
+
}
|
|
232
|
+
}}
|
|
233
|
+
defaultValue={currentPrinter?.ip ?? ''}
|
|
234
|
+
render={() => (
|
|
235
|
+
<OInput
|
|
236
|
+
placeholder={`${t('EXAMPLE_SHORT', 'Ex:')} ${t('NICKNAME_EXAMPLE_TEXT', 'Kitchen printer')}`}
|
|
237
|
+
placeholderTextColor={theme.colors.arrowColor}
|
|
238
|
+
style={{
|
|
239
|
+
...styles.inputStyle,
|
|
240
|
+
borderColor: isErrorNickname ? theme.colors.danger500 : theme.colors.tabBar,
|
|
241
|
+
marginBottom: 10
|
|
242
|
+
}}
|
|
243
|
+
value={currentPrinter?.nickname ?? ''}
|
|
244
|
+
selectionColor={theme.colors.primary}
|
|
245
|
+
color={theme.colors.textGray}
|
|
246
|
+
onChange={(value: any) => {
|
|
247
|
+
setValue('nickname', value)
|
|
248
|
+
setCurrentPrinter({
|
|
249
|
+
...currentPrinter,
|
|
250
|
+
nickname: value
|
|
251
|
+
})
|
|
252
|
+
}}
|
|
253
|
+
/>
|
|
254
|
+
)}
|
|
148
255
|
/>
|
|
149
256
|
<OText
|
|
150
|
-
size={
|
|
151
|
-
style={{ paddingTop: 0 }}
|
|
257
|
+
size={20}
|
|
258
|
+
style={{ paddingTop: 0, marginBottom: 10 }}
|
|
152
259
|
>
|
|
153
|
-
{t('
|
|
260
|
+
{`${t('CONNECTION_TYPE', 'Connection type')}:`}
|
|
154
261
|
</OText>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
262
|
+
<WrapperIcon
|
|
263
|
+
activeOpacity={1}
|
|
264
|
+
style={{
|
|
265
|
+
borderColor: currentPrinter?.type === 1 ? theme.colors.primary : theme.colors.textGray
|
|
266
|
+
}}
|
|
267
|
+
onPress={() => {
|
|
268
|
+
setCurrentPrinter({
|
|
269
|
+
...currentPrinter,
|
|
270
|
+
type: 1,
|
|
271
|
+
ip: '',
|
|
272
|
+
portName: currentPrinter?.portName1
|
|
273
|
+
})
|
|
274
|
+
}}
|
|
275
|
+
>
|
|
276
|
+
<FAIcons
|
|
277
|
+
name='bluetooth'
|
|
278
|
+
size={22}
|
|
279
|
+
{...(currentPrinter?.type === 1 ? { color: theme.colors.primary } : {})}
|
|
280
|
+
style={styles.optionIcons}
|
|
281
|
+
/>
|
|
282
|
+
<OText
|
|
283
|
+
size={18}
|
|
284
|
+
style={{ paddingTop: 0 }}
|
|
285
|
+
>
|
|
286
|
+
{t('CONNECTION_VIA_BLUETOOTH', 'Via Bluetooth')}
|
|
287
|
+
</OText>
|
|
288
|
+
</WrapperIcon>
|
|
289
|
+
<WrapperIcon
|
|
290
|
+
activeOpacity={1}
|
|
291
|
+
style={{
|
|
292
|
+
borderColor: currentPrinter?.type === 2 ? theme.colors.primary : theme.colors.textGray
|
|
293
|
+
}}
|
|
294
|
+
onPress={() => setCurrentPrinter({ ...currentPrinter, type: 2 })}
|
|
295
|
+
>
|
|
296
|
+
<MCIcons
|
|
297
|
+
name='access-point-network'
|
|
298
|
+
size={22}
|
|
299
|
+
{...(currentPrinter?.type === 2 ? { color: theme.colors.primary } : {})}
|
|
300
|
+
style={styles.optionIcons}
|
|
301
|
+
/>
|
|
302
|
+
<OText
|
|
303
|
+
size={18}
|
|
304
|
+
style={{ paddingTop: 0 }}
|
|
305
|
+
>
|
|
306
|
+
{t('CONNECTION_VIA_LAN', 'Via LAN')}
|
|
307
|
+
</OText>
|
|
308
|
+
</WrapperIcon>
|
|
309
|
+
<View style={{ flexDirection: 'column', marginTop: 30 }}>
|
|
310
|
+
{currentPrinter?.type === 1 && (
|
|
311
|
+
<OText
|
|
312
|
+
size={14}
|
|
313
|
+
color={theme.colors.toastInfo}
|
|
314
|
+
style={{ marginBottom: 10 }}
|
|
315
|
+
>
|
|
316
|
+
{t('SEARCH_AVAILABLE_PRINTER_MESSAGE', 'Use the search icon to find an available printer')}
|
|
317
|
+
</OText>
|
|
318
|
+
)}
|
|
319
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
159
320
|
<Controller
|
|
160
321
|
control={control}
|
|
161
|
-
name={'ip'}
|
|
322
|
+
name={currentPrinter?.type === 2 ? 'ip' : 'bt'}
|
|
162
323
|
rules={{
|
|
163
|
-
required:
|
|
324
|
+
required: currentPrinter?.type === 2
|
|
325
|
+
? t('VALIDATION_ERROR_IP_ADDRESS_REQUIRED', 'Ip address is required')
|
|
326
|
+
: t('VALIDATION_ERROR_BLUETOOTH_PORN_REQUIRED', 'Bluetooth port name is required'),
|
|
164
327
|
pattern: {
|
|
165
|
-
value:
|
|
166
|
-
|
|
328
|
+
value: currentPrinter?.type === 2
|
|
329
|
+
? /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i
|
|
330
|
+
: /^[a-zA-Z0-9]+$/i,
|
|
331
|
+
message: currentPrinter?.type === 2
|
|
332
|
+
? t('INVALID_ERROR_IP_ADDRESS', 'Invalid ip address')
|
|
333
|
+
: t('INVALID_ERROR_BLUETOOTH_PORT_NAME', 'Invalid bluetooth port name')
|
|
167
334
|
}
|
|
168
335
|
}}
|
|
169
|
-
defaultValue={currentPrinter?.ip ?? ''}
|
|
336
|
+
defaultValue={currentPrinter?.type === 2 ? currentPrinter?.ip ?? '' : currentPrinter?.bt ?? ''}
|
|
170
337
|
render={() => (
|
|
171
338
|
<OInput
|
|
172
|
-
placeholder={
|
|
339
|
+
placeholder={currentPrinter?.type === 2
|
|
340
|
+
? t('IP_ADDRESS', 'Ip address')
|
|
341
|
+
: t('BLUETOOTH_PORT', 'Bluetooth port')
|
|
342
|
+
}
|
|
173
343
|
placeholderTextColor={theme.colors.arrowColor}
|
|
174
344
|
style={{
|
|
175
345
|
...styles.inputStyle,
|
|
176
|
-
borderColor:
|
|
346
|
+
borderColor: isErrorInput ? theme.colors.danger500 : theme.colors.tabBar
|
|
177
347
|
}}
|
|
178
|
-
value={currentPrinter?.ip ?? ''}
|
|
348
|
+
value={currentPrinter?.type === 2 ? currentPrinter?.ip ?? '' : currentPrinter?.bt ?? ''}
|
|
179
349
|
selectionColor={theme.colors.primary}
|
|
180
350
|
color={theme.colors.textGray}
|
|
181
351
|
onChange={(value: any) => {
|
|
182
|
-
setValue('ip', value)
|
|
352
|
+
setValue(currentPrinter?.type === 2 ? 'ip' : 'bt', value)
|
|
183
353
|
setCurrentPrinter({
|
|
184
354
|
...currentPrinter,
|
|
185
|
-
ip: value
|
|
355
|
+
[currentPrinter?.type === 2 ? 'ip' : 'bt']: value
|
|
186
356
|
})
|
|
187
357
|
}}
|
|
188
358
|
/>
|
|
189
359
|
)}
|
|
190
360
|
/>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
361
|
+
{currentPrinter?.type === 1 && (
|
|
362
|
+
<>
|
|
363
|
+
{!discoverPort.loading ? (
|
|
364
|
+
<FAIcons
|
|
365
|
+
name='search'
|
|
366
|
+
size={22}
|
|
367
|
+
color={theme.colors.primary}
|
|
368
|
+
style={{ marginLeft: 10 }}
|
|
369
|
+
onPress={() => portDiscovery()}
|
|
370
|
+
/>
|
|
371
|
+
) : (
|
|
372
|
+
<ActivityIndicator
|
|
373
|
+
size="small"
|
|
374
|
+
style={{ marginLeft: 10 }}
|
|
375
|
+
color={theme.colors.primary}
|
|
376
|
+
/>
|
|
377
|
+
)}
|
|
378
|
+
</>
|
|
379
|
+
)}
|
|
204
380
|
</View>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
381
|
+
</View>
|
|
382
|
+
<OText
|
|
383
|
+
size={14}
|
|
384
|
+
color={theme.colors.tabBar}
|
|
385
|
+
style={{ paddingTop: 5, paddingLeft: 10 }}
|
|
386
|
+
>
|
|
387
|
+
{discoverPort.msg ? (
|
|
388
|
+
<MessageAlert
|
|
389
|
+
message={discoverPort.msg}
|
|
390
|
+
resetMsg={() => setDiscoverPort({ ...discoverPort, msg: null })}
|
|
391
|
+
/>
|
|
392
|
+
) : (
|
|
393
|
+
`${t('EXAMPLE_SHORT', 'Ex:')} ${currentPrinter?.type === 2 ? '8.8.8.8' : currentPrinter?.portName1}`
|
|
394
|
+
)}
|
|
395
|
+
</OText>
|
|
396
|
+
</WrapperIcons>
|
|
397
|
+
)}
|
|
215
398
|
</ContainerEdition>
|
|
216
399
|
</Container>
|
|
400
|
+
<View>
|
|
401
|
+
<OButton
|
|
402
|
+
text={t('SAVE_PRINTER', 'Save Printer')}
|
|
403
|
+
imgRightSrc={null}
|
|
404
|
+
textStyle={styles.savePrinterBtnText}
|
|
405
|
+
style={styles.savePrinterBtn}
|
|
406
|
+
bgColor={theme.colors.primary}
|
|
407
|
+
borderColor={theme.colors.primary}
|
|
408
|
+
isDisabled={
|
|
409
|
+
isErrorNickname ||
|
|
410
|
+
!currentPrinter?.model ||
|
|
411
|
+
currentPrinter?.type === 1 && !currentPrinter?.bt ||
|
|
412
|
+
currentPrinter?.type === 2 && !currentPrinter?.ip
|
|
413
|
+
}
|
|
414
|
+
onClick={() => onSubmit()}
|
|
415
|
+
/>
|
|
416
|
+
</View>
|
|
417
|
+
</SafeAreaView>
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const dropDownIcon = () => {
|
|
422
|
+
const theme = useTheme()
|
|
423
|
+
|
|
424
|
+
return (
|
|
425
|
+
<FeatherIcon
|
|
426
|
+
name='chevron-down'
|
|
427
|
+
size={20}
|
|
428
|
+
color={theme.colors.white}
|
|
429
|
+
/>
|
|
217
430
|
)
|
|
218
431
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const PRINTERS = [
|
|
2
|
+
{ model: 'mPOP', emulation: 'StarPRNT', printMode: 'append' },
|
|
3
|
+
{ model: 'FVP10', emulation: 'StarLine', printMode: 'append' },
|
|
4
|
+
{ model: 'TSP100', emulation: 'StarGraphic', printMode: 'appendBitmapText' },
|
|
5
|
+
{ model: 'TSP100IV', emulation: 'StarLine', printMode: 'append' },
|
|
6
|
+
{ model: 'TSP65011', emulation: 'StarLine', printMode: 'append' },
|
|
7
|
+
{ model: 'TSP7001', emulation: 'StarLine', printMode: 'append' },
|
|
8
|
+
{ model: 'TSP80011', emulation: 'StarLine', printMode: 'append' },
|
|
9
|
+
{ model: 'SP700', emulation: 'StarDotImpact', printMode: 'append' },
|
|
10
|
+
{ model: 'SM-S210i', emulation: 'EscPosMobile', printMode: 'append' },
|
|
11
|
+
{ model: 'SM-S220i', emulation: 'EscPosMobile', printMode: 'append' },
|
|
12
|
+
{ model: 'SM-S230i', emulation: 'EscosMobile', printMode: 'append' },
|
|
13
|
+
{ model: 'SM-T300i/T300', emulation: 'EscPosMobile', printMode: 'append' },
|
|
14
|
+
{ model: 'SM-T400i', emulation: 'EscosMobile', printMode: 'append' },
|
|
15
|
+
{ model: 'SM-L200', emulation: 'StarPRNT', printMode: 'append' },
|
|
16
|
+
{ model: 'SM-L300', emulation: 'StarPRNT', printMode: 'append' },
|
|
17
|
+
{ model: 'BSC10', emulation: 'EscPos', bt: 'BT:BSC10', printMode: 'append' },
|
|
18
|
+
{ model: 'SM-S210i StarPRNT', emulation: 'StarPRNT', printMode: 'append' },
|
|
19
|
+
{ model: 'SM-S220i StarPRNT', emulation: 'StarPRNT', printMode: 'append' },
|
|
20
|
+
{ model: 'SM-S230i StarPRNT', emulation: 'StarPRNT', printMode: 'append' },
|
|
21
|
+
{ model: 'SM-T300i/T300 StarPRNT', emulation: 'StarPRNT', printMode: 'append' },
|
|
22
|
+
{ model: 'SM-T400i StarPRNT', emulation: 'StarPRNT', printMode: 'append' },
|
|
23
|
+
]
|