ordering-ui-react-native 0.22.36 → 0.22.37-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 (164) 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/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/themes/business/index.tsx +2 -0
  8. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  9. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  10. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  11. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  12. package/themes/business/src/components/Chat/index.tsx +15 -3
  13. package/themes/business/src/components/DriverMap/index.tsx +49 -26
  14. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  15. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  16. package/themes/business/src/components/LanguageSelector/index.tsx +1 -4
  17. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  18. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  19. package/themes/business/src/components/MapView/index.tsx +46 -29
  20. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -19
  21. package/themes/business/src/components/OrderDetails/Business.tsx +47 -27
  22. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  23. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +156 -46
  24. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  25. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  26. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  27. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  28. package/themes/business/src/components/OrderSummary/index.tsx +6 -4
  29. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  30. package/themes/business/src/components/OrdersOption/index.tsx +332 -231
  31. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  32. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  33. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +29 -18
  34. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  35. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  36. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  37. package/themes/business/src/components/PrinterEdition/index.tsx +431 -0
  38. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  39. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  40. package/themes/business/src/components/PrinterSettings/index.tsx +162 -174
  41. package/themes/business/src/components/PrinterSettings/styles.tsx +14 -1
  42. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  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 +48 -19
  46. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  47. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  48. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  49. package/themes/business/src/config/currency.tsx +1010 -0
  50. package/themes/business/src/hooks/useLocation.tsx +16 -12
  51. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  52. package/themes/business/src/types/index.tsx +21 -7
  53. package/themes/business/src/utils/index.tsx +28 -3
  54. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  55. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  56. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  57. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  58. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  59. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  60. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  61. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  62. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  63. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  64. package/themes/original/index.tsx +11 -0
  65. package/themes/original/src/components/AddressForm/index.tsx +27 -16
  66. package/themes/original/src/components/AddressList/index.tsx +8 -7
  67. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  68. package/themes/original/src/components/BusinessBasicInformation/index.tsx +5 -8
  69. package/themes/original/src/components/BusinessItemAccordion/index.tsx +14 -6
  70. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  71. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
  72. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  73. package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
  74. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  75. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  76. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  77. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  78. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  79. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  80. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  81. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  82. package/themes/original/src/components/Cart/index.tsx +49 -15
  83. package/themes/original/src/components/CartContent/index.tsx +2 -4
  84. package/themes/original/src/components/Checkout/index.tsx +127 -77
  85. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  86. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  87. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  88. package/themes/original/src/components/Favorite/index.tsx +1 -5
  89. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  90. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
  91. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  92. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  93. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  94. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  95. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  96. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  97. package/themes/original/src/components/Help/index.tsx +2 -0
  98. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  99. package/themes/original/src/components/Home/index.tsx +35 -19
  100. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  101. package/themes/original/src/components/LoginForm/index.tsx +14 -11
  102. package/themes/original/src/components/MessageListing/index.tsx +2 -1
  103. package/themes/original/src/components/Messages/index.tsx +27 -19
  104. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  105. package/themes/original/src/components/MomentOption/index.tsx +80 -52
  106. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  107. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -4
  108. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  109. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  110. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  111. package/themes/original/src/components/NavBar/index.tsx +7 -4
  112. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  113. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  114. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  115. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
  116. package/themes/original/src/components/OrderDetails/index.tsx +45 -22
  117. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  118. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  119. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  120. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  121. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  122. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  123. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  124. package/themes/original/src/components/PaymentOptions/index.tsx +462 -461
  125. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  126. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  127. package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
  128. package/themes/original/src/components/ProductForm/ActionButton.tsx +17 -20
  129. package/themes/original/src/components/ProductForm/index.tsx +107 -102
  130. package/themes/original/src/components/ProductItemAccordion/index.tsx +30 -38
  131. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  132. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  133. package/themes/original/src/components/Promotions/index.tsx +6 -9
  134. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  135. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  136. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  137. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  138. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  139. package/themes/original/src/components/Sessions/index.tsx +3 -3
  140. package/themes/original/src/components/SignupForm/index.tsx +44 -32
  141. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
  142. package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
  143. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  144. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  145. package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
  146. package/themes/original/src/components/StripeElementsForm/index.tsx +8 -4
  147. package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
  148. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  149. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  150. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  151. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  152. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  153. package/themes/original/src/components/UserFormDetails/index.tsx +102 -74
  154. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  155. package/themes/original/src/components/UserVerification/index.tsx +15 -4
  156. package/themes/original/src/components/Wallets/index.tsx +6 -3
  157. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  158. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  159. package/themes/original/src/components/shared/OButton.tsx +5 -4
  160. package/themes/original/src/components/shared/OInput.tsx +4 -8
  161. package/themes/original/src/components/shared/OModal.tsx +7 -2
  162. package/themes/original/src/types/index.tsx +12 -4
  163. package/themes/original/src/utils/index.tsx +29 -0
  164. 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,61 +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: '', printMode: 'append' },
70
- { model: 'FVP10', emulation: 'StarLine', portName1: 'BT:FVP10', type: 1, ip: '', printMode: 'append' },
71
- { model: 'TSP100', emulation: 'StarGraphic', portName1: 'BT:TSP100', type: 1, ip: '', printMode: 'appendBitmapText' },
72
- { model: 'TSP100IV', emulation: 'StarLine', portName1: 'BT:TSP100iv', type: 1, ip: '', printMode: 'append' },
73
- { model: 'TSP65011', emulation: 'StarLine', portName1: 'BT:TSP65011', type: 1, ip: '', printMode: 'append' },
74
- { model: 'TSP7001', emulation: 'StarLine', portName1: 'BT:TSP7001', type: 1, ip: '', printMode: 'append' },
75
- { model: 'TSP80011', emulation: 'StarLine', portName1: 'BT:TSP80011', type: 1, ip: '', printMode: 'append' },
76
- { model: 'SP700', emulation: 'StarDotImpact', portName1: 'BT:SP700', type: 1, ip: '', printMode: 'append' },
77
- { model: 'SM-S210i', emulation: 'EscPosMobile', portName1: 'BT:SMS210i', type: 1, ip: '', printMode: 'append' },
78
- { model: 'SM-S220i', emulation: 'EscPosMobile', portName1: 'BT:SMS220i', type: 1, ip: '', printMode: 'append' },
79
- { model: 'SM-S230i', emulation: 'EscosMobile', portName1: 'BT:SMS230i', type: 1, ip: '', printMode: 'append' },
80
- { model: 'SM-T300i/T300', emulation: 'EscPosMobile', portName1: 'BT:SMT300i/T300', type: 1, ip: '', printMode: 'append' },
81
- { model: 'SM-T400i', emulation: 'EscosMobile', portName1: 'BT:SMT400i', type: 1, ip: '', printMode: 'append' },
82
- { model: 'SM-L200', emulation: 'StarPRNT', portName1: 'BT:SML200', type: 1, ip: '', printMode: 'append' },
83
- { model: 'SM-L300', emulation: 'StarPRNT', portName1: 'BT:SML300', type: 1, ip: '', printMode: 'append' },
84
- { model: 'BSC10', emulation: 'EscPos', portName1: 'BT:BSC10', type: 1, ip: '', printMode: 'append' },
85
- { model: 'SM-S210i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS210i', type: 1, ip: '', printMode: 'append' },
86
- { model: 'SM-S220i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS220i', type: 1, ip: '', printMode: 'append' },
87
- { model: 'SM-S230i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMS230i', type: 1, ip: '', printMode: 'append' },
88
- { model: 'SM-T300i/T300 StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMT300i', type: 1, ip: '', printMode: 'append' },
89
- { model: 'SM-T400i StarPRNT', emulation: 'StarPRNT', portName1: 'BT:SMT400i', type: 1, ip: '', printMode: 'append' },
90
- ]
87
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
91
88
 
92
- const handleClick = async (item: any, type?: number, ip?: string) => {
89
+ const handleClick = async ({ item, type, ip, edit, isAdd, index }: any) => {
93
90
  let _item = item
94
- 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)
95
99
  _item = {
96
- ...currentPrinter,
100
+ ..._currentPrinter,
97
101
  ...item,
98
- type: type ?? currentPrinter?.type,
99
- ip: ip ?? currentPrinter?.ip ?? '',
100
- portName: (type ?? currentPrinter?.type) === 1 || !ip
101
- ? item.portName1 ?? currentPrinter?.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
102
106
  : `TCP:${ip}`
103
107
  }
108
+ edit ? (_printers[idx] = _item) : _printers.push(_item)
104
109
  }
105
- setCurrentPrinter(_item)
106
- await _setStoreData('printer', _item)
107
- type === 1 && onClose && onClose()
108
- }
109
-
110
- const onLayout = (event: any, type: string) => {
111
- const { width } = event.nativeEvent.layout;
112
- setLayoutWidth({ ...layoutWidth, [type]: width })
113
- };
114
110
 
115
- const onSubmit = ({ ip }: any) => {
116
- handleClick(currentPrinter, 2, ip)
117
- onClose && onClose()
111
+ setPrinters({ list: _printers })
112
+ await _setStoreData('printers', _printers)
113
+ type === 1 && onClose && onClose()
118
114
  }
119
115
 
120
116
  const handleAutoPrint = async () => {
@@ -124,156 +120,148 @@ export const PrinterSettings = (props: any) => {
124
120
 
125
121
  useEffect(() => {
126
122
  const getStorageData = async () => {
127
- const printer = await _retrieveStoreData('printer')
123
+ const printers = await _retrieveStoreData('printers')
128
124
  const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
129
- setCurrentPrinter(printer)
125
+ setPrinters({ list: printers ?? [] })
130
126
  setAutoPrintEnabled(!!autoPrint)
131
127
  }
132
128
 
133
129
  getStorageData()
134
130
  }, [])
135
131
 
136
- useEffect(() => {
137
- currentPrinter?.ip && !isErrorIp && setValue('ip', currentPrinter?.ip)
138
- }, [currentPrinter?.type])
139
-
140
132
  return (
141
- <ScrollView
142
- showsVerticalScrollIndicator={false}
143
- >
144
- <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 }}>
145
140
  {t('PRINTER_SETTINGS', 'Printer Settings')}
146
141
  </OText>
147
- <EnabledAutoPrint>
148
- <View style={{ flex: 1 }}>
149
- <OText
150
- numberOfLines={2}
151
- adjustsFontSizeToFit
152
- style={{ ...styles.label, paddingHorizontal: 0 }}>
153
- {t('AUTO_PRINT_AFTER_ACCEPTING_ORDER', 'Auto print after accepting order')}
154
- </OText>
155
- </View>
156
- <ToggleSwitch
157
- isOn={autoPrintEnabled}
158
- onColor={theme.colors.primary}
159
- offColor={theme.colors.offColor}
160
- size="small"
161
- onToggle={() => handleAutoPrint()}
162
- 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 })}
163
172
  />
164
- </EnabledAutoPrint>
165
- <View style={{ paddingHorizontal: 30 }}>
166
- {printerList.map((item: any, i: number) => (
167
- <Container
173
+ )}
174
+ <View>
175
+ {printers.list.map((item: any, i: number) => (
176
+ <ContainerList
168
177
  key={i}
169
178
  activeOpacity={1}
170
- onPress={() => handleClick(item)}
171
179
  >
172
180
  <View style={styles.wrapperContainer}>
173
- <View style={{ flexDirection: 'row' }}>
181
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
174
182
  <TouchableOpacity
175
183
  activeOpacity={1}
176
184
  style={styles.wIconContainer}
177
- onPress={() => handleClick(item)}
185
+ onPress={() => setOpenModal({ open: true, data: { ...item, index: i} })}
178
186
  >
179
187
  <SimpleLineIcons
180
188
  name='printer'
181
189
  color={theme.colors.textGray}
182
190
  size={18}
183
- 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
+ }}
184
195
  />
185
196
  <OText
186
197
  size={18}
187
- color={currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray}
198
+ color={theme.colors.primary}
188
199
  >
189
- {item.model}
200
+ {item?.nickname ?? item.model}
190
201
  </OText>
191
202
  </TouchableOpacity>
192
- {currentPrinter?.model === item.model && (
193
- <TouchableOpacity
194
- activeOpacity={1}
195
- onPress={() => handleClick(null)}
196
- style={{ width: 40 }}
197
- >
198
- <FeatherIcon
199
- name='x-circle'
200
- color={theme.colors.danger500}
201
- size={20}
202
- style={styles.icons}
203
- />
204
- </TouchableOpacity>
205
- )}
206
- </View>
207
- <View
208
- style={styles.wrapperIcons}
209
- >
210
- <View style={styles.wrapperIcons} onLayout={(e) => onLayout(e, 'actionsBtns')}>
211
- <FAIcons
212
- name='bluetooth'
213
- size={20}
214
- {...(currentPrinter?.type === 1 && currentPrinter?.model === item.model ? { color: theme.colors.primary } : {})}
215
- style={{ ...styles.optionIcons, borderColor: currentPrinter?.type === 1 && currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
216
- 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}
217
210
  />
218
- <MCIcons
219
- name='access-point-network'
220
- size={20}
221
- {...(currentPrinter?.type === 2 && currentPrinter?.model === item.model ? { color: theme.colors.primary } : {})}
222
- style={{ ...styles.optionIcons, borderColor: currentPrinter?.type === 2 && currentPrinter?.model === item.model ? theme.colors.primary : theme.colors.textGray }}
223
- 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}
224
221
  />
225
- </View>
226
- {currentPrinter?.type === 2 && currentPrinter?.model === item.model && (
227
- <View style={{ flexDirection: 'row', width: WIDTH_SCREEN - 60 - layoutWidth.actionsBtns }}>
228
- <Controller
229
- control={control}
230
- name={'ip'}
231
- rules={{
232
- required: t('VALIDATION_ERROR_IP_ADDRESS_REQUIRED', 'Ip address is required'),
233
- pattern: {
234
- 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,
235
- message: t('INVALID_ERROR_IP_ADDRESS', 'Invalid ip address')
236
- }
237
- }}
238
- defaultValue={currentPrinter?.ip ?? ''}
239
- render={() => (
240
- <OInput
241
- placeholder={t('IP_ADDRESS', 'Ip address')}
242
- placeholderTextColor={theme.colors.arrowColor}
243
- style={{ ...styles.inputStyle, borderColor: isErrorIp ? theme.colors.danger500 : theme.colors.tabBar }}
244
- value={currentPrinter?.ip ?? ''}
245
- selectionColor={theme.colors.primary}
246
- color={theme.colors.textGray}
247
- onChange={(value: any) => {
248
- setValue('ip', value)
249
- setCurrentPrinter({
250
- ...currentPrinter,
251
- ip: value
252
- })
253
- }}
254
- />
255
- )}
256
- />
257
- <TouchableOpacity
258
- activeOpacity={1}
259
- disabled={isErrorIp}
260
- onPress={handleSubmit(onSubmit)}
261
- style={{ width: 40 }}
262
- >
263
- <FeatherIcon
264
- name='save'
265
- size={20}
266
- color={isErrorIp ? theme.colors.tabBar : theme.colors.primary }
267
- style={styles.icons}
268
- />
269
- </TouchableOpacity>
270
- </View>
271
- )}
222
+ </TouchableOpacity>
272
223
  </View>
273
224
  </View>
274
- </Container>
225
+ </ContainerList>
275
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
+ )}
276
249
  </View>
277
- </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>
278
266
  )
279
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
+ `
@@ -22,6 +22,7 @@ import {
22
22
  } from './styles';
23
23
  import { OText, OAlert } from '../shared';
24
24
  import { ProductItemAccordionParams } from '../../types';
25
+ import { getCurrenySymbol } from '../../utils';
25
26
 
26
27
  export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
27
28
  const {
@@ -160,7 +161,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
160
161
  }}>
161
162
  <View style={{ flexDirection: 'row' }}>
162
163
  <OText size={12} color={theme.colors.textGray}>
163
- {parsePrice(getProductPrice(product), { currency })}
164
+ {parsePrice(getProductPrice(product), { currency: getCurrenySymbol(currency) })}
164
165
  </OText>
165
166
 
166
167
  {(
@@ -281,7 +282,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
281
282
  suboption.position,
282
283
  )
283
284
  : '',
284
- price: parsePrice(suboption.price, { currency }),
285
+ price: parsePrice(suboption.price, { currency: getCurrenySymbol(currency) }),
285
286
  })}
286
287
  </OText>
287
288
  </ProductSubOption>
@@ -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}>
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { View, StyleSheet, ScrollView, ActivityIndicator, Pressable } from 'react-native';
3
+ import { _retrieveStoreData, _clearStoreData } from '../../providers/StoreUtil';
3
4
  import { useForm } from 'react-hook-form';
4
5
  import { launchImageLibrary } from 'react-native-image-picker';
5
6
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
@@ -20,6 +21,7 @@ import {
20
21
  UserData,
21
22
  EditButton,
22
23
  EnabledStatusDriver,
24
+ RemoveAccount
23
25
  } from './styles';
24
26
  import { LogoutButton } from '../LogoutButton';
25
27
  import { LanguageSelector } from '../LanguageSelector';
@@ -36,6 +38,8 @@ import {
36
38
  OInput,
37
39
  OModal,
38
40
  } from '../../components/shared';
41
+ import { OAlert } from '../../../../../src/components/shared'
42
+
39
43
  import { sortInputFields, getTraduction } from '../../utils';
40
44
  import { ProfileParams } from '../../types';
41
45
  import { NotFoundSource } from '../NotFoundSource';
@@ -49,6 +53,7 @@ const ProfileUI = (props: ProfileParams) => {
49
53
  toggleIsEdit,
50
54
  cleanFormState,
51
55
  handleToggleAvalaibleStatusDriver,
56
+ handleRemoveAccount,
52
57
  isAlsea,
53
58
  isShowDriverStatus,
54
59
  navigation
@@ -62,8 +67,9 @@ const ProfileUI = (props: ProfileParams) => {
62
67
  const [{ loading }, { loadOriginalValidationFields }] = useValidationFields()
63
68
  const { errors } = useForm();
64
69
  const theme = useTheme();
70
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
65
71
 
66
- const [phoneInputData, setPhoneInputData] = useState({
72
+ const [phoneInputData, setPhoneInputData] = useState<any>({
67
73
  error: '',
68
74
  phone: {
69
75
  country_phone_code: null,
@@ -76,16 +82,7 @@ const ProfileUI = (props: ProfileParams) => {
76
82
  const [phoneToShow, setPhoneToShow] = useState('');
77
83
  const [openModal, setOpenModal] = useState(false)
78
84
  const allowDriverUpdateData = user?.level !== 4 || configs?.allow_driver_update_data?.value === "1"
79
- useEffect(() => {
80
- if (phoneInputData.phone.cellphone) {
81
- const codeNumberPhone = phoneInputData.phone.cellphone.slice(0, 3);
82
- const numberPhone = phoneInputData.phone.cellphone.slice(
83
- 3,
84
- phoneInputData.phone.cellphone?.length,
85
- );
86
- setPhoneToShow(`(${codeNumberPhone}) ${numberPhone}`);
87
- }
88
- }, [phoneInputData.phone.cellphone]);
85
+ const isAdmin = user?.level === 0
89
86
 
90
87
  const setUserCellPhone = (isEdit = false) => {
91
88
  if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
@@ -151,6 +148,28 @@ const ProfileUI = (props: ProfileParams) => {
151
148
  });
152
149
  };
153
150
 
151
+ const onRemoveAccount = async () => {
152
+ setConfirm({
153
+ open: true,
154
+ content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
155
+ title: t('ACCOUNT_ALERT', 'Account alert'),
156
+ handleOnAccept: () => {
157
+ setConfirm({ ...confirm, open: false })
158
+ handleRemoveAccount && handleRemoveAccount(user?.id)
159
+ _clearStoreData({ excludedKeys: ['isTutorial', 'language'] });
160
+ props?.setRootState && props?.setRootState({ isAuth: false, token: null })
161
+ }
162
+ })
163
+ }
164
+
165
+ useEffect(() => {
166
+ if (phoneInputData.phone.cellphone) {
167
+ const codeNumberPhone = phoneInputData.phone.country_phone_code
168
+ const numberPhone = phoneInputData.phone.cellphone
169
+ setPhoneToShow(`(${codeNumberPhone}) ${numberPhone}`);
170
+ }
171
+ }, [phoneInputData.phone.cellphone]);
172
+
154
173
  useEffect(() => {
155
174
  const isLoadingDriver = userState?.loadingDriver ?? true;
156
175
 
@@ -158,8 +177,8 @@ const ProfileUI = (props: ProfileParams) => {
158
177
  if (userState?.result?.error) {
159
178
  const messageError =
160
179
  userState.result.error || userState.result.error[0];
161
- showToast(ToastType.Error, getTraduction(messageError, t));
162
- } else {
180
+ showToast(ToastType.Error, typeof messageError === 'string' ? getTraduction(messageError, t) : t('CANNOT_UPDATE_AVAILABLE_STATE', 'Cannot update available state'));
181
+ } else {
163
182
  showToast(
164
183
  ToastType.Success,
165
184
  t('AVAILABLE_STATE_IS_UPDATED', 'Available state is updated'),
@@ -467,7 +486,6 @@ const ProfileUI = (props: ProfileParams) => {
467
486
  />
468
487
 
469
488
  <OText style={styles.label}>{t('PHONE', 'Phone')}</OText>
470
-
471
489
  <OInput
472
490
  isSecured={true}
473
491
  placeholder={
@@ -490,10 +508,11 @@ const ProfileUI = (props: ProfileParams) => {
490
508
  handleCancelEdit={handleCancelEdit}
491
509
  toggleIsEdit={toggleIsEdit}
492
510
  isAlsea={isAlsea}
511
+ allowDriverUpdateData={allowDriverUpdateData}
493
512
  />
494
513
  </View>
495
514
  )}
496
- {!validationFields.loading && !isEdit && allowDriverUpdateData && (
515
+ {!validationFields.loading && !isEdit && (
497
516
  <EditButton>
498
517
  <OButton
499
518
  text={t('EDIT', 'Edit')}
@@ -520,7 +539,7 @@ const ProfileUI = (props: ProfileParams) => {
520
539
  }} />
521
540
  </Pressable>
522
541
  ) : (
523
- <Pressable style={{ marginBottom: 10 }} onPress={() => setOpenModal(true)}>
542
+ <Pressable style={{ marginBottom: 10 }} onPress={() => navigation.navigate('PrinterSetup')}>
524
543
  <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
525
544
  <OText size={16}>{t('PRINTER_SETTINGS', 'Printer Settings')}</OText>
526
545
  <AntDesignIcon size={18} name='right' />
@@ -548,18 +567,28 @@ const ProfileUI = (props: ProfileParams) => {
548
567
 
549
568
  <LogoutButton />
550
569
  </Actions>
570
+ <RemoveAccount disabled={isAdmin} onPress={() => onRemoveAccount()} activeOpacity={0.7}>
571
+ <AntDesignIcon size={16} name='close' color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
572
+ <OText size={14} lineHeight={24} weight={'400'} style={{ opacity: isAdmin ? 0.5 : 1 }} color={theme.colors.danger500}>{t('REMOVE_ACCOUNT', 'Remove account')}</OText>
573
+ </RemoveAccount>
551
574
  <OModal
552
575
  open={openModal}
553
576
  onClose={() => setOpenModal(false)}
554
577
  entireModal
555
578
  hideIcons
556
579
  >
557
- {props.isBusinessApp ? (
558
- <PrinterSettings onClose={() => setOpenModal(false)} />
559
- ) : (
580
+ {!props.isBusinessApp && (
560
581
  <DriverSchedule schedule={user?.schedule} />
561
582
  )}
562
583
  </OModal>
584
+ <OAlert
585
+ open={confirm.open}
586
+ title={confirm.title}
587
+ content={confirm.content}
588
+ onAccept={confirm.handleOnAccept}
589
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
590
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
591
+ />
563
592
  </ScrollView>
564
593
  )}
565
594
  </>
@@ -34,3 +34,10 @@ export const Actions = styled.View`
34
34
  justify-content: space-between;
35
35
  align-items: flex-start;
36
36
  `;
37
+
38
+ export const RemoveAccount = styled.TouchableOpacity`
39
+ flex-direction: row;
40
+ justify-content: flex-start;
41
+ align-items: center;
42
+ margin-bottom: 24px;
43
+ `