ordering-ui-react-native 0.21.71 → 0.21.73

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.71",
3
+ "version": "0.21.73",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -33,6 +33,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
33
33
  const [state, setState] = useState({
34
34
  selectedPrinter: { url: undefined },
35
35
  });
36
+ const paymethodsLength = order?.payment_events?.filter((item: any) => item.event === 'payment')?.length
36
37
 
37
38
  const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
38
39
  if (name !== 'No') {
@@ -83,6 +84,24 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
83
84
  const customerName = `${order?.customer?.name ?? ''} ${order?.customer?.middle_name ?? ''} ${order?.customer?.lastname ?? ''} ${order?.customer?.second_lastname ?? ''
84
85
  }`?.replace(' ', ' ')?.trim() ?? ''
85
86
 
87
+ const walletName: any = {
88
+ cash: {
89
+ name: t('CASH_WALLET', 'Cash Wallet')
90
+ },
91
+ credit_point: {
92
+ name: t('POINTS_WALLET', 'Points Wallet')
93
+ }
94
+ }
95
+
96
+ const handlePaymethodsListString = () => {
97
+ const paymethodsList = order?.payment_events?.filter((item: any) => item.event === 'payment').map((paymethod: any) => {
98
+ return paymethod?.wallet_event
99
+ ? walletName[paymethod?.wallet_event?.wallet?.type]?.name
100
+ : t(paymethod?.paymethod?.gateway?.toUpperCase(), paymethod?.paymethod?.name)
101
+ })
102
+ return paymethodsList.join(', ')
103
+ }
104
+
86
105
  const orderSummary = () => {
87
106
  return `
88
107
  <div>
@@ -99,7 +118,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
99
118
  : parseDate(order?.delivery_datetime, { utc: false })
100
119
  }
101
120
  </br>
102
- ${t('PAYMENT_METHOD')}: ${order?.paymethod?.name}
121
+ ${paymethodsLength > 1 ? 'PAYMENT_METHODS' : 'PAYMENT_METHOD'}: ${handlePaymethodsListString()}
103
122
  </p>
104
123
 
105
124
  <h1>${t('CUSTOMER_DETAILS', 'Customer details')}</h1>
@@ -114,8 +133,8 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
114
133
  } </br>`
115
134
  : ''
116
135
  }
117
- ${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}
118
- </br>
136
+ ${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}
137
+ </br>
119
138
  ${!!order?.customer?.internal_number
120
139
  ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number
121
140
  } </br>`
@@ -379,10 +398,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
379
398
  }`}
380
399
  </OText>
381
400
 
382
- <OText style={{ marginBottom: 5 }}>{`${t('PAYMENT_METHOD')}: ${t(
383
- order?.paymethod?.name.toUpperCase(),
384
- order?.paymethod?.name,
385
- )}`}</OText>
401
+ <OText style={{ marginBottom: 5 }}>{`${t(`${paymethodsLength > 1 ? 'PAYMENT_METHODS' : 'PAYMENT_METHOD'}`, `${paymethodsLength > 1 ? 'Payment methods' : 'Payment method'}`)}: ${handlePaymethodsListString()}`}</OText>
386
402
  </OrderHeader>
387
403
 
388
404
  <OrderCustomer>
@@ -170,12 +170,12 @@ const CheckoutUI = (props: any) => {
170
170
  const [paymethodClicked, setPaymethodClicked] = useState<any>(null)
171
171
  const [showTitle, setShowTitle] = useState(false)
172
172
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
173
+ const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
173
174
  const containerRef = useRef<any>()
174
175
  const cardsMethods = ['credomatic']
175
176
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
176
177
  const placeSpotTypes = [3, 4, 5]
177
178
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
178
- const isGiftCardCart = !cart?.business_id
179
179
  const businessConfigs = businessDetails?.business?.configs ?? []
180
180
  const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
181
181
  const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
@@ -359,11 +359,21 @@ const CheckoutUI = (props: any) => {
359
359
  if (cart?.products?.length === 0) {
360
360
  if (cart?.business_id !== null) {
361
361
  onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
362
- } else {
362
+ } else if (isGiftCardCart) {
363
363
  onNavigationRedirect('Wallets')
364
364
  }
365
365
  }
366
- }, [cart?.products])
366
+ }, [cart?.products?.length])
367
+
368
+ useEffect(() => {
369
+ if (cart?.products?.length > 0) {
370
+ if (cart?.uuid && cart?.business_id === null) {
371
+ setIsGiftCardCart(true)
372
+ } else {
373
+ setIsGiftCardCart(false)
374
+ }
375
+ }
376
+ }, [cart?.uuid, cart?.products?.length])
367
377
 
368
378
  useEffect(() => {
369
379
  onFailPaypal()
@@ -27,9 +27,9 @@ const StyledButton = styled.View<Props>`
27
27
  padding-left: 20px;
28
28
  padding-right: 20px;
29
29
  position: relative;
30
- ${(props: any) => props?.theme?.general?.components?.buttons?.borderRadius && css`
31
- border-radius: ${props?.theme?.general?.components?.buttons?.borderRadius}px;
32
- `}
30
+ ${(props: any) => props?.borderRadius && css`
31
+ border-radius: ${typeof props?.borderRadius === 'string' ? props?.borderRadius : `${props?.borderRadius}px`};
32
+ `}
33
33
  `
34
34
  const StyledButtonDisabled = styled(StyledButton)`
35
35
  background-color: ${(props: any) => props.theme.colors.disabled};
@@ -53,9 +53,9 @@ const Wrapper = styled.Pressable`
53
53
  align-items: center;
54
54
  justify-content: center;
55
55
  width: 100%;
56
- ${(props: any) => props.theme?.general?.components?.inputs?.borderRadius && css`
57
- border-radius: ${props?.theme?.general?.components?.inputs?.borderRadius};
58
- `}
56
+ ${(props: any) => props?.borderRadius && css`
57
+ border-radius: ${typeof props?.borderRadius === 'string' ? props?.borderRadius : `${props?.borderRadius}px`};
58
+ `}
59
59
  `;
60
60
 
61
61
  const OInput = (props: Props): React.ReactElement => {
@@ -70,6 +70,7 @@ const OInput = (props: Props): React.ReactElement => {
70
70
  ? props.borderColor
71
71
  : inputFocused ? theme.colors.primary : theme.colors.border,
72
72
  ...props.style,
73
+ borderRadius: parseInt(theme?.general?.components?.inputs?.borderRadius) || props.style?.borderRadius
73
74
  }}>
74
75
  {props.icon ? (
75
76
  <OIcon
@@ -104,9 +105,9 @@ const OInput = (props: Props): React.ReactElement => {
104
105
  props.forwardRef && (props.forwardRef.current = e)
105
106
  }}
106
107
  style={{
107
- ...(theme?.general?.components?.inputs?.color && {
108
- color: theme?.general?.components?.inputs?.color
109
- }),
108
+ ...(theme?.general?.components?.inputs?.color && {
109
+ color: theme?.general?.components?.inputs?.color
110
+ }),
110
111
  ...props?.inputStyle
111
112
  }}
112
113
  onFocus={() => setInputFocused(true)}