1
1
import { ReactNode } from 'react' ;
2
2
import { ADVERT_TYPE , ERROR_CODES } from '@/constants' ;
3
+ import { useLiveChat } from '@/hooks/custom-hooks' ;
3
4
import { AdRateError } from '@/pages/my-ads/components' ;
4
5
import { Localize } from '@deriv-com/translations' ;
5
6
import { Button , Modal , Text , useDevice } from '@deriv-com/ui' ;
@@ -24,7 +25,8 @@ const getAdErrorMessage = (
24
25
balanceAvailable : number ,
25
26
advertType : string ,
26
27
dailyBuyLimit : string ,
27
- dailySellLimit : string
28
+ dailySellLimit : string ,
29
+ onLiveChatClick : ( ) => void
28
30
) : string => {
29
31
const errorMessages : { [ key : string ] : ReactNode | string } = {
30
32
[ ERROR_CODES . ADVERT_INACTIVE ] : < AdRateError /> ,
@@ -64,7 +66,10 @@ const getAdErrorMessage = (
64
66
/>
65
67
) ,
66
68
[ ERROR_CODES . ADVERTISER_TEMP_BAN ] : (
67
- < Localize i18n_default_text = 'You’re not allowed to use Deriv P2P to advertise. Please contact us via live chat for more information.' />
69
+ < Localize
70
+ components = { [ < a key = { 0 } onClick = { onLiveChatClick } /> ] }
71
+ i18n_default_text = 'You’re not allowed to use Deriv P2P to advertise. Please contact us via <0>live chat</0> for more information.'
72
+ />
68
73
) ,
69
74
} ;
70
75
@@ -82,6 +87,10 @@ const AdErrorTooltipModal = ({
82
87
remainingAmount,
83
88
visibilityStatus = [ ] ,
84
89
} : TAdErrorTooltipModal ) => {
90
+ const { LiveChatWidget } = useLiveChat ( ) ;
91
+ const onLiveChatClick = ( ) => {
92
+ LiveChatWidget . call ( 'maximize' ) ;
93
+ } ;
85
94
const { isMobile } = useDevice ( ) ;
86
95
const textSize = isMobile ? 'md' : 'sm' ;
87
96
const getMultipleErrorMessages = ( errorStatuses : string [ ] ) =>
@@ -95,7 +104,8 @@ const AdErrorTooltipModal = ({
95
104
balanceAvailable ,
96
105
advertType ,
97
106
dailyBuyLimit ,
98
- dailySellLimit
107
+ dailySellLimit ,
108
+ onLiveChatClick
99
109
) }
100
110
</ div >
101
111
) ) ;
@@ -118,7 +128,8 @@ const AdErrorTooltipModal = ({
118
128
balanceAvailable ,
119
129
advertType ,
120
130
dailyBuyLimit ,
121
- dailySellLimit
131
+ dailySellLimit ,
132
+ onLiveChatClick
122
133
)
123
134
) : (
124
135
< >
0 commit comments