ordering-ui-react-native 0.21.31 → 0.21.32

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.31",
3
+ "version": "0.21.32",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -386,21 +386,30 @@ const ChatUI = (props: MessagesParams) => {
386
386
  style={{ ...styles.firstMessageText, textAlign: 'center' }}
387
387
  >
388
388
  {
389
- message.change?.attribute !== 'driver_id'
390
- ?
391
- `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute)
392
- ? `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}`
393
- : `${message.change?.attribute !== 'logistic_status'
394
- ? message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])
395
- : message.change.old !== null && getLogisticTag(message.change.old)} ${t('TO', 'to')} ${message.change?.attribute !== 'logistic_status'
396
- ? t(ORDER_STATUS[parseInt(message.change.new, 10)])
397
- : getLogisticTag(message.change.new)}`
398
- }`
399
- : message.change.new
389
+ message.change?.attribute === 'driver_group_id'
390
+ ? message.change.old
391
+ ? t('ORDER_ATTRIBUTE_CHANGED_FROM_TO')
392
+ .replace('_attribute_', t(message.change?.attribute.toUpperCase()).toLowerCase())
393
+ .replace('_from_', message.change.old)
394
+ .replace('_to_', message.change.new)
395
+ : t('ORDER_ATTRIBUTE_CHANGED_TO')
396
+ .replace('_attribute_', t(message.change?.attribute.toUpperCase()).toLowerCase())
397
+ .replace('_to_', message.change.new)
398
+ : message.change?.attribute !== 'driver_id'
400
399
  ?
401
- `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
402
- :
403
- `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
400
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute)
401
+ ? `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}`
402
+ : `${message.change?.attribute !== 'logistic_status'
403
+ ? message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])
404
+ : message.change.old !== null && getLogisticTag(message.change.old)} ${t('TO', 'to')} ${message.change?.attribute !== 'logistic_status'
405
+ ? t(ORDER_STATUS[parseInt(message.change.new, 10)])
406
+ : getLogisticTag(message.change.new)}`
407
+ }`
408
+ : message.change.new
409
+ ?
410
+ `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
411
+ :
412
+ `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
404
413
  }
405
414
  </OText>
406
415
  <OText size={10} color={'#aaa'} style={{ alignSelf: 'flex-start' }}>
@@ -106,6 +106,7 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
106
106
  location={businessLocation.location}
107
107
  markerTitle={businessState?.business?.name}
108
108
  businessZones={businessState?.business?.zones}
109
+ delta={30}
109
110
  />
110
111
  </WrapBusinessMap>
111
112
  )}
@@ -192,6 +192,7 @@ const CheckoutUI = (props: any) => {
192
192
  }, cart?.subtotal)
193
193
 
194
194
  const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
195
+ const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled && validationFields?.fields?.card?.zipcode?.required && !paymethodSelected?.data?.card?.zipcode
195
196
 
196
197
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
197
198
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
@@ -200,7 +201,8 @@ const CheckoutUI = (props: any) => {
200
201
  validationFields?.fields?.checkout?.driver_tip?.enabled &&
201
202
  validationFields?.fields?.checkout?.driver_tip?.required &&
202
203
  (Number(cart?.driver_tip) <= 0)) ||
203
- (validateCommentsCartField)
204
+ (validateCommentsCartField) ||
205
+ (validateZipcodeCard)
204
206
  || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
205
207
 
206
208
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
@@ -896,6 +898,15 @@ const CheckoutUI = (props: any) => {
896
898
  {t('WARNING_INVALID_CART_COMMENTS', 'Cart comments is required.')}
897
899
  </OText>
898
900
  )}
901
+
902
+ {validateZipcodeCard && (
903
+ <OText
904
+ color={theme.colors.error}
905
+ size={12}
906
+ >
907
+ {t('WARNING_CARD_ZIPCODE_REQUIRED', 'Your card selected has not zipcode')}
908
+ </OText>
909
+ )}
899
910
  </ChErrors>
900
911
  </View>
901
912
  )}
@@ -20,7 +20,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
20
20
  handleToggleMap,
21
21
  locations,
22
22
  isIntGeoCoder,
23
- businessZones
23
+ businessZones,
24
+ delta
24
25
  } = props
25
26
 
26
27
  const [, t] = useLanguage()
@@ -31,8 +32,8 @@ export const GoogleMap = (props: GoogleMapsParams) => {
31
32
  const [region, setRegion] = useState({
32
33
  latitude: location.lat,
33
34
  longitude: location.lng,
34
- latitudeDelta: 0.0010,
35
- longitudeDelta: 0.0010 * ASPECT_RATIO
35
+ latitudeDelta: delta ?? 0.0010,
36
+ longitudeDelta: (delta ?? 0.0010) * ASPECT_RATIO
36
37
  })
37
38
  const [MARKERS, SETMARKERS] = useState(locations)
38
39
  let mapRef = useRef<any>(null)
@@ -265,7 +266,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
265
266
  )}
266
267
  {(businessZone.type === 5 && businessZone?.data?.distance) && (
267
268
  <Circle
268
- center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng}}
269
+ center={{ latitude: center.lat, longitude: center.lng}}
269
270
  radius={businessZone?.data.distance * units[businessZone?.data?.unit]}
270
271
  fillColor={fillStyles.fillColor}
271
272
  strokeColor={fillStyles.strokeColor}
@@ -152,6 +152,7 @@ const MessagesUI = (props: MessagesParams) => {
152
152
  }
153
153
  const newMessage: any = [];
154
154
  messages.messages.map((message: any) => {
155
+ if (message.change?.attribute === 'driver_group_id') return
155
156
  if (business && message.type !== 0 && (messagesToShow?.messages?.length || message?.can_see?.includes('2'))) {
156
157
  newMessage.push({
157
158
  _id: message?.id,
@@ -40,6 +40,9 @@ export const OSItem = styled.View`
40
40
  justify-content: space-between;
41
41
  align-items: center;
42
42
  padding: 10px 0px;
43
+ ${({ isInvalid } : any) => isInvalid && css`
44
+ opacity: 0.7;
45
+ `}
43
46
  `;
44
47
 
45
48
  export const OSItemContent = styled.TouchableOpacity`
@@ -4,6 +4,7 @@ import {
4
4
  PaymentOptionStripe,
5
5
  useSession,
6
6
  useLanguage,
7
+ useValidationFields
7
8
  } from 'ordering-components/native';
8
9
  import { PlaceholderLine } from 'rn-placeholder';
9
10
  import { useTheme } from 'styled-components/native';
@@ -40,10 +41,13 @@ export const StripeCardsListUI = (props: any) => {
40
41
 
41
42
  const [{ token }] = useSession();
42
43
  const [, t] = useLanguage();
43
-
44
+ const [validationFields] = useValidationFields()
45
+ const validateZipcodeCard =
46
+ validationFields?.fields?.card?.zipcode?.enabled && validationFields?.fields?.card?.zipcode?.required
44
47
  const paymethodsWithoutSaveCards = ['credomatic']
45
48
 
46
49
  const handleCardSelected = (card: any) => {
50
+ if (!card?.zipcode && validateZipcodeCard) return
47
51
  handleCardClick(card);
48
52
  onSelectCard(card);
49
53
  }
@@ -92,7 +96,8 @@ export const StripeCardsListUI = (props: any) => {
92
96
  style={styles.cardsList}
93
97
  >
94
98
  {cardsList.cards.map((card: any) => (
95
- <OSItem key={card.id} isUnique={cardsList.cards.length}>
99
+ <OSItem key={card.id} isUnique={cardsList.cards.length} isInvalid={!card?.zipcode && validateZipcodeCard}>
100
+ {console.log(card?.zipcode && validateZipcodeCard)}
96
101
  <OSItemContent onPress={() => handleCardSelected(card)}>
97
102
  <View style={styles.viewStyle}>
98
103
  {card.id === cardSelected?.id ? (
@@ -117,6 +122,13 @@ export const StripeCardsListUI = (props: any) => {
117
122
  XXXX-XXXX-XXXX-{card.last4}
118
123
  </OText>
119
124
  </View>
125
+ {!card?.zipcode && validateZipcodeCard && (
126
+ <View style={styles.viewStyle}>
127
+ <OText size={10} color={theme?.colors?.danger5}>
128
+ ({t('MISSING_ZIPCODE', 'Missing zipcode')})
129
+ </OText>
130
+ </View>
131
+ )}
120
132
  </OSItemContent>
121
133
  <OSItemActions>
122
134
  <OAlert
@@ -636,6 +636,7 @@ export interface GoogleMapsParams {
636
636
  handleToggleMap?: () => void,
637
637
  isIntGeoCoder: boolean,
638
638
  businessZones?: any
639
+ delta?: number
639
640
  }
640
641
 
641
642
  export interface HelpParams {