ordering-ui-admin-external 1.23.3 → 1.23.5

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.
@@ -10,12 +10,16 @@ import {
10
10
  Square as UnCheckedIcon,
11
11
  InfoCircle,
12
12
  RecordCircleFill,
13
- Circle
13
+ Circle,
14
+ InfoCircleFill
14
15
  } from 'react-bootstrap-icons'
15
16
 
16
17
  import { useTheme } from 'styled-components'
17
18
  import { Alert, Modal, ImageCrop, ColorPicker } from '../../Shared'
18
19
  import { ContentForm } from '../ContentForm'
20
+ import Skeleton from 'react-loading-skeleton'
21
+ import { AdvancedSettings } from '../AdvancedSettings'
22
+ import { CustomDomain } from '../CustomDomain'
19
23
  import { bytesConverter } from '../../../utils'
20
24
  import {
21
25
  Container,
@@ -44,10 +48,12 @@ import {
44
48
  HeaderInfoWrapper,
45
49
  InfoContent,
46
50
  RadioItem,
47
- SlugWrapper
51
+ SlugWrapper,
52
+ CustomeDomainDesc,
53
+ TitleWrapper,
54
+ CustomDomainInfo,
55
+ CustomDomainInfoContent
48
56
  } from './styles'
49
- import Skeleton from 'react-loading-skeleton'
50
- import { AdvancedSettings } from '../AdvancedSettings'
51
57
 
52
58
  const OrderingWebsiteUI = (props) => {
53
59
  const {
@@ -57,7 +63,9 @@ const OrderingWebsiteUI = (props) => {
57
63
  handleUpdateSiteTheme,
58
64
  advancedValues,
59
65
  setAdvancedValues,
60
- themesList
66
+ themesList,
67
+ site,
68
+ setSite
61
69
  } = props
62
70
 
63
71
  const [, t] = useLanguage()
@@ -75,6 +83,7 @@ const OrderingWebsiteUI = (props) => {
75
83
  const [homePageContent, setHomePageContent] = useState(false)
76
84
  const [footerContent, setFooterContent] = useState(false)
77
85
  const [selectedSetting, setSelectedSetting] = useState('basic')
86
+ const [isCustomDomain, setIsCustomDomain] = useState(false)
78
87
 
79
88
  const settingsList = [
80
89
  { key: 'basic', name: t('BASIC_SETTINGS', 'Basic Settings') },
@@ -221,7 +230,21 @@ const OrderingWebsiteUI = (props) => {
221
230
  <FormWrapper>
222
231
  <InputFormWrapper>
223
232
  <InnerBlock>
224
- <h4>{t('WEBSITE_SETTINGS', 'Website settings')}</h4>
233
+ <TitleWrapper>
234
+ <h4>{t('WEBSITE_SETTINGS', 'Website settings')}</h4>
235
+ <CustomDomainInfo>
236
+ <IconButton
237
+ color='primary'
238
+ >
239
+ <InfoCircleFill />
240
+ </IconButton>
241
+ <CustomDomainInfoContent>
242
+ <span>{t('CUSTOM_DOMAIN_INFO_DESC_1', 'When creating a custom domain, add your domain or subdomain without http protocol or slashes.')}</span>
243
+ <span>{t('EXAMPLE', 'Example')}: www.customerwebsite.ordering.co</span>
244
+ <span>{t('CUSTOM_DOMAIN_INFO_DESC_2', 'If you have problems with the set-up, please contact our')}<a href='https://www.ordering.co/contact-ordering' rel='noopener noreferrer' target='_blank'>{t('CUSTOMER_SUPPORT_TEAM', 'customer support team')}</a></span>
245
+ </CustomDomainInfoContent>
246
+ </CustomDomainInfo>
247
+ </TitleWrapper>
225
248
  <FormGroup>
226
249
  <label>
227
250
  {orderingTheme?.loading ? (
@@ -295,14 +318,47 @@ const OrderingWebsiteUI = (props) => {
295
318
  {orderingTheme?.loading ? (
296
319
  <Skeleton height={40} style={{ width: '100%' }} />
297
320
  ) : (
298
- <Button
299
- color='primary'
300
- outline
301
- borderRadius='8px'
302
- onClick={() => window.open('https://www.ordering.co/custom-domain-change', '_blank')}
303
- >
304
- {t('REQUEST_CUSTOM_DOMAIN', 'Request custom domain')}
305
- </Button>
321
+ <>
322
+ {site?.domain && site?.ssl_status !== 'error' && (
323
+ <TemporalDomail isDisabled={site?.ssl_process_status === 'pending'} marginBottom={site?.ssl_process_status === 'ended'}>
324
+ {t('VISIT', 'Visit')}: <a href={`https://${site?.domain}`} rel='noopener noreferrer' target='_blank'>https://{site?.domain}</a>
325
+ </TemporalDomail>
326
+ )}
327
+ {(site?.ssl_process_status === 'ended') && (
328
+ <Button
329
+ color='primary'
330
+ outline
331
+ borderRadius='8px'
332
+ onClick={() => setIsCustomDomain(true)}
333
+ >
334
+ {site?.domain ? t('REQUEST_CUSTOM_DOMAIN', 'Request custom domain') : t('CHANGE_CUSTOM_DOMAIN', 'Change custom domain')}
335
+ </Button>
336
+ )}
337
+ {site?.domain && (
338
+ <>
339
+ {site?.ssl_status === 'issued' && (
340
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_ISSUED', 'Your domain is now added , please verify the custom domain link above.')}</CustomeDomainDesc>)}
341
+ {site?.ssl_status === 'pre-issued' && (
342
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_PRE_ISSUED', 'Process almost finish, please wait')}</CustomeDomainDesc>
343
+ )}
344
+ {site?.ssl_status === 'error' && (
345
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_ERROR', 'Custom domain can\'t be created, please try again with valid data')}</CustomeDomainDesc>
346
+ )}
347
+ {((site?.ssl_status === 'pending_validation') || (site?.ssl_status === 'void' && site?.ssl_process_status === 'pending')) && (
348
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_PENDING_VALIDATION', 'A custom domain is being created, please wait')}</CustomeDomainDesc>
349
+ )}
350
+ {site?.ssl_status === 'revoked' && (
351
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_REVOKED', 'Warning: Custom domain is revoked')}</CustomeDomainDesc>
352
+ )}
353
+ {site?.ssl_status === 'cancelled' && (
354
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_CANCELLED', 'Custom domain is cancelled')}</CustomeDomainDesc>
355
+ )}
356
+ {site?.ssl_status === 'expired' && (
357
+ <CustomeDomainDesc>{t('CUSTOM_DOMAIN_STATUS_EXPIRED', 'Custom domain is expired')}</CustomeDomainDesc>
358
+ )}
359
+ </>
360
+ )}
361
+ </>
306
362
  )}
307
363
  </FormGroup>
308
364
  </InnerBlock>
@@ -547,14 +603,14 @@ const OrderingWebsiteUI = (props) => {
547
603
  </Button>
548
604
  </FormWrapper>
549
605
  )}
550
- {/* {selectedSetting === 'advanced' && !orderingTheme?.loading && (
606
+ {selectedSetting === 'advanced' && !orderingTheme?.loading && (
551
607
  <AdvancedSettings
552
608
  themesList={themesList}
553
609
  advancedValues={advancedValues}
554
610
  setAdvancedValues={setAdvancedValues}
555
611
  handleUpdateSiteTheme={handleUpdateSiteTheme}
556
612
  />
557
- )} */}
613
+ )}
558
614
  </Container>
559
615
  <Alert
560
616
  title={t('ORDERING', 'Ordering')}
@@ -606,6 +662,17 @@ const OrderingWebsiteUI = (props) => {
606
662
  type='footer_content'
607
663
  />
608
664
  </Modal>
665
+ <Modal
666
+ width='70%'
667
+ open={isCustomDomain}
668
+ onClose={() => setIsCustomDomain(false)}
669
+ >
670
+ <CustomDomain
671
+ site={site}
672
+ onClose={() => setIsCustomDomain(false)}
673
+ setSite={setSite}
674
+ />
675
+ </Modal>
609
676
  </>
610
677
  )
611
678
  }
@@ -617,4 +684,4 @@ export const OrderingWebsite = (props) => {
617
684
  appId: 'website'
618
685
  }
619
686
  return <OrderingWebsiteController {...orderingWebsiteProps} />
620
- }
687
+ }
@@ -178,6 +178,18 @@ export const TemporalDomail = styled.div`
178
178
  > a {
179
179
  color: ${props => props.theme.colors.primary};
180
180
  }
181
+
182
+ ${({ isDisabled }) => isDisabled && css`
183
+ pointer-events: none;
184
+ color: ${props => props.theme.colors.disabled};
185
+ > a {
186
+ color: ${props => props.theme.colors.disabled};
187
+ }
188
+ `}
189
+
190
+ ${({ marginBottom }) => marginBottom && css`
191
+ margin-bottom: 10px;
192
+ `}
181
193
  `
182
194
 
183
195
  export const ImageFormGroup = styled.div`
@@ -429,6 +441,10 @@ export const InfoContent = styled.div`
429
441
  right: initial;
430
442
  `}
431
443
 
444
+ span {
445
+ display: block;
446
+ }
447
+
432
448
  > a {
433
449
  color: ${props => props.theme.colors.primary};
434
450
  margin: 0 5px;
@@ -472,16 +488,123 @@ export const RadioItem = styled.div`
472
488
  line-height: 24px;
473
489
  }
474
490
  `
475
- export const SlugWrapper = styled.div`
476
- margin-bottom: 20px;
477
- label {
491
+
492
+ export const CustomeDomainDesc = styled.p`
493
+ margin-top: 5px;
494
+ margin-bottom: 0px;
495
+ font-weight: 400;
496
+ font-size: 12px;
497
+ `
498
+
499
+ export const TitleWrapper = styled.div`
500
+ display: flex;
501
+ align-items: center;
502
+ `
503
+
504
+ export const CustomDomainInfo = styled.div`
505
+ position: relative;
506
+
507
+ > button {
508
+ height: 21px;
509
+ svg {
510
+ width: 13px;
511
+ height: 13px;
512
+ color: ${props => props.theme.colors.headingColor};
513
+ }
514
+ }
515
+ &:hover > div {
516
+ visibility: visible;
517
+ opacity: 1;
518
+ }
519
+ `
520
+
521
+ export const CustomDomainInfoContent = styled.div`
522
+ position: absolute;
523
+ top: 100%;
524
+ z-index: 999;
525
+ background: ${props => props.theme.colors.backgroundInfo};
526
+ box-sizing: border-box;
527
+ box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.12);
528
+ border-radius: 7.6px;
529
+ padding: 8px 12px;
530
+ font-size: 12px;
531
+ line-height: 18px;
532
+ min-width: 150px;
533
+ transition: all 0.3s linear;
534
+ visibility: hidden;
535
+ opacity: 0;
536
+ right: -100px;
537
+ ${props => props.theme.rtl && css`
538
+ left: 0px;s
539
+ right: initial;
540
+ `}
541
+
542
+ span {
478
543
  display: block;
479
- margin-bottom: 12px;
480
- font-weight: 400;
544
+ }
545
+
546
+ a {
547
+ color: ${props => props.theme.colors.primary};
548
+ padding-left: 5px;
549
+ }
550
+
551
+ @media (min-width: 576px) {
552
+ min-width: 350px;
553
+ padding: 10px 16px;
554
+ left: 0px;
555
+ ${props => props.theme.rtl && css`
556
+ right: 0px;
557
+ left: initial;
558
+ `}
559
+ }
560
+ `
561
+ export const Option = styled.div`
562
+ display: flex;
563
+ align-items: center;
564
+ cursor: pointer;
565
+ padding: 5px;
566
+ border-radius: 7.6px;
567
+ img {
568
+ min-height: 38px;
569
+ min-width: 38px;
570
+ height: 38px;
571
+ width: 38px;
572
+ border-radius: 8px;
573
+ object-fit: cover;
574
+ box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
575
+ ${props => props.theme?.rtl ? css`
576
+ margin-left: 8px;
577
+ ` : css`
578
+ margin-right: 8px;
579
+ `}
580
+ }
581
+ > span {
582
+ max-width: 200px;
481
583
  font-size: 14px;
482
- line-height: 24px;
584
+ font-weight: 700;
585
+ text-overflow: ellipsis;
586
+ white-space: nowrap;
587
+ overflow: hidden;
483
588
  }
484
- > input, textarea {
589
+
590
+ @media (min-width: 768px) {
591
+ > span {
592
+ max-width: 560px;
593
+ }
594
+ }
595
+ `
596
+ export const SelectWrapper = styled.div`
597
+ margin-bottom: 20px;
598
+
599
+ .select {
485
600
  width: 100%;
601
+ background: ${props => props.theme.colors.secundary};
602
+ border: none;
603
+ font-size: 14px;
604
+
605
+ > div:first-child {
606
+ padding-top: 4px;
607
+ padding-bottom: 4px;
608
+ }
486
609
  }
487
610
  `
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react'
2
2
  import parsePhoneNumber from 'libphonenumber-js'
3
3
  import PhoneInput from 'react-phone-number-input'
4
4
  import { useLanguage, useConfig, useSession } from 'ordering-components-admin-external'
5
-
5
+ import { findExitingCode } from '../../../utils'
6
6
  import { Container, ErrorMsg } from './styles'
7
7
 
8
8
  export const InputPhoneNumber = (props) => {
@@ -42,7 +42,7 @@ export const InputPhoneNumber = (props) => {
42
42
  <PhoneInput
43
43
  disabled={disabled}
44
44
  placeholder={t('PHONE_NUMBER', 'Phone number')}
45
- defaultCountry={configs?.default_country_code?.value}
45
+ defaultCountry={findExitingCode(configs?.default_country_code?.value?.toUpperCase())}
46
46
  value={value}
47
47
  displayInitialValueAsLocalNumber
48
48
  onChange={(val) => setValue && setValue(val, isValidPhoneNumber(val))}
@@ -51,7 +51,8 @@ export const BusinessDetailsUI = (props) => {
51
51
  actionStatus,
52
52
  handleUpdatePreorderConfigs,
53
53
  handleUpdateSpoonityKey,
54
- spoonityKeyState
54
+ spoonityKeyState,
55
+ siteState
55
56
  } = props
56
57
 
57
58
  const history = useHistory()
@@ -185,6 +186,7 @@ export const BusinessDetailsUI = (props) => {
185
186
  handleDeleteBusiness={handleDeleteBusiness}
186
187
  extraOpen={extraOpen}
187
188
  spoonityConfig={spoonityConfig}
189
+ siteState={siteState}
188
190
  />
189
191
  )}
190
192
  {extraOpen && (
@@ -74,7 +74,8 @@ const BusinessProductsListingUI = (props) => {
74
74
  setFees,
75
75
  getBusiness,
76
76
  businessTypes,
77
- setBusinessTypes
77
+ setBusinessTypes,
78
+ siteState
78
79
  } = props
79
80
 
80
81
  const history = useHistory()
@@ -210,7 +211,10 @@ const BusinessProductsListingUI = (props) => {
210
211
  }
211
212
 
212
213
  const handleOpenSite = () => {
213
- window.open(`https://${ordering.project}.tryordering.com/store/${businessState?.business?.slug}`, '_blank')
214
+ const url = siteState?.site?.domain && siteState?.site?.ssl_process_status === 'ended'
215
+ ? `https://${siteState?.site?.domain}/store/${businessState?.business?.slug}`
216
+ : `https://${ordering.project}.tryordering.com/store/${businessState?.business?.slug}`
217
+ window.open(url, '_blank')
214
218
  }
215
219
 
216
220
  const handleOpenAddBusiness = () => {
@@ -38,7 +38,8 @@ export const BusinessSummary = (props) => {
38
38
  handleDuplicateBusiness,
39
39
  handleDeleteBusiness,
40
40
  extraOpen,
41
- spoonityConfig
41
+ spoonityConfig,
42
+ siteState
42
43
  } = props
43
44
  const [, t] = useLanguage()
44
45
  const [{ optimizeImage }] = useUtils()
@@ -56,7 +57,10 @@ export const BusinessSummary = (props) => {
56
57
  }
57
58
 
58
59
  const handleOpenSite = () => {
59
- window.open(`https://${ordering.project}.tryordering.com/store/${businessState?.business?.slug}`, '_blank')
60
+ const url = siteState?.site?.domain && siteState?.site?.ssl_process_status === 'ended'
61
+ ? `https://${siteState?.site?.domain}/store/${businessState?.business?.slug}`
62
+ : `https://${ordering.project}.tryordering.com/store/${businessState?.business?.slug}`
63
+ window.open(url, '_blank')
60
64
  }
61
65
 
62
66
  const itemsExcluded = !!spoonityConfig ? ['publishing', 'personalization'] : ['publishing', 'spoonity_key', 'personalization']
@@ -110,10 +114,10 @@ export const BusinessSummary = (props) => {
110
114
  key: 'ordering_channels',
111
115
  value: t('ORDERING_CHANNELS', 'Ordering channels')
112
116
  },
113
- // {
114
- // key: 'publishing',
115
- // value: t('PUBLISHING', 'Publishing')
116
- // },
117
+ {
118
+ key: 'publishing',
119
+ value: t('PUBLISHING', 'Publishing')
120
+ },
117
121
  {
118
122
  key: 'sales_channels',
119
123
  value: t('SALES_CHANNELS', 'Sales channels')
@@ -3,7 +3,7 @@ import FaCcMastercard from '@meronex/icons/fa/FaCcMastercard'
3
3
  import FaCcVisa from '@meronex/icons/fa/FaCcVisa'
4
4
  import FaCreditCard from '@meronex/icons/fa/FaCreditCard'
5
5
  import moment from 'moment'
6
- import { useLanguage } from 'ordering-components-admin-external'
6
+ import { useLanguage, CODES } from 'ordering-components-admin-external'
7
7
 
8
8
  export const optimizeImage = (url, params, fallback) => {
9
9
  if (!url && fallback) return fallback
@@ -194,6 +194,11 @@ export const getSeconds = (seconds) => {
194
194
  return Math.floor(remain - Math.floor(remain / 60) * 60)
195
195
  }
196
196
 
197
+ export const findExitingCode = (countryCode) => {
198
+ const code = CODES.find(code => code.countryCode === (countryCode || '').toUpperCase())
199
+ return code?.countryCode
200
+ }
201
+
197
202
  /**
198
203
  * Function to check if a number is decimal or not
199
204
  * @param {*} value number to check if decimal or not