ordering-ui-react-native 0.22.0 → 0.22.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.22.00",
3
+ "version": "0.22.02",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -4,8 +4,10 @@ import {
4
4
  View,
5
5
  TouchableOpacity,
6
6
  ActivityIndicator,
7
+ Alert,
7
8
  } from 'react-native';
8
9
  import Clipboard from '@react-native-clipboard/clipboard';
10
+ import { StarPRNT } from 'react-native-star-prnt';
9
11
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
10
12
  import { useTheme } from 'styled-components/native';
11
13
  import {
@@ -35,6 +37,8 @@ import CountryPicker from 'react-native-country-picker-modal';
35
37
  import { NotFoundSource } from '../NotFoundSource';
36
38
  import { OrderHeaderComponent } from './OrderHeaderComponent';
37
39
  import { OrderContentComponent } from './OrderContentComponent';
40
+ import { _retrieveStoreData } from '../../providers/StoreUtil'
41
+ import { usePrinterCommands } from './usePrinterCommands'
38
42
 
39
43
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
40
44
  const {
@@ -57,6 +61,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
57
61
  const [{ parsePrice, parseNumber, parseDate }] = useUtils();
58
62
  const [{ user, token }] = useSession();
59
63
  const [{ configs }] = useConfig();
64
+ const { generateCommands } = usePrinterCommands()
60
65
  const [, { showToast }] = useToast();
61
66
  const [unreadAlert, setUnreadAlert] = useState({
62
67
  business: false,
@@ -70,6 +75,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
70
75
  const [openModalForAccept, setOpenModalForAccept] = useState(false);
71
76
  const [openModalForMapView, setOpenModalForMapView] = useState(false);
72
77
  const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
78
+ const [printerSettings, setPrinterSettings] = useState('')
73
79
 
74
80
  if (order?.status === 7 || order?.status === 4) {
75
81
  if (drivers?.length > 0 && drivers) {
@@ -291,7 +297,40 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
291
297
  setOpenModalForAccept(true);
292
298
  };
293
299
 
300
+ const printAction = async (printerSettings: any, commands: any) => {
301
+ try {
302
+ var printResult = await StarPRNT.print(printerSettings?.emulation, commands, printerSettings?.portName);
303
+ Alert.alert(
304
+ t('PRINT_SUCCESS_TITLE', 'Print Success'),
305
+ t('PRINT_SUCCESS_SUBTITLE', `Go check your _printer_ printer!`).replace('_printer_', printerSettings?.model),
306
+ [
307
+ {text: 'OK', onPress: () => null},
308
+ ],
309
+ { cancelable: false }
310
+ )
311
+ } catch (e) {
312
+ Alert.alert(
313
+ t('PRINT_FAIL_TITLE', 'Connection Failed'),
314
+ t('PRINT_FAIL_SUBTITLE', 'Make sure your Star Printer is turned on and have thermal paper in it.'),
315
+ [
316
+ {text: 'OK', onPress: () => null},
317
+ ],
318
+ { cancelable: false }
319
+ )
320
+ }
321
+ }
322
+
294
323
  const handleViewSummaryOrder = () => {
324
+ if (printerSettings) {
325
+ const commands: any = generateCommands({
326
+ ...order,
327
+ orderStatus: getOrderStatus(order?.status, t)?.value
328
+ })
329
+ commands.push({ appendCutPaper: StarPRNT.CutPaperAction.PartialCutWithFeed })
330
+
331
+ printAction(printerSettings, commands)
332
+ return
333
+ }
295
334
  navigation?.navigate &&
296
335
  navigation.navigate('OrderSummary', {
297
336
  order,
@@ -372,6 +411,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
372
411
  }
373
412
  }, [driverLocation]);
374
413
 
414
+ useEffect(() => {
415
+ const getPrinterDefault = async () => {
416
+ const printer = await _retrieveStoreData('printer')
417
+ setPrinterSettings(printer)
418
+ }
419
+
420
+ getPrinterDefault()
421
+ }, [])
422
+
375
423
  const styles = StyleSheet.create({
376
424
  driverOff: {
377
425
  backgroundColor: theme.colors.notAvailable,
@@ -0,0 +1,147 @@
1
+ import { useConfig, useUtils, useLanguage} from 'ordering-components/native'
2
+
3
+ import { verifyDecimals, getProductPrice } from '../../utils';
4
+
5
+ /**
6
+ * Hook to create commands for star micronics printer using PassPRNT library
7
+ * @returns array of strings
8
+ */
9
+
10
+ export const usePrinterCommands = () => {
11
+ const [, t] = useLanguage()
12
+ const [{ configs }] = useConfig();
13
+ const [{ parsePrice, parseNumber, parseDate }] = useUtils();
14
+
15
+ const deliveryStatus: any = {
16
+ 1: t('DELIVERY', 'Delivery'),
17
+ 2: t('PICK_UP', 'Pick up'),
18
+ 3: t('EAT_IN', 'Eat In'),
19
+ 4: t('CURBSIDE', 'Curbside'),
20
+ 5: t('DRIVER_THRU', 'Driver thru'),
21
+ };
22
+
23
+ const walletName: any = {
24
+ cash: {
25
+ name: t('CASH_WALLET', 'Cash Wallet')
26
+ },
27
+ credit_point: {
28
+ name: t('POINTS_WALLET', 'Points Wallet')
29
+ }
30
+ }
31
+
32
+ const percentTip = (order: any) =>
33
+ parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
34
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
35
+ verifyDecimals(order?.summary?.driver_tip, parseNumber);
36
+
37
+ const handlePaymethodsListString = (order: any) => {
38
+ const paymethodsList = order?.payment_events?.filter((item: any) => item.event === 'payment').map((paymethod: any) => {
39
+ return paymethod?.wallet_event
40
+ ? walletName[paymethod?.wallet_event?.wallet?.type]?.name
41
+ : t(paymethod?.paymethod?.gateway?.toUpperCase(), paymethod?.paymethod?.name)
42
+ })
43
+ return paymethodsList.join(', ')
44
+ }
45
+
46
+ const paymethodsLength = (order: any) => order?.payment_events?.filter((item: any) => item.event === 'payment')?.length
47
+
48
+ const customerName = (order: any) => `${order?.customer?.name ?? ''} ${order?.customer?.middle_name ?? ''} ${order?.customer?.lastname ?? ''} ${order?.customer?.second_lastname ?? ''}`?.replace(' ', ' ')?.trim() ?? ''
49
+
50
+ const generateCommands = (order: any) => {
51
+ let commands: any = [];
52
+
53
+ const textProps = { fontSize: 12 }
54
+
55
+ const generateProductsText = () => {
56
+ const list: any = []
57
+
58
+ if (order?.products.length) {
59
+ order?.products.map((product: any) => {
60
+ list.push(`${product?.quantity} ${product?.name} \t\t ${parsePrice(product.total ?? getProductPrice(product))}`)
61
+
62
+ product.options?.map((option: any) => {
63
+ list.push({ text: `\t ${option.name}`, props: { fontSize: 10 } })
64
+
65
+ option.suboptions?.map((suboption: any) => {
66
+ const { quantity, name, position, price } = suboption
67
+ const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : ''
68
+ const string = name !== 'No'
69
+ ? pos
70
+ ? `${quantity} x ${name} ${pos} +${parsePrice(price)}`
71
+ : `${quantity} x ${name} +${parsePrice(price)}`
72
+ : 'No'
73
+
74
+ list.push({ text: `\t\t ${string}`, props: { fontSize: 10 } })
75
+ })
76
+ })
77
+
78
+ if (product.comment) {
79
+ list.push({ text: `\t ${t('COMMENT', 'Comment')}`, props: { fontSize: 10 } })
80
+ list.push({ text: `\t\t ${product.comment}`, props: { fontSize: 10 } })
81
+ }
82
+
83
+ list.push('_separator_')
84
+ })
85
+ }
86
+
87
+ return list
88
+ }
89
+
90
+ const appends: any = [
91
+ { text: `${t('ORDER_NO', 'Order No.')} ${order.id}`, props: { fontSize: 16 } },
92
+ ' ',
93
+ order.orderStatus,
94
+ { text: `${t('DELIVERY_TYPE', 'Delivery Type')}: ${deliveryStatus[order?.delivery_type]}`, props: { fontSize: 14 } },
95
+ { text: `${t(`PAYMENT_METHOD${paymethodsLength(order) > 1 ? 'S' : ''}`, `Payment method${paymethodsLength(order) > 1 ? 's' : ''}`)}: ${handlePaymethodsListString(order)}`, props: { fontSize: 14 } },
96
+ `${t('DELIVERY_DATE', 'Delivery Date')}: ${order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}`,
97
+ '_separator_',
98
+ { text: `${t('CUSTOMER_DETAILS', 'Customer details')}`, props: { fontSize: 14 } },
99
+ `${t('FULL_NAME', 'Full Name')}: ${customerName(order)}`,
100
+ `${t('EMAIL', 'Email')}: ${order?.customer?.email}`,
101
+ `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}`,
102
+ `${!!order?.customer?.phone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.phone}` : '\n'}`,
103
+ `${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}`,
104
+ `${!!order?.customer?.internal_number ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number}` : '\n'}`,
105
+ `${!!order?.customer?.zipcode ? `${t('ZIPCODE', 'Zipcode')}: ${order?.customer?.zipcode}` : '\n'}`,
106
+ '_separator_',
107
+ { text: `${t('BUSINESS_DETAILS', 'Business details')}`, props: { fontSize: 14 } },
108
+ order?.business?.name,
109
+ order?.business?.email,
110
+ `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}`,
111
+ `${!!order?.business?.phone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone}` : '\n'}`,
112
+ `${t('ADDRESS', 'Address')}: ${order?.business?.address}`,
113
+ `${!!order?.business?.address_notes ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes}` : '\n'}`,
114
+ '_separator_',
115
+ { text: `${t('ORDER_DETAILS', 'Order Details')}`, props: { fontSize: 14 } },
116
+ ...generateProductsText(),
117
+ ' ',
118
+ `${t('SUBTOTAL', 'Subtotal')} \t\t ${parsePrice(order.tax_type === 1 ? (order?.summary?.subtotal + order?.summary?.tax) ?? 0 : order?.summary?.subtotal ?? 0)}`,
119
+ `${order?.summary?.discount > 0 ? `${order?.offer_type === 1 ? `${t('DISCOUNT', 'Discount')} (${verifyDecimals(order?.offer_rate, parsePrice)}%)` : t('DISCOUNT', 'Discount')} \t\t ${parsePrice(order?.summary?.discount)}` : '\n'}`,
120
+ `${order?.tax_type !== 1 ? `${t('TAX', 'Tax')} (${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%) \t\t ${parsePrice(order?.summary?.tax ?? 0)}` : '\n'}`,
121
+ `${order?.summary?.delivery_price > 0 ? `${t('DELIVERY_FEE', 'Delivery Fee')} \t\t ${parsePrice(order?.summary?.delivery_price ?? 0)}` : '\n'}`,
122
+ `${t('DRIVER_TIP', 'Driver tip')} ${percentTip(order) ? `(${percentTip(order)}%)` : ''} \t\t ${parsePrice(order?.summary?.driver_tip ?? 0)}`,
123
+ `${t('SERVICE_FEE', 'Service Fee')} (${verifyDecimals(order?.summary?.service_fee, parseNumber)}%) \t\t ${parsePrice(order?.summary?.service_fee ?? 0)}`,
124
+ '_separator_',
125
+ `${t('TOTAL', 'Total')} \t\t ${parsePrice(order?.summary?.total ?? 0)}`,
126
+ ' ',
127
+ ' ',
128
+ ]
129
+
130
+ commands = [
131
+ ...commands,
132
+ ...appends.map((append: any) => {
133
+ return append === '_separator_'
134
+ ? { appendBitmapText: '---------------------------------------' }
135
+ : {
136
+ appendBitmapText: append?.text ?? append,
137
+ ...textProps,
138
+ ...append?.props
139
+ }
140
+ })
141
+ ]
142
+
143
+ return commands
144
+ }
145
+
146
+ return { generateCommands }
147
+ }
@@ -0,0 +1,248 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { ScrollView, StyleSheet, TouchableOpacity, View, Dimensions } from 'react-native'
3
+ import { useForm, Controller } from 'react-hook-form';
4
+ import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
5
+ import FeatherIcon from 'react-native-vector-icons/Feather'
6
+ import MCIcons from 'react-native-vector-icons/MaterialCommunityIcons'
7
+ import FAIcons from 'react-native-vector-icons/FontAwesome'
8
+ import { useTheme } from 'styled-components/native'
9
+ import { useLanguage } from 'ordering-components/native'
10
+
11
+ import { _setStoreData, _retrieveStoreData } from '../../providers/StoreUtil'
12
+ import { Container } from './styles'
13
+ import { OText, OInput} from '../shared'
14
+
15
+ export const PrinterSettings = (props: any) => {
16
+ const { onClose } = props
17
+
18
+ const [currentPrinter, setCurrentPrinter] = useState<any>(null)
19
+ const [layoutWidth, setLayoutWidth] = useState<any>({ actionsBtns: 0 })
20
+
21
+ const WIDTH_SCREEN = Dimensions.get('window').width
22
+
23
+ const [, t] = useLanguage()
24
+ const theme = useTheme()
25
+ const { handleSubmit, control, setValue, watch } = useForm();
26
+
27
+ const watchIp = watch('ip')
28
+ 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)
29
+
30
+ const styles = StyleSheet.create({
31
+ icons: {
32
+ maxWidth: 40,
33
+ height: 40,
34
+ padding: 10,
35
+ alignItems: 'flex-end'
36
+ },
37
+ optionIcons: {
38
+ padding: 8,
39
+ borderWidth: 1,
40
+ marginRight: 10,
41
+ borderRadius: 8,
42
+ },
43
+ wIconContainer: {
44
+ flexDirection: 'row',
45
+ alignItems: 'center',
46
+ width: WIDTH_SCREEN - 60 - 40
47
+ },
48
+ wrapperContainer: {
49
+ flexDirection: 'column',
50
+ },
51
+ wrapperIcons: {
52
+ flexDirection: 'row',
53
+ justifyContent: 'flex-start',
54
+ marginBottom: 5,
55
+ },
56
+ inputStyle: {
57
+ height: 40,
58
+ borderWidth: 1,
59
+ borderRadius: 8,
60
+ },
61
+ })
62
+
63
+ const printerList = [
64
+ { model: 'mPOP', emulation: 'StarPRNT', portName1: 'BT:mPOP', type: 1, ip: '' },
65
+ { model: 'FVP10', emulation: 'StarLine', portName1: 'BT:FVP10', type: 1, ip: '' },
66
+ { model: 'TSP100', emulation: 'StarGraphic', portName1: 'BT:TSP100', type: 1, ip: '' },
67
+ { model: 'TSP65011', emulation: 'StarLine', portName1: 'BT:TSP65011', type: 1, ip: '' },
68
+ { model: 'TSP7001', emulation: 'StarLine', portName1: 'BT:TSP7001', type: 1, ip: '' },
69
+ { model: 'TSP80011', emulation: 'StarLine', portName1: 'BT:TSP80011', type: 1, ip: '' },
70
+ { model: 'SP700', emulation: 'StarDotimpact', portName1: 'BT:SP700', type: 1, ip: '' },
71
+ { model: 'SM-S210i', emulation: 'EscPosMobile', portName1: 'BT:SMS210i', type: 1, ip: '' },
72
+ { model: 'SM-S220i', emulation: 'EscPosMobile', portName1: 'BT:SMS220i', type: 1, ip: '' },
73
+ { model: 'SM-S230i', emulation: 'EscosMobile', portName1: 'BT:SMS230i', type: 1, ip: '' },
74
+ { model: 'SM-T300i/T300', emulation: 'EscPosMobile', portName1: 'BT:SMT300i/T300', type: 1, ip: '' },
75
+ { model: 'SM-T400i', emulation: 'EscosMobile', portName1: 'BT:SMT400i', type: 1, ip: '' },
76
+ { model: 'SM-L200', emulation: 'StarPRNT', portName1: 'BT:SML200', type: 1, ip: '' },
77
+ { model: 'SM-L300', emulation: 'StarPRNT', portName1: 'BT:SML300', type: 1, ip: '' },
78
+ { model: 'BSC10', emulation: 'EscPos', portName1: 'BT:BSC10', type: 1, ip: '' },
79
+ { model: 'SM-S210i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS210i', type: 1, ip: '' },
80
+ { model: 'SM-S220i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS220i', type: 1, ip: '' },
81
+ { model: 'SM-S230i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS230i', type: 1, ip: '' },
82
+ { model: 'SM-T300i/T300 StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMT300i', type: 1, ip: '' },
83
+ { model: 'SM-T400i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMT400i', type: 1, ip: '' },
84
+ ]
85
+
86
+ const handleClick = async (item: any, type?: number, ip?: string) => {
87
+ let _item = item
88
+ if (_item) {
89
+ _item = {
90
+ ...currentPrinter,
91
+ ...item,
92
+ type: type ?? currentPrinter?.type,
93
+ ip: ip ?? currentPrinter?.ip,
94
+ portName: (type ?? currentPrinter?.type) === 1 || !ip
95
+ ? currentPrinter?.portName1 ?? item.portName1
96
+ : `TCP:${ip}`
97
+ }
98
+ }
99
+ setCurrentPrinter(_item)
100
+ await _setStoreData('printer', _item)
101
+ type === 1 && onClose && onClose()
102
+ }
103
+
104
+ const onLayout = (event: any, type: string) => {
105
+ const { width } = event.nativeEvent.layout;
106
+ setLayoutWidth({ ...layoutWidth, [type]: width })
107
+ };
108
+
109
+ const onSubmit = ({ ip }: any) => {
110
+ handleClick(currentPrinter, 2, ip)
111
+ onClose && onClose()
112
+ }
113
+
114
+ useEffect(() => {
115
+ const getPrinterDefault = async () => {
116
+ const printer = await _retrieveStoreData('printer')
117
+ setCurrentPrinter(printer)
118
+ }
119
+
120
+ getPrinterDefault()
121
+ }, [])
122
+
123
+ useEffect(() => {
124
+ currentPrinter?.ip && !isErrorIp && setValue('ip', currentPrinter?.ip)
125
+ }, [currentPrinter?.type])
126
+
127
+ return (
128
+ <ScrollView
129
+ showsVerticalScrollIndicator={false}
130
+ >
131
+ <OText size={24} style={{ paddingLeft: 30 }}>
132
+ {t('PRINTER_SETTINGS', 'Printer Settings')}
133
+ </OText>
134
+ <View style={{ padding: 30 }}>
135
+ {printerList.map((item: any, i: number) => (
136
+ <Container
137
+ key={i}
138
+ activeOpacity={1}
139
+ onPress={() => handleClick(item)}
140
+ >
141
+ <View style={styles.wrapperContainer}>
142
+ <View style={{ flexDirection: 'row' }}>
143
+ <TouchableOpacity
144
+ activeOpacity={1}
145
+ style={styles.wIconContainer}
146
+ onPress={() => handleClick(item)}
147
+ >
148
+ <SimpleLineIcons
149
+ name='printer'
150
+ color={theme.colors.textGray}
151
+ size={18}
152
+ style={{ ...styles.icons, color: currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
153
+ />
154
+ <OText
155
+ size={18}
156
+ color={currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray}
157
+ >
158
+ {item.model}
159
+ </OText>
160
+ </TouchableOpacity>
161
+ {currentPrinter?.model === item.model && (
162
+ <TouchableOpacity
163
+ activeOpacity={1}
164
+ onPress={() => handleClick(null)}
165
+ style={{ width: 40 }}
166
+ >
167
+ <FeatherIcon
168
+ name='x-circle'
169
+ color={theme.colors.danger500}
170
+ size={20}
171
+ style={styles.icons}
172
+ />
173
+ </TouchableOpacity>
174
+ )}
175
+ </View>
176
+ <View
177
+ style={styles.wrapperIcons}
178
+ >
179
+ <View style={styles.wrapperIcons} onLayout={(e) => onLayout(e, 'actionsBtns')}>
180
+ <FAIcons
181
+ name='bluetooth'
182
+ size={20}
183
+ {...(currentPrinter?.type === 1 && currentPrinter?.model === item.model ? { color: theme.colors.primary } : {})}
184
+ style={{ ...styles.optionIcons, borderColor: currentPrinter?.type === 1 && currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
185
+ onPress={() => handleClick(item, 1)}
186
+ />
187
+ <MCIcons
188
+ name='access-point-network'
189
+ size={20}
190
+ {...(currentPrinter?.type === 2 && currentPrinter?.model === item.model ? { color: theme.colors.primary } : {})}
191
+ style={{ ...styles.optionIcons, borderColor: currentPrinter?.type === 2 && currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
192
+ onPress={() => handleClick(item, 2)}
193
+ />
194
+ </View>
195
+ {currentPrinter?.type === 2 && currentPrinter?.model === item.model && (
196
+ <View style={{ flexDirection: 'row', width: WIDTH_SCREEN - 60 - layoutWidth.actionsBtns }}>
197
+ <Controller
198
+ control={control}
199
+ name={'ip'}
200
+ rules={{
201
+ required: t('VALIDATION_ERROR_IP_ADDRESS_REQUIRED', 'Ip address is required'),
202
+ pattern: {
203
+ 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,
204
+ message: t('INVALID_ERROR_IP_ADDRESS', 'Invalid ip address')
205
+ }
206
+ }}
207
+ defaultValue={currentPrinter?.ip ?? ''}
208
+ render={() => (
209
+ <OInput
210
+ placeholder={t('IP_ADDRESS', 'Ip address')}
211
+ placeholderTextColor={theme.colors.arrowColor}
212
+ style={{ ...styles.inputStyle, borderColor: isErrorIp ? theme.colors.danger500 : theme.colors.tabBar }}
213
+ value={currentPrinter?.ip ?? ''}
214
+ selectionColor={theme.colors.primary}
215
+ color={theme.colors.textGray}
216
+ onChange={(value: any) => {
217
+ setValue('ip', value)
218
+ setCurrentPrinter({
219
+ ...currentPrinter,
220
+ ip: value
221
+ })
222
+ }}
223
+ />
224
+ )}
225
+ />
226
+ <TouchableOpacity
227
+ activeOpacity={1}
228
+ disabled={isErrorIp}
229
+ onPress={handleSubmit(onSubmit)}
230
+ style={{ width: 40 }}
231
+ >
232
+ <FeatherIcon
233
+ name='save'
234
+ size={20}
235
+ color={isErrorIp ? theme.colors.tabBar : theme.colors.primary }
236
+ style={styles.icons}
237
+ />
238
+ </TouchableOpacity>
239
+ </View>
240
+ )}
241
+ </View>
242
+ </View>
243
+ </Container>
244
+ ))}
245
+ </View>
246
+ </ScrollView>
247
+ )
248
+ }
@@ -0,0 +1,10 @@
1
+ import styled from "styled-components/native";
2
+
3
+ export const Container = styled.View`
4
+ flex-direction: row;
5
+ justify-content: space-between;
6
+ width: 100%;
7
+ padding: 5px 5px 5px 0;
8
+ border-bottom-width: 1px;
9
+ border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
10
+ `
@@ -24,6 +24,7 @@ import { LogoutButton } from '../LogoutButton';
24
24
  import { LanguageSelector } from '../LanguageSelector';
25
25
  import { UserFormDetailsUI } from '../UserFormDetails';
26
26
  import { DriverSchedule } from '../DriverSchedule'
27
+ import { PrinterSettings } from '../PrinterSettings'
27
28
  import ToggleSwitch from 'toggle-switch-react-native';
28
29
  import { UDWrapper } from '../UserFormDetails/styles';
29
30
  import {
@@ -485,11 +486,10 @@ const ProfileUI = (props: ProfileParams) => {
485
486
  handleCancelEdit={handleCancelEdit}
486
487
  toggleIsEdit={toggleIsEdit}
487
488
  isAlsea={isAlsea}
488
- allowDriverUpdateData={allowDriverUpdateData}
489
489
  />
490
490
  </View>
491
491
  )}
492
- {!validationFields.loading && !isEdit && (
492
+ {!validationFields.loading && !isEdit && allowDriverUpdateData && (
493
493
  <EditButton>
494
494
  <OButton
495
495
  text={t('EDIT', 'Edit')}
@@ -503,17 +503,31 @@ const ProfileUI = (props: ProfileParams) => {
503
503
  />
504
504
  </EditButton>
505
505
  )}
506
- <Pressable style={{ marginBottom: 10 }} onPress={() => setOpenModal(true)}>
507
- <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
508
- <OText size={16}>{t('SCHEDULE', 'Schedule')}</OText>
509
- <AntDesignIcon size={18} name='right' />
510
- </View>
511
- <View style={{
512
- borderBottomColor: theme.colors.tabBar,
513
- borderBottomWidth: 1,
514
- marginTop: 10
515
- }} />
516
- </Pressable>
506
+ {!props.isBusinessApp ? (
507
+ <Pressable style={{ marginBottom: 10 }} onPress={() => setOpenModal(true)}>
508
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
509
+ <OText size={16}>{t('SCHEDULE', 'Schedule')}</OText>
510
+ <AntDesignIcon size={18} name='right' />
511
+ </View>
512
+ <View style={{
513
+ borderBottomColor: theme.colors.tabBar,
514
+ borderBottomWidth: 1,
515
+ marginTop: 10
516
+ }} />
517
+ </Pressable>
518
+ ) : (
519
+ <Pressable style={{ marginBottom: 10 }} onPress={() => setOpenModal(true)}>
520
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
521
+ <OText size={16}>{t('PRINTER_SETTINGS', 'Printer Settings')}</OText>
522
+ <AntDesignIcon size={18} name='right' />
523
+ </View>
524
+ <View style={{
525
+ borderBottomColor: theme.colors.tabBar,
526
+ borderBottomWidth: 1,
527
+ marginTop: 10
528
+ }} />
529
+ </Pressable>
530
+ )}
517
531
  <Pressable style={{ marginBottom: 10 }} onPress={() => navigation.navigate('Sessions')}>
518
532
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
519
533
  <OText size={16}>{t('SESSIONS', 'Sessions')}</OText>
@@ -536,7 +550,11 @@ const ProfileUI = (props: ProfileParams) => {
536
550
  entireModal
537
551
  hideIcons
538
552
  >
539
- <DriverSchedule schedule={user?.schedule} />
553
+ {props.isBusinessApp ? (
554
+ <PrinterSettings onClose={() => setOpenModal(false)} />
555
+ ) : (
556
+ <DriverSchedule schedule={user?.schedule} />
557
+ )}
540
558
  </OModal>
541
559
  </ScrollView>
542
560
  )}
@@ -48,8 +48,8 @@ export const useLocation = () => {
48
48
  GeoLocation.getCurrentPosition(
49
49
  ({ coords }) => {
50
50
  resolve({
51
- latitude: typeof coords.latitude !== 'number' && !Number.isNaN(coords.latitude) ? coords.latitude : 0,
52
- longitude: typeof coords.longitude !== 'number' && !Number.isNaN(coords.longitude) ? coords.longitude : 0,
51
+ latitude: typeof coords.latitude === 'number' && !Number.isNaN(coords.latitude) ? coords.latitude : 0,
52
+ longitude: typeof coords.longitude === 'number' && !Number.isNaN(coords.longitude) ? coords.longitude : 0,
53
53
  speed: coords.speed,
54
54
  });
55
55
  },
@@ -59,6 +59,7 @@ export interface ProfileParams {
59
59
  isAlsea?: boolean;
60
60
  isShowDriverStatus?: boolean;
61
61
  isFocused?: boolean;
62
+ isBusinessApp?: boolean;
62
63
  }
63
64
 
64
65
  export interface AddressListParams {