ordering-ui-react-native 0.18.29 → 0.18.31

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.18.29",
3
+ "version": "0.18.31",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -216,6 +216,25 @@ export const AnalyticsSegment = (props: any) => {
216
216
  })
217
217
  }
218
218
 
219
+ const handleProductAddedToWishlist = (product: any) => {
220
+ segmentClient.track('Product Added to Wishlist', product)
221
+ }
222
+
223
+ const handleProductRemovedFromWishlist = (product: any) => {
224
+ segmentClient.track('Product Removed from Wishlist', product)
225
+ }
226
+
227
+ const handleWishlistProductAddedToCart = (product: any, result: any) => {
228
+ segmentClient.track('Wishlist Product Added to Cart', {
229
+ cart_id: result.uuid,
230
+ product_id: product.id,
231
+ name: product.name,
232
+ category: product.categoryId,
233
+ price: product.price,
234
+ quantity: product.quantity
235
+ })
236
+ }
237
+
219
238
  useEffect(() => {
220
239
  if (segmentClient?.config?.writeKey) {
221
240
  events.on('products_searched', handleProductsSearched)
@@ -237,6 +256,9 @@ export const AnalyticsSegment = (props: any) => {
237
256
  events.on('userLogin', handleLogin)
238
257
  events.on('order_placed', handleOrderPlaced)
239
258
  events.on('order_added', handleAddOrder)
259
+ events.on('product_added_to_wishlist', handleProductAddedToWishlist)
260
+ events.on('product_removed_from_wishlist', handleProductRemovedFromWishlist)
261
+ events.on('wishlist_product_added_to_cart', handleWishlistProductAddedToCart)
240
262
  }
241
263
  return () => {
242
264
  if (segmentClient?.config?.writeKey) {
@@ -259,6 +281,9 @@ export const AnalyticsSegment = (props: any) => {
259
281
  events.off('userLogin', handleLogin)
260
282
  events.off('order_placed', handleOrderPlaced)
261
283
  events.off('order_added', handleAddOrder)
284
+ events.off('product_added_to_wishlist', handleProductAddedToWishlist)
285
+ events.off('product_removed_from_wishlist', handleProductRemovedFromWishlist)
286
+ events.off('wishlist_product_added_to_cart', handleWishlistProductAddedToCart)
262
287
  }
263
288
  }
264
289
  }, [segmentClient])
@@ -278,6 +303,5 @@ export const AnalyticsSegment = (props: any) => {
278
303
  {children}
279
304
  </AnalyticsProvider>
280
305
  </>
281
-
282
306
  )
283
307
  }
@@ -3,6 +3,7 @@ import {
3
3
  BusinessReviews as BusinessReviewController,
4
4
  useLanguage,
5
5
  useOrder,
6
+ useUtils
6
7
  } from 'ordering-components/native';
7
8
  import { useTheme } from 'styled-components/native';
8
9
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
@@ -30,6 +31,7 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
30
31
  const theme = useTheme();
31
32
  const [searchReview, setSearchReview] = useState('')
32
33
  const [orderState] = useOrder();
34
+ const [{ parseDate }] = useUtils()
33
35
 
34
36
  const styles = StyleSheet.create({
35
37
  starIcon: {
@@ -94,7 +96,7 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
94
96
  const ReviewItem = ({ comment, created_at, total }: any) => (
95
97
  <View style={{ marginBottom: 30 }}>
96
98
  <OText size={12} color={theme.colors.textSecondary}>
97
- {moment(created_at).format('MMMM d, yyyy • hh:mm')}
99
+ {parseDate(created_at, { outputFormat: 'MMMM D, YYYY • hh:mm A' })}
98
100
  </OText>
99
101
  <OText size={12} color={theme.colors.textNormal}>{comment}</OText>
100
102
  </View>
@@ -7,7 +7,7 @@ import { Wrapper } from './styles'
7
7
 
8
8
  import { PhoneInputParams } from '../../types';
9
9
  import { OIcon, OText } from '../shared';
10
- import { transformCountryCode } from '../../utils'
10
+ import { findExitingCode, transformCountryCode } from '../../utils'
11
11
 
12
12
  export const PhoneInputNumber = (props: PhoneInputParams) => {
13
13
  const {
@@ -113,7 +113,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
113
113
  !isNaN(defaultCode)
114
114
  ? transformCountryCode(defaultCode)
115
115
  : defaultCode
116
- : configs?.default_country_code?.value?.toUpperCase()}
116
+ : findExitingCode(configs?.default_country_code?.value?.toUpperCase())}
117
117
  onChangeFormattedText={(text: string) => handleChangeNumber(text)}
118
118
  withDarkTheme
119
119
  onChangeCountry={(country) => changeCountry?.(country)}
@@ -271,6 +271,11 @@ export const transformCountryCode = (countryCode: number) => {
271
271
  return code?.countryCode
272
272
  }
273
273
 
274
+ export const findExitingCode = (countryCode: string) => {
275
+ const code = CODES.find((code: any) => code.countryCode === countryCode)
276
+ return code?.countryCode
277
+ }
278
+
274
279
  /**
275
280
  * Function to check if a number is decimal or not
276
281
  * @param {*} value number to check if decimal or not