ordering-ui-react-native 0.22.8 → 0.22.9-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 (162) hide show
  1. package/package.json +6 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/StripeMethodForm/index.tsx +4 -2
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/context/OfflineActions/index.tsx +236 -0
  8. package/src/types/index.tsx +2 -1
  9. package/themes/business/index.tsx +2 -0
  10. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  11. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  12. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  13. package/themes/business/src/components/BusinessProductList/index.tsx +2 -1
  14. package/themes/business/src/components/Chat/index.tsx +15 -3
  15. package/themes/business/src/components/DriverMap/index.tsx +49 -27
  16. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  17. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  18. package/themes/business/src/components/LanguageSelector/index.tsx +2 -3
  19. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  20. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  21. package/themes/business/src/components/MapView/index.tsx +36 -17
  22. package/themes/business/src/components/NewOrderNotification/index.tsx +40 -27
  23. package/themes/business/src/components/OrderDetails/Business.tsx +38 -21
  24. package/themes/business/src/components/OrderDetails/Delivery.tsx +138 -55
  25. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +125 -43
  26. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +62 -24
  27. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  28. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +138 -64
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  30. package/themes/business/src/components/OrderSummary/index.tsx +209 -73
  31. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  32. package/themes/business/src/components/OrdersOption/index.tsx +217 -156
  33. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  34. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  35. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +39 -16
  36. package/themes/business/src/components/PreviousOrders/index.tsx +76 -66
  37. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  38. package/themes/business/src/components/PrinterEdition/index.tsx +431 -0
  39. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  40. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  41. package/themes/business/src/components/PrinterSettings/index.tsx +162 -173
  42. package/themes/business/src/components/PrinterSettings/styles.tsx +14 -1
  43. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  44. package/themes/business/src/components/StoresList/index.tsx +2 -2
  45. package/themes/business/src/components/UserProfileForm/index.tsx +16 -17
  46. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  47. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  48. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  49. package/themes/business/src/types/index.tsx +13 -4
  50. package/themes/business/src/utils/index.tsx +25 -1
  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 +6 -0
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  59. package/themes/original/index.tsx +11 -0
  60. package/themes/original/src/components/AddressForm/index.tsx +32 -17
  61. package/themes/original/src/components/AddressList/index.tsx +8 -7
  62. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  63. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  64. package/themes/original/src/components/BusinessBasicInformation/index.tsx +5 -8
  65. package/themes/original/src/components/BusinessController/index.tsx +5 -5
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +13 -5
  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 +18 -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/index.tsx +1 -1
  78. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  79. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  80. package/themes/original/src/components/Cart/index.tsx +38 -14
  81. package/themes/original/src/components/CartContent/index.tsx +2 -4
  82. package/themes/original/src/components/Checkout/index.tsx +112 -58
  83. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  84. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  85. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  86. package/themes/original/src/components/Favorite/index.tsx +1 -5
  87. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  88. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
  89. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  90. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  91. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  92. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  93. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  94. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  95. package/themes/original/src/components/Help/index.tsx +2 -0
  96. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  97. package/themes/original/src/components/Home/index.tsx +3 -11
  98. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  99. package/themes/original/src/components/LoginForm/index.tsx +4 -7
  100. package/themes/original/src/components/MessageListing/index.tsx +2 -1
  101. package/themes/original/src/components/Messages/index.tsx +27 -19
  102. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  103. package/themes/original/src/components/MomentOption/index.tsx +80 -51
  104. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  105. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  106. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  107. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  108. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  109. package/themes/original/src/components/NavBar/index.tsx +7 -4
  110. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  111. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  112. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  113. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +13 -10
  114. package/themes/original/src/components/OrderDetails/index.tsx +44 -21
  115. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  116. package/themes/original/src/components/OrderProgress/index.tsx +5 -4
  117. package/themes/original/src/components/OrderSummary/index.tsx +29 -10
  118. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  119. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  120. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  121. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  122. package/themes/original/src/components/PaymentOptions/index.tsx +0 -2
  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 +17 -20
  126. package/themes/original/src/components/ProductForm/index.tsx +107 -102
  127. package/themes/original/src/components/ProductItemAccordion/index.tsx +50 -43
  128. package/themes/original/src/components/ProductItemAccordion/styles.tsx +0 -3
  129. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  130. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  131. package/themes/original/src/components/Promotions/index.tsx +6 -9
  132. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  133. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  134. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  135. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  136. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  137. package/themes/original/src/components/Sessions/index.tsx +3 -3
  138. package/themes/original/src/components/SignupForm/index.tsx +86 -78
  139. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
  140. package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
  141. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  142. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  143. package/themes/original/src/components/StripeCardsList/index.tsx +10 -3
  144. package/themes/original/src/components/StripeElementsForm/index.tsx +76 -62
  145. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  146. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  147. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  148. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  149. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  150. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  151. package/themes/original/src/components/UserFormDetails/index.tsx +159 -133
  152. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  153. package/themes/original/src/components/UserVerification/index.tsx +14 -4
  154. package/themes/original/src/components/Wallets/index.tsx +6 -3
  155. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  156. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  157. package/themes/original/src/components/shared/OButton.tsx +5 -4
  158. package/themes/original/src/components/shared/OInput.tsx +4 -8
  159. package/themes/original/src/components/shared/OModal.tsx +7 -2
  160. package/themes/original/src/types/index.tsx +5 -1
  161. package/themes/original/src/utils/index.tsx +30 -1
  162. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,33 +1,28 @@
1
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';
2
+ import { StyleSheet, TouchableOpacity, View, Dimensions } from 'react-native'
4
3
  import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
5
4
  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
5
  import { useTheme } from 'styled-components/native'
9
6
  import ToggleSwitch from 'toggle-switch-react-native';
10
7
  import { useLanguage } from 'ordering-components/native'
11
8
 
12
9
  import { _setStoreData, _retrieveStoreData } from '../../providers/StoreUtil'
13
- import { Container, EnabledAutoPrint } from './styles'
14
- import { OText, OInput} from '../shared'
10
+ import { Container, ContainerList, EnabledAutoPrint, NoPrintersContainer } from './styles'
11
+ import { OText, OIcon, OModal, OButton } from '../shared'
12
+ import { PrinterEdition } from '../PrinterEdition'
15
13
 
16
14
  export const PrinterSettings = (props: any) => {
17
- const { onClose } = props
15
+ const { navigation, onClose } = props
18
16
 
19
- const [currentPrinter, setCurrentPrinter] = useState<any>(null)
17
+ const [printers, setPrinters] = useState<any>({ list: [] })
20
18
  const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
21
- const [layoutWidth, setLayoutWidth] = useState<any>({ actionsBtns: 0 })
19
+ const [openModal, setOpenModal] = useState<any>({ open: false, data: null })
22
20
 
23
21
  const WIDTH_SCREEN = Dimensions.get('window').width
22
+ const HEIGHT_SCREEN = Dimensions.get('window').height
24
23
 
25
24
  const [, t] = useLanguage()
26
25
  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)
31
26
 
32
27
  const styles = StyleSheet.create({
33
28
  icons: {
@@ -45,7 +40,7 @@ export const PrinterSettings = (props: any) => {
45
40
  wIconContainer: {
46
41
  flexDirection: 'row',
47
42
  alignItems: 'center',
48
- width: WIDTH_SCREEN - 60 - 40
43
+ width: WIDTH_SCREEN - 40 - 22 - 22 - 10, // screen - margin - icon - icon - marginIcon
49
44
  },
50
45
  wrapperContainer: {
51
46
  flexDirection: 'column',
@@ -60,60 +55,62 @@ export const PrinterSettings = (props: any) => {
60
55
  borderWidth: 1,
61
56
  borderRadius: 8,
62
57
  },
63
- label: {
64
- color: theme.colors.textGray
58
+ btnBackArrow: {
59
+ borderWidth: 0,
60
+ width: 32,
61
+ height: 32,
62
+ tintColor: theme.colors.textGray,
63
+ backgroundColor: theme.colors.clear,
64
+ borderColor: theme.colors.clear,
65
+ shadowColor: theme.colors.clear,
66
+ paddingLeft: 0,
67
+ paddingRight: 0,
68
+ },
69
+ titleGroups: {
70
+ alignItems: 'center',
71
+ flexDirection: 'row',
72
+ minHeight: 33,
73
+ },
74
+ addButtonText: {
75
+ color: theme.colors.inputTextColor,
76
+ fontSize: 16,
77
+ },
78
+ addButton: {
79
+ height: 40,
80
+ marginTop: 10,
81
+ borderRadius: 8,
82
+ marginRight: 10,
83
+ marginBottom: 10,
65
84
  },
66
85
  })
67
86
 
68
- const printerList = [
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: '' },
89
- ]
87
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
90
88
 
91
- const handleClick = async (item: any, type?: number, ip?: string) => {
89
+ const handleClick = async ({ item, type, ip, edit, isAdd, index }: any) => {
92
90
  let _item = item
93
- if (_item) {
91
+ const action = edit || isAdd
92
+ let _printers = printers.list
93
+ const idx = index ?? _printers.findIndex((p: any) => p.model === _item.model)
94
+
95
+ if (idx !== -1 && !action) {
96
+ _printers.splice(idx, 1);
97
+ } else {
98
+ const _currentPrinter = _printers.find((p: any) => p.model === _item?.model)
94
99
  _item = {
95
- ...currentPrinter,
100
+ ..._currentPrinter,
96
101
  ...item,
97
- type: type ?? currentPrinter?.type,
98
- ip: ip ?? currentPrinter?.ip,
99
- portName: (type ?? currentPrinter?.type) === 1 || !ip
100
- ? currentPrinter?.portName1 ?? item.portName1
102
+ type: type ?? _currentPrinter?.type ?? 1,
103
+ ip: ip ?? _currentPrinter?.ip ?? '',
104
+ portName: (type ?? _currentPrinter?.type) === 1 || !ip
105
+ ? item?.bt ?? item.portName1 ?? _currentPrinter?.portName1
101
106
  : `TCP:${ip}`
102
107
  }
108
+ edit ? (_printers[idx] = _item) : _printers.push(_item)
103
109
  }
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
110
 
114
- const onSubmit = ({ ip }: any) => {
115
- handleClick(currentPrinter, 2, ip)
116
- onClose && onClose()
111
+ setPrinters({ list: _printers })
112
+ await _setStoreData('printers', _printers)
113
+ type === 1 && onClose && onClose()
117
114
  }
118
115
 
119
116
  const handleAutoPrint = async () => {
@@ -123,156 +120,148 @@ export const PrinterSettings = (props: any) => {
123
120
 
124
121
  useEffect(() => {
125
122
  const getStorageData = async () => {
126
- const printer = await _retrieveStoreData('printer')
123
+ const printers = await _retrieveStoreData('printers')
127
124
  const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
128
- setCurrentPrinter(printer)
125
+ setPrinters({ list: printers ?? [] })
129
126
  setAutoPrintEnabled(!!autoPrint)
130
127
  }
131
128
 
132
129
  getStorageData()
133
130
  }, [])
134
131
 
135
- useEffect(() => {
136
- currentPrinter?.ip && !isErrorIp && setValue('ip', currentPrinter?.ip)
137
- }, [currentPrinter?.type])
138
-
139
132
  return (
140
- <ScrollView
141
- showsVerticalScrollIndicator={false}
142
- >
143
- <OText size={24} style={{ paddingLeft: 30 }}>
133
+ <Container>
134
+ <View style={styles.titleGroups}>
135
+ <TouchableOpacity onPress={() => goToBack()} style={styles.btnBackArrow}>
136
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
137
+ </TouchableOpacity>
138
+ </View>
139
+ <OText size={24} style={{ paddingTop: 0 }}>
144
140
  {t('PRINTER_SETTINGS', 'Printer Settings')}
145
141
  </OText>
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}
142
+ {!!printers.list.length && (
143
+ <EnabledAutoPrint>
144
+ <View style={{ flex: 1 }}>
145
+ <OText
146
+ numberOfLines={2}
147
+ adjustsFontSizeToFit
148
+ color={theme.colors.textGray}
149
+ style={{ paddingHorizontal: 0 }}>
150
+ {t('AUTO_PRINT_AFTER_ACCEPTING_ORDER', 'Auto print after accepting order')}
151
+ </OText>
152
+ </View>
153
+ <ToggleSwitch
154
+ isOn={autoPrintEnabled}
155
+ onColor={theme.colors.primary}
156
+ offColor={theme.colors.offColor}
157
+ size="small"
158
+ onToggle={() => handleAutoPrint()}
159
+ animationSpeed={200}
160
+ />
161
+ </EnabledAutoPrint>
162
+ )}
163
+ {!!printers.list.length && (
164
+ <OButton
165
+ text={t('ADD_PRINTER', 'Add printer')}
166
+ imgRightSrc={null}
167
+ textStyle={styles.addButtonText}
168
+ style={styles.addButton}
169
+ bgColor={theme.colors.primary}
170
+ borderColor={theme.colors.primary}
171
+ onClick={() => setOpenModal({ open: true, data: null })}
162
172
  />
163
- </EnabledAutoPrint>
164
- <View style={{ paddingHorizontal: 30 }}>
165
- {printerList.map((item: any, i: number) => (
166
- <Container
173
+ )}
174
+ <View>
175
+ {printers.list.map((item: any, i: number) => (
176
+ <ContainerList
167
177
  key={i}
168
178
  activeOpacity={1}
169
- onPress={() => handleClick(item)}
170
179
  >
171
180
  <View style={styles.wrapperContainer}>
172
- <View style={{ flexDirection: 'row' }}>
181
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
173
182
  <TouchableOpacity
174
183
  activeOpacity={1}
175
184
  style={styles.wIconContainer}
176
- onPress={() => handleClick(item)}
185
+ onPress={() => setOpenModal({ open: true, data: { ...item, index: i} })}
177
186
  >
178
187
  <SimpleLineIcons
179
188
  name='printer'
180
189
  color={theme.colors.textGray}
181
190
  size={18}
182
- style={{ ...styles.icons, color: currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
191
+ style={{
192
+ ...styles.icons,
193
+ color: theme.colors.primary
194
+ }}
183
195
  />
184
196
  <OText
185
197
  size={18}
186
- color={currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray}
198
+ color={theme.colors.primary}
187
199
  >
188
- {item.model}
200
+ {item?.nickname ?? item.model}
189
201
  </OText>
190
202
  </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}
208
- >
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)}
203
+ <TouchableOpacity
204
+ activeOpacity={1}
205
+ onPress={() => setOpenModal({ open: true, data: { ...item, index: i} })}
206
+ >
207
+ <FeatherIcon
208
+ name='edit'
209
+ size={22}
216
210
  />
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)}
211
+ </TouchableOpacity>
212
+ <TouchableOpacity
213
+ activeOpacity={1}
214
+ onPress={() => handleClick({ item })}
215
+ style={{ marginLeft: 10 }}
216
+ >
217
+ <FeatherIcon
218
+ name='trash-2'
219
+ size={22}
220
+ color={theme.colors.danger500}
223
221
  />
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
- )}
222
+ </TouchableOpacity>
271
223
  </View>
272
224
  </View>
273
- </Container>
225
+ </ContainerList>
274
226
  ))}
227
+ {!printers.list.length && (
228
+ <NoPrintersContainer style={{ height: HEIGHT_SCREEN/2 }}>
229
+ <OText
230
+ size={20}
231
+ color={theme.colors.textGray}
232
+ numberOfLines={2}
233
+ adjustsFontSizeToFit
234
+ style={{ paddingHorizontal: 0, opacity: 0.4 }}
235
+ >
236
+ {t('NO_PRINTERS_CONFIGURED', 'No printers configured')}
237
+ </OText>
238
+ <OButton
239
+ text={t('ADD_PRINTER', 'Add printer')}
240
+ imgRightSrc={null}
241
+ textStyle={styles.addButtonText}
242
+ style={styles.addButton}
243
+ bgColor={theme.colors.primary}
244
+ borderColor={theme.colors.primary}
245
+ onClick={() => setOpenModal({ open: true, data: null })}
246
+ />
247
+ </NoPrintersContainer>
248
+ )}
275
249
  </View>
276
- </ScrollView>
250
+ <OModal
251
+ hideIcons
252
+ entireModal
253
+ customClose
254
+ open={openModal.open}
255
+ style={{ paddingTop: 0, marginTop: 0 }}
256
+ onClose={() => setOpenModal({ open: false, data: null })}
257
+ >
258
+ <PrinterEdition
259
+ printer={openModal.data}
260
+ printersList={printers}
261
+ handleChangePrinter={handleClick}
262
+ onClose={() => setOpenModal({ open: false, data: null })}
263
+ />
264
+ </OModal>
265
+ </Container>
277
266
  )
278
267
  }
@@ -1,6 +1,10 @@
1
1
  import styled from "styled-components/native";
2
2
 
3
3
  export const Container = styled.View`
4
+ margin-bottom: 50px;
5
+ `
6
+
7
+ export const ContainerList = styled.View`
4
8
  flex-direction: row;
5
9
  justify-content: space-between;
6
10
  width: 100%;
@@ -13,5 +17,14 @@ export const EnabledAutoPrint = styled.View`
13
17
  flex-direction: row;
14
18
  justify-content: space-between;
15
19
  align-items: center;
16
- padding: 20px 30px 10px;
20
+ padding: 20px 0px 10px;
17
21
  `;
22
+
23
+ export const NoPrintersContainer = styled.View`
24
+ flex-direction: column;
25
+ align-items: center;
26
+ justify-content: center;
27
+ margin-top: 40px;
28
+ height: 100%;
29
+ flex: 1;
30
+ `
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  import React, { useState, useEffect, useRef } from 'react'
2
4
  import {
3
5
  useLanguage,
@@ -149,10 +149,10 @@ const StoresListUI = (props: BusinessesListingParams) => {
149
149
  width={12}
150
150
  height={12}
151
151
  color={theme.colors.skyBlue}
152
- style={{ marginRight: 5, marginTop: 3 }}
152
+ style={{ marginRight: 5 }}
153
153
  />
154
154
  <OText size={12}>
155
- {t('MORE_SETTINGS_GO_TO', 'For more settings go to')}{' '}
155
+ {t('MORE_SETTINGS_GO_TO', 'For more settings go to ')}
156
156
  </OText>
157
157
  <TouchableOpacity onPress={() => { Linking.openURL(t('LINK_MORE_SETTINGS_GO_TO', 'https://app.ordering.co')) }}>
158
158
  <OText size={12} color={theme.colors.skyBlue}>
@@ -11,7 +11,8 @@ import {
11
11
  useToast,
12
12
  useLanguage,
13
13
  useUtils,
14
- useConfig
14
+ useConfig,
15
+ useValidationFields
15
16
  } from 'ordering-components/native';
16
17
  import {
17
18
  CenterView,
@@ -57,11 +58,12 @@ const ProfileUI = (props: ProfileParams) => {
57
58
  const [, t] = useLanguage();
58
59
  const [, { showToast }] = useToast();
59
60
  const [{ optimizeImage }] = useUtils();
60
- const [{ configs }] = useConfig()
61
+ const [{ configs }] = useConfig();
62
+ const [{ loading }, { loadOriginalValidationFields }] = useValidationFields()
61
63
  const { errors } = useForm();
62
64
  const theme = useTheme();
63
65
 
64
- const [phoneInputData, setPhoneInputData] = useState({
66
+ const [phoneInputData, setPhoneInputData] = useState<any>({
65
67
  error: '',
66
68
  phone: {
67
69
  country_phone_code: null,
@@ -76,11 +78,8 @@ const ProfileUI = (props: ProfileParams) => {
76
78
  const allowDriverUpdateData = user?.level !== 4 || configs?.allow_driver_update_data?.value === "1"
77
79
  useEffect(() => {
78
80
  if (phoneInputData.phone.cellphone) {
79
- const codeNumberPhone = phoneInputData.phone.cellphone.slice(0, 3);
80
- const numberPhone = phoneInputData.phone.cellphone.slice(
81
- 3,
82
- phoneInputData.phone.cellphone?.length,
83
- );
81
+ const codeNumberPhone = phoneInputData.phone.country_phone_code
82
+ const numberPhone = phoneInputData.phone.cellphone
84
83
  setPhoneToShow(`(${codeNumberPhone}) ${numberPhone}`);
85
84
  }
86
85
  }, [phoneInputData.phone.cellphone]);
@@ -262,15 +261,17 @@ const ProfileUI = (props: ProfileParams) => {
262
261
 
263
262
  return (
264
263
  <>
265
- {validationFields?.error && (
264
+ {validationFields?.error && !loading && (
266
265
  <NotFoundSource
267
266
  content={
268
- validationFields?.error[0] ||
269
- validationFields?.error[0]?.message ||
267
+ validationFields?.error?.[0] ||
268
+ validationFields?.error?.[0]?.message ||
270
269
  t('NETWORK_ERROR', 'Network Error')
271
270
  }
272
271
  image={theme.images.general.notFound}
273
272
  conditioned={false}
273
+ onClickButton={() => loadOriginalValidationFields({ forceLoading: true })}
274
+ btnTitle={t('REFRESH_PROFILE', 'Refresh profile')}
274
275
  />
275
276
  )}
276
277
 
@@ -463,7 +464,6 @@ const ProfileUI = (props: ProfileParams) => {
463
464
  />
464
465
 
465
466
  <OText style={styles.label}>{t('PHONE', 'Phone')}</OText>
466
-
467
467
  <OInput
468
468
  isSecured={true}
469
469
  placeholder={
@@ -486,10 +486,11 @@ const ProfileUI = (props: ProfileParams) => {
486
486
  handleCancelEdit={handleCancelEdit}
487
487
  toggleIsEdit={toggleIsEdit}
488
488
  isAlsea={isAlsea}
489
+ allowDriverUpdateData={allowDriverUpdateData}
489
490
  />
490
491
  </View>
491
492
  )}
492
- {!validationFields.loading && !isEdit && allowDriverUpdateData && (
493
+ {!validationFields.loading && !isEdit && (
493
494
  <EditButton>
494
495
  <OButton
495
496
  text={t('EDIT', 'Edit')}
@@ -516,7 +517,7 @@ const ProfileUI = (props: ProfileParams) => {
516
517
  }} />
517
518
  </Pressable>
518
519
  ) : (
519
- <Pressable style={{ marginBottom: 10 }} onPress={() => setOpenModal(true)}>
520
+ <Pressable style={{ marginBottom: 10 }} onPress={() => navigation.navigate('PrinterSetup')}>
520
521
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
521
522
  <OText size={16}>{t('PRINTER_SETTINGS', 'Printer Settings')}</OText>
522
523
  <AntDesignIcon size={18} name='right' />
@@ -550,9 +551,7 @@ const ProfileUI = (props: ProfileParams) => {
550
551
  entireModal
551
552
  hideIcons
552
553
  >
553
- {props.isBusinessApp ? (
554
- <PrinterSettings onClose={() => setOpenModal(false)} />
555
- ) : (
554
+ {!props.isBusinessApp && (
556
555
  <DriverSchedule schedule={user?.schedule} />
557
556
  )}
558
557
  </OModal>
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react'
2
2
  import { useLanguage, useUtils, WebsocketStatus as WebsocketStatusController } from 'ordering-components/native'
3
- import { TouchableOpacity, View, StyleSheet } from 'react-native'
3
+ import { TouchableOpacity, View, StyleSheet, Platform } from 'react-native'
4
4
  import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
5
5
  import { useTheme } from 'styled-components/native'
6
6
  import RNRestart from 'react-native-restart'
@@ -37,7 +37,7 @@ const SocketStatusUI = (props: any) => {
37
37
  paddingLeft: 0,
38
38
  paddingRight: 0,
39
39
  marginBottom: 30,
40
- marginTop: 30
40
+ marginTop: Platform.OS === 'ios' ? 60 : 30
41
41
  },
42
42
  })
43
43
 
@@ -4,8 +4,10 @@ import { useTheme } from 'styled-components/native';
4
4
 
5
5
  const Wrapper = styled.View`
6
6
  border-radius: 10px;
7
- border: 1px solid ${(props: any) => props.theme.colors.lightGray};
7
+ border-width: 1px;
8
+ border-color: ${(props: any) => props.theme.colors.lightGray};
8
9
  `;
10
+
9
11
  const Inner = styled.TextInput`
10
12
  height: 100px;
11
13
  padding: 5px 10px 5px 10px;
@@ -29,16 +31,13 @@ const OTextarea = (props: Props) => {
29
31
  ref={props.textTareaRef}
30
32
  onFocus={() => props.onFocus()}
31
33
  onChangeText={(txt: any) => props.onChange(txt)}
32
- textAlignVertical={'top'}
33
34
  placeholder={props.placeholder}
34
- placeholderTextColor={theme.colors.arrowColor}
35
- numberOfLines={props.lines}
36
- underlineColorAndroid={'transparent'}
37
- value={props.value}
35
+ placeholderTextColor={theme.colors.lightGray}
36
+ numberOfLines={props.lines}
37
+ underlineColorAndroid={'transparent'}
38
+ value={props.value}
39
+ multiline={true}
38
40
  autoFocus={props.autoFocus}
39
- multiline={true}
40
- selectionColor={theme.colors.primary}
41
- color={theme.colors.textGray}
42
41
  />
43
42
  </Wrapper>
44
43
  );