ordering-ui-react-native 0.17.54 → 0.17.56

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,5 +1,18 @@
1
1
  import styled from 'styled-components/native';
2
2
 
3
+ export const LoginWith = styled.View`
4
+ display: flex;
5
+ width: 100%;
6
+ margin-bottom: 30px;
7
+ `;
8
+
9
+ export const TabsContainer = styled.View`
10
+ min-width: ${({ width }: { width: number }) => `${width}px`};
11
+ width: auto;
12
+ display: flex;
13
+ flex-direction: row;
14
+ `;
15
+
3
16
  export const LogoWrapper = styled.View`
4
17
  align-items: center;
5
18
  `;
@@ -11,4 +24,4 @@ export const RecaptchaButton = styled.View`
11
24
  flex-direction: row;
12
25
  align-items: center;
13
26
  margin-bottom: 10px;
14
- `
27
+ `
@@ -86,6 +86,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
86
86
  return (
87
87
  <Wrapper>
88
88
  <PhoneInput
89
+ containerStyle={{ width: '100%' }}
89
90
  ref={phoneInput}
90
91
  defaultValue={userphoneNumber || defaultValue}
91
92
  defaultCode={defaultCode ? transformCountryCode(defaultCode) : configs?.default_country_code?.value}
@@ -1,5 +1,3 @@
1
1
  import styled from 'styled-components/native';
2
2
 
3
- export const Wrapper = styled.View`
4
- flex: 1
5
- `
3
+ export const Wrapper = styled.View``;
@@ -95,14 +95,14 @@ const styles = StyleSheet.create({
95
95
  position: 'relative',
96
96
  width: '100%',
97
97
  },
98
- titleSection: {
99
- width: '100%',
100
- height: 30,
101
- display: 'flex',
102
- justifyContent: 'space-between',
103
- alignItems: 'center',
104
- marginBottom: 20,
105
- },
98
+ titleSection: {
99
+ width: '100%',
100
+ justifyContent: 'space-between',
101
+ alignItems: 'flex-start',
102
+ paddingLeft: 40,
103
+ paddingRight: 40,
104
+ marginBottom: 40,
105
+ },
106
106
  cancelBtn: {
107
107
  position: 'absolute',
108
108
  left: 0,
@@ -111,9 +111,12 @@ const styles = StyleSheet.create({
111
111
  },
112
112
  modalText: {
113
113
  marginTop: 15,
114
- fontSize: 25,
115
- textAlign: "center",
116
- zIndex: 10
114
+ fontSize: 20,
115
+ lineHeight: 30,
116
+ fontWeight: '600',
117
+ textAlign: "center",
118
+ zIndex: 10,
119
+ width: '100%'
117
120
  },
118
121
  wrapperIcon: {
119
122
  overflow: 'hidden',
@@ -22,7 +22,13 @@ export const Container = (props: Props) => {
22
22
  <SafeAreStyled
23
23
  nestedScrollEnabled={props.nestedScrollEnabled}
24
24
  >
25
- <ContainerStyled {...props} ref={props?.forwardRef}>{props.children}</ContainerStyled>
25
+ <ContainerStyled
26
+ {...props}
27
+ keyboardShouldPersistTaps="handled"
28
+ ref={props?.forwardRef}
29
+ >
30
+ {props.children}
31
+ </ContainerStyled>
26
32
  </SafeAreStyled>
27
33
  );
28
34
  };
@@ -84,6 +84,12 @@ export interface LoginParams {
84
84
  useRootPoint?: any;
85
85
  enableReCaptcha?: boolean;
86
86
  handleReCaptcha?: (vlaue: any) => void;
87
+ useLoginOtp?: any;
88
+ otpType?: any;
89
+ setOtpType?: any;
90
+ generateOtpCode?: any;
91
+ useLoginOtpEmail?: any;
92
+ useLoginOtpCellphone?: any;
87
93
  }
88
94
 
89
95
  export interface ProductItemAccordionParams {
@@ -482,3 +488,10 @@ export interface Cart {
482
488
  export interface NoNetworkParams {
483
489
  image?: any;
484
490
  }
491
+ export interface otpParams {
492
+ willVerifyOtpState: boolean,
493
+ setWillVerifyOtpState: (val : boolean) => void,
494
+ onSubmit: any,
495
+ handleLoginOtp: (code : string) => void,
496
+ setAlertState: any
497
+ }
@@ -0,0 +1,15 @@
1
+ export const formatSeconds = (seconds : number) => {
2
+ // Hours, minutes and seconds
3
+ const hrs = Math.floor(seconds / 3600)
4
+ const mins = Math.floor((seconds % 3600) / 60)
5
+ const secs = Math.floor(seconds % 60)
6
+
7
+ // Output like '1:01' or '4:03:59' or '123:03:59'
8
+ let ret = ''
9
+ if (hrs > 0) {
10
+ ret += '' + hrs + ':' + (mins < 10 ? '0' : '')
11
+ }
12
+ ret += '' + mins + ':' + (secs < 10 ? '0' : '')
13
+ ret += '' + secs
14
+ return ret
15
+ }
@@ -75,7 +75,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
75
75
  const theme = useTheme();
76
76
  const [, t] = useLanguage()
77
77
  const [{ auth }] = useSession()
78
- const [orderState, { clearCart }] = useOrder()
78
+ const [orderState, { addProduct, updateProduct }] = useOrder()
79
79
  const [{ parsePrice }] = useUtils()
80
80
  const [, { showToast }] = useToast()
81
81
  const [{ configs }] = useConfig()
@@ -134,6 +134,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
134
134
  const [searchBarHeight, setSearchBarHeight] = useState(60)
135
135
 
136
136
  const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
137
+ const isQuickAddProduct = configs?.add_product_with_one_click?.value === '1'
137
138
  const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
138
139
 
139
140
  const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
@@ -142,20 +143,39 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
142
143
  const onRedirect = (route: string, params?: any) => {
143
144
  navigation.navigate(route, params)
144
145
  }
145
-
146
- const onProductClick = (product: any) => {
147
- const productAddedToCartLength = currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0) || 0
148
- if (product?.type === 'service' && business?.professionals?.length > 0) {
149
- setCurrentProduct(product)
150
- setOpenService(true)
151
- return
146
+ const onProductClick = async (product: any) => {
147
+ if (product.extras.length === 0 && !product.inventoried && auth && isQuickAddProduct) {
148
+ const isProductAddedToCart = currentCart?.products?.find((Cproduct: any) => Cproduct.id === product.id)
149
+ const productQuantity = isProductAddedToCart?.quantity
150
+ const addCurrentProduct = {
151
+ ...product,
152
+ quantity: 1
153
+ }
154
+ const updateCurrentProduct = {
155
+ id: product.id,
156
+ code: isProductAddedToCart?.code,
157
+ quantity: productQuantity + 1
158
+ }
159
+ const cartData = currentCart?.business_id ? currentCart : { business_id: business.id }
160
+ if (isProductAddedToCart) {
161
+ await updateProduct(updateCurrentProduct, cartData, isQuickAddProduct)
162
+ } else {
163
+ await addProduct(addCurrentProduct, cartData, isQuickAddProduct)
164
+ }
165
+ } else {
166
+ const productAddedToCartLength = currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0) || 0
167
+ if (product?.type === 'service' && business?.professionals?.length > 0) {
168
+ setCurrentProduct(product)
169
+ setOpenService(true)
170
+ return
171
+ }
172
+ onRedirect('ProductDetails', {
173
+ product: product,
174
+ businessSlug: business.slug,
175
+ businessId: business.id,
176
+ productAddedToCartLength
177
+ })
152
178
  }
153
- onRedirect('ProductDetails', {
154
- product: product,
155
- businessSlug: business.slug,
156
- businessId: business.id,
157
- productAddedToCartLength
158
- })
159
179
  }
160
180
 
161
181
  const handleCancel = () => {