ordering-ui-react-native 0.22.42 → 0.22.43-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.
Files changed (161) hide show
  1. package/package.json +6 -8
  2. package/src/DeliveryApp.tsx +1 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  8. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  9. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  10. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  11. package/themes/business/src/components/Chat/index.tsx +15 -3
  12. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  13. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  14. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  15. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  16. package/themes/business/src/components/LogoutButton/index.tsx +14 -5
  17. package/themes/business/src/components/MapView/index.tsx +42 -22
  18. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -19
  19. package/themes/business/src/components/OrderDetails/Business.tsx +34 -16
  20. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  21. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
  22. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  23. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  24. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  25. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  26. package/themes/business/src/components/OrderSummary/index.tsx +6 -4
  27. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  28. package/themes/business/src/components/OrdersOption/index.tsx +332 -231
  29. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  30. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  31. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +29 -18
  32. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  33. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  34. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  35. package/themes/business/src/components/PrinterEdition/index.tsx +310 -97
  36. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  37. package/themes/business/src/components/PrinterSettings/index.tsx +101 -90
  38. package/themes/business/src/components/PrinterSettings/styles.tsx +9 -0
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  43. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  46. package/themes/business/src/config/currency.tsx +1010 -0
  47. package/themes/business/src/hooks/useLocation.tsx +16 -12
  48. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  49. package/themes/business/src/types/index.tsx +22 -7
  50. package/themes/business/src/utils/index.tsx +28 -3
  51. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  53. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  55. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  56. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  57. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  58. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  59. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/original/index.tsx +9 -1
  62. package/themes/original/src/components/AddressForm/index.tsx +25 -17
  63. package/themes/original/src/components/AddressList/index.tsx +8 -7
  64. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  65. package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +14 -6
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
  69. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  70. package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
  71. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  72. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  73. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  74. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  75. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  76. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  77. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  78. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  79. package/themes/original/src/components/Cart/index.tsx +49 -15
  80. package/themes/original/src/components/CartContent/index.tsx +2 -4
  81. package/themes/original/src/components/Checkout/index.tsx +127 -79
  82. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  83. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  84. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  85. package/themes/original/src/components/Favorite/index.tsx +1 -5
  86. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  87. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
  88. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  89. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  90. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  91. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  92. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  93. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  94. package/themes/original/src/components/Help/index.tsx +2 -0
  95. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  96. package/themes/original/src/components/Home/index.tsx +35 -19
  97. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  98. package/themes/original/src/components/LoginForm/index.tsx +13 -10
  99. package/themes/original/src/components/MessageListing/index.tsx +2 -1
  100. package/themes/original/src/components/Messages/index.tsx +20 -13
  101. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  102. package/themes/original/src/components/MomentOption/index.tsx +80 -52
  103. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  104. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -4
  105. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  106. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  107. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  108. package/themes/original/src/components/NavBar/index.tsx +7 -4
  109. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  110. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  111. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  112. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
  113. package/themes/original/src/components/OrderDetails/index.tsx +44 -21
  114. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  115. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  116. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  117. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  118. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  119. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  120. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  121. package/themes/original/src/components/PaymentOptions/index.tsx +462 -461
  122. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  123. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  124. package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
  125. package/themes/original/src/components/ProductForm/ActionButton.tsx +7 -12
  126. package/themes/original/src/components/ProductForm/index.tsx +107 -102
  127. package/themes/original/src/components/ProductItemAccordion/index.tsx +30 -38
  128. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  129. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  130. package/themes/original/src/components/Promotions/index.tsx +2 -2
  131. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  132. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  133. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  134. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  135. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  136. package/themes/original/src/components/Sessions/index.tsx +3 -3
  137. package/themes/original/src/components/SignupForm/index.tsx +44 -32
  138. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
  139. package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
  140. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  141. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  142. package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
  143. package/themes/original/src/components/StripeElementsForm/index.tsx +8 -4
  144. package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
  145. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  146. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  147. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +8 -5
  148. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  149. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  150. package/themes/original/src/components/UserFormDetails/index.tsx +102 -74
  151. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  152. package/themes/original/src/components/UserVerification/index.tsx +15 -4
  153. package/themes/original/src/components/Wallets/index.tsx +6 -3
  154. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  155. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  156. package/themes/original/src/components/shared/OButton.tsx +5 -4
  157. package/themes/original/src/components/shared/OInput.tsx +4 -8
  158. package/themes/original/src/components/shared/OModal.tsx +7 -2
  159. package/themes/original/src/types/index.tsx +12 -4
  160. package/themes/original/src/utils/index.tsx +29 -0
  161. 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 { Dimensions, StyleSheet, TouchableOpacity, View } from 'react-native';
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 WIDTH_SCREEN = Dimensions.get('window').width
39
+ const HEIGHT_SCREEN = Dimensions.get('window').height
29
40
  const [, t] = useLanguage()
30
41
  const theme = useTheme()
31
- const { handleSubmit, control, setValue, watch } = useForm();
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
- item: currentPrinter,
88
+ index: currentPrinter?.index ?? null,
89
+ type: currentPrinter?.type,
90
+ ip: currentPrinter?.ip,
91
+ item: currentPrinter
59
92
  })
60
93
  }
61
94
 
62
- const onSubmit = ({ ip }: any) => {
63
- handleChangePrinter({ type: 2, ip, edit: true })
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
- <Container>
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
- {printer.model}
167
+ {t('PRINTER_CONFIGURE', 'Printer Configure')}
103
168
  </OText>
104
169
  </WrapperHeader>
105
170
 
106
- <WrapperIcons>
107
- <OText
108
- size={20}
109
- style={{ paddingTop: 0, marginBottom: 10 }}
110
- >
111
- {`${t('CONNECTION_TYPE', 'Connection type')}:`}
112
- </OText>
113
- <WrapperIcon
114
- activeOpacity={1}
115
- style={{
116
- borderColor: currentPrinter?.type === 1 ? theme.colors.primary : theme.colors.textGray
117
- }}
118
- onPress={() => {
119
- setCurrentPrinter({ ...printer, type: 1 })
120
- handleChangePrinter({ type: 1, ip: null, edit: true })
121
- }}
122
- >
123
- <FAIcons
124
- name='bluetooth'
125
- size={22}
126
- {...(currentPrinter?.type === 1 ? { color: theme.colors.primary } : {})}
127
- style={styles.optionIcons}
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={18}
131
- style={{ paddingTop: 0 }}
219
+ size={20}
220
+ style={{ paddingTop: 0, marginBottom: 10 }}
132
221
  >
133
- {t('CONNECTION_VIA_BLUETOOTH', 'Via Bluetooth')}
222
+ {`${t('PRINTER_NICKNAME', 'Nickname')}:`}
134
223
  </OText>
135
- </WrapperIcon>
136
- <WrapperIcon
137
- activeOpacity={1}
138
- style={{
139
- borderColor: currentPrinter?.type === 2 ? theme.colors.primary : theme.colors.textGray
140
- }}
141
- onPress={() => setCurrentPrinter({ ...printer, type: 2 })}
142
- >
143
- <MCIcons
144
- name='access-point-network'
145
- size={22}
146
- {...(currentPrinter?.type === 2 ? { color: theme.colors.primary } : {})}
147
- style={styles.optionIcons}
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={18}
151
- style={{ paddingTop: 0 }}
257
+ size={20}
258
+ style={{ paddingTop: 0, marginBottom: 10 }}
152
259
  >
153
- {t('CONNECTION_VIA_LAN', 'Via LAN')}
260
+ {`${t('CONNECTION_TYPE', 'Connection type')}:`}
154
261
  </OText>
155
- </WrapperIcon>
156
- {currentPrinter?.type === 2 && (
157
- <>
158
- <View style={{ flexDirection: 'row' }}>
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: t('VALIDATION_ERROR_IP_ADDRESS_REQUIRED', 'Ip address is 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: /^((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,
166
- message: t('INVALID_ERROR_IP_ADDRESS', 'Invalid ip address')
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={t('IP_ADDRESS', 'Ip address')}
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: isErrorIp ? theme.colors.danger500 : theme.colors.tabBar
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
- <TouchableOpacity
192
- activeOpacity={1}
193
- disabled={isErrorIp}
194
- onPress={handleSubmit(onSubmit)}
195
- style={{ width: 40 }}
196
- >
197
- <FeatherIcon
198
- name='save'
199
- size={20}
200
- color={isErrorIp ? theme.colors.tabBar : theme.colors.primary }
201
- style={{ ...styles.icons, paddingRight: 0 }}
202
- />
203
- </TouchableOpacity>
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
- <OText
206
- size={14}
207
- color={theme.colors.tabBar}
208
- style={{ paddingTop: 5, paddingLeft: 10 }}
209
- >
210
- {`${t('EXAMPLE_SHORT', 'Ex:')} 8.8.8.8`}
211
- </OText>
212
- </>
213
- )}
214
- </WrapperIcons>
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
+ ]