ordering-ui-admin-external 1.23.5 → 1.24.0
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/_bundles/{ordering-ui-admin.a1255b2c1a2d4b87080d.js → ordering-ui-admin.0c354f3e7da49f56465b.js} +2 -2
- package/_modules/components/CartRecovery/RecoveryActionAdd/index.js +325 -0
- package/_modules/components/CartRecovery/RecoveryGeneral/index.js +41 -17
- package/_modules/components/Delivery/DriversCompaniesList/styles.js +1 -1
- package/_modules/components/Delivery/DriversCompaniesListing/index.js +20 -2
- package/_modules/components/Delivery/DriversCompaniesListing/styles.js +2 -2
- package/_modules/components/Delivery/DriversCompanyAddForm/GeneralForm/index.js +122 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/GeneralForm/styles.js +21 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/ScheduleForm/index.js +27 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/ScheduleForm/styles.js +14 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/WebhooksForm/index.js +60 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/WebhooksForm/styles.js +16 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/index.js +114 -0
- package/_modules/components/Delivery/DriversCompanyAddForm/styles.js +18 -0
- package/_modules/components/MyProducts/AdvancedSettings/index.js +66 -82
- package/_modules/components/MyProducts/AdvancedSettings/styles.js +40 -44
- package/_modules/components/MyProducts/OrderingWebsite/SelectBusiness.js +59 -0
- package/_modules/components/MyProducts/OrderingWebsite/SelectFranchise.js +59 -0
- package/_modules/components/MyProducts/OrderingWebsite/index.js +21 -29
- package/_modules/components/MyProducts/OrderingWebsite/styles.js +1 -1
- package/_modules/components/MyProducts/UploadAudio/index.js +170 -0
- package/_modules/components/MyProducts/UploadAudio/styles.js +30 -0
- package/_modules/components/MyProducts/index.js +8 -1
- package/_modules/components/Orders/DeliveriesLocation/index.js +1 -0
- package/_modules/components/Orders/OrderBill/index.js +4 -3
- package/_modules/components/Orders/OrderContactInformation/index.js +14 -12
- package/_modules/components/Orders/OrderDetails/index.js +6 -131
- package/_modules/components/Orders/OrdersTable/index.js +2 -2
- package/_modules/components/Settings/NotificationSetting/index.js +1 -1
- package/_modules/components/Settings/SettingsList/index.js +1 -1
- package/_modules/components/Settings/SettingsList/styles.js +2 -2
- package/_modules/components/SidebarMenu/index.js +22 -22
- package/_modules/components/Stores/BusinessDetails/index.js +2 -1
- package/_modules/components/Stores/BusinessDeviceDetail/index.js +66 -16
- package/_modules/components/Stores/BusinessDeviceDetail/styles.js +7 -5
- package/_modules/components/Stores/BusinessSalesChannel/index.js +13 -4
- package/_modules/components/Stores/BusinessSalesFacebook/FacebookProfile.js +2 -2
- package/_modules/components/Stores/BusinessSalesFacebook/index.js +2 -2
- package/_modules/components/Stores/BusinessSalesGoogle/index.js +2 -2
- package/_modules/components/Stores/BusinessSalesInstagram/AdvancedInstagram.js +3 -2
- package/_modules/components/Stores/BusinessSalesInstagram/GeneralInstagram.js +2 -2
- package/_modules/components/Stores/BusinessSalesInstagram/index.js +3 -5
- package/_modules/components/Users/CustomersListing/index.js +5 -3
- package/_modules/utils/index.js +203 -2
- package/index-template.js +1 -1
- package/index.html +1 -0
- package/package.json +2 -2
- package/public/push/onesignal/OneSignalSDKUpdaterWorker.js +1 -0
- package/public/push/onesignal/OneSignalSDKWorker.js +1 -0
- package/src/components/CartRecovery/RecoveryActionAdd/index.js +355 -0
- package/src/components/CartRecovery/RecoveryGeneral/index.js +23 -4
- package/src/components/Delivery/DriversCompaniesList/styles.js +1 -1
- package/src/components/Delivery/DriversCompaniesListing/index.js +29 -12
- package/src/components/Delivery/DriversCompaniesListing/styles.js +1 -1
- package/src/components/Delivery/DriversCompanyAddForm/GeneralForm/index.js +120 -0
- package/src/components/Delivery/DriversCompanyAddForm/GeneralForm/styles.js +32 -0
- package/src/components/Delivery/DriversCompanyAddForm/ScheduleForm/index.js +29 -0
- package/src/components/Delivery/DriversCompanyAddForm/ScheduleForm/styles.js +11 -0
- package/src/components/Delivery/DriversCompanyAddForm/WebhooksForm/index.js +69 -0
- package/src/components/Delivery/DriversCompanyAddForm/WebhooksForm/styles.js +24 -0
- package/src/components/Delivery/DriversCompanyAddForm/index.js +121 -0
- package/src/components/Delivery/DriversCompanyAddForm/styles.js +39 -0
- package/src/components/MyProducts/AdvancedSettings/index.js +35 -36
- package/src/components/MyProducts/AdvancedSettings/styles.js +3 -11
- package/src/components/MyProducts/OrderingWebsite/SelectBusiness.js +47 -0
- package/src/components/MyProducts/OrderingWebsite/SelectFranchise.js +47 -0
- package/src/components/MyProducts/OrderingWebsite/index.js +20 -30
- package/src/components/MyProducts/OrderingWebsite/styles.js +0 -4
- package/src/components/MyProducts/UploadAudio/index.js +168 -0
- package/src/components/MyProducts/UploadAudio/styles.js +120 -0
- package/src/components/MyProducts/index.js +3 -1
- package/src/components/Orders/DeliveriesLocation/index.js +1 -0
- package/src/components/Orders/OrderBill/index.js +9 -6
- package/src/components/Orders/OrderContactInformation/index.js +5 -1
- package/src/components/Orders/OrderDetails/index.js +7 -35
- package/src/components/Orders/OrdersTable/index.js +3 -1
- package/src/components/Settings/NotificationSetting/index.js +2 -0
- package/src/components/Settings/SettingsList/index.js +53 -53
- package/src/components/Settings/SettingsList/styles.js +2 -1
- package/src/components/Settings/SettingsSelectUI/index.js +1 -1
- package/src/components/SidebarMenu/index.js +1 -0
- package/src/components/Stores/BusinessDetails/index.js +1 -0
- package/src/components/Stores/BusinessDeviceDetail/index.js +46 -7
- package/src/components/Stores/BusinessDeviceDetail/styles.js +11 -0
- package/src/components/Stores/BusinessSalesChannel/index.js +12 -6
- package/src/components/Stores/BusinessSalesFacebook/FacebookProfile.js +2 -2
- package/src/components/Stores/BusinessSalesFacebook/index.js +3 -3
- package/src/components/Stores/BusinessSalesGoogle/index.js +3 -3
- package/src/components/Stores/BusinessSalesInstagram/AdvancedInstagram.js +2 -2
- package/src/components/Stores/BusinessSalesInstagram/GeneralInstagram.js +2 -2
- package/src/components/Stores/BusinessSalesInstagram/index.js +3 -3
- package/src/components/Users/CustomersListing/index.js +2 -3
- package/src/utils/index.js +53 -0
- package/template/app.js +76 -3
- package/template/config.json +1 -0
- /package/_bundles/{ordering-ui-admin.a1255b2c1a2d4b87080d.js.LICENSE.txt → ordering-ui-admin.0c354f3e7da49f56465b.js.LICENSE.txt} +0 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
CopyInputWrapper
|
|
9
9
|
} from './styles'
|
|
10
10
|
|
|
11
|
-
export const FacebookProfile = ({
|
|
11
|
+
export const FacebookProfile = ({ storeUrl }) => {
|
|
12
12
|
const [, t] = useLanguage()
|
|
13
13
|
const theme = useTheme()
|
|
14
14
|
|
|
@@ -20,7 +20,7 @@ export const FacebookProfile = ({ businessSlug }) => {
|
|
|
20
20
|
<p>{t('BUSINESS_FACEBOOK_PROFILE_STEP1_DESC', 'Copy this link below. It’s your unique Ordering link for facebook.')}</p>
|
|
21
21
|
<CopyInputWrapper>
|
|
22
22
|
<Input
|
|
23
|
-
defaultValue='https://yourbusinessname.com/store/storename'
|
|
23
|
+
defaultValue={storeUrl || 'https://yourbusinessname.com/store/storename'}
|
|
24
24
|
disabled
|
|
25
25
|
/>
|
|
26
26
|
</CopyInputWrapper>
|
|
@@ -4,7 +4,7 @@ import { useWindowSize } from '../../../hooks/useWindowSize'
|
|
|
4
4
|
import {
|
|
5
5
|
Container,
|
|
6
6
|
Header,
|
|
7
|
-
LeftHeader
|
|
7
|
+
LeftHeader
|
|
8
8
|
// Tabs,
|
|
9
9
|
// Tab
|
|
10
10
|
} from './styles'
|
|
@@ -14,7 +14,7 @@ import { FacebookProfile } from './FacebookProfile'
|
|
|
14
14
|
import { FacebookPost } from './FacebookPost'
|
|
15
15
|
|
|
16
16
|
export const BusinessSalesFacebook = (props) => {
|
|
17
|
-
const { onClose, socialItem,
|
|
17
|
+
const { onClose, socialItem, storeUrl } = props
|
|
18
18
|
|
|
19
19
|
const { width } = useWindowSize()
|
|
20
20
|
// const [, t] = useLanguage()
|
|
@@ -74,7 +74,7 @@ export const BusinessSalesFacebook = (props) => {
|
|
|
74
74
|
</Tab>
|
|
75
75
|
))}
|
|
76
76
|
</Tabs> */}
|
|
77
|
-
{selectedTab === 'profile' && <FacebookProfile
|
|
77
|
+
{selectedTab === 'profile' && <FacebookProfile storeUrl={storeUrl} />}
|
|
78
78
|
{selectedTab === 'post' && <FacebookPost />}
|
|
79
79
|
</Container>
|
|
80
80
|
)
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
|
|
|
2
2
|
import { useLanguage } from 'ordering-components-admin-external'
|
|
3
3
|
import { useWindowSize } from '../../../hooks/useWindowSize'
|
|
4
4
|
import { IconButton, Input } from '../../../styles'
|
|
5
|
-
import { XLg
|
|
5
|
+
import { XLg } from 'react-bootstrap-icons'
|
|
6
6
|
import { useTheme } from 'styled-components'
|
|
7
7
|
import {
|
|
8
8
|
Container,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from './styles'
|
|
15
15
|
|
|
16
16
|
export const BusinessSalesGoogle = (props) => {
|
|
17
|
-
const { onClose, socialItem,
|
|
17
|
+
const { onClose, socialItem, storeUrl } = props
|
|
18
18
|
|
|
19
19
|
const { width } = useWindowSize()
|
|
20
20
|
const [, t] = useLanguage()
|
|
@@ -77,7 +77,7 @@ export const BusinessSalesGoogle = (props) => {
|
|
|
77
77
|
<p>{t('BUSINESS_GOOGLE_STEP3_DESC', 'Scroll down and find Order ahead links and Menu link fields. Paste the link below.')}</p>
|
|
78
78
|
<CopyInputWrapper isBottom>
|
|
79
79
|
<Input
|
|
80
|
-
defaultValue='https://yourbusinessname.com/store/storename'
|
|
80
|
+
defaultValue={storeUrl || 'https://yourbusinessname.com/store/storename'}
|
|
81
81
|
disabled
|
|
82
82
|
/>
|
|
83
83
|
</CopyInputWrapper>
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ImageWrapper
|
|
10
10
|
} from './styles'
|
|
11
11
|
|
|
12
|
-
export const AdvancedInstagram = (
|
|
12
|
+
export const AdvancedInstagram = ({ storeUrl }) => {
|
|
13
13
|
const [, t] = useLanguage()
|
|
14
14
|
const theme = useTheme()
|
|
15
15
|
|
|
@@ -40,7 +40,7 @@ export const AdvancedInstagram = (props) => {
|
|
|
40
40
|
/>
|
|
41
41
|
<CopyInputWrapper isBottom>
|
|
42
42
|
<Input
|
|
43
|
-
defaultValue='https://yourbusinessname.com/store/storename'
|
|
43
|
+
defaultValue={storeUrl || 'https://yourbusinessname.com/store/storename'}
|
|
44
44
|
disabled
|
|
45
45
|
/>
|
|
46
46
|
</CopyInputWrapper>
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
CopyInputWrapper
|
|
9
9
|
} from './styles'
|
|
10
10
|
|
|
11
|
-
export const GeneralInstagram = ({
|
|
11
|
+
export const GeneralInstagram = ({ storeUrl }) => {
|
|
12
12
|
const [, t] = useLanguage()
|
|
13
13
|
const theme = useTheme()
|
|
14
14
|
|
|
@@ -37,7 +37,7 @@ export const GeneralInstagram = ({ businessSlug }) => {
|
|
|
37
37
|
<p>{t('BUSINESS_INSTAGRAM_GENERAL_STEP5_DESC', 'Just add this link to the website field:')}</p>
|
|
38
38
|
<CopyInputWrapper isBottom>
|
|
39
39
|
<Input
|
|
40
|
-
defaultValue='https://yourbusinessname.com/store/storename'
|
|
40
|
+
defaultValue={storeUrl || 'https://yourbusinessname.com/store/storename'}
|
|
41
41
|
disabled
|
|
42
42
|
/>
|
|
43
43
|
</CopyInputWrapper>
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from './styles'
|
|
15
15
|
|
|
16
16
|
export const BusinessSalesInstagram = (props) => {
|
|
17
|
-
const { onClose, socialItem,
|
|
17
|
+
const { onClose, socialItem, storeUrl } = props
|
|
18
18
|
|
|
19
19
|
const { width } = useWindowSize()
|
|
20
20
|
const [, t] = useLanguage()
|
|
@@ -74,8 +74,8 @@ export const BusinessSalesInstagram = (props) => {
|
|
|
74
74
|
</Tab>
|
|
75
75
|
))}
|
|
76
76
|
</Tabs>
|
|
77
|
-
{selectedTab === 'general' && <GeneralInstagram
|
|
78
|
-
{selectedTab === 'advanced' && <AdvancedInstagram
|
|
77
|
+
{selectedTab === 'general' && <GeneralInstagram storeUrl={storeUrl} />}
|
|
78
|
+
{selectedTab === 'advanced' && <AdvancedInstagram />}
|
|
79
79
|
</Container>
|
|
80
80
|
)
|
|
81
81
|
}
|
|
@@ -129,16 +129,15 @@ const CustomersListingUI = (props) => {
|
|
|
129
129
|
<VerifiedStatusFilterContainer>
|
|
130
130
|
<Button
|
|
131
131
|
color={(orderFilterValue === '' || orderFilterValue === null) ? 'primary' : 'secundaryDark'}
|
|
132
|
-
onClick={() => handleChangeOrderFilterValue(
|
|
132
|
+
onClick={() => handleChangeOrderFilterValue(null)}
|
|
133
133
|
>
|
|
134
134
|
{t('ALL', 'All')}
|
|
135
|
-
{(orderFilterValue === '' || orderFilterValue === null) && <CloseIcon />}
|
|
136
135
|
</Button>
|
|
137
136
|
{orderList.map((item, i) => (
|
|
138
137
|
<Button
|
|
139
138
|
key={i}
|
|
140
139
|
color={orderFilterValue === item.value ? 'primary' : 'secundaryDark'}
|
|
141
|
-
onClick={() => handleChangeOrderFilterValue(item.value)}
|
|
140
|
+
onClick={() => handleChangeOrderFilterValue(prev => prev === item.value ? null : item.value)}
|
|
142
141
|
>
|
|
143
142
|
{item.name}
|
|
144
143
|
{orderFilterValue === item.value && <CloseIcon />}
|
package/src/utils/index.js
CHANGED
|
@@ -389,6 +389,59 @@ export const reviewCommentList = (type) => {
|
|
|
389
389
|
return reviews[type]
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
+
export const getOrderStatus = (status) => {
|
|
393
|
+
const orderStatus = [
|
|
394
|
+
{ key: 0, value: 'Pending Order', slug: 'PENDING_ORDER', percentage: 10 },
|
|
395
|
+
{ key: 1, value: 'Completed by admin', slug: 'COMPLETED_BY_ADMIN', percentage: 100 },
|
|
396
|
+
{ key: 2, value: 'Reject by admin', slug: 'REJECT_BY_ADMIN', percentage: 0 },
|
|
397
|
+
{ key: 3, value: 'Driver arrived by business', slug: 'DRIVER_IN_BUSINESS', percentage: 60 },
|
|
398
|
+
{ key: 4, value: 'Preparation Completed', slug: 'PREPARATION_COMPLETED', percentage: 20 },
|
|
399
|
+
{ key: 5, value: 'Reject by business', slug: 'REJECT_BY_BUSINESS', percentage: 0 },
|
|
400
|
+
{ key: 6, value: 'Reject by driver', slug: 'REJECT_BY_DRIVER', percentage: 0 },
|
|
401
|
+
{ key: 7, value: 'Accepted by business', slug: 'ACCEPTED_BY_BUSINESS', percentage: 15 },
|
|
402
|
+
{ key: 8, value: 'Accepted by driver', slug: 'ACCEPTED_BY_DRIVER', percentage: 40 },
|
|
403
|
+
{ key: 9, value: 'Pick up completed by driver', slug: 'PICK_UP_COMPLETED_BY_DRIVER', percentage: 70 },
|
|
404
|
+
{ key: 10, value: 'Pick up Failed by driver', slug: 'PICK_UP_FAILED_BY_DRIVER', percentage: 0 },
|
|
405
|
+
{ key: 11, value: 'Delivery completed by driver', slug: 'DELIVERY_COMPLETED_BY_DRIVER', percentage: 100 },
|
|
406
|
+
{ key: 12, value: 'Delivery Failed by driver', slug: 'DELIVERY_FAILED_BY_DRIVER', percentage: 0 },
|
|
407
|
+
{ key: 13, value: 'Preorder', slug: 'PREORDER', percentage: 0 },
|
|
408
|
+
{ key: 14, value: 'Order not ready', slug: 'ORDER_NOT_READY', percentage: 15 },
|
|
409
|
+
{ key: 15, value: 'Pickup completed by customer', slug: 'PICKUP_COMPLETED_BY_CUSTOMER', percentage: 100 },
|
|
410
|
+
{ key: 16, value: 'Canceled by customer', slug: 'CANCELED_BY_CUSTOMER', percentage: 0 },
|
|
411
|
+
{ key: 17, value: 'Not picked by customer', slug: 'NOT_PICKED_BY_CUSTOMER', percentage: 0 },
|
|
412
|
+
{ key: 18, value: 'Driver almost arrived to business', slug: 'DRIVER_ALMOST_ARRIVED_TO_BUSINESS', percentage: 50 },
|
|
413
|
+
{ key: 19, value: 'Driver almost arrived to customer', slug: 'DRIVER_ALMOST_ARRIVED_TO_CUSTOMER', percentage: 90 },
|
|
414
|
+
{ key: 20, value: 'Customer almost arrived to business', slug: 'CUSTOMER_ALMOST_ARRIVED_TO_BUSINESS', percentage: 90 },
|
|
415
|
+
{ key: 21, value: 'Customer arrived to business', slug: 'CUSTOMER_ARRIVED_TO_BUSINESS', percentage: 90 },
|
|
416
|
+
{ key: 22, value: 'Looking for driver', slug: 'ORDER_LOOKING_FOR_DRIVER', percentage: 30 },
|
|
417
|
+
{ key: 23, value: 'Driver on way', slug: 'ORDER_DRIVER_ON_WAY', percentage: 80 }
|
|
418
|
+
]
|
|
419
|
+
|
|
420
|
+
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
421
|
+
return objectStatus && objectStatus
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export const getOrderStatuPickUp = (status) => {
|
|
425
|
+
const orderStatus = [
|
|
426
|
+
{ key: 0, value: 'Pending Order', slug: 'PENDING_ORDER', percentage: 10 },
|
|
427
|
+
{ key: 1, value: 'Completed by admin', slug: 'COMPLETED_BY_ADMIN', percentage: 100 },
|
|
428
|
+
{ key: 2, value: 'Reject by admin', slug: 'REJECT_BY_ADMIN', percentage: 0 },
|
|
429
|
+
{ key: 4, value: 'Preparation Completed', slug: 'PREPARATION_COMPLETED', percentage: 50 },
|
|
430
|
+
{ key: 5, value: 'Reject by business', slug: 'REJECT_BY_BUSINESS', percentage: 0 },
|
|
431
|
+
{ key: 7, value: 'Accepted by business', slug: 'ACCEPTED_BY_BUSINESS', percentage: 30 },
|
|
432
|
+
{ key: 13, value: 'Preorder', slug: 'PREORDER', percentage: 0 },
|
|
433
|
+
{ key: 14, value: 'Order not ready', slug: 'ORDER_NOT_READY', percentage: 30 },
|
|
434
|
+
{ key: 15, value: 'Pickup completed by customer', slug: 'PICKUP_COMPLETED_BY_CUSTOMER', percentage: 100 },
|
|
435
|
+
{ key: 16, value: 'Canceled by customer', slug: 'CANCELED_BY_CUSTOMER', percentage: 0 },
|
|
436
|
+
{ key: 17, value: 'Not picked by customer', slug: 'NOT_PICKED_BY_CUSTOMER', percentage: 0 },
|
|
437
|
+
{ key: 20, value: 'Customer almost arrived to business', slug: 'CUSTOMER_ALMOST_ARRIVED_TO_BUSINESS', percentage: 70 },
|
|
438
|
+
{ key: 21, value: 'Customer arrived to business', slug: 'CUSTOMER_ARRIVED_TO_BUSINESS', percentage: 90 },
|
|
439
|
+
]
|
|
440
|
+
|
|
441
|
+
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
442
|
+
return objectStatus && objectStatus
|
|
443
|
+
}
|
|
444
|
+
|
|
392
445
|
/**
|
|
393
446
|
* function to manage order reject comment list
|
|
394
447
|
* @param {string} param0 type of orders to return
|
package/template/app.js
CHANGED
|
@@ -5,9 +5,18 @@ import {
|
|
|
5
5
|
Route,
|
|
6
6
|
Link,
|
|
7
7
|
Redirect,
|
|
8
|
-
useLocation
|
|
8
|
+
useLocation,
|
|
9
|
+
useHistory
|
|
9
10
|
} from 'react-router-dom'
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useSession,
|
|
13
|
+
useOrder,
|
|
14
|
+
useLanguage,
|
|
15
|
+
useConfig,
|
|
16
|
+
GoogleTagManager,
|
|
17
|
+
CannyIdentification,
|
|
18
|
+
useEvent
|
|
19
|
+
} from 'ordering-components-admin-external'
|
|
11
20
|
import { NotNetworkConnectivity } from '../src/components/NotNetworkConnectivity'
|
|
12
21
|
import { useOnlineStatus } from '../src/hooks/useOnlineStatus'
|
|
13
22
|
import { useWindowSize } from '../src/hooks/useWindowSize'
|
|
@@ -77,10 +86,15 @@ import { OrderingWidgets } from './pages/OrderingWidgets'
|
|
|
77
86
|
import { BusinessDevicesList } from './pages/BusinessDevicesList'
|
|
78
87
|
|
|
79
88
|
export const App = () => {
|
|
89
|
+
const history = useHistory()
|
|
90
|
+
const [events] = useEvent()
|
|
80
91
|
const [{ auth, loading, user }] = useSession()
|
|
81
92
|
const [orderStatus] = useOrder()
|
|
82
|
-
const [{ configs }] = useConfig()
|
|
93
|
+
const [{ configs, loading: configLoading }] = useConfig()
|
|
83
94
|
const [loaded, setLoaded] = useState(false)
|
|
95
|
+
const [oneSignalState, setOneSignalState] = useState({
|
|
96
|
+
notification_app: settings.notification_app
|
|
97
|
+
})
|
|
84
98
|
const [, t] = useLanguage()
|
|
85
99
|
const onlineStatus = useOnlineStatus()
|
|
86
100
|
const { height } = useWindowSize()
|
|
@@ -115,6 +129,64 @@ export const App = () => {
|
|
|
115
129
|
}
|
|
116
130
|
}, [height])
|
|
117
131
|
|
|
132
|
+
const oneSignalSetup = () => {
|
|
133
|
+
if (!configs?.onesignal_dashboardweb_id?.value) {
|
|
134
|
+
setOneSignalState({
|
|
135
|
+
notification_app: settings.notification_app
|
|
136
|
+
})
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
const OneSignal = window.OneSignal || []
|
|
140
|
+
const initConfig = {
|
|
141
|
+
appId: configs?.onesignal_dashboardweb_id?.value,
|
|
142
|
+
// allowLocalhostAsSecureOrigin: true,
|
|
143
|
+
notificationClickHandlerAction: 'navigate'
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
OneSignal.push(function () {
|
|
147
|
+
OneSignal.SERVICE_WORKER_PARAM = { scope: '/push/onesignal/' }
|
|
148
|
+
OneSignal.SERVICE_WORKER_PATH = 'push/onesignal/OneSignalSDKWorker.js'
|
|
149
|
+
OneSignal.SERVICE_WORKER_UPDATER_PATH = 'push/onesignal/OneSignalSDKWorker.js'
|
|
150
|
+
OneSignal.init(initConfig)
|
|
151
|
+
|
|
152
|
+
const onNotificationClicked = function (data) {
|
|
153
|
+
if (data?.data?.order_uuid) {
|
|
154
|
+
history.push(`/orders?id=${data?.data?.order_uuid}`)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const handler = function (data) {
|
|
158
|
+
onNotificationClicked(data)
|
|
159
|
+
OneSignal.addListenerForNotificationOpened(handler)
|
|
160
|
+
}
|
|
161
|
+
OneSignal.addListenerForNotificationOpened(handler)
|
|
162
|
+
|
|
163
|
+
OneSignal.on('subscriptionChange', function (isSubscribed) {
|
|
164
|
+
if (isSubscribed) {
|
|
165
|
+
OneSignal.getUserId((userId) => {
|
|
166
|
+
const data = {
|
|
167
|
+
...oneSignalState,
|
|
168
|
+
notification_token: userId
|
|
169
|
+
}
|
|
170
|
+
setOneSignalState(data)
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
OneSignal.getUserId((userId) => {
|
|
176
|
+
const data = {
|
|
177
|
+
...oneSignalState,
|
|
178
|
+
notification_token: userId
|
|
179
|
+
}
|
|
180
|
+
setOneSignalState(data)
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (configLoading) return
|
|
187
|
+
oneSignalSetup()
|
|
188
|
+
}, [configLoading, events])
|
|
189
|
+
|
|
118
190
|
return (
|
|
119
191
|
<>
|
|
120
192
|
<ListenPageChanges />
|
|
@@ -160,6 +232,7 @@ export const App = () => {
|
|
|
160
232
|
<Login
|
|
161
233
|
useLoginByEmail
|
|
162
234
|
elementLinkToForgotPassword={<Link to='/password/forgot'>{t('RESET_PASSWORD', 'Reset password')}</Link>}
|
|
235
|
+
notificationState={oneSignalState}
|
|
163
236
|
/>
|
|
164
237
|
)
|
|
165
238
|
: (
|
package/template/config.json
CHANGED