ordering-ui-react-native 0.22.1 → 0.22.3

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.01",
3
+ "version": "0.22.03",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -48,7 +48,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
48
48
  readMessages,
49
49
  messagesReadList,
50
50
  handleAssignDriver,
51
- handleChangeOrderStatus,
52
51
  isFromCheckout,
53
52
  driverLocation,
54
53
  actions,
@@ -76,6 +75,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
76
75
  const [openModalForMapView, setOpenModalForMapView] = useState(false);
77
76
  const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
78
77
  const [printerSettings, setPrinterSettings] = useState('')
78
+ const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
79
79
 
80
80
  if (order?.status === 7 || order?.status === 4) {
81
81
  if (drivers?.length > 0 && drivers) {
@@ -126,6 +126,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
126
126
  }
127
127
  }
128
128
 
129
+ const handleChangeOrderStatus = async (status: any, isAcceptOrReject: any = {}) => {
130
+ if (props.handleChangeOrderStatus) {
131
+ const order: any = await props.handleChangeOrderStatus(status, isAcceptOrReject)
132
+
133
+ if (order?.status !== 0 && autoPrintEnabled && printerSettings) {
134
+ handleViewSummaryOrder()
135
+ }
136
+ }
137
+ }
138
+
129
139
  const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
130
140
  if (name !== 'No') {
131
141
  const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
@@ -412,12 +422,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
412
422
  }, [driverLocation]);
413
423
 
414
424
  useEffect(() => {
415
- const getPrinterDefault = async () => {
416
- const printer = await _retrieveStoreData('printer')
425
+ const getStorageData = async () => {
426
+ const printer = await _retrieveStoreData('printer')
427
+ const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
417
428
  setPrinterSettings(printer)
429
+ setAutoPrintEnabled(!!autoPrint)
418
430
  }
419
431
 
420
- getPrinterDefault()
432
+ getStorageData()
421
433
  }, [])
422
434
 
423
435
  const styles = StyleSheet.create({
@@ -50,20 +50,17 @@ export const usePrinterCommands = () => {
50
50
  const generateCommands = (order: any) => {
51
51
  let commands: any = [];
52
52
 
53
- const textProps = {
54
- fontSize: 12,
55
- absolutePosition: 40
56
- }
53
+ const textProps = { fontSize: 12 }
57
54
 
58
55
  const generateProductsText = () => {
59
56
  const list: any = []
60
57
 
61
58
  if (order?.products.length) {
62
59
  order?.products.map((product: any) => {
63
- list.push(`${product?.quantity} ${product?.name} \t\t\t ${parsePrice(product.total ?? getProductPrice(product))}`)
60
+ list.push(`${product?.quantity} ${product?.name} \t\t ${parsePrice(product.total ?? getProductPrice(product))}`)
64
61
 
65
62
  product.options?.map((option: any) => {
66
- list.push(`\t ${option.name}`)
63
+ list.push({ text: `\t ${option.name}`, props: { fontSize: 10 } })
67
64
 
68
65
  option.suboptions?.map((suboption: any) => {
69
66
  const { quantity, name, position, price } = suboption
@@ -74,16 +71,16 @@ export const usePrinterCommands = () => {
74
71
  : `${quantity} x ${name} +${parsePrice(price)}`
75
72
  : 'No'
76
73
 
77
- list.push(`\t\t ${string}`)
74
+ list.push({ text: `\t\t ${string}`, props: { fontSize: 10 } })
78
75
  })
79
76
  })
80
77
 
81
78
  if (product.comment) {
82
- list.push(`\t ${t('COMMENT', 'Comment')}`)
83
- list.push(`\t\t ${product.comment}`)
79
+ list.push({ text: `\t ${t('COMMENT', 'Comment')}`, props: { fontSize: 10 } })
80
+ list.push({ text: `\t\t ${product.comment}`, props: { fontSize: 10 } })
84
81
  }
85
82
 
86
- list.push('------------------------------------------------',)
83
+ list.push('_separator_')
87
84
  })
88
85
  }
89
86
 
@@ -91,14 +88,14 @@ export const usePrinterCommands = () => {
91
88
  }
92
89
 
93
90
  const appends: any = [
94
- `${t('ORDER_NO', 'Order No.')} ${order.id}`,
95
- '\n', // need to replace with other break line command
91
+ { text: `${t('ORDER_NO', 'Order No.')} ${order.id}`, props: { fontSize: 16 } },
92
+ ' ',
96
93
  order.orderStatus,
97
- `${t('DELIVERY_TYPE', 'Delivery Type')}: ${deliveryStatus[order?.delivery_type]}`,
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 } },
98
96
  `${t('DELIVERY_DATE', 'Delivery Date')}: ${order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}`,
99
- `${t(`PAYMENT_METHOD${paymethodsLength(order) > 1 ? 'S' : ''}`, `Payment method${paymethodsLength(order) > 1 ? 's' : ''}`)}: ${handlePaymethodsListString(order)}`,
100
- '\n', // need to replace with other break line command
101
- `${t('CUSTOMER_DETAILS', 'Customer details')}`,
97
+ '_separator_',
98
+ { text: `${t('CUSTOMER_DETAILS', 'Customer details')}`, props: { fontSize: 14 } },
102
99
  `${t('FULL_NAME', 'Full Name')}: ${customerName(order)}`,
103
100
  `${t('EMAIL', 'Email')}: ${order?.customer?.email}`,
104
101
  `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}`,
@@ -106,31 +103,41 @@ export const usePrinterCommands = () => {
106
103
  `${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}`,
107
104
  `${!!order?.customer?.internal_number ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number}` : '\n'}`,
108
105
  `${!!order?.customer?.zipcode ? `${t('ZIPCODE', 'Zipcode')}: ${order?.customer?.zipcode}` : '\n'}`,
109
- '\n', // need to replace with other break line command
110
- `${t('BUSINESS_DETAILS', 'Business details')}`,
106
+ '_separator_',
107
+ { text: `${t('BUSINESS_DETAILS', 'Business details')}`, props: { fontSize: 14 } },
111
108
  order?.business?.name,
112
109
  order?.business?.email,
113
110
  `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}`,
114
111
  `${!!order?.business?.phone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone}` : '\n'}`,
115
112
  `${t('ADDRESS', 'Address')}: ${order?.business?.address}`,
116
113
  `${!!order?.business?.address_notes ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes}` : '\n'}`,
117
- '\n', // need to replace with other break line command
118
- `${t('ORDER_DETAILS', 'Order Details')}`,
114
+ '_separator_',
115
+ { text: `${t('ORDER_DETAILS', 'Order Details')}`, props: { fontSize: 14 } },
119
116
  ...generateProductsText(),
120
- '\n', // need to replace with other break line command
121
- `${t('SUBTOTAL', 'Subtotal')} \t\t\t ${parsePrice(order.tax_type === 1 ? (order?.summary?.subtotal + order?.summary?.tax) ?? 0 : order?.summary?.subtotal ?? 0)}`,
122
- `${order?.summary?.discount > 0 ? `${order?.offer_type === 1 ? `${t('DISCOUNT', 'Discount')} (${verifyDecimals(order?.offer_rate, parsePrice)}%)` : t('DISCOUNT', 'Discount')} \t\t\t ${parsePrice(order?.summary?.discount)}` : '\n'}`,
123
- `${order?.tax_type !== 1 ? `${t('TAX', 'Tax')} (${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%) \t\t\t ${parsePrice(order?.summary?.tax ?? 0)}` : '\n'}`,
124
- `${order?.summary?.delivery_price > 0 ? `${t('DELIVERY_FEE', 'Delivery Fee')} \t\t\t ${parsePrice(order?.summary?.delivery_price ?? 0)}` : '\n'}`,
125
- `${t('DRIVER_TIP', 'Driver tip')} ${percentTip(order) ? `(${percentTip(order)}%)` : ''} \t\t\t ${parsePrice(order?.summary?.driver_tip ?? 0)}`,
126
- `${t('SERVICE_FEE', 'Service Fee')} (${verifyDecimals(order?.summary?.service_fee, parseNumber)}%) \t\t\t ${parsePrice(order?.summary?.service_fee ?? 0)}`,
127
- '------------------------------------------------',
128
- `${t('TOTAL', 'Total')} \t\t\t ${parsePrice(order?.summary?.total ?? 0)}`
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
+ ' ',
129
128
  ]
130
129
 
131
130
  commands = [
132
131
  ...commands,
133
- ...appends.map((append: any) => ({ appendBitmapText: append, ...textProps }))
132
+ ...appends.map((append: any) => {
133
+ return append === '_separator_'
134
+ ? { appendBitmapText: '---------------------------------------' }
135
+ : {
136
+ appendBitmapText: append?.text ?? append,
137
+ ...textProps,
138
+ ...append?.props
139
+ }
140
+ })
134
141
  ]
135
142
 
136
143
  return commands
@@ -1,21 +1,33 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import { ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native'
2
+ import { ScrollView, StyleSheet, TouchableOpacity, View, Dimensions } from 'react-native'
3
+ import { useForm, Controller } from 'react-hook-form';
3
4
  import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
4
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'
5
8
  import { useTheme } from 'styled-components/native'
9
+ import ToggleSwitch from 'toggle-switch-react-native';
6
10
  import { useLanguage } from 'ordering-components/native'
7
11
 
8
12
  import { _setStoreData, _retrieveStoreData } from '../../providers/StoreUtil'
9
- import { Container } from './styles'
10
- import { OText } from '../shared'
13
+ import { Container, EnabledAutoPrint } from './styles'
14
+ import { OText, OInput} from '../shared'
11
15
 
12
16
  export const PrinterSettings = (props: any) => {
13
17
  const { onClose } = props
14
18
 
15
19
  const [currentPrinter, setCurrentPrinter] = useState<any>(null)
20
+ const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
21
+ const [layoutWidth, setLayoutWidth] = useState<any>({ actionsBtns: 0 })
22
+
23
+ const WIDTH_SCREEN = Dimensions.get('window').width
16
24
 
17
25
  const [, t] = useLanguage()
18
26
  const theme = useTheme()
27
+ const { handleSubmit, control, setValue, watch } = useForm();
28
+
29
+ const watchIp = watch('ip')
30
+ 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)
19
31
 
20
32
  const styles = StyleSheet.create({
21
33
  icons: {
@@ -24,46 +36,106 @@ export const PrinterSettings = (props: any) => {
24
36
  padding: 10,
25
37
  alignItems: 'flex-end'
26
38
  },
39
+ optionIcons: {
40
+ padding: 8,
41
+ borderWidth: 1,
42
+ marginRight: 10,
43
+ borderRadius: 8,
44
+ },
45
+ wIconContainer: {
46
+ flexDirection: 'row',
47
+ alignItems: 'center',
48
+ width: WIDTH_SCREEN - 60 - 40
49
+ },
50
+ wrapperContainer: {
51
+ flexDirection: 'column',
52
+ },
53
+ wrapperIcons: {
54
+ flexDirection: 'row',
55
+ justifyContent: 'flex-start',
56
+ marginBottom: 5,
57
+ },
58
+ inputStyle: {
59
+ height: 40,
60
+ borderWidth: 1,
61
+ borderRadius: 8,
62
+ },
63
+ label: {
64
+ color: theme.colors.textGray
65
+ },
27
66
  })
28
67
 
29
68
  const printerList = [
30
- { model: 'mPOP', emulation: 'StarPRNT', portName: 'BT:TSP100' },
31
- { model: 'FVP10', emulation: 'StarLine', portName: 'BT:TSP100' },
32
- { model: 'TSP100', emulation: 'StarGraphic', portName: 'BT:TSP100' },
33
- { model: 'TSP65011', emulation: 'StarLine', portName: 'BT:TSP100' },
34
- { model: 'TSP7001', emulation: 'StarLine', portName: 'BT:TSP100' },
35
- { model: 'TSP80011', emulation: 'StarLine', portName: 'BT:TSP100' },
36
- { model: 'SP700', emulation: 'StarDotimpact', portName: 'BT:TSP100' },
37
- { model: 'SM-S210i', emulation: 'EscPosMobile', portName: 'BT:TSP100' },
38
- { model: 'SM-S220i', emulation: 'EscPosMobile', portName: 'BT:TSP100' },
39
- { model: 'SM-S230i', emulation: 'EscosMobile', portName: 'BT:TSP100' },
40
- { model: 'SM-T300i/T300', emulation: 'EscPosMobile', portName: 'BT:TSP100' },
41
- { model: 'SM-T400i', emulation: 'EscosMobile', portName: 'BT:TSP100' },
42
- { model: 'SM-L200', emulation: 'StarPRNT', portName: 'BT:TSP100' },
43
- { model: 'SM-L300', emulation: 'StarPRNT', portName: 'BT:TSP100' },
44
- { model: 'BSC10', emulation: 'EscPos', portName: 'BT:TSP100' },
45
- { model: 'SM-S210i StarPRNT', emulation: 'StarPRNT', portName: 'BT:TSP100' },
46
- { model: 'SM-S220i StarPRNT', emulation: 'StarPRNT', portName: 'BT:TSP100' },
47
- { model: 'SM-S230i StarPRNT', emulation: 'StarPRNT', portName: 'BT:TSP100' },
48
- { model: 'SM-T300i/T300 StarPRNT', emulation: 'StarPRNT', portName: 'BT:TSP100' },
49
- { model: 'SM-T400i StarPRNT', emulation: 'StarPRNT', portName: 'BT:TSP100' },
69
+ { model: 'mPOP', emulation: 'StarPRNT', portName1: 'BT:mPOP', type: 1, ip: '' },
70
+ { model: 'FVP10', emulation: 'StarLine', portName1: 'BT:FVP10', type: 1, ip: '' },
71
+ { model: 'TSP100', emulation: 'StarGraphic', portName1: 'BT:TSP100', type: 1, ip: '' },
72
+ { model: 'TSP65011', emulation: 'StarLine', portName1: 'BT:TSP65011', type: 1, ip: '' },
73
+ { model: 'TSP7001', emulation: 'StarLine', portName1: 'BT:TSP7001', type: 1, ip: '' },
74
+ { model: 'TSP80011', emulation: 'StarLine', portName1: 'BT:TSP80011', type: 1, ip: '' },
75
+ { model: 'SP700', emulation: 'StarDotimpact', portName1: 'BT:SP700', type: 1, ip: '' },
76
+ { model: 'SM-S210i', emulation: 'EscPosMobile', portName1: 'BT:SMS210i', type: 1, ip: '' },
77
+ { model: 'SM-S220i', emulation: 'EscPosMobile', portName1: 'BT:SMS220i', type: 1, ip: '' },
78
+ { model: 'SM-S230i', emulation: 'EscosMobile', portName1: 'BT:SMS230i', type: 1, ip: '' },
79
+ { model: 'SM-T300i/T300', emulation: 'EscPosMobile', portName1: 'BT:SMT300i/T300', type: 1, ip: '' },
80
+ { model: 'SM-T400i', emulation: 'EscosMobile', portName1: 'BT:SMT400i', type: 1, ip: '' },
81
+ { model: 'SM-L200', emulation: 'StarPRNT', portName1: 'BT:SML200', type: 1, ip: '' },
82
+ { model: 'SM-L300', emulation: 'StarPRNT', portName1: 'BT:SML300', type: 1, ip: '' },
83
+ { model: 'BSC10', emulation: 'EscPos', portName1: 'BT:BSC10', type: 1, ip: '' },
84
+ { model: 'SM-S210i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS210i', type: 1, ip: '' },
85
+ { model: 'SM-S220i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS220i', type: 1, ip: '' },
86
+ { model: 'SM-S230i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS230i', type: 1, ip: '' },
87
+ { model: 'SM-T300i/T300 StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMT300i', type: 1, ip: '' },
88
+ { model: 'SM-T400i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMT400i', type: 1, ip: '' },
50
89
  ]
51
90
 
52
- const handleClick = async (item: any) => {
53
- setCurrentPrinter(item)
54
- await _setStoreData('printer', item)
91
+ const handleClick = async (item: any, type?: number, ip?: string) => {
92
+ let _item = item
93
+ if (_item) {
94
+ _item = {
95
+ ...currentPrinter,
96
+ ...item,
97
+ type: type ?? currentPrinter?.type,
98
+ ip: ip ?? currentPrinter?.ip,
99
+ portName: (type ?? currentPrinter?.type) === 1 || !ip
100
+ ? currentPrinter?.portName1 ?? item.portName1
101
+ : `TCP:${ip}`
102
+ }
103
+ }
104
+ setCurrentPrinter(_item)
105
+ await _setStoreData('printer', _item)
106
+ type === 1 && onClose && onClose()
107
+ }
108
+
109
+ const onLayout = (event: any, type: string) => {
110
+ const { width } = event.nativeEvent.layout;
111
+ setLayoutWidth({ ...layoutWidth, [type]: width })
112
+ };
113
+
114
+ const onSubmit = ({ ip }: any) => {
115
+ handleClick(currentPrinter, 2, ip)
55
116
  onClose && onClose()
56
117
  }
57
118
 
119
+ const handleAutoPrint = async () => {
120
+ setAutoPrintEnabled(!autoPrintEnabled)
121
+ await _setStoreData('auto_print_after_accept_order', !autoPrintEnabled)
122
+ }
123
+
58
124
  useEffect(() => {
59
- const getPrinterDefault = async () => {
125
+ const getStorageData = async () => {
60
126
  const printer = await _retrieveStoreData('printer')
127
+ const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
61
128
  setCurrentPrinter(printer)
129
+ setAutoPrintEnabled(!!autoPrint)
62
130
  }
63
131
 
64
- getPrinterDefault()
132
+ getStorageData()
65
133
  }, [])
66
134
 
135
+ useEffect(() => {
136
+ currentPrinter?.ip && !isErrorIp && setValue('ip', currentPrinter?.ip)
137
+ }, [currentPrinter?.type])
138
+
67
139
  return (
68
140
  <ScrollView
69
141
  showsVerticalScrollIndicator={false}
@@ -71,44 +143,133 @@ export const PrinterSettings = (props: any) => {
71
143
  <OText size={24} style={{ paddingLeft: 30 }}>
72
144
  {t('PRINTER_SETTINGS', 'Printer Settings')}
73
145
  </OText>
74
- <View style={{ padding: 30 }}>
146
+ <EnabledAutoPrint>
147
+ <View style={{ flex: 1 }}>
148
+ <OText
149
+ numberOfLines={2}
150
+ adjustsFontSizeToFit
151
+ style={{ ...styles.label, paddingHorizontal: 0 }}>
152
+ {t('AUTO_PRINT_AFTER_ACCEPTING_ORDER', 'Auto print after accepting order')}
153
+ </OText>
154
+ </View>
155
+ <ToggleSwitch
156
+ isOn={autoPrintEnabled}
157
+ onColor={theme.colors.primary}
158
+ offColor={theme.colors.offColor}
159
+ size="small"
160
+ onToggle={() => handleAutoPrint()}
161
+ animationSpeed={200}
162
+ />
163
+ </EnabledAutoPrint>
164
+ <View style={{ paddingHorizontal: 30 }}>
75
165
  {printerList.map((item: any, i: number) => (
76
166
  <Container
77
167
  key={i}
78
168
  activeOpacity={1}
79
169
  onPress={() => handleClick(item)}
80
170
  >
81
- <TouchableOpacity
82
- activeOpacity={1}
83
- style={{ flexDirection: 'row', alignItems: 'center' }}
84
- onPress={() => handleClick(item)}
85
- >
86
- <SimpleLineIcons
87
- name='printer'
88
- color={theme.colors.textGray}
89
- size={18}
90
- style={{ ...styles.icons, color: currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
91
- />
92
- <OText
93
- size={18}
94
- color={currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray}
95
- >
96
- {item.model}
97
- </OText>
98
- </TouchableOpacity>
99
- {currentPrinter?.model === item.model && (
100
- <TouchableOpacity
101
- activeOpacity={1}
102
- onPress={() => handleClick(null)}
171
+ <View style={styles.wrapperContainer}>
172
+ <View style={{ flexDirection: 'row' }}>
173
+ <TouchableOpacity
174
+ activeOpacity={1}
175
+ style={styles.wIconContainer}
176
+ onPress={() => handleClick(item)}
177
+ >
178
+ <SimpleLineIcons
179
+ name='printer'
180
+ color={theme.colors.textGray}
181
+ size={18}
182
+ style={{ ...styles.icons, color: currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
183
+ />
184
+ <OText
185
+ size={18}
186
+ color={currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray}
187
+ >
188
+ {item.model}
189
+ </OText>
190
+ </TouchableOpacity>
191
+ {currentPrinter?.model === item.model && (
192
+ <TouchableOpacity
193
+ activeOpacity={1}
194
+ onPress={() => handleClick(null)}
195
+ style={{ width: 40 }}
196
+ >
197
+ <FeatherIcon
198
+ name='x-circle'
199
+ color={theme.colors.danger500}
200
+ size={20}
201
+ style={styles.icons}
202
+ />
203
+ </TouchableOpacity>
204
+ )}
205
+ </View>
206
+ <View
207
+ style={styles.wrapperIcons}
103
208
  >
104
- <FeatherIcon
105
- name='x-circle'
106
- color={theme.colors.danger500}
107
- size={20}
108
- style={styles.icons}
109
- />
110
- </TouchableOpacity>
111
- )}
209
+ <View style={styles.wrapperIcons} onLayout={(e) => onLayout(e, 'actionsBtns')}>
210
+ <FAIcons
211
+ name='bluetooth'
212
+ size={20}
213
+ {...(currentPrinter?.type === 1 && currentPrinter?.model === item.model ? { color: theme.colors.primary } : {})}
214
+ style={{ ...styles.optionIcons, borderColor: currentPrinter?.type === 1 && currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
215
+ onPress={() => handleClick(item, 1)}
216
+ />
217
+ <MCIcons
218
+ name='access-point-network'
219
+ size={20}
220
+ {...(currentPrinter?.type === 2 && currentPrinter?.model === item.model ? { color: theme.colors.primary } : {})}
221
+ style={{ ...styles.optionIcons, borderColor: currentPrinter?.type === 2 && currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
222
+ onPress={() => handleClick(item, 2)}
223
+ />
224
+ </View>
225
+ {currentPrinter?.type === 2 && currentPrinter?.model === item.model && (
226
+ <View style={{ flexDirection: 'row', width: WIDTH_SCREEN - 60 - layoutWidth.actionsBtns }}>
227
+ <Controller
228
+ control={control}
229
+ name={'ip'}
230
+ rules={{
231
+ required: t('VALIDATION_ERROR_IP_ADDRESS_REQUIRED', 'Ip address is required'),
232
+ pattern: {
233
+ 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,
234
+ message: t('INVALID_ERROR_IP_ADDRESS', 'Invalid ip address')
235
+ }
236
+ }}
237
+ defaultValue={currentPrinter?.ip ?? ''}
238
+ render={() => (
239
+ <OInput
240
+ placeholder={t('IP_ADDRESS', 'Ip address')}
241
+ placeholderTextColor={theme.colors.arrowColor}
242
+ style={{ ...styles.inputStyle, borderColor: isErrorIp ? theme.colors.danger500 : theme.colors.tabBar }}
243
+ value={currentPrinter?.ip ?? ''}
244
+ selectionColor={theme.colors.primary}
245
+ color={theme.colors.textGray}
246
+ onChange={(value: any) => {
247
+ setValue('ip', value)
248
+ setCurrentPrinter({
249
+ ...currentPrinter,
250
+ ip: value
251
+ })
252
+ }}
253
+ />
254
+ )}
255
+ />
256
+ <TouchableOpacity
257
+ activeOpacity={1}
258
+ disabled={isErrorIp}
259
+ onPress={handleSubmit(onSubmit)}
260
+ style={{ width: 40 }}
261
+ >
262
+ <FeatherIcon
263
+ name='save'
264
+ size={20}
265
+ color={isErrorIp ? theme.colors.tabBar : theme.colors.primary }
266
+ style={styles.icons}
267
+ />
268
+ </TouchableOpacity>
269
+ </View>
270
+ )}
271
+ </View>
272
+ </View>
112
273
  </Container>
113
274
  ))}
114
275
  </View>
@@ -8,3 +8,10 @@ export const Container = styled.View`
8
8
  border-bottom-width: 1px;
9
9
  border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
10
10
  `
11
+
12
+ export const EnabledAutoPrint = styled.View`
13
+ flex-direction: row;
14
+ justify-content: space-between;
15
+ align-items: center;
16
+ padding: 20px 30px 10px;
17
+ `;
@@ -392,7 +392,7 @@ export interface OrderDetailsParams {
392
392
  urlToShare?: string;
393
393
  messages?: any;
394
394
  handleAssignDriver?: (id: any) => {};
395
- handleChangeOrderStatus?: (status: any) => {};
395
+ handleChangeOrderStatus?: (status: any, isAcceptOrReject: any) => {};
396
396
  order?: any;
397
397
  isFromRoot?: any;
398
398
  handleOrderRedirect?: () => {};