ordering-ui-react-native 0.22.67-release → 0.22.68-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.
@@ -1,3 +1,4 @@
1
+
1
2
  import React, { useState, useEffect } from 'react'
2
3
  import { View } from 'react-native'
3
4
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
@@ -45,7 +46,7 @@ const PaymentOptionWalletUI = (props: any) => {
45
46
  new Array(walletsState.result?.length).fill(false)
46
47
  );
47
48
 
48
- const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate)}`
49
+ const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate, { isTruncable: true })}`
49
50
 
50
51
  const walletName: any = {
51
52
  cash: {
@@ -87,65 +88,65 @@ const PaymentOptionWalletUI = (props: any) => {
87
88
  {!walletsState.loading &&
88
89
  !walletsState.error &&
89
90
  walletsState.result?.length > 0 &&
90
- (
91
- <>
92
- {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
- <Container
94
- key={wallet.id}
95
- isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
- onPress={() => handleOnChange(idx, wallet)}
97
- disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
- >
99
- <SectionLeft>
100
- {checkedState[idx] ? (
101
- <MaterialCommunityIcons
102
- name="checkbox-marked"
103
- size={25}
104
- color={theme.colors.primary}
105
- />
106
- ) : (
107
- <MaterialCommunityIcons
108
- name="checkbox-blank-outline"
109
- size={25}
110
- color={theme.colors.disabled}
111
- />
112
- )}
113
- <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
- <View>
115
- <OText
116
- style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ?{
117
- color: theme.colors.disabled
118
- } : {}}
119
- >
120
- {walletName[wallet.type]?.name}
121
- </OText>
91
+ (
92
+ <>
93
+ {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
94
+ <Container
95
+ key={wallet.id}
96
+ isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
97
+ onPress={() => handleOnChange(idx, wallet)}
98
+ disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
99
+ >
100
+ <SectionLeft>
101
+ {checkedState[idx] ? (
102
+ <MaterialCommunityIcons
103
+ name="checkbox-marked"
104
+ size={25}
105
+ color={theme.colors.primary}
106
+ />
107
+ ) : (
108
+ <MaterialCommunityIcons
109
+ name="checkbox-blank-outline"
110
+ size={25}
111
+ color={theme.colors.disabled}
112
+ />
113
+ )}
114
+ <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
115
+ <View>
116
+ <OText
117
+ style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ? {
118
+ color: theme.colors.disabled
119
+ } : {}}
120
+ >
121
+ {walletName[wallet.type]?.name}
122
+ </OText>
123
+ </View>
122
124
  </View>
123
- </View>
124
- </SectionLeft>
125
-
126
- <View style={{maxWidth: '35%', alignItems: 'flex-end' }}>
127
- {wallet.type === 'cash' && (
128
- <OText>
129
- {parsePrice(wallet?.balance)}
130
- </OText>
131
- )}
132
- {wallet.type === 'credit_point' && (
133
- <OText>
134
- <OText color={theme.colors.primary} weight='bold'>
135
- {`${wallet?.balance} ${t('POINTS', 'Points')}`}
125
+ </SectionLeft>
126
+
127
+ <View style={{ maxWidth: '35%', alignItems: 'flex-end' }}>
128
+ {wallet.type === 'cash' && (
129
+ <OText>
130
+ {parsePrice(wallet?.balance, { isTruncable: true })}
136
131
  </OText>
132
+ )}
133
+ {wallet.type === 'credit_point' && (
137
134
  <OText>
138
- {wallet?.balance > 0
139
- ? creditBalance(wallet)
140
- : null}
135
+ <OText color={theme.colors.primary} weight='bold'>
136
+ {`${wallet?.balance} ${t('POINTS', 'Points')}`}
137
+ </OText>
138
+ <OText>
139
+ {wallet?.balance > 0
140
+ ? creditBalance(wallet)
141
+ : null}
142
+ </OText>
141
143
  </OText>
142
- </OText>
143
- )}
144
- </View>
145
- </Container>
146
- ))}
147
- </>
148
- )}
144
+ )}
145
+ </View>
146
+ </Container>
147
+ ))}
148
+ </>
149
+ )}
149
150
 
150
151
  {walletsState?.loading && (
151
152
  <View>
@@ -143,7 +143,7 @@ const ServiceFormUI = (props: ServiceFormParams) => {
143
143
  const valid = busyTimes.some(item => {
144
144
  return (moment.utc(item?.start).local().valueOf() <= moment(selectedMoment).valueOf() &&
145
145
  moment(selectedMoment).valueOf() < moment.utc(item?.end).local().valueOf()) ||
146
- (moment.utc(item?.start).local().valueOf() < moment(selectedMoment).add(duration, 'minutes').valueOf() &&
146
+ (moment.utc(item?.start).local().valueOf() < moment(selectedMoment).valueOf() &&
147
147
  moment(selectedMoment).add(duration, 'minutes').valueOf() < moment.utc(item?.end).local().valueOf())
148
148
  })
149
149
  return valid
@@ -177,7 +177,7 @@ export const VerifyPhone = (props: any) => {
177
177
  size={16}
178
178
  color={theme.colors.error}
179
179
  >
180
- {`* ${t(getTraduction(e))}`}
180
+ {`* ${t(getTraduction(e, t))}`}
181
181
  </OText>
182
182
  ))}
183
183
  </ErrorSection>
@@ -3,7 +3,7 @@ import { ImageSourcePropType, ImageStyle, ViewStyle, TextInputProps, TextStyle }
3
3
  import styled from 'styled-components/native';
4
4
  import OIcon from './OIcon';
5
5
  import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
6
- import { useTheme } from 'styled-components/native';
6
+ import { useTheme, css } from 'styled-components/native';
7
7
 
8
8
  const Input = styled.TextInput`
9
9
  flex-grow: 1;
@@ -14,33 +14,33 @@ const Input = styled.TextInput`
14
14
  `;
15
15
 
16
16
  interface Props extends TextInputProps {
17
- bgColor?: string;
18
- borderColor?: string;
19
- isRequired?: boolean;
20
- requiredMsg?: string;
21
- isDisabled?: boolean;
22
- isSecured?: boolean;
23
- style?: ViewStyle;
24
- placeholder?: string;
25
- icon?: ImageSourcePropType | string;
26
- iconRight?: ImageSourcePropType;
27
- iconColor?: string;
28
- iconRightColor?: string;
29
- iconStyle?: ImageStyle;
30
- iconRightStyle?: ImageStyle;
31
- iconCustomRight?: any;
32
- value?: string;
33
- onChange?: any;
34
- name?: string;
35
- type?: string;
36
- multiline?: boolean;
37
- vertorIcon?: string;
38
- vectorIconColor?: string;
39
- forwardRef?: any;
40
- inputStyle?: TextStyle;
41
- wrapperRef?: any;
42
- onPress?: any;
43
- isFocusHighlight?: boolean
17
+ bgColor?: string;
18
+ borderColor?: string;
19
+ isRequired?: boolean;
20
+ requiredMsg?: string;
21
+ isDisabled?: boolean;
22
+ isSecured?: boolean;
23
+ style?: ViewStyle;
24
+ placeholder?: string;
25
+ icon?: ImageSourcePropType | string;
26
+ iconRight?: ImageSourcePropType;
27
+ iconColor?: string;
28
+ iconRightColor?: string;
29
+ iconStyle?: ImageStyle;
30
+ iconRightStyle?: ImageStyle;
31
+ iconCustomRight?: any;
32
+ value?: string;
33
+ onChange?: any;
34
+ name?: string;
35
+ type?: string;
36
+ multiline?: boolean;
37
+ vertorIcon?: string;
38
+ vectorIconColor?: string;
39
+ forwardRef?: any;
40
+ inputStyle?: TextStyle;
41
+ wrapperRef?: any;
42
+ onPress?: any;
43
+ isFocusHighlight?: boolean
44
44
  }
45
45
 
46
46
  const Wrapper = styled.Pressable`
@@ -53,81 +53,85 @@ const Wrapper = styled.Pressable`
53
53
  align-items: center;
54
54
  justify-content: center;
55
55
  width: 100%;
56
+ ${(props: any) => props?.borderRadius && css`
57
+ border-radius: ${typeof props?.borderRadius === 'string' ? props?.borderRadius : `${props?.borderRadius}px`};
58
+ `}
56
59
  `;
57
60
 
58
61
  const OInput = (props: Props): React.ReactElement => {
59
- const theme = useTheme();
60
- const [inputFocused, setInputFocused] = React.useState(false)
61
- return (
62
- <Wrapper
63
- onPress={() => { props.forwardRef?.current?.focus?.(); props.onPress && props.onPress() }}
64
- style={{
65
- backgroundColor: props.bgColor,
66
- borderColor: !props.isFocusHighlight
67
- ? props.borderColor
68
- : inputFocused ? theme.colors.primary : theme.colors.border,
69
- ...props.style,
70
- }}>
71
- {props.icon ? (
72
- <OIcon
73
- src={props.icon}
74
- color={props.iconColor}
75
- width={16}
76
- height={20}
77
- style={{ marginRight: 10, ...props.iconStyle }}
78
- />
79
- ) : null}
80
- {props.vertorIcon && (
81
- <MaterialIcon name={props?.vertorIcon} size={20} color={props?.vectorIconColor} style={{ marginHorizontal: 10 }} />
82
- )}
83
- <Input
84
- autoFocus={props?.autoFocus}
85
- name={props.name}
86
- secureTextEntry={props.isSecured}
87
- onChangeText={(txt: any) => props.name ? props.onChange({ target: { name: props.name, value: txt } }) : props.onChange(txt)}
88
- defaultValue={props.value}
89
- placeholder={props.placeholder ? props.placeholder : ''}
90
- keyboardType={props.type || 'default'}
91
- multiline={props.multiline}
92
- scrollEnabled={props.multiline}
93
- editable={!props.isDisabled}
94
- autoCapitalize={props.autoCapitalize}
95
- autoCompleteType={props.autoCompleteType}
96
- autoCorrect={props.autoCorrect}
97
- returnKeyType={props.returnKeyType}
98
- onSubmitEditing={props.onSubmitEditing}
99
- blurOnSubmit={props.blurOnSubmit}
100
- ref={(e: any) => {
101
- props.forwardRef && (props.forwardRef.current = e)
102
- }}
103
- style={{
62
+ const theme = useTheme();
63
+ const [inputFocused, setInputFocused] = React.useState(false)
64
+ return (
65
+ <Wrapper
66
+ onPress={() => { props.forwardRef?.current?.focus?.(); props.onPress && props.onPress() }}
67
+ style={{
68
+ backgroundColor: props.bgColor,
69
+ borderColor: !props.isFocusHighlight
70
+ ? props.borderColor
71
+ : inputFocused ? theme.colors.primary : theme.colors.border,
72
+ ...props.style,
73
+ borderRadius: parseInt(theme?.general?.components?.inputs?.borderRadius) || props.style?.borderRadius
74
+ }}>
75
+ {props.icon ? (
76
+ <OIcon
77
+ src={props.icon}
78
+ color={props.iconColor}
79
+ width={16}
80
+ height={20}
81
+ style={{ marginRight: 10, ...props.iconStyle }}
82
+ />
83
+ ) : null}
84
+ {props.vertorIcon && (
85
+ <MaterialIcon name={props?.vertorIcon} size={20} color={props?.vectorIconColor} style={{ marginHorizontal: 10 }} />
86
+ )}
87
+ <Input
88
+ autoFocus={props?.autoFocus}
89
+ name={props.name}
90
+ secureTextEntry={props.isSecured}
91
+ onChangeText={(txt: any) => props.name ? props.onChange({ target: { name: props.name, value: txt } }) : props.onChange(txt)}
92
+ defaultValue={props.value}
93
+ placeholder={props.placeholder ? props.placeholder : ''}
94
+ keyboardType={props.type || 'default'}
95
+ multiline={props.multiline}
96
+ scrollEnabled={props.multiline}
97
+ editable={!props.isDisabled}
98
+ autoCapitalize={props.autoCapitalize}
99
+ autoCompleteType={props.autoCompleteType}
100
+ autoCorrect={props.autoCorrect}
101
+ returnKeyType={props.returnKeyType}
102
+ onSubmitEditing={props.onSubmitEditing}
103
+ blurOnSubmit={props.blurOnSubmit}
104
+ ref={(e: any) => {
105
+ props.forwardRef && (props.forwardRef.current = e)
106
+ }}
107
+ style={{
104
108
  ...(theme?.general?.components?.inputs?.color && {
105
109
  color: theme?.general?.components?.inputs?.color
106
110
  }),
107
- ...props?.inputStyle
108
- }}
109
- onFocus={() => setInputFocused(true)}
110
- onBlur={() => setInputFocused(false)}
111
- />
112
- {props.iconRight && (
113
- <OIcon
114
- src={props.iconRight}
115
- color={props.iconRightColor}
116
- width={16}
117
- height={16}
118
- style={{ ...props.iconRightStyle }}
119
- />
120
- )}
121
- {props.iconCustomRight}
122
- </Wrapper>
123
- );
111
+ ...props?.inputStyle
112
+ }}
113
+ onFocus={() => setInputFocused(true)}
114
+ onBlur={() => setInputFocused(false)}
115
+ />
116
+ {props.iconRight && (
117
+ <OIcon
118
+ src={props.iconRight}
119
+ color={props.iconRightColor}
120
+ width={16}
121
+ height={16}
122
+ style={{ ...props.iconRightStyle }}
123
+ />
124
+ )}
125
+ {props.iconCustomRight}
126
+ </Wrapper>
127
+ );
124
128
  };
125
129
 
126
130
  OInput.defaultProps = {
127
- iconColor: '#959595',
128
- bgColor: 'white',
129
- borderColor: 'white',
130
- isFocusHighlight: false
131
+ iconColor: '#959595',
132
+ bgColor: 'white',
133
+ borderColor: 'white',
134
+ isFocusHighlight: false
131
135
  };
132
136
 
133
137
  export default OInput;
@@ -28,7 +28,7 @@ const Alert = (props: Props) => {
28
28
  show={open}
29
29
  showProgress={false}
30
30
  title={title}
31
- message={getTraduction(content?.[0])}
31
+ message={getTraduction(content?.[0], t)}
32
32
  closeOnTouchOutside={true}
33
33
  closeOnHardwareBackPress={false}
34
34
  showConfirmButton={true}
@@ -1,12 +1,8 @@
1
1
  import React from 'react';
2
- import { useLanguage } from 'ordering-components/native';
3
2
  import FontAwesome from 'react-native-vector-icons/FontAwesome';
4
3
  import { CODES } from 'ordering-components/native'
5
4
  import { ORDER_TYPES } from '../config/constants';
6
5
  import { useTheme } from 'styled-components/native';
7
- import ReactNativeHapticFeedback from "react-native-haptic-feedback";
8
-
9
- const [languageState, t] = useLanguage();
10
6
  const theme = useTheme()
11
7
 
12
8
  export const flatArray = (arr: any) => [].concat(...arr)
@@ -20,8 +16,7 @@ export const orderTypeList = ['delivery', 'pickup', 'eatin', 'curbside', 'drivet
20
16
  * Function to return the traduction depending of a key 't'
21
17
  * @param {string} key for traduction
22
18
  */
23
- export const getTraduction = (key: string) => {
24
- const [, t] = useLanguage()
19
+ export const getTraduction = (key: string, t: any) => {
25
20
  const keyList: any = {
26
21
  // Add the key and traduction that you need below
27
22
  ERROR_ORDER_WITHOUT_CART: 'The order was placed without a cart',
@@ -131,32 +126,34 @@ export const monthsEnum: any = {
131
126
  Dec: 'MONTHSHORT12',
132
127
  }
133
128
 
134
- export const locale = {
135
- name: languageState?.language?.code?.slice(0, 2),
136
- config: {
137
- months: [
138
- t('MONTH1', 'January'),
139
- t('MONTH2', 'February'),
140
- t('MONTH3', 'March'),
141
- t('MONTH4', 'April'),
142
- t('MONTH5', 'May'),
143
- t('MONTH6', 'June'),
144
- t('MONTH7', 'July'),
145
- t('MONTH8', 'August'),
146
- t('MONTH9', 'September'),
147
- t('MONTH10', 'October'),
148
- t('MONTH11', 'November'),
149
- t('MONTH12', 'December')
150
- ],
151
- weekdaysShort: [
152
- t('DAYSHORT7', 'Sun'),
153
- t('DAYSHORT1', 'Mon'),
154
- t('DAYSHORT2', 'Tue'),
155
- t('DAYSHORT3', 'Wed'),
156
- t('DAYSHORT4', 'Thu'),
157
- t('DAYSHORT5', 'Fri'),
158
- t('DAYSHORT6', 'Sat')
159
- ],
129
+ export const locale = (languageState: any, t: any) => {
130
+ return {
131
+ name: languageState?.language?.code?.slice(0, 2),
132
+ config: {
133
+ months: [
134
+ t('MONTH1', 'January'),
135
+ t('MONTH2', 'February'),
136
+ t('MONTH3', 'March'),
137
+ t('MONTH4', 'April'),
138
+ t('MONTH5', 'May'),
139
+ t('MONTH6', 'June'),
140
+ t('MONTH7', 'July'),
141
+ t('MONTH8', 'August'),
142
+ t('MONTH9', 'September'),
143
+ t('MONTH10', 'October'),
144
+ t('MONTH11', 'November'),
145
+ t('MONTH12', 'December')
146
+ ],
147
+ weekdaysShort: [
148
+ t('DAYSHORT7', 'Sun'),
149
+ t('DAYSHORT1', 'Mon'),
150
+ t('DAYSHORT2', 'Tue'),
151
+ t('DAYSHORT3', 'Wed'),
152
+ t('DAYSHORT4', 'Thu'),
153
+ t('DAYSHORT5', 'Fri'),
154
+ t('DAYSHORT6', 'Sat')
155
+ ],
156
+ }
160
157
  }
161
158
  };
162
159
 
@@ -366,7 +363,7 @@ export const priceList = [
366
363
  { level: '5', content: '$$$$$' }
367
364
  ]
368
365
 
369
- export const getLogisticTag = (status: any) => {
366
+ export const getLogisticTag = (status: any, t: any) => {
370
367
  const keyList: any = {
371
368
  0: t('PENDING', 'Pending'),
372
369
  1: t('IN_PROGRESS', 'In progress'),
@@ -377,7 +374,7 @@ export const getLogisticTag = (status: any) => {
377
374
  return keyList[status] ? keyList[status] : t('UNKNOWN', 'Unknown')
378
375
  }
379
376
 
380
- export const getOrderStatus = (s: string, t?: any) => {
377
+ export const getOrderStatus = (s: string, t: any) => {
381
378
  const status = parseInt(s);
382
379
  const orderStatus = [
383
380
  {
@@ -594,7 +591,7 @@ export const getOrderStatus = (s: string, t?: any) => {
594
591
  return objectStatus && objectStatus;
595
592
  }
596
593
 
597
- export const getOrderStatuPickUp = (s: any) => {
594
+ export const getOrderStatuPickUp = (s: any, t: any) => {
598
595
  const status = parseInt(s);
599
596
  const orderStatus = [
600
597
  {
@@ -744,13 +741,3 @@ export const lightenDarkenColor = (color: any) => {
744
741
  return false
745
742
  }
746
743
  }
747
-
748
- export const vibrateApp = (impact?: string) => {
749
- const options = {
750
- enableVibrateFallback: true,
751
- ignoreAndroidSystemSettings: false
752
- };
753
-
754
- ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
755
-
756
- }