Skip to content

Commit a160919

Browse files
committed
fix: recap tip button event
1 parent 7207cf2 commit a160919

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

apps/mochi-web/components/Profile/RecapSection.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ import { utils } from 'ethers'
3434
import { truncate } from '@dwarvesf/react-utils'
3535
import { useTheme } from '~hooks/useTheme'
3636
import clsx from 'clsx'
37-
import { useState } from 'react'
37+
import { useCallback, useState } from 'react'
3838
import { useFetchTotalBalance } from '~hooks/profile/useFetchTotalBalance'
39+
import { ROUTES } from '~constants/routes'
40+
import { useRouter } from 'next/router'
41+
import events from '~constants/events'
3942

4043
const intervals = [
4144
{
@@ -120,6 +123,14 @@ const UserSection = ({ type, statTx }: Props) => {
120123
/>
121124
)
122125

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+
123134
if (type === 'sent' && !statTx) {
124135
return (
125136
<div className="flex items-center py-4 space-x-2">
@@ -128,7 +139,12 @@ const UserSection = ({ type, statTx }: Props) => {
128139
<Typography level="p5" color="textTertiary">
129140
To send money
130141
</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+
>
132148
<TipSolid className="w-4 h-4" />
133149
tip
134150
</Button>

0 commit comments

Comments
 (0)