ordering-ui-external 2.6.5 → 2.6.8

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.
Files changed (97) hide show
  1. package/_bundles/0.ordering-ui.ba64d5c9c7490676feb5.js +1 -0
  2. package/_bundles/{5.ordering-ui.80bc71775c11b08c37b2.js → 5.ordering-ui.ba64d5c9c7490676feb5.js} +1 -1
  3. package/_bundles/{7.ordering-ui.80bc71775c11b08c37b2.js → 7.ordering-ui.ba64d5c9c7490676feb5.js} +2 -2
  4. package/_bundles/ordering-ui.ba64d5c9c7490676feb5.js +2 -0
  5. package/_modules/components/LanguageSelector/index.js +1 -0
  6. package/_modules/components/OrderTypeSelectorHeader/index.js +3 -1
  7. package/_modules/components/SmartAppBanner/index.js +5 -2
  8. package/_modules/contexts/ThemeContext/index.js +1 -1
  9. package/_modules/styles/Select/index.js +14 -2
  10. package/_modules/styles/Selects/index.js +11 -8
  11. package/_modules/themes/callcenterOriginal/src/components/Orders/OrderMetaFields/index.js +1 -1
  12. package/_modules/themes/eight/src/components/AddressForm/index.js +4 -1
  13. package/_modules/themes/eight/src/components/SingleProductCard/index.js +1 -1
  14. package/_modules/themes/five/src/components/BusinessBasicInformation/BusinessInfoComponent.js +168 -0
  15. package/_modules/themes/five/src/components/BusinessBasicInformation/SearchComponent.js +39 -0
  16. package/_modules/themes/five/src/components/BusinessBasicInformation/SocialNetWork.js +19 -0
  17. package/_modules/themes/five/src/components/BusinessBasicInformation/index.js +35 -156
  18. package/_modules/themes/five/src/components/BusinessBasicInformation/styles.js +45 -35
  19. package/_modules/themes/five/src/components/BusinessProductsCategories/index.js +1 -1
  20. package/_modules/themes/five/src/components/BusinessesListing/layouts/StarbucksBusinessesListing/index.js +1 -1
  21. package/_modules/themes/five/src/components/CardForm/index.js +16 -3
  22. package/_modules/themes/five/src/components/CardForm/styles.js +13 -9
  23. package/_modules/themes/five/src/components/CardFormCustom/cardUtils.js +102 -0
  24. package/_modules/themes/five/src/components/CardFormCustom/index.js +148 -0
  25. package/_modules/themes/five/src/components/CardFormCustom/styles.js +16 -0
  26. package/_modules/themes/five/src/components/CartPopover/styles.js +1 -1
  27. package/_modules/themes/five/src/components/Checkout/index.js +31 -22
  28. package/_modules/themes/five/src/components/LanguageSelector/index.js +4 -1
  29. package/_modules/themes/five/src/components/LoginForm/index.js +11 -8
  30. package/_modules/themes/five/src/components/Modal/styles.js +1 -1
  31. package/_modules/themes/five/src/components/OrderContextUI/index.js +13 -1
  32. package/_modules/themes/five/src/components/OrderDetails/OrderHistory.js +7 -3
  33. package/_modules/themes/five/src/components/OrderDetails/index.js +4 -2
  34. package/_modules/themes/five/src/components/PaymentOptionCard/index.js +84 -0
  35. package/_modules/themes/five/src/components/PaymentOptionStripe/index.js +48 -22
  36. package/_modules/themes/five/src/components/PaymentOptionStripe/styles.js +3 -1
  37. package/_modules/themes/five/src/components/PaymentOptions/index.js +46 -24
  38. package/_modules/themes/five/src/components/RenderProductsLayout/index.js +1 -1
  39. package/_modules/themes/five/src/components/SearchProducts/styles.js +1 -1
  40. package/_modules/themes/five/src/components/UserDetails/index.js +1 -1
  41. package/_modules/themes/five/src/components/UserPopover/styles.js +1 -1
  42. package/_modules/themes/five/src/styles/Select/index.js +4 -2
  43. package/_modules/themes/five/src/styles/Selects/index.js +7 -4
  44. package/_modules/themes/four/src/components/LoginForm/index.js +1 -1
  45. package/_modules/themes/pwa/src/components/MomentPopover/styles.js +1 -1
  46. package/_modules/themes/seven/src/components/ProductForm/productForm.js +3 -1
  47. package/_modules/themes/six/src/components/BusinessesListing/index.js +1 -1
  48. package/index.html +1 -1
  49. package/package.json +4 -2
  50. package/src/components/LanguageSelector/index.js +1 -0
  51. package/src/components/OrderTypeSelectorHeader/index.js +3 -1
  52. package/src/components/SmartAppBanner/index.js +4 -2
  53. package/src/contexts/ThemeContext/index.js +1 -1
  54. package/src/styles/Select/index.js +11 -2
  55. package/src/styles/Selects/index.js +1 -1
  56. package/src/themes/five/src/components/BusinessBasicInformation/BusinessInfoComponent.js +230 -0
  57. package/src/themes/five/src/components/BusinessBasicInformation/SearchComponent.js +40 -0
  58. package/src/themes/five/src/components/BusinessBasicInformation/SocialNetWork.js +10 -0
  59. package/src/themes/five/src/components/BusinessBasicInformation/index.js +39 -247
  60. package/src/themes/five/src/components/BusinessBasicInformation/styles.js +14 -4
  61. package/src/themes/five/src/components/BusinessProductsCategories/index.js +1 -1
  62. package/src/themes/five/src/components/CardForm/index.js +25 -4
  63. package/src/themes/five/src/components/CardForm/styles.js +35 -0
  64. package/src/themes/five/src/components/CardFormCustom/cardUtils.js +111 -0
  65. package/src/themes/five/src/components/CardFormCustom/index.js +161 -0
  66. package/src/themes/five/src/components/CardFormCustom/styles.js +20 -0
  67. package/src/themes/five/src/components/CartPopover/styles.js +1 -1
  68. package/src/themes/five/src/components/Checkout/index.js +34 -25
  69. package/src/themes/five/src/components/LanguageSelector/index.js +2 -1
  70. package/src/themes/five/src/components/LoginForm/index.js +6 -4
  71. package/src/themes/five/src/components/Modal/styles.js +1 -0
  72. package/src/themes/five/src/components/OrderContextUI/index.js +10 -3
  73. package/src/themes/five/src/components/OrderDetails/OrderHistory.js +4 -3
  74. package/src/themes/five/src/components/OrderDetails/index.js +1 -1
  75. package/src/themes/five/src/components/PaymentOptionCard/index.js +70 -0
  76. package/src/themes/five/src/components/PaymentOptionStripe/index.js +46 -20
  77. package/src/themes/five/src/components/PaymentOptionStripe/styles.js +6 -1
  78. package/src/themes/five/src/components/PaymentOptions/index.js +28 -3
  79. package/src/themes/five/src/components/ProductForm/index.js +0 -1
  80. package/src/themes/five/src/components/RenderProductsLayout/index.js +1 -1
  81. package/src/themes/five/src/components/SearchProducts/styles.js +1 -1
  82. package/src/themes/five/src/components/UserDetails/index.js +1 -1
  83. package/src/themes/five/src/components/UserPopover/styles.js +1 -1
  84. package/src/themes/five/src/styles/Select/index.js +3 -2
  85. package/src/themes/five/src/styles/Selects/index.js +1 -1
  86. package/src/themes/pwa/src/components/MomentPopover/styles.js +4 -1
  87. package/template/theme.json +3 -1
  88. package/_bundles/0.ordering-ui.80bc71775c11b08c37b2.js +0 -1
  89. package/_bundles/ordering-ui.80bc71775c11b08c37b2.js +0 -2
  90. /package/_bundles/{1.ordering-ui.80bc71775c11b08c37b2.js → 1.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  91. /package/_bundles/{2.ordering-ui.80bc71775c11b08c37b2.js → 2.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  92. /package/_bundles/{4.ordering-ui.80bc71775c11b08c37b2.js → 4.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  93. /package/_bundles/{6.ordering-ui.80bc71775c11b08c37b2.js → 6.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  94. /package/_bundles/{7.ordering-ui.80bc71775c11b08c37b2.js.LICENSE.txt → 7.ordering-ui.ba64d5c9c7490676feb5.js.LICENSE.txt} +0 -0
  95. /package/_bundles/{8.ordering-ui.80bc71775c11b08c37b2.js → 8.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  96. /package/_bundles/{9.ordering-ui.80bc71775c11b08c37b2.js → 9.ordering-ui.ba64d5c9c7490676feb5.js} +0 -0
  97. /package/_bundles/{ordering-ui.80bc71775c11b08c37b2.js.LICENSE.txt → ordering-ui.ba64d5c9c7490676feb5.js.LICENSE.txt} +0 -0
@@ -0,0 +1,161 @@
1
+ import React, { useState } from 'react'
2
+ import Card from 'react-credit-cards-2'
3
+ import 'react-credit-cards-2/es/styles-compiled.css'
4
+ import {
5
+ formatCreditCardNumber,
6
+ formatCVC,
7
+ formatExpirationDate,
8
+ getCardType
9
+ } from './cardUtils'
10
+ import { useForm } from 'react-hook-form'
11
+ import { Input } from '../../styles/Inputs'
12
+ import { useLanguage } from 'ordering-components-external'
13
+ import Button from '../../styles/Buttons'
14
+ import { FormContainer, InputContainer } from './styles'
15
+
16
+ export const CardFormCustom = (props) => {
17
+ const {
18
+ handleNewCard,
19
+ setAddCardOpen
20
+ } = props
21
+
22
+ const [, t] = useLanguage()
23
+ const [formState, setFormState] = useState({
24
+ cvc: '',
25
+ expiry: '',
26
+ focus: '',
27
+ name: '',
28
+ number: ''
29
+ })
30
+
31
+ const formMethods = useForm()
32
+
33
+ const handleInputFocus = (e) => {
34
+ setFormState({
35
+ ...formState,
36
+ focus: e.target.name
37
+ })
38
+ }
39
+
40
+ const handleInputChange = ({ target }) => {
41
+ if (target.name === 'number') {
42
+ target.value = formatCreditCardNumber(target.value)
43
+ } else if (target.name === 'expiry') {
44
+ target.value = formatExpirationDate(target.value)
45
+ } else if (target.name === 'cvc') {
46
+ target.value = formatCVC(target.value)
47
+ }
48
+ setFormState({
49
+ ...formState,
50
+ [target.name]: target.value
51
+ })
52
+ }
53
+
54
+ const onSubmit = (values) => {
55
+ const cardBrand = getCardType(values?.number)
56
+ const lastFourDigits = values?.number.substr(-4)
57
+ const card = {
58
+ type: 'card',
59
+ brand: cardBrand,
60
+ last4: lastFourDigits,
61
+ ccnumber: values?.number?.replace(/\s/g, ''),
62
+ ccexp: values?.expiry?.replace('/', ''),
63
+ cvv: values?.cvc
64
+ }
65
+ handleNewCard(card)
66
+ setAddCardOpen(false)
67
+ }
68
+
69
+ return (
70
+ <FormContainer id='PaymentForm'>
71
+ <Card
72
+ cvc={formState.cvc}
73
+ expiry={formState.expiry}
74
+ focused={formState.focus}
75
+ name={formState.name}
76
+ number={formState.number}
77
+ placeholders={{
78
+ name: t('YOUR_NAME_HERE', 'Your name here')
79
+ }}
80
+ />
81
+ <form
82
+ onSubmit={formMethods.handleSubmit(onSubmit)}
83
+ >
84
+ <InputContainer>
85
+ <Input
86
+ type='tel'
87
+ name='number'
88
+ placeholder={t('CARD_NUMBER', 'Card number')}
89
+ inputMode='numeric'
90
+ onChange={handleInputChange}
91
+ onFocus={handleInputFocus}
92
+ pattern='[\d| ]{16,22}'
93
+ format={formatCreditCardNumber}
94
+ maxLength={19}
95
+ ref={
96
+ formMethods.register({
97
+ required: t('CARD_NUMBER_REQUIRED', 'Card number is required'),
98
+ pattern: /^[\d| ]{16,22}$/i
99
+ })
100
+ }
101
+ isError={formMethods.errors.number}
102
+ />
103
+ </InputContainer>
104
+ <InputContainer>
105
+ <Input
106
+ type='text'
107
+ name='name'
108
+ placeholder={t('NAME', 'Name')}
109
+ onChange={handleInputChange}
110
+ onFocus={handleInputFocus}
111
+ ref={
112
+ formMethods.register({
113
+ required: t('NAME_REQUIRED', 'Name is required'),
114
+ })
115
+ }
116
+ isError={formMethods.errors.name}
117
+ />
118
+ </InputContainer>
119
+ <InputContainer>
120
+ <Input
121
+ type='text'
122
+ name='expiry'
123
+ pattern='\d\d/\d\d'
124
+ placeholder={t('EXPIRY', 'Expiry')}
125
+ onChange={handleInputChange}
126
+ onFocus={handleInputFocus}
127
+ format={formatExpirationDate}
128
+ ref={
129
+ formMethods.register({
130
+ required: t('EXPIRY_DATE_REQUIRED', 'Expiry date required')
131
+ })
132
+ }
133
+ isError={formMethods.errors.expiry}
134
+ />
135
+ <Input
136
+ type='text'
137
+ name='cvc'
138
+ placeholder={t('CVC', 'CVC')}
139
+ pattern='\d{3,4}'
140
+ onChange={handleInputChange}
141
+ onFocus={handleInputFocus}
142
+ format={formatCVC}
143
+ ref={
144
+ formMethods.register({
145
+ required: t('CVC_REQUIRED', 'CVC is required')
146
+ })
147
+ }
148
+ isError={formMethods.errors.cvc}
149
+ />
150
+ </InputContainer>
151
+ <Button
152
+ type='submit'
153
+ color='primary'
154
+ disabled={Object.keys(formMethods.errors)?.length > 0}
155
+ >
156
+ {t('SAVE', 'Save')}
157
+ </Button>
158
+ </form>
159
+ </FormContainer>
160
+ )
161
+ }
@@ -0,0 +1,20 @@
1
+ import styled, { css } from 'styled-components'
2
+
3
+ export const InputContainer = styled.div`
4
+ width: 100%;
5
+ display: flex;
6
+ justify-content: space-between;
7
+
8
+ input{
9
+ box-sizing: border-box;
10
+ width: 100%;
11
+ margin: 10px;
12
+ }
13
+ `
14
+
15
+ export const FormContainer = styled.div`
16
+ button{
17
+ width: 100%;
18
+ margin: 10px;
19
+ }
20
+ `
@@ -31,7 +31,7 @@ export const PopoverBody = styled.div`
31
31
  padding: 15px;
32
32
  border-radius: 10px;
33
33
  max-width: 500px;
34
- z-index: 2000;
34
+ z-index: 10002;
35
35
  box-shadow: rgba(0, 0, 0, 0.2) 0px 8px 24px;
36
36
  `
37
37
 
@@ -3,7 +3,7 @@ import VscWarning from '@meronex/icons/vsc/VscWarning'
3
3
  import Skeleton from 'react-loading-skeleton'
4
4
  import { useTheme } from 'styled-components'
5
5
  import { Modal } from '../Modal'
6
- import {
6
+ import {
7
7
  Checkout as CheckoutController,
8
8
  useOrder,
9
9
  useSession,
@@ -21,7 +21,6 @@ import { UpsellingPage } from '../UpsellingPage'
21
21
  import parsePhoneNumber from 'libphonenumber-js'
22
22
  import { useHistory } from 'react-router-dom'
23
23
  import { ArrowLeft } from 'react-bootstrap-icons'
24
-
25
24
  import {
26
25
  Container,
27
26
  WrapperLeftContainer,
@@ -129,7 +128,7 @@ const CheckoutUI = (props) => {
129
128
  const [openModal, setOpenModal] = useState({ login: false, signup: false })
130
129
  const [allowedGuest, setAllowedGuest] = useState(false)
131
130
  const [cardList, setCardList] = useState([])
132
-
131
+ const cardsMethods = ['stripe', 'credomatic']
133
132
  const businessConfigs = businessDetails?.business?.configs ?? []
134
133
  const isTableNumberEnabled = configs?.table_numer_enabled?.value
135
134
  const isWalletCashEnabled = businessConfigs.find(config => config.key === 'wallet_cash_enabled')?.value === '1'
@@ -147,7 +146,7 @@ const CheckoutUI = (props) => {
147
146
 
148
147
  const isDisablePlaceOrderButton = !cart?.valid ||
149
148
  (!paymethodSelected && cart?.balance > 0) ||
150
- (paymethodSelected?.gateway === 'stripe' && cardList?.cards?.length === 0) ||
149
+ (cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
151
150
  placing ||
152
151
  errorCash ||
153
152
  loading ||
@@ -246,7 +245,7 @@ const CheckoutUI = (props) => {
246
245
  if (userSelected && userSelected?.cellphone) {
247
246
  if (userSelected?.country_phone_code) {
248
247
  let phone = null
249
- phone = `+${userSelected?.country_phone_code}${userSelected?.cellphone}`
248
+ phone = `+${userSelected?.country_phone_code}${userSelected?.cellphone.replace(`+${userSelected?.country_phone_code}`, '')}`
250
249
  const phoneNumber = parsePhoneNumber(phone)
251
250
  if (!phoneNumber?.isValid()) {
252
251
  errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_INVALID', 'The field Phone number is invalid.'))
@@ -526,24 +525,24 @@ const CheckoutUI = (props) => {
526
525
 
527
526
  {
528
527
  !!(!isMultiDriverTips && driverTipsField) &&
529
- <>
530
- <DriverTipContainer>
531
- <h1>{t('DRIVER_TIPS', 'Driver Tips')}</h1>
532
- <p>{t('100%_OF_THE_TIP_YOUR_DRIVER', '100% of the tip goes to your driver')}</p>
533
- <DriverTips
534
- businessId={cart?.business_id}
535
- driverTipsOptions={driverTipsOptions}
536
- isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
537
- isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
538
- driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
539
- ? cart?.driver_tip
540
- : cart?.driver_tip_rate}
541
- cart={cart}
542
- useOrderContext
543
- />
544
- </DriverTipContainer>
545
- <DriverTipDivider />
546
- </>
528
+ <>
529
+ <DriverTipContainer>
530
+ <h1>{t('DRIVER_TIPS', 'Driver Tips')}</h1>
531
+ <p>{t('100%_OF_THE_TIP_YOUR_DRIVER', '100% of the tip goes to your driver')}</p>
532
+ <DriverTips
533
+ businessId={cart?.business_id}
534
+ driverTipsOptions={driverTipsOptions}
535
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
536
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
537
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
538
+ ? cart?.driver_tip
539
+ : cart?.driver_tip_rate}
540
+ cart={cart}
541
+ useOrderContext
542
+ />
543
+ </DriverTipContainer>
544
+ <DriverTipDivider />
545
+ </>
547
546
  }
548
547
  {!cartState.loading && placeSpotsEnabled && cart?.business_id && (
549
548
  <SelectSpotContainer>
@@ -576,7 +575,7 @@ const CheckoutUI = (props) => {
576
575
  businessConfigs={businessConfigs}
577
576
  loyaltyRewardRate={
578
577
  creditPointPlanOnBusiness?.accumulation_rate ??
579
- (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
578
+ (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
580
579
  }
581
580
  />
582
581
  </CartContainer>
@@ -838,8 +837,18 @@ export const Checkout = (props) => {
838
837
  handleOrderRedirect(result.order.uuid)
839
838
  setCartState({ ...cartState, loading: false })
840
839
  } else if (result.status === 2) {
840
+ let credomaticData = null
841
+ if (result?.paymethod_data?.gateway === 'credomatic') {
842
+ const urlParams = new URLSearchParams(window.location.search)
843
+ const paramsObj = Object.fromEntries(urlParams.entries())
844
+ credomaticData = {
845
+ credomatic: {
846
+ ...paramsObj
847
+ }
848
+ }
849
+ }
841
850
  try {
842
- const confirmCartRes = await confirmCart(cartUuid)
851
+ const confirmCartRes = await confirmCart(cartUuid, credomaticData)
843
852
  if (confirmCartRes.error) {
844
853
  setAlertState({
845
854
  open: true,
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect } from 'react'
2
2
  import { LanguageSelector as LanguageSelectorController } from 'ordering-components-external'
3
3
  import { Select } from '../../styles/Select'
4
4
  import { Container } from './styles'
@@ -40,6 +40,7 @@ const LanguageSelectorUI = (props) => {
40
40
  src={`http://purecatamphetamine.github.io/country-flag-icons/3x2/${transformLanguageToCountry(currentLanguage)}.svg`}
41
41
  />
42
42
  <Select
43
+ zIndex={20000}
43
44
  isHomeStyle
44
45
  options={languagesState?.loading ? defaultLanguages : _languages}
45
46
  defaultValue={languagesState?.loading ? defaultCurrentLanguage : currentLanguage}
@@ -11,7 +11,8 @@ import {
11
11
  useSession,
12
12
  useToast, ToastType,
13
13
  ReCaptcha,
14
- useApi
14
+ useApi,
15
+ useOptimizationLoad
15
16
  } from 'ordering-components-external'
16
17
  import { Alert } from '../Confirm'
17
18
  import { SpinnerLoader } from '../../../../../components/SpinnerLoader'
@@ -96,6 +97,7 @@ const LoginFormUI = (props) => {
96
97
  const theme = useTheme()
97
98
  const [, { showToast }] = useToast()
98
99
  const [{ configs }] = useConfig()
100
+ const [optimizationLoad] = useOptimizationLoad()
99
101
  const formMethods = useForm()
100
102
  const [recaptchaConfig] = useRecaptcha(enableReCaptcha)
101
103
  const [alertState, setAlertState] = useState({ open: false, content: [] })
@@ -118,9 +120,9 @@ const LoginFormUI = (props) => {
118
120
  scope: 'profile'
119
121
  }
120
122
 
121
- const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
122
- const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
123
- const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
123
+ const googleLoginEnabled = optimizationLoad?.result?.configs?.google_login_enabled?.value === '1'
124
+ const facebookLoginEnabled = optimizationLoad?.result?.configs?.facebook_login_enabled?.value === '1'
125
+ const appleLoginEnabled = optimizationLoad?.result?.configs?.apple_login_enabled?.value === '1'
124
126
 
125
127
  const spoonityTitle = configs?.spoonity_title?.value
126
128
 
@@ -22,6 +22,7 @@ export const ModalDialog = styled.div`
22
22
  max-height: 100vh;
23
23
  overflow: auto;
24
24
  overflow-x: ${({ disableOverflowX }) => disableOverflowX ? 'hidden' : 'auto'};
25
+ z-index: 10001;
25
26
  @media (min-width: 769px) {
26
27
  width: ${({ width }) => width || '50%'};
27
28
  max-height: 90vh;
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import { useLanguage, useOrder, useConfig, useSession } from 'ordering-components-external'
3
3
  import { MomentPopover } from '../../../../pwa/src/components/MomentPopover'
4
4
  import { OrderTypeSelectorHeader } from '../../../../../components/OrderTypeSelectorHeader'
@@ -13,6 +13,7 @@ import {
13
13
  FeatureItems,
14
14
  ItemInline
15
15
  } from './styles'
16
+ import { useWindowSize } from '../../../../../hooks/useWindowSize'
16
17
 
17
18
  export const OrderContextUI = (props) => {
18
19
  const { isCheckOut, setMapErrors, isCustomerMode, isBusinessList } = props
@@ -25,7 +26,7 @@ export const OrderContextUI = (props) => {
25
26
  const [openPopover, setOpenPopover] = useState({})
26
27
  const [modals, setModals] = useState({ listOpen: false, formOpen: false, citiesOpen: false })
27
28
  const [alertState, setAlertState] = useState({ open: false, content: [] })
28
-
29
+ const windowSize = useWindowSize()
29
30
  const userCustomer = JSON.parse(window.localStorage.getItem('user-customer'))
30
31
 
31
32
  const configTypes = configState?.configs?.order_types_allowed?.value.split('|').map(value => Number(value)) || []
@@ -66,6 +67,12 @@ export const OrderContextUI = (props) => {
66
67
  }
67
68
  }
68
69
 
70
+ useEffect(() => {
71
+ const handleCloseallPopovers = () => handleClosePopover('moment')
72
+ window.addEventListener('scroll', handleCloseallPopovers)
73
+ return () => window.removeEventListener('scroll', handleCloseallPopovers)
74
+ }, [])
75
+
69
76
  return (
70
77
  <>
71
78
  <Container isBusinessList={isBusinessList} hero={props.hideHero} isCheckOut={isCheckOut}>
@@ -78,7 +85,7 @@ export const OrderContextUI = (props) => {
78
85
  </AddressMenu>
79
86
  <FeatureItems>
80
87
  <ItemInline>
81
- <OrderTypeSelectorHeader configTypes={configTypes} />
88
+ <OrderTypeSelectorHeader configTypes={configTypes} autoCloseWhenScroll={windowSize.width < 576} />
82
89
  </ItemInline>
83
90
  {isPreOrderSetting && (
84
91
  <ItemInline>
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { useLanguage, useUtils } from 'ordering-components-external'
2
+ import { useLanguage, useUtils, useConfig } from 'ordering-components-external'
3
3
  import { ArrowRight, CheckCircleFill } from 'react-bootstrap-icons'
4
4
  import { Button } from '../../styles/Buttons'
5
5
  import { formatSeconds, getTraduction } from '../../../../../utils'
@@ -21,6 +21,7 @@ export const OrderHistory = (props) => {
21
21
 
22
22
  const [, t] = useLanguage()
23
23
  const [{ parseDate }] = useUtils()
24
+ const [{ configs }] = useConfig()
24
25
 
25
26
  const getLogisticTagStatus = (status) => {
26
27
  switch (status) {
@@ -113,7 +114,7 @@ export const OrderHistory = (props) => {
113
114
  {t('VIA', 'Via')}{' '}
114
115
  {order.app_id ? t(order.app_id.toUpperCase(), order.app_id) : t('OTHER', 'Other')}
115
116
  </h3>
116
- <p>{parseDate(order.created_at, { outputFormat: 'MMM DD, hh:mm A' })}</p>
117
+ <p>{parseDate(order.created_at, { outputFormat: `MMM DD, ${configs?.general_hour_format?.value}` })}</p>
117
118
  </DetailWrapper>
118
119
  </HistoryItemWrapper>
119
120
  )}
@@ -152,7 +153,7 @@ export const OrderHistory = (props) => {
152
153
  ) : <>{t('DRIVER_UNASSIGNED', 'Driver unassigned')}</>}
153
154
  </h3>
154
155
  )}
155
- <p>{parseDate(message.created_at, { outputFormat: 'MMM DD, hh:mm A' })}</p>
156
+ <p>{parseDate(message.created_at, { outputFormat: `MMM DD, ${configs?.general_hour_format?.value}` })}</p>
156
157
  </DetailWrapper>
157
158
  </HistoryItemWrapper>
158
159
  ))}
@@ -424,7 +424,7 @@ const OrderDetailsUI = (props) => {
424
424
  {activeStatus.includes(order?.status) ? (
425
425
  <OrderEta order={order} />
426
426
  ) : (
427
- parseDate(order?.reporting_data?.at[`status:${order.status}`])
427
+ parseDate(order?.reporting_data?.at[`status:${order.status}`], { outputFormat: `YYYY-MM-DD ${configs?.general_hour_format?.value}` })
428
428
  )}
429
429
  </p>
430
430
  )}
@@ -0,0 +1,70 @@
1
+ import { PaymentOptionStripe, useLanguage, useSession } from 'ordering-components-external'
2
+ import React, { useEffect, useState } from 'react'
3
+ import { CardFormCustom } from '../CardFormCustom'
4
+ import Modal from '../Modal'
5
+ import { PaymentOptionStripeUI } from '../PaymentOptionStripe'
6
+ import { AddNewCard } from '../PaymentOptionStripe/styles'
7
+
8
+ const PaymentOptionCardUI = (props) => {
9
+ const {
10
+ deleteCard,
11
+ cardsList,
12
+ handleCardClick,
13
+ handleNewCard,
14
+ paymethodSelected,
15
+ cardSelected,
16
+ gateway,
17
+ paymethodsWithoutSaveCards,
18
+ onSelectCard
19
+ } = props
20
+
21
+ const [, t] = useLanguage()
22
+ const [{ token }] = useSession()
23
+
24
+ const [addCardOpen, setAddCardOpen] = useState(false)
25
+
26
+ useEffect(() => {
27
+ if (cardsList?.cards?.length > 0) {
28
+ setAddCardOpen(true)
29
+ }
30
+ }, [cardsList?.cards])
31
+
32
+ return (
33
+ <>
34
+ <PaymentOptionStripeUI
35
+ deleteCard={deleteCard}
36
+ cardsList={cardsList}
37
+ handleCardClick={handleCardClick}
38
+ handleNewCard={handleNewCard}
39
+ paymethodSelected={paymethodSelected}
40
+ cardSelected={cardSelected}
41
+ gateway={gateway}
42
+ onSelectCard={onSelectCard}
43
+ />
44
+
45
+ {token && !cardsList.loading && (!cardSelected || !paymethodsWithoutSaveCards.includes(gateway)) && (
46
+ <AddNewCard>
47
+ <span onClick={() => setAddCardOpen(true)}>{t('ADD_NEW_CARD', 'Add new card')}</span>
48
+ </AddNewCard>
49
+ )}
50
+
51
+ <Modal
52
+ open={addCardOpen}
53
+ onClose={() => setAddCardOpen(false)}
54
+ title={t('ADD_NEW_CARD', 'Add new card')}
55
+ >
56
+ <CardFormCustom handleNewCard={handleNewCard} setAddCardOpen={setAddCardOpen} />
57
+ </Modal>
58
+ </>
59
+ )
60
+ }
61
+
62
+ export const PaymentOptionCard = (props) => {
63
+ const paymentOptionStripeProps = {
64
+ ...props,
65
+ UIComponent: PaymentOptionCardUI
66
+ }
67
+ return (
68
+ <PaymentOptionStripe {...paymentOptionStripeProps} />
69
+ )
70
+ }
@@ -5,7 +5,9 @@ import {
5
5
  useSession,
6
6
  useLanguage
7
7
  } from 'ordering-components-external'
8
- import FiMoreVertical from '@meronex/icons/fi/FiMoreVertical'
8
+ import IosRadioButtonOn from '@meronex/icons/ios/IosRadioButtonOn'
9
+ import IosRadioButtonOff from '@meronex/icons/ios/IosRadioButtonOff'
10
+ import { Trash } from 'react-bootstrap-icons'
9
11
  import { useTheme } from 'styled-components'
10
12
 
11
13
  import { Modal } from '../Modal'
@@ -22,16 +24,18 @@ import {
22
24
  CardItemActions,
23
25
  BlockLoading,
24
26
  AddNewCard,
25
- ActionsContent,
26
27
  CardItemActionsWrapper
27
28
  } from './styles'
28
29
 
29
- const PaymentOptionStripeUI = (props) => {
30
+ export const PaymentOptionStripeUI = (props) => {
30
31
  const {
31
32
  deleteCard,
32
33
  cardsList,
33
34
  handleCardClick,
34
- handleNewCard
35
+ handleNewCard,
36
+ paymethodSelected,
37
+ cardSelected,
38
+ gateway
35
39
  } = props
36
40
  const [{ token }] = useSession()
37
41
  const [, t] = useLanguage()
@@ -39,6 +43,8 @@ const PaymentOptionStripeUI = (props) => {
39
43
 
40
44
  const [addCartOpen, setAddCardOpen] = useState(false)
41
45
 
46
+ const paymethodsWithoutSaveCards = ['credomatic']
47
+
42
48
  const _handleNewCard = (card) => {
43
49
  setAddCardOpen(false)
44
50
  handleNewCard(card)
@@ -55,6 +61,12 @@ const PaymentOptionStripeUI = (props) => {
55
61
  })
56
62
  }
57
63
 
64
+ useEffect(() => {
65
+ if (!cardsList?.loading && cardsList?.cards?.length === 0 && !paymethodsWithoutSaveCards.includes(gateway)) {
66
+ setAddCardOpen(true)
67
+ }
68
+ }, [cardsList?.loading])
69
+
58
70
  return (
59
71
  <>
60
72
  {props.beforeElements?.map((BeforeElement, i) => (
@@ -79,7 +91,7 @@ const PaymentOptionStripeUI = (props) => {
79
91
  )}
80
92
  {token && cardsList.cards && cardsList.cards.length > 0 && (
81
93
  <>
82
- {cardsList?.cards?.map((card, i) => (
94
+ {cardsList?.cards?.map((card, i) =>
83
95
  <PaymentCard
84
96
  {...props}
85
97
  key={i}
@@ -87,11 +99,14 @@ const PaymentOptionStripeUI = (props) => {
87
99
  handleDeleteCard={() => handleDeleteCard(card)}
88
100
  card={card}
89
101
  defaultSelected={i === 0}
102
+ active={(paymethodSelected || cardSelected?.id) === card.id}
103
+ cardSelected={cardSelected}
104
+ paymethodSelected={paymethodSelected}
90
105
  />
91
- ))}
106
+ )}
92
107
  </>
93
108
  )}
94
- {token && !cardsList.loading && (
109
+ {token && !cardsList.loading && !paymethodsWithoutSaveCards.includes(gateway) && (
95
110
  <AddNewCard>
96
111
  <span onClick={() => setAddCardOpen(true)}>{t('ADD_NEW_CARD', 'Add new card')}</span>
97
112
  </AddNewCard>
@@ -148,14 +163,15 @@ export const PaymentCard = (props) => {
148
163
  handleDeleteCard,
149
164
  card,
150
165
  handleCardClick,
151
- onSelectCard
166
+ onSelectCard,
167
+ active,
168
+ cardSelected
152
169
  } = props
153
170
 
154
- const [, t] = useLanguage()
155
- const theme = useTheme()
156
171
  const [isShowActions, setIsShowActions] = useState(false)
157
172
  const cardActionsRef = useRef(null)
158
173
  const actionWrapperRef = useRef(null)
174
+ const theme = useTheme()
159
175
 
160
176
  const handleClickOutside = (e) => {
161
177
  if (!isShowActions) return
@@ -168,7 +184,8 @@ export const PaymentCard = (props) => {
168
184
  const handleChangeDefaultCard = (e) => {
169
185
  if (actionWrapperRef.current?.contains(e.target)) return
170
186
  handleCardClick(card)
171
- onSelectCard({
187
+ onSelectCard && onSelectCard({
188
+ ...cardSelected,
172
189
  id: card.id,
173
190
  type: 'card',
174
191
  card: {
@@ -178,6 +195,19 @@ export const PaymentCard = (props) => {
178
195
  })
179
196
  }
180
197
 
198
+ useEffect(() => {
199
+ if (!cardSelected) return
200
+ onSelectCard && onSelectCard({
201
+ ...cardSelected,
202
+ id: cardSelected?.id,
203
+ type: 'card',
204
+ card: {
205
+ brand: cardSelected?.brand,
206
+ last4: cardSelected?.last4
207
+ }
208
+ })
209
+ }, [cardSelected])
210
+
181
211
  useEffect(() => {
182
212
  window.addEventListener('click', handleClickOutside)
183
213
  return () => window.removeEventListener('click', handleClickOutside)
@@ -186,25 +216,21 @@ export const PaymentCard = (props) => {
186
216
  return (
187
217
  <CardItem onClick={handleChangeDefaultCard} isCursor>
188
218
  <CardItemContent>
219
+ <span className='checks'>
220
+ {active ? <IosRadioButtonOn /> : <IosRadioButtonOff />}
221
+ </span>
189
222
  <div>
190
223
  <img src={getIconCard(card?.brand)} alt={card?.brand} />
191
224
  </div>
192
225
  <span>
193
- {card?.brand} {card.last4}
226
+ XXXX-XXXX-XXXX-{card?.last4}
194
227
  </span>
195
228
  </CardItemContent>
196
229
  <CardItemActions>
197
230
  <CardItemActionsWrapper ref={actionWrapperRef}>
198
231
  <span ref={cardActionsRef}>
199
- <FiMoreVertical onClick={() => setIsShowActions(true)} />
232
+ <Trash color={theme.colors.lightGray} onClick={() => handleDeleteCard()} />
200
233
  </span>
201
- {
202
- isShowActions && (
203
- <ActionsContent>
204
- <div className='delete' onClick={handleDeleteCard}>{t('DELETE', 'Delete')}</div>
205
- </ActionsContent>
206
- )
207
- }
208
234
  </CardItemActionsWrapper>
209
235
  </CardItemActions>
210
236
  </CardItem>