ordering-ui-react-native 0.21.46 → 0.21.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.21.46",
3
+ "version": "0.21.47",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -76,6 +76,7 @@
76
76
  "react-native-color-matrix-image-filters": "^5.2.10",
77
77
  "react-native-country-picker-modal": "^2.0.0",
78
78
  "react-native-credit-card-input": "^0.4.1",
79
+ "react-native-date-picker": "^4.2.13",
79
80
  "react-native-device-info": "^8.7.1",
80
81
  "react-native-document-picker": "^5.2.0",
81
82
  "react-native-elements": "^3.0.0-alpha.1",
@@ -515,7 +515,10 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
515
515
  <View
516
516
  style={{
517
517
  ...styles.bottomParent,
518
- marginBottom: (keyboardState.height === 0) ? isPage ? 0 : 30 : keyboardState.height - (isPage ? 20 : -10)
518
+ marginBottom: Platform.OS === 'ios'
519
+ ? 30 : (keyboardState.height === 0)
520
+ ? isPage ? 0 : 30
521
+ : keyboardState.height - (isPage ? 20 : -10)
519
522
  }}
520
523
  >
521
524
  <OButton
@@ -99,6 +99,7 @@ import { Promotions } from './src/components/Promotions'
99
99
  import { PageBanner } from './src/components/PageBanner'
100
100
  import { MultiCart } from './src/components/MultiCart'
101
101
  import { USER_TYPE, ORDER_TYPES } from './src/config/constants'
102
+ import { DatePickerUI } from './src/components/DatePicker'
102
103
 
103
104
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from './src/components/OrderSummary/styles';
104
105
 
@@ -263,7 +264,7 @@ export {
263
264
  Promotions,
264
265
  PageBanner,
265
266
  MyOrders,
266
- MultiCart,
267
+ MultiCart,
267
268
  ORDER_TYPES,
268
269
  USER_TYPE,
269
270
 
@@ -340,5 +341,8 @@ export {
340
341
  _retrieveStoreData,
341
342
  _setStoreData,
342
343
  _removeStoreData,
343
- _clearStoreData
344
+ _clearStoreData,
345
+
346
+ // Date Picker
347
+ DatePickerUI
344
348
  }
@@ -570,7 +570,9 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
570
570
  />
571
571
  </ProfessionalFilterWrapper>
572
572
  )}
573
- <PageBanner position='app_business_page' navigation={navigation} />
573
+ {businessState?.business?.id && (
574
+ <PageBanner position='app_business_page' businessId={businessState?.business?.id} navigation={navigation} />
575
+ )}
574
576
  <View
575
577
  style={{
576
578
  height: 8,
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import DatePicker from 'react-native-date-picker'
3
+ import { DateContainer } from './styles';
4
+
5
+ export const DatePickerUI = (props: any) => {
6
+ const {
7
+ birthdate,
8
+ handleChangeDate
9
+ } = props;
10
+
11
+ return (
12
+ <DateContainer>
13
+ <DatePicker mode="date" date={birthdate ? new Date(birthdate) : new Date()} onDateChange={handleChangeDate} />
14
+ </DateContainer>
15
+ );
16
+ };
17
+
@@ -0,0 +1,20 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const DateContainer = styled.View`
4
+ display: flex;
5
+ align-items: center;
6
+ margin-bottom: 20px;
7
+
8
+ input {
9
+ border-radius: 20px;
10
+ width: 140px;
11
+ outline: none;
12
+ padding: 10px 15px;
13
+ border: 1px solid #E9ECEF;
14
+ }
15
+
16
+ .react-datepicker__triangle {
17
+ transform: translate(40px, 0px) !important;
18
+ }
19
+
20
+ `
@@ -13,6 +13,8 @@ import { OAlert } from '../../../../../src/components/shared'
13
13
  import { PhoneInputNumber } from '../PhoneInputNumber';
14
14
  import { sortInputFields } from '../../utils';
15
15
  import { ListItem } from '../UserProfile/styles';
16
+ import moment from 'moment';
17
+ import { DatePickerUI } from '../DatePicker';
16
18
 
17
19
  export const UserFormDetailsUI = (props: any) => {
18
20
  const {
@@ -81,6 +83,8 @@ export const UserFormDetailsUI = (props: any) => {
81
83
  const [isValid, setIsValid] = useState(false)
82
84
  const [isChanged, setIsChanged] = useState(false)
83
85
  const [isModalOpen, setIsModalOpen] = useState(false)
86
+ const [birthdate, setBirthdate] = useState(user?.birthdate ?? null)
87
+ const [showDatePicker, setShowDatePicker] = useState(false)
84
88
  const [phoneInputData, setPhoneInputData] = useState({
85
89
  error: '',
86
90
  phone: {
@@ -92,6 +96,7 @@ export const UserFormDetailsUI = (props: any) => {
92
96
 
93
97
  const isAdmin = user?.level === 0
94
98
  const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
99
+ const showInputBirthday = validationFields?.fields?.checkout?.birthdate?.enabled ?? false
95
100
 
96
101
  const handleSuccessSignup = (user: any) => {
97
102
  login({
@@ -206,6 +211,13 @@ export const UserFormDetailsUI = (props: any) => {
206
211
  handleChangeInput(countryCode, true);
207
212
  }
208
213
 
214
+ const _handleChangeDate = (date: any) => {
215
+ setBirthdate(date)
216
+ const _birthdate = moment(date).format('YYYY-MM-DD')
217
+ handleChangeInput({ target: { name: 'birthdate', value: _birthdate } })
218
+ setShowDatePicker(false)
219
+ }
220
+
209
221
  const onRemoveAccount = () => {
210
222
  setConfirm({
211
223
  open: true,
@@ -268,6 +280,14 @@ export const UserFormDetailsUI = (props: any) => {
268
280
  }
269
281
  }, [phoneInputData, configs?.verification_phone_required?.value, isChanged])
270
282
 
283
+ useEffect(() => {
284
+ if (!validationFields.loading && birthdate) {
285
+ setValue('birthdate', formState?.result?.result
286
+ ? formState?.result?.result?.birthdate
287
+ : formState?.changes?.birthdate ?? (user && user?.birthdate) ?? '')
288
+ }
289
+ }, [validationFields, birthdate])
290
+
271
291
  useEffect(() => {
272
292
  if (!requiredFields || formState?.changes?.length === 0) return
273
293
  const _isValid = requiredFields.every((key: any) => formState?.changes[key])
@@ -359,7 +379,21 @@ export const UserFormDetailsUI = (props: any) => {
359
379
  </React.Fragment>
360
380
  ),
361
381
  )}
362
-
382
+ {showInputBirthday && (
383
+ <WrapperPhone>
384
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
385
+ {t('BIRTHDATE', 'Birthdate')}
386
+ </OText>
387
+ <TouchableOpacity onPress={() => setShowDatePicker(!showDatePicker)}>
388
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ alignSelf: 'flex-start' }}>
389
+ {birthdate ? moment(birthdate).format('YYYY-MM-DD') : ''}
390
+ </OText>
391
+ </TouchableOpacity>
392
+ {showDatePicker && (
393
+ <DatePickerUI birthdate={birthdate} handleChangeDate={_handleChangeDate} />
394
+ )}
395
+ </WrapperPhone>
396
+ )}
363
397
  {!!showInputPhoneNumber && ((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
364
398
  <WrapperPhone>
365
399
  <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>