ordering-ui-react-native 0.21.79 → 0.21.80-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/PaymentOptionsWebView/index.tsx +1 -0
  5. package/src/components/StripeMethodForm/index.tsx +6 -4
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/types/index.tsx +3 -1
  8. package/themes/business/index.tsx +4 -0
  9. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  10. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  11. package/themes/business/src/components/BusinessProductList/index.tsx +2 -1
  12. package/themes/business/src/components/Chat/index.tsx +3 -1
  13. package/themes/business/src/components/DriverMap/index.tsx +44 -27
  14. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  15. package/themes/business/src/components/Home/index.tsx +5 -1
  16. package/themes/business/src/components/LanguageSelector/index.tsx +2 -3
  17. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  18. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  19. package/themes/business/src/components/MapView/index.tsx +36 -17
  20. package/themes/business/src/components/NewOrderNotification/index.tsx +74 -24
  21. package/themes/business/src/components/OrderDetails/Business.tsx +65 -7
  22. package/themes/business/src/components/OrderDetails/Delivery.tsx +35 -20
  23. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +110 -40
  24. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +61 -35
  25. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  26. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
  27. package/themes/business/src/components/OrderSummary/index.tsx +223 -73
  28. package/themes/business/src/components/OrdersListManager/index.tsx +9 -1
  29. package/themes/business/src/components/OrdersOption/index.tsx +247 -159
  30. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  31. package/themes/business/src/components/PreviousMessages/index.tsx +12 -0
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +25 -15
  33. package/themes/business/src/components/PreviousOrders/index.tsx +5 -3
  34. package/themes/business/src/components/PrinterEdition/index.tsx +363 -0
  35. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  36. package/themes/business/src/components/PrinterSettings/index.tsx +267 -0
  37. package/themes/business/src/components/PrinterSettings/styles.tsx +30 -0
  38. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  39. package/themes/business/src/components/Sessions/index.tsx +187 -0
  40. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  43. package/themes/business/src/components/UserProfileForm/index.tsx +84 -47
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/components/shared/OInput.tsx +2 -0
  46. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  47. package/themes/business/src/hooks/useLocation.tsx +5 -4
  48. package/themes/business/src/types/index.tsx +23 -5
  49. package/themes/business/src/utils/index.tsx +19 -1
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  54. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  55. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  56. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  57. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  58. package/themes/original/index.tsx +13 -1
  59. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  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 +6 -9
  65. package/themes/original/src/components/BusinessController/index.tsx +12 -7
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +13 -5
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +2 -3
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +1 -3
  69. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  70. package/themes/original/src/components/BusinessPreorder/index.tsx +20 -15
  71. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +5 -5
  72. package/themes/original/src/components/BusinessProductsList/index.tsx +2 -2
  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 -11
  81. package/themes/original/src/components/CartContent/index.tsx +21 -8
  82. package/themes/original/src/components/Checkout/index.tsx +108 -60
  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/GiftCardOrdersList/index.tsx +64 -0
  90. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  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/SingleGiftCard/index.tsx +101 -0
  96. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  97. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +82 -0
  98. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  99. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  100. package/themes/original/src/components/Help/index.tsx +2 -0
  101. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  102. package/themes/original/src/components/Home/index.tsx +2 -10
  103. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  104. package/themes/original/src/components/LoginForm/index.tsx +4 -7
  105. package/themes/original/src/components/MessageListing/index.tsx +1 -0
  106. package/themes/original/src/components/Messages/index.tsx +8 -7
  107. package/themes/original/src/components/MomentOption/index.tsx +13 -2
  108. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  109. package/themes/original/src/components/MultiCheckout/index.tsx +139 -87
  110. package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -1
  111. package/themes/original/src/components/MyOrders/index.tsx +21 -26
  112. package/themes/original/src/components/NavBar/index.tsx +4 -2
  113. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  114. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  115. package/themes/original/src/components/OrderDetails/OrderEta.tsx +1 -1
  116. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +5 -7
  117. package/themes/original/src/components/OrderDetails/index.tsx +27 -10
  118. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  119. package/themes/original/src/components/OrderProgress/index.tsx +22 -3
  120. package/themes/original/src/components/OrderSummary/index.tsx +28 -9
  121. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  122. package/themes/original/src/components/OrdersOption/index.tsx +2 -4
  123. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  124. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  125. package/themes/original/src/components/PaymentOptions/index.tsx +17 -9
  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 +55 -49
  131. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  132. package/themes/original/src/components/ProductOptionSubOption/index.tsx +8 -1
  133. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  134. package/themes/original/src/components/Promotions/index.tsx +6 -9
  135. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  136. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  137. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  138. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  139. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  140. package/themes/original/src/components/Sessions/index.tsx +3 -3
  141. package/themes/original/src/components/SignupForm/index.tsx +86 -78
  142. package/themes/original/src/components/SingleOrderCard/index.tsx +1 -2
  143. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  144. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  145. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  146. package/themes/original/src/components/StripeCardsList/index.tsx +10 -3
  147. package/themes/original/src/components/StripeElementsForm/index.tsx +77 -60
  148. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  149. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  150. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  151. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  152. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  153. package/themes/original/src/components/UserDetails/index.tsx +3 -2
  154. package/themes/original/src/components/UserFormDetails/index.tsx +155 -131
  155. package/themes/original/src/components/UserProfile/index.tsx +11 -2
  156. package/themes/original/src/components/Wallets/index.tsx +6 -3
  157. package/themes/original/src/components/WebsocketStatus/index.tsx +169 -0
  158. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  159. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  160. package/themes/original/src/components/shared/OButton.tsx +5 -4
  161. package/themes/original/src/components/shared/OInput.tsx +4 -8
  162. package/themes/original/src/types/index.tsx +5 -1
  163. package/themes/original/src/utils/index.tsx +12 -1
  164. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,267 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { StyleSheet, TouchableOpacity, View, Dimensions } from 'react-native'
3
+ import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
4
+ import FeatherIcon from 'react-native-vector-icons/Feather'
5
+ import { useTheme } from 'styled-components/native'
6
+ import ToggleSwitch from 'toggle-switch-react-native';
7
+ import { useLanguage } from 'ordering-components/native'
8
+
9
+ import { _setStoreData, _retrieveStoreData } from '../../providers/StoreUtil'
10
+ import { Container, ContainerList, EnabledAutoPrint, NoPrintersContainer } from './styles'
11
+ import { OText, OIcon, OModal, OButton } from '../shared'
12
+ import { PrinterEdition } from '../PrinterEdition'
13
+
14
+ export const PrinterSettings = (props: any) => {
15
+ const { navigation, onClose } = props
16
+
17
+ const [printers, setPrinters] = useState<any>({ list: [] })
18
+ const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
19
+ const [openModal, setOpenModal] = useState<any>({ open: false, data: null })
20
+
21
+ const WIDTH_SCREEN = Dimensions.get('window').width
22
+ const HEIGHT_SCREEN = Dimensions.get('window').height
23
+
24
+ const [, t] = useLanguage()
25
+ const theme = useTheme()
26
+
27
+ const styles = StyleSheet.create({
28
+ icons: {
29
+ maxWidth: 40,
30
+ height: 40,
31
+ padding: 10,
32
+ alignItems: 'flex-end'
33
+ },
34
+ optionIcons: {
35
+ padding: 8,
36
+ borderWidth: 1,
37
+ marginRight: 10,
38
+ borderRadius: 8,
39
+ },
40
+ wIconContainer: {
41
+ flexDirection: 'row',
42
+ alignItems: 'center',
43
+ width: WIDTH_SCREEN - 40 - 22 - 22 - 10, // screen - margin - icon - icon - marginIcon
44
+ },
45
+ wrapperContainer: {
46
+ flexDirection: 'column',
47
+ },
48
+ wrapperIcons: {
49
+ flexDirection: 'row',
50
+ justifyContent: 'flex-start',
51
+ marginBottom: 5,
52
+ },
53
+ inputStyle: {
54
+ height: 40,
55
+ borderWidth: 1,
56
+ borderRadius: 8,
57
+ },
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,
84
+ },
85
+ })
86
+
87
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
88
+
89
+ const handleClick = async ({ item, type, ip, edit, isAdd, index }: any) => {
90
+ let _item = 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)
99
+ _item = {
100
+ ..._currentPrinter,
101
+ ...item,
102
+ type: type ?? _currentPrinter?.type ?? 1,
103
+ ip: ip ?? _currentPrinter?.ip ?? '',
104
+ portName: (type ?? _currentPrinter?.type) === 1 || !ip
105
+ ? item.portName1 ?? _currentPrinter?.portName1
106
+ : `TCP:${ip}`
107
+ }
108
+ edit ? (_printers[idx] = _item) : _printers.push(_item)
109
+ }
110
+
111
+ setPrinters({ list: _printers })
112
+ await _setStoreData('printers', _printers)
113
+ type === 1 && onClose && onClose()
114
+ }
115
+
116
+ const handleAutoPrint = async () => {
117
+ setAutoPrintEnabled(!autoPrintEnabled)
118
+ await _setStoreData('auto_print_after_accept_order', !autoPrintEnabled)
119
+ }
120
+
121
+ useEffect(() => {
122
+ const getStorageData = async () => {
123
+ const printers = await _retrieveStoreData('printers')
124
+ const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
125
+ setPrinters({ list: printers ?? [] })
126
+ setAutoPrintEnabled(!!autoPrint)
127
+ }
128
+
129
+ getStorageData()
130
+ }, [])
131
+
132
+ return (
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 }}>
140
+ {t('PRINTER_SETTINGS', 'Printer Settings')}
141
+ </OText>
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 })}
172
+ />
173
+ )}
174
+ <View>
175
+ {printers.list.map((item: any, i: number) => (
176
+ <ContainerList
177
+ key={i}
178
+ activeOpacity={1}
179
+ >
180
+ <View style={styles.wrapperContainer}>
181
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
182
+ <TouchableOpacity
183
+ activeOpacity={1}
184
+ style={styles.wIconContainer}
185
+ onPress={() => setOpenModal({ open: true, data: { ...item, index: i} })}
186
+ >
187
+ <SimpleLineIcons
188
+ name='printer'
189
+ color={theme.colors.textGray}
190
+ size={18}
191
+ style={{
192
+ ...styles.icons,
193
+ color: theme.colors.primary
194
+ }}
195
+ />
196
+ <OText
197
+ size={18}
198
+ color={theme.colors.primary}
199
+ >
200
+ {item?.nickname ?? item.model}
201
+ </OText>
202
+ </TouchableOpacity>
203
+ <TouchableOpacity
204
+ activeOpacity={1}
205
+ onPress={() => setOpenModal({ open: true, data: { ...item, index: i} })}
206
+ >
207
+ <FeatherIcon
208
+ name='edit'
209
+ size={22}
210
+ />
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}
221
+ />
222
+ </TouchableOpacity>
223
+ </View>
224
+ </View>
225
+ </ContainerList>
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
+ )}
249
+ </View>
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>
266
+ )
267
+ }
@@ -0,0 +1,30 @@
1
+ import styled from "styled-components/native";
2
+
3
+ export const Container = styled.View`
4
+ margin-bottom: 50px;
5
+ `
6
+
7
+ export const ContainerList = styled.View`
8
+ flex-direction: row;
9
+ justify-content: space-between;
10
+ width: 100%;
11
+ padding: 5px 5px 5px 0;
12
+ border-bottom-width: 1px;
13
+ border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
14
+ `
15
+
16
+ export const EnabledAutoPrint = styled.View`
17
+ flex-direction: row;
18
+ justify-content: space-between;
19
+ align-items: center;
20
+ padding: 20px 0px 10px;
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,
@@ -0,0 +1,187 @@
1
+ import React, { useState } from 'react'
2
+ import { View, TouchableOpacity, Platform, StyleSheet } from 'react-native'
3
+ import { useLanguage, useSession, useUtils, Sessions as SessionsController } from 'ordering-components/native'
4
+ import { SessionsParams } from '../../types'
5
+ import { OAlert } from '../../../../../src/components/shared'
6
+ import { OButton, OIcon, OText } from '../shared'
7
+ import { useTheme } from 'styled-components/native'
8
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
9
+ import AntIcon from 'react-native-vector-icons/AntDesign'
10
+
11
+ import {
12
+ SessionsWrapper,
13
+ SessionItem,
14
+ DurationWrapper,
15
+ Container
16
+ } from './styles'
17
+
18
+ export const SessionsUI = (props: SessionsParams) => {
19
+ const {
20
+ navigation,
21
+ sessionsList,
22
+ actionState,
23
+ handleDeleteSession,
24
+ handleDeleteAllSessions
25
+ } = props
26
+
27
+ const [, t] = useLanguage()
28
+ const [{ user }] = useSession()
29
+ const [{ parseDate }] = useUtils()
30
+ const theme = useTheme()
31
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
32
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
33
+
34
+ const onDeleteSession = (session: any) => {
35
+ setConfirm({
36
+ open: true,
37
+ title: t('WEB_APPNAME', 'Ordering'),
38
+ content: [t('QUESTION_DELETE_SESSION', 'Are you sure to delete this session?')],
39
+ handleOnAccept: () => {
40
+ handleDeleteSession(session)
41
+ setConfirm({ ...confirm, open: false })
42
+ }
43
+ })
44
+ }
45
+
46
+ const onDeleteAllSessions = (isOldUser: any, deleteCurrent: any) => {
47
+ setConfirm({
48
+ open: true,
49
+ title: t('WEB_APPNAME', 'Ordering'),
50
+ content:
51
+ isOldUser
52
+ ? [t('QUESTION_ENABLE_ALL_SESSIONS', 'Are you sure to enable all sessions?')]
53
+ : deleteCurrent
54
+ ? [t('QUESTION_DELETE_ALL_SESSIONS', 'Are you sure that you want to delete all sessions?')]
55
+ : [t('QUESTION_DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Are you sure that you want to delete all sessions except current?')],
56
+ handleOnAccept: () => {
57
+ handleDeleteAllSessions(deleteCurrent)
58
+ setConfirm({ ...confirm, open: false })
59
+ }
60
+ })
61
+ }
62
+
63
+ const styles = StyleSheet.create({
64
+ titleGroups: {
65
+ alignItems: 'center',
66
+ flexDirection: 'row',
67
+ minHeight: 33,
68
+ },
69
+ btnBackArrow: {
70
+ borderWidth: 0,
71
+ width: 32,
72
+ height: 32,
73
+ tintColor: theme.colors.textGray,
74
+ backgroundColor: theme.colors.clear,
75
+ borderColor: theme.colors.clear,
76
+ shadowColor: theme.colors.clear,
77
+ paddingLeft: 0,
78
+ paddingRight: 0,
79
+ marginTop: Platform.OS === 'ios' ? 30 : 10
80
+ },
81
+ innerPadding: {
82
+ paddingLeft: 10,
83
+ paddingRight: 10
84
+ }
85
+ });
86
+
87
+ return (
88
+ <Container
89
+ pdng={Platform.OS === 'ios' ? '10px' : '8px'}
90
+ style={styles.innerPadding}
91
+ >
92
+ <View style={styles.titleGroups}>
93
+ <TouchableOpacity onPress={() => goToBack()} style={styles.btnBackArrow}>
94
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
95
+ </TouchableOpacity>
96
+ </View>
97
+ <OText size={24} style={{ paddingTop: 12 }}>
98
+ {t('SESSIONS', 'Sessions')}
99
+ </OText>
100
+ {user?.session_strategy === 'jwt_session' ? (
101
+ <>
102
+ {sessionsList.loading ? (
103
+ [...Array(5).keys()].map(i => (
104
+ <SessionItem key={i}>
105
+ <Placeholder Animation={Fade}>
106
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
107
+ <View style={{ flex: 1 }}>
108
+ <PlaceholderLine width={40} />
109
+ <PlaceholderLine width={40} />
110
+ </View>
111
+ <PlaceholderLine width={5} />
112
+ </View>
113
+ </Placeholder>
114
+ </SessionItem>
115
+ ))
116
+ ) : (
117
+ sessionsList.sessions.length > 0 ? (
118
+ <SessionsWrapper>
119
+ {sessionsList.sessions.reverse().map((session: any) => (
120
+ <SessionItem key={session.id}>
121
+ <DurationWrapper>
122
+ <OText>{parseDate(session.created_at)}</OText>
123
+ <OText>{parseDate(session.valid_thru)}</OText>
124
+ </DurationWrapper>
125
+ {session.current && (
126
+ <OText mLeft={15} style={{ flex: 1 }}>({t('CURRENT', 'Current')})</OText>
127
+ )}
128
+ <TouchableOpacity
129
+ onPress={() => onDeleteSession(session)}
130
+ >
131
+ <AntIcon name='close' size={16} color={theme.colors.red} />
132
+ </TouchableOpacity>
133
+ </SessionItem>
134
+ ))}
135
+ <OButton
136
+ text={t('DELETE_ALL_SESSIONS', 'Delete all sessions')}
137
+ isDisabled={actionState.loading}
138
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
139
+ onClick={() => onDeleteAllSessions(false, true)}
140
+ style={{ borderRadius: 7.6, marginTop: 30 }}
141
+ />
142
+ <OButton
143
+ text={t('DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Delete all sessions except current')}
144
+ isDisabled={actionState.loading}
145
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
146
+ onClick={() => onDeleteAllSessions(false, false)}
147
+ style={{ borderRadius: 7.6, marginTop: 20 }}
148
+ />
149
+ </SessionsWrapper>
150
+ ) : (
151
+ <OText>{t('YOU_DONT_HAVE_ANY_SESSIONS', 'You don\'t have any sessions')}</OText>
152
+ )
153
+ )}
154
+ </>
155
+ ) : (
156
+ <View>
157
+ <OText>
158
+ {t('YOU_DONT_HAVE_ENABLED_THE_SESSIONS', 'You don\'t have enabled the sessions, please active them to have a better control of your sessions.')}
159
+ </OText>
160
+ <OButton
161
+ text={t('ACTIVE_SESSIONS', 'Active sessions')}
162
+ isDisabled={actionState.loading}
163
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
164
+ onClick={() => onDeleteAllSessions(true, false)}
165
+ style={{ borderRadius: 7.6, marginTop: 20 }}
166
+ />
167
+ </View>
168
+ )}
169
+ <OAlert
170
+ open={confirm.open}
171
+ title={confirm.title}
172
+ content={confirm.content}
173
+ onAccept={confirm.handleOnAccept}
174
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
175
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
176
+ />
177
+ </Container>
178
+ )
179
+ }
180
+
181
+ export const Sessions = (props: SessionsParams) => {
182
+ const sessionsProps = {
183
+ ...props,
184
+ UIComponent: SessionsUI
185
+ }
186
+ return <SessionsController {...sessionsProps} />
187
+ }
@@ -0,0 +1,20 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const SessionsWrapper = styled.View`
4
+ `
5
+ export const SessionItem = styled.View`
6
+ flex-direction: row;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ padding-vertical: 15px;
10
+ border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
11
+ border-bottom-width: 1px;
12
+ `
13
+ export const DurationWrapper = styled.View`
14
+ /* flex-direction: row; */
15
+ `
16
+
17
+ export const Container = styled.View`
18
+ padding-top: ${(props: any) => props.pdng};
19
+ margin-bottom: 50px;
20
+ `
@@ -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}>