ordering-ui-react-native 0.21.78 → 0.21.80

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.78",
3
+ "version": "0.21.80",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -50,6 +50,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
50
50
  const theme = useTheme();
51
51
  const [, t] = useLanguage();
52
52
  const [{ parseDate }] = useUtils();
53
+ const paymethodsLength = order?.payment_events?.filter((item: any) => item.event === 'payment')?.length
53
54
 
54
55
  const styles = StyleSheet.create({
55
56
  icons: {
@@ -120,6 +121,15 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
120
121
  ? t('CURBSIDE', 'Curbside')
121
122
  : t('DRIVER_THRU', 'Driver thru')
122
123
 
124
+ const handlePaymethodsListString = () => {
125
+ const paymethodsList = order?.payment_events?.filter((item: any) => item.event === 'payment').map((paymethod: any) => {
126
+ return paymethod?.wallet_event
127
+ ? walletName[paymethod?.wallet_event?.wallet?.type]?.name
128
+ : t(paymethod?.paymethod?.gateway?.toUpperCase(), paymethod?.paymethod?.name)
129
+ })
130
+ return paymethodsList.join(', ')
131
+ }
132
+
123
133
  return (
124
134
  <>
125
135
  {!props.isCustomView && (
@@ -283,20 +293,10 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
283
293
  )}
284
294
  <OText>
285
295
  <OText size={13} weight='bold'>
286
- {`${t('PAYMENT_METHODS', 'Payment methods')}: `}
296
+ {`${t(paymethodsLength > 1 ? 'PAYMENT_METHODS' : 'PAYMENT_METHOD', paymethodsLength > 1 ? 'Payment methods' : 'Payment method')}: `}
287
297
  </OText>
288
298
  {order?.payment_events?.length > 0 ? (
289
- <OText size={13}>
290
- {order?.payment_events?.map((event: any, idx: number) => {
291
- return event?.wallet_event
292
- ? idx < order?.payment_events?.length - 1
293
- ? `${walletName[event?.wallet_event?.wallet?.type]?.name} - `
294
- : walletName[event?.wallet_event?.wallet?.type]?.name
295
- : idx < order?.payment_events?.length - 1
296
- ? `${t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)} - `
297
- : t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)
298
- })}
299
- </OText>
299
+ <OText size={13}>{`${handlePaymethodsListString()}`}</OText>
300
300
  ) : (
301
301
  <OText size={13}>{t(order?.paymethod?.gateway?.toUpperCase(), order?.paymethod?.name)}</OText>
302
302
  )}
@@ -118,7 +118,7 @@ export const OrderSummary = ({ order, navigation, orderStatus, askBluetoothPermi
118
118
  : parseDate(order?.delivery_datetime, { utc: false })
119
119
  }
120
120
  </br>
121
- ${paymethodsLength > 1 ? 'PAYMENT_METHODS' : 'PAYMENT_METHOD'}: ${handlePaymethodsListString()}
121
+ ${t(paymethodsLength > 1 ? 'PAYMENT_METHODS' : 'PAYMENT_METHOD', paymethodsLength > 1 ? 'Payment methods' : 'Payment method')}: ${handlePaymethodsListString()}
122
122
  </p>
123
123
 
124
124
  <h1>${t('CUSTOMER_DETAILS', 'Customer details')}</h1>
@@ -72,7 +72,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
72
72
 
73
73
  const getProductPrice = (product: any) => {
74
74
  let subOptionPrice = 0;
75
- if (product?.options?.length > 0 && product?.options?.suboptions?.length > 0) {
75
+ if (product?.options?.length > 0 && product?.options[0]?.suboptions?.length > 0) {
76
76
  for (const option of product?.options) {
77
77
  for (const suboption of option?.suboptions) {
78
78
  subOptionPrice += suboption.quantity * suboption.price;
@@ -118,7 +118,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
118
118
 
119
119
  const onTextLayout = useCallback((e: any) => {
120
120
  setLengthMore((e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2); //to check the text is more than 2 lines or not
121
- },[]);
121
+ }, []);
122
122
 
123
123
  return (
124
124
  <AccordionSection>