@@ -34,8 +34,11 @@ import { utils } from 'ethers'
34
34
import { truncate } from '@dwarvesf/react-utils'
35
35
import { useTheme } from '~hooks/useTheme'
36
36
import clsx from 'clsx'
37
- import { useState } from 'react'
37
+ import { useCallback , useState } from 'react'
38
38
import { useFetchTotalBalance } from '~hooks/profile/useFetchTotalBalance'
39
+ import { ROUTES } from '~constants/routes'
40
+ import { useRouter } from 'next/router'
41
+ import events from '~constants/events'
39
42
40
43
const intervals = [
41
44
{
@@ -120,6 +123,14 @@ const UserSection = ({ type, statTx }: Props) => {
120
123
/>
121
124
)
122
125
126
+ const { pathname, push } = useRouter ( )
127
+ const redirectToTipWidget = async ( ) => {
128
+ if ( pathname !== ROUTES . HOME ) {
129
+ await push ( ROUTES . HOME )
130
+ }
131
+ window . dispatchEvent ( new Event ( events . TIP_WIDGET . FOCUS_AMOUNT ) )
132
+ }
133
+
123
134
if ( type === 'sent' && ! statTx ) {
124
135
return (
125
136
< div className = "flex items-center py-4 space-x-2" >
@@ -128,7 +139,12 @@ const UserSection = ({ type, statTx }: Props) => {
128
139
< Typography level = "p5" color = "textTertiary" >
129
140
To send money
130
141
</ Typography >
131
- < Button variant = "link" color = "neutral" className = "pr-0 pl-0 h-auto" >
142
+ < Button
143
+ variant = "link"
144
+ color = "neutral"
145
+ className = "pr-0 pl-0 h-auto"
146
+ onClick = { redirectToTipWidget }
147
+ >
132
148
< TipSolid className = "w-4 h-4" />
133
149
tip
134
150
</ Button >
0 commit comments