ordering-ui-react-native 0.12.14 → 0.12.18

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 (105) hide show
  1. package/package.json +1 -1
  2. package/src/components/AddressList/index.tsx +3 -1
  3. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +168 -156
  4. package/themes/business/src/components/NewOrderNotification/index.tsx +14 -1
  5. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -1
  6. package/themes/business/src/components/OrdersOption/index.tsx +19 -15
  7. package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +389 -0
  8. package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +36 -0
  9. package/themes/business/src/components 2/BusinessController/index.tsx +155 -0
  10. package/themes/business/src/components 2/BusinessController/styles.tsx +19 -0
  11. package/themes/business/src/components 2/Chat/index.tsx +1152 -0
  12. package/themes/business/src/components 2/Chat/styles.tsx +12 -0
  13. package/themes/business/src/components 2/Contacts/index.tsx +299 -0
  14. package/themes/business/src/components 2/Contacts/styles.tsx +42 -0
  15. package/themes/business/src/components 2/DriverMap/index.tsx +525 -0
  16. package/themes/business/src/components 2/FloatingButton/index.tsx +141 -0
  17. package/themes/business/src/components 2/FloatingButton/styles.tsx +35 -0
  18. package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +204 -0
  19. package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +11 -0
  20. package/themes/business/src/components 2/GoogleMap/index.tsx +347 -0
  21. package/themes/business/src/components 2/Home/index.tsx +111 -0
  22. package/themes/business/src/components 2/Home/styles.tsx +27 -0
  23. package/themes/business/src/components 2/LanguageSelector/index.tsx +124 -0
  24. package/themes/business/src/components 2/LanguageSelector/lang_country.json +152 -0
  25. package/themes/business/src/components 2/LanguageSelector/styles.tsx +17 -0
  26. package/themes/business/src/components 2/LoginForm/index.tsx +663 -0
  27. package/themes/business/src/components 2/LoginForm/styles.tsx +48 -0
  28. package/themes/business/src/components 2/LogoutButton/index.tsx +63 -0
  29. package/themes/business/src/components 2/MapView/index.tsx +317 -0
  30. package/themes/business/src/components 2/MessagesOption/index.tsx +337 -0
  31. package/themes/business/src/components 2/MessagesOption/styles.tsx +27 -0
  32. package/themes/business/src/components 2/NewOrderNotification/index.tsx +167 -0
  33. package/themes/business/src/components 2/NewOrderNotification/styles.tsx +8 -0
  34. package/themes/business/src/components 2/NotFoundSource/index.tsx +52 -0
  35. package/themes/business/src/components 2/NotFoundSource/styles.tsx +17 -0
  36. package/themes/business/src/components 2/OrderDetails/Business.tsx +683 -0
  37. package/themes/business/src/components 2/OrderDetails/Delivery.tsx +454 -0
  38. package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +391 -0
  39. package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +148 -0
  40. package/themes/business/src/components 2/OrderDetails/styles.tsx +84 -0
  41. package/themes/business/src/components 2/OrderMessage/index.tsx +344 -0
  42. package/themes/business/src/components 2/OrderMessage/styles.tsx +5 -0
  43. package/themes/business/src/components 2/OrderSummary/index.tsx +700 -0
  44. package/themes/business/src/components 2/OrderSummary/styles.tsx +61 -0
  45. package/themes/business/src/components 2/OrdersOption/index.tsx +755 -0
  46. package/themes/business/src/components 2/OrdersOption/styles.tsx +54 -0
  47. package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +51 -0
  48. package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +8 -0
  49. package/themes/business/src/components 2/OrdersOptionCity/index.tsx +52 -0
  50. package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +8 -0
  51. package/themes/business/src/components 2/OrdersOptionDate/index.tsx +52 -0
  52. package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +8 -0
  53. package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +35 -0
  54. package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +8 -0
  55. package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +50 -0
  56. package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +8 -0
  57. package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +49 -0
  58. package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +8 -0
  59. package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +46 -0
  60. package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +8 -0
  61. package/themes/business/src/components 2/PhoneInputNumber/index.tsx +160 -0
  62. package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +3 -0
  63. package/themes/business/src/components 2/PreviousMessages/index.tsx +304 -0
  64. package/themes/business/src/components 2/PreviousMessages/styles.tsx +32 -0
  65. package/themes/business/src/components 2/PreviousOrders/index.tsx +180 -0
  66. package/themes/business/src/components 2/PreviousOrders/styles.tsx +38 -0
  67. package/themes/business/src/components 2/ProductItemAccordion/index.tsx +301 -0
  68. package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +61 -0
  69. package/themes/business/src/components 2/SearchBar/index.tsx +112 -0
  70. package/themes/business/src/components 2/SignupForm/index.tsx +530 -0
  71. package/themes/business/src/components 2/SignupForm/styles.tsx +16 -0
  72. package/themes/business/src/components 2/StoresList/index.tsx +208 -0
  73. package/themes/business/src/components 2/StoresList/styles.tsx +26 -0
  74. package/themes/business/src/components 2/UserFormDetails/index.tsx +513 -0
  75. package/themes/business/src/components 2/UserFormDetails/styles.tsx +40 -0
  76. package/themes/business/src/components 2/UserProfileForm/index.tsx +496 -0
  77. package/themes/business/src/components 2/UserProfileForm/styles.tsx +36 -0
  78. package/themes/business/src/components 2/VerifyPhone/index.tsx +201 -0
  79. package/themes/business/src/components 2/VerifyPhone/styles.tsx +43 -0
  80. package/themes/business/src/components 2/shared/OAlert.tsx +52 -0
  81. package/themes/business/src/components 2/shared/OButton.tsx +149 -0
  82. package/themes/business/src/components 2/shared/OChatBubble.tsx +100 -0
  83. package/themes/business/src/components 2/shared/ODropDown.tsx +195 -0
  84. package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +328 -0
  85. package/themes/business/src/components 2/shared/OFab.tsx +54 -0
  86. package/themes/business/src/components 2/shared/OIcon.tsx +67 -0
  87. package/themes/business/src/components 2/shared/OIconButton.tsx +127 -0
  88. package/themes/business/src/components 2/shared/OInput.tsx +144 -0
  89. package/themes/business/src/components 2/shared/OLink.tsx +76 -0
  90. package/themes/business/src/components 2/shared/OModal.tsx +275 -0
  91. package/themes/business/src/components 2/shared/OSegment.tsx +86 -0
  92. package/themes/business/src/components 2/shared/OText.tsx +55 -0
  93. package/themes/business/src/components 2/shared/OTextarea.tsx +46 -0
  94. package/themes/business/src/components 2/shared/OToast.tsx +92 -0
  95. package/themes/business/src/components 2/shared/index.tsx +27 -0
  96. package/themes/business/src/types/index.tsx +4 -1
  97. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +128 -83
  98. package/themes/kiosk/src/components/DrawerView/index.tsx +57 -0
  99. package/themes/kiosk/src/components/DrawerView/styles.tsx +30 -0
  100. package/themes/kiosk/src/components/LanguageSelector/index.tsx +78 -58
  101. package/themes/kiosk/src/components/OrderDetails/index.tsx +3 -1
  102. package/themes/kiosk/src/components/ProductForm/index.tsx +129 -127
  103. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  104. package/themes/original/src/components/BusinessesListing/index.tsx +9 -6
  105. package/themes/original/src/components/OrderProgress/index.tsx +32 -18
@@ -0,0 +1,389 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import {
3
+ Linking,
4
+ Keyboard,
5
+ Platform,
6
+ View,
7
+ KeyboardAvoidingView,
8
+ TextInput
9
+ } from 'react-native';
10
+ import { useTheme } from 'styled-components/native';
11
+ import { useLanguage } from 'ordering-components/native';
12
+ import { Content, Timer, TimeField, Header, Action, Comments } from './styles';
13
+ import { FloatingButton } from '../FloatingButton';
14
+ import { OText, OButton, OTextarea, OIconButton } from '../shared';
15
+ import { AcceptOrRejectOrderParams } from '../../types';
16
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
17
+
18
+ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
19
+ const {
20
+ customerCellphone,
21
+ loading,
22
+ action,
23
+ handleUpdateOrder,
24
+ actions,
25
+ closeModal,
26
+ orderId,
27
+ notShowCustomerPhone,
28
+ titleAccept,
29
+ titleReject,
30
+ appTitle,
31
+ } = props;
32
+
33
+ const [, t] = useLanguage();
34
+ const theme = useTheme();
35
+ const scrollViewRef = useRef<any>(null);
36
+ const viewRef = useRef<any>(null);
37
+ const timerRef = useRef() as React.MutableRefObject<TextInput>;
38
+ const textTareaRef = useRef<any>();
39
+ const [hour, setHour] = useState('00');
40
+ const [min, setMin] = useState('00');
41
+ const [time, setTime] = useState('');
42
+ const [comments, setComments] = useState('');
43
+ const [isKeyboardShow, setIsKeyboardShow] = useState(false);
44
+ const phoneNumber = customerCellphone;
45
+ let codeNumberPhone, numberPhone, numberToShow;
46
+ const { top, bottom} = useSafeAreaInsets()
47
+
48
+ const handleFocus = () => {
49
+ viewRef?.current?.measure((x: any, y: any) => {
50
+ scrollViewRef?.current?.scrollTo({ x: 0, y });
51
+ });
52
+ };
53
+
54
+ const handleFocusTimer = () => {
55
+ timerRef?.current?.measure((x: any, y: any) => {
56
+ scrollViewRef?.current?.scrollTo({ x: 0, y });
57
+ });
58
+ };
59
+
60
+ useEffect(() => {
61
+ const keyboardDidShowListener = Keyboard.addListener(
62
+ 'keyboardDidShow',
63
+ () => {
64
+ setIsKeyboardShow(true);
65
+ },
66
+ );
67
+ const keyboardDidHideListener = Keyboard.addListener(
68
+ 'keyboardDidHide',
69
+ () => {
70
+ setIsKeyboardShow(false);
71
+ },
72
+ );
73
+ return () => {
74
+ keyboardDidShowListener.remove();
75
+ keyboardDidHideListener.remove();
76
+ };
77
+ }, []);
78
+
79
+ if (!notShowCustomerPhone) {
80
+ if (phoneNumber) {
81
+ codeNumberPhone = phoneNumber.slice(0, 3);
82
+ numberPhone = phoneNumber.slice(3, phoneNumber?.length);
83
+ numberToShow = `(${codeNumberPhone}) ${numberPhone}`;
84
+ }
85
+ }
86
+
87
+ const handleArrowBack: any = () => {
88
+ closeModal(false);
89
+ };
90
+
91
+ const handleTime = (e: any) => {
92
+ if (
93
+ e.includes(',') ||
94
+ e.includes('.') ||
95
+ e.includes('-') ||
96
+ e.includes(' ')
97
+ )
98
+ return;
99
+
100
+ setTime(e.slice(-4));
101
+ const mins = e.slice(-2);
102
+ const hours = e.slice(-4, -2);
103
+
104
+ setMin(mins);
105
+ setHour(hours);
106
+ setTime(`${hours}${mins}`);
107
+ };
108
+
109
+ useEffect(() => {
110
+ if (actions && action === 'accept') {
111
+ openTimerIOnput();
112
+ }
113
+
114
+ if (actions && (action === 'reject' || action === 'failed')) {
115
+ openTextTareaOInput();
116
+ }
117
+ }, []);
118
+
119
+ const handleFixTime = () => {
120
+ if (min >= '60') {
121
+ setMin('59');
122
+ }
123
+
124
+ if (min.length < 2) setMin(`0${min}`);
125
+ if (hour.length < 2) setHour(`0${hour}`);
126
+
127
+ if (!hour) setHour('00');
128
+ };
129
+
130
+ const openTimerIOnput = () => {
131
+ const isFocus = timerRef.current.isFocused();
132
+ if (isFocus) {
133
+ timerRef.current.blur();
134
+ }
135
+
136
+ if (!isFocus) {
137
+ if (time.length > 1) timerRef.current.clear();
138
+ timerRef.current.focus();
139
+ handleFocusTimer();
140
+ }
141
+ };
142
+
143
+ const openTextTareaOInput = () => {
144
+ const isFocus = textTareaRef.current.isFocused();
145
+ if (isFocus && textTareaRef?.current) {
146
+ textTareaRef.current.blur();
147
+ }
148
+
149
+ if (!isFocus && textTareaRef?.current) {
150
+ textTareaRef.current.focus();
151
+ }
152
+ };
153
+
154
+ const handleAcceptOrReject = () => {
155
+ handleFixTime();
156
+
157
+ let minsToSend = min;
158
+
159
+ if (min > '60') minsToSend = '59';
160
+
161
+ const time = parseInt(hour || '0') * 60 + (parseInt(minsToSend) || 0);
162
+
163
+ let bodyToSend;
164
+ const orderStatus: any = {
165
+ acceptByBusiness: {
166
+ prepared_in: time,
167
+ status: 7,
168
+ },
169
+ rejectByBusiness: {
170
+ comment: comments,
171
+ status: 5,
172
+ },
173
+ acceptByDriver: {
174
+ delivered_in: time,
175
+ status: 8,
176
+ },
177
+ rejectByDriver: {
178
+ comment: comments,
179
+ status: 6,
180
+ },
181
+ failedByDriver: {
182
+ comment: comments,
183
+ status: 12
184
+ }
185
+ };
186
+
187
+ if (actions && action === 'accept') {
188
+ bodyToSend = orderStatus[actions.accept];
189
+ }
190
+ if (actions && action === 'reject') {
191
+ bodyToSend = orderStatus[actions.reject];
192
+ }
193
+ if(actions && action === 'failed'){
194
+ bodyToSend = orderStatus[actions.failed]
195
+ }
196
+
197
+ bodyToSend.id = orderId;
198
+
199
+ handleUpdateOrder && handleUpdateOrder(bodyToSend.status, bodyToSend);
200
+ };
201
+
202
+ return (
203
+ <KeyboardAvoidingView
204
+ enabled
205
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
206
+ style={{ flex: 1, paddingHorizontal: 30, paddingTop: 30, marginTop: top, marginBottom: bottom,justifyContent: 'space-between' }}>
207
+ <View>
208
+ <OIconButton
209
+ icon={theme.images.general.arrow_left}
210
+ borderColor={theme.colors.clear}
211
+ iconStyle={{ width: 20, height: 20 }}
212
+ style={{
213
+ maxWidth: 40,
214
+ height: 35,
215
+ justifyContent: 'flex-end',
216
+ marginBottom: 30,
217
+ }}
218
+ onClick={() => handleArrowBack()}
219
+ />
220
+ <OText
221
+ size={20}
222
+ color={theme.colors.textGray}
223
+ style={{
224
+ fontFamily: 'Poppins',
225
+ fontStyle: 'normal',
226
+ }}
227
+ weight="600">
228
+ {action === 'accept'
229
+ ? `${t(titleAccept?.key, titleAccept?.text)}:`
230
+ : t(titleReject?.key, titleReject?.text)}
231
+ </OText>
232
+ </View>
233
+ <Content showsVerticalScrollIndicator={false} ref={scrollViewRef}>
234
+ <Header>
235
+ {action === 'reject' && (
236
+ <>
237
+ {!notShowCustomerPhone && (
238
+ <>
239
+ <OText
240
+ size={15}
241
+ color={theme.colors.textGray}
242
+ style={{ marginTop: 10 }}>
243
+ {t(
244
+ 'CALL_YOUR_CUSTOMER_TO_RESOLVE_THE_ISSUE_AS_POLITELY_AS_POSSIBLE',
245
+ 'Call your customer to resolve the issue as politely as possible',
246
+ )}
247
+ </OText>
248
+
249
+ {numberToShow ? (
250
+ <OButton
251
+ bgColor="transparent"
252
+ borderColor={theme.colors.primary}
253
+ textStyle={{
254
+ color: theme.colors.primary,
255
+ fontSize: 20,
256
+ }}
257
+ style={{
258
+ borderRadius: 10,
259
+ marginVertical: 20,
260
+ }}
261
+ imgLeftStyle={{
262
+ resizeMode: 'contain',
263
+ left: 20,
264
+ position: 'absolute',
265
+ }}
266
+ imgLeftSrc={theme.images.general.cellphone}
267
+ text={numberToShow}
268
+ onClick={() =>
269
+ Linking.openURL(`tel:${customerCellphone}`)
270
+ }
271
+ />
272
+ ) : (
273
+ <OButton
274
+ bgColor="transparent"
275
+ borderColor={theme.colors.primary}
276
+ textStyle={{
277
+ color: theme.colors.primary,
278
+ fontSize: 15,
279
+ }}
280
+ style={{
281
+ borderRadius: 10,
282
+ marginVertical: 20,
283
+ }}
284
+ imgLeftStyle={{
285
+ resizeMode: 'contain',
286
+ left: 20,
287
+ position: 'absolute',
288
+ }}
289
+ isDisabled={true}
290
+ imgLeftSrc={theme.images.general.cellphone}
291
+ text={t('NOT_NUMBER', "There's not phonenumber.")}
292
+ onClick={() =>
293
+ Linking.openURL(`tel:${customerCellphone}`)
294
+ }
295
+ />
296
+ )}
297
+ </>
298
+ )}
299
+
300
+ <OText
301
+ size={15}
302
+ color={theme.colors.textGray}
303
+ style={{ marginBottom: 10 }}>
304
+ {t(
305
+ 'MARK_THE_ORDER_AS_REJECTED',
306
+ 'Mark the order as rejected',
307
+ )}
308
+ </OText>
309
+
310
+ <OText>
311
+ <OText style={{ fontWeight: '600' }}>
312
+ {t('NOTE', 'Note')}
313
+ {': '}
314
+ </OText>
315
+
316
+ <OText size={15} color={theme.colors.textGray}>
317
+ {t(
318
+ 'YOUR_CUSTOMER_WILL_RECEIVE_A_NOTIFICATION_ABOUT_THIS_ACTIONS',
319
+ 'Your customer will receive a notification about this actions',
320
+ )}
321
+ </OText>
322
+ </OText>
323
+ </>
324
+ )}
325
+ </Header>
326
+
327
+ {action === 'accept' && (
328
+ <View style={{ height: 400, justifyContent: 'center' }}>
329
+ <Timer onPress={() => openTimerIOnput()}>
330
+ <OText weight="600" style={{ textAlign: 'center' }} size={55}>
331
+ {hour}
332
+ </OText>
333
+ {hour.length > 0 && <OText size={55}>:</OText>}
334
+ <OText weight="600" style={{ textAlign: 'center' }} size={55}>
335
+ {min}
336
+ </OText>
337
+ </Timer>
338
+ </View>
339
+ )}
340
+ <TimeField
341
+ ref={timerRef}
342
+ keyboardType="numeric"
343
+ value={time}
344
+ placeholder={'00:00'}
345
+ onChangeText={handleTime}
346
+ onPressOut={() => handleFixTime()}
347
+ editable={true}
348
+ autoFocus={actions && action === 'accept'}
349
+ selectionColor={theme.colors.primary}
350
+ placeholderTextColor={theme.colors.textGray}
351
+ color={theme.colors.textGray}
352
+ onEndEditing={handleFixTime}
353
+ />
354
+
355
+ {(action === 'reject' || action === 'failed') && (
356
+ <Comments ref={viewRef}>
357
+ <OTextarea
358
+ textTareaRef={textTareaRef}
359
+ autoFocus={actions && (action === 'reject' || action === 'failed')}
360
+ onFocus={handleFocus}
361
+ placeholder={t(
362
+ 'PLEASE_TYPE_YOUR_COMMENTS_IN_HERE',
363
+ 'Please type your comments in here',
364
+ )}
365
+ value={comments}
366
+ onChange={setComments}
367
+ />
368
+ <View style={{ height: 20 }} />
369
+ </Comments>
370
+ )}
371
+ </Content>
372
+
373
+ <Action>
374
+ <FloatingButton
375
+ firstButtonClick={() => {
376
+ handleAcceptOrReject();
377
+ }}
378
+ btnText={
379
+ action === 'accept'
380
+ ? t('ACCEPT', 'Accept')
381
+ : t('REJECT', 'Reject')
382
+ }
383
+ color={action === 'accept' ? theme.colors.green : theme.colors.red}
384
+ widthButton={'100%'}
385
+ />
386
+ </Action>
387
+ </KeyboardAvoidingView>
388
+ );
389
+ };
@@ -0,0 +1,36 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const Content = styled.ScrollView`
4
+ background-color: ${(props: any) => props.theme.colors.white};
5
+ margin-bottom: 30px;
6
+ `;
7
+
8
+ export const Timer = styled.TouchableOpacity`
9
+ padding: 40px;
10
+ justify-content: center;
11
+ flex-direction: row;
12
+ align-items: center;
13
+ width: 245px;
14
+ height: 245px;
15
+ background-color: ${(props: any) => props.theme.colors.inputChat};
16
+ border-radius: 123px;
17
+ align-self: center;
18
+ `;
19
+
20
+ export const TimeField = styled.TextInput`
21
+ font-size: 55px;
22
+ font-family: 'Poppins-Regular';
23
+ font-weight: 600;
24
+ text-align: center;
25
+ width: 0;
26
+ height: 0;
27
+ opacity: 0;
28
+ `;
29
+
30
+ export const Header = styled.View``;
31
+
32
+ export const Action = styled.View``;
33
+
34
+ export const Comments = styled.View`
35
+ margin-top: 20px;
36
+ `;
@@ -0,0 +1,155 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { StyleSheet, View, ActivityIndicator } from 'react-native';
3
+ import ToggleSwitch from 'toggle-switch-react-native';
4
+ import { useTheme } from 'styled-components/native';
5
+ import {
6
+ BusinessController as BusinessSingleCard,
7
+ useUtils,
8
+ useLanguage,
9
+ ToastType,
10
+ useToast,
11
+ } from 'ordering-components/native';
12
+ import { Card, Information, Logo } from './styles';
13
+ import { OIcon, OText } from '../shared';
14
+ import { BusinessControllerParams } from '../../types';
15
+
16
+ export const BusinessControllerUI = (props: BusinessControllerParams) => {
17
+ const { businessState, updateBusiness, isUpdateStore, setIsUpdateStore } =
18
+ props;
19
+
20
+ const { loading, business, error } = businessState;
21
+
22
+ const theme = useTheme();
23
+ const [{ optimizeImage }] = useUtils();
24
+ const [, t] = useLanguage();
25
+ const [, { showToast }] = useToast();
26
+
27
+ const [updatingBusiness, setUpdatingBusiness] = useState(false);
28
+
29
+ const handleSwitch = () => {
30
+ setUpdatingBusiness(true);
31
+ setIsUpdateStore(true);
32
+
33
+ updateBusiness &&
34
+ updateBusiness(business?.id, { enabled: !business?.enabled });
35
+ };
36
+
37
+ useEffect(() => {
38
+ if (updatingBusiness && !error) {
39
+ showToast(
40
+ ToastType.Info,
41
+ business?.enabled
42
+ ? t('ENABLED_BUSINESS', 'Enabled business')
43
+ : t('DISABLED_BUSINESS', 'Disabled business'),
44
+ );
45
+ }
46
+
47
+ if (error) {
48
+ showToast(
49
+ ToastType.Error,
50
+ t('ERROR_UPDATING_BUSINESS', 'Error updating business'),
51
+ );
52
+ }
53
+
54
+ setIsUpdateStore(false);
55
+ setUpdatingBusiness(false);
56
+ }, [business]);
57
+
58
+ const styles = StyleSheet.create({
59
+ icon: {
60
+ borderRadius: 7.6,
61
+ width: 70,
62
+ height: 70,
63
+ },
64
+ logo: {
65
+ padding: 2,
66
+ borderRadius: 18,
67
+ shadowColor: '#000',
68
+ shadowOffset: {
69
+ width: 0,
70
+ height: 1.5,
71
+ },
72
+ shadowOpacity: 0.21,
73
+ shadowRadius: 3,
74
+ elevation: 7,
75
+ },
76
+ header: {
77
+ flexDirection: 'row',
78
+ justifyContent: 'space-between',
79
+ width: '100%',
80
+ },
81
+ title: {
82
+ fontWeight: '600',
83
+ fontSize: 18,
84
+ color: theme.colors.textGray,
85
+ },
86
+ address: {
87
+ fontSize: 14,
88
+ color: theme.colors.unselectText,
89
+ },
90
+ });
91
+
92
+ return (
93
+ <>
94
+ {business && (
95
+ <Card key={business?.id}>
96
+ <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
97
+ <Logo style={styles.logo}>
98
+ <OIcon
99
+ url={optimizeImage(business?.logo, 'h_300,c_limit')}
100
+ style={styles.icon}
101
+ />
102
+ </Logo>
103
+
104
+ <View
105
+ style={{
106
+ flex: 1,
107
+ flexDirection: 'row',
108
+ alignItems: 'flex-start',
109
+ }}>
110
+ <Information>
111
+ <View style={styles.header}>
112
+ <OText style={styles.title} numberOfLines={1}>
113
+ {business?.name}
114
+ </OText>
115
+ </View>
116
+
117
+ <OText style={styles.address} numberOfLines={1}>
118
+ {business?.address}
119
+ </OText>
120
+
121
+ <OText style={styles.address} numberOfLines={1}>
122
+ {business?.zipcode}
123
+ </OText>
124
+ </Information>
125
+
126
+ {loading && isUpdateStore ? (
127
+ <ActivityIndicator size="small" color={theme.colors.primary} />
128
+ ) : (
129
+ <ToggleSwitch
130
+ isOn={business?.enabled}
131
+ onColor={theme.colors.primary}
132
+ offColor={theme.colors.offColor}
133
+ size="small"
134
+ onToggle={handleSwitch}
135
+ disabled={loading}
136
+ animationSpeed={200}
137
+ />
138
+ )}
139
+ </View>
140
+ </View>
141
+ </Card>
142
+ )}
143
+ </>
144
+ );
145
+ };
146
+
147
+ export const BusinessController = (props: BusinessControllerParams) => {
148
+ const BusinessControllerProps = {
149
+ ...props,
150
+ isDisabledInterval: true,
151
+ UIComponent: BusinessControllerUI,
152
+ };
153
+
154
+ return <BusinessSingleCard {...BusinessControllerProps} />;
155
+ };
@@ -0,0 +1,19 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const Card = styled.View`
4
+ flex: 1;
5
+ justify-content: center;
6
+ align-items: flex-start;
7
+ flex-direction: row;
8
+ margin-bottom: 30px;
9
+ min-height: 64px;
10
+ `;
11
+
12
+ export const Information = styled.View`
13
+ margin-horizontal: 10px;
14
+ flex: 1;
15
+ `;
16
+
17
+ export const Logo = styled.View`
18
+ min-height: 64px;
19
+ `;