()
| 5 | import { Origin } from '../../lib/log'; |
| 6 | |
| 7 | export const useTopReaderModal = (): void => { |
| 8 | const { query, replace } = useRouter(); |
| 9 | const { openModal } = useLazyModal(); |
| 10 | |
| 11 | useEffect(() => { |
| 12 | if (!query || !query.topreader || !query.badgeId) { |
| 13 | return; |
| 14 | } |
| 15 | |
| 16 | openModal({ |
| 17 | type: LazyModal.TopReaderBadge, |
| 18 | props: { |
| 19 | badgeId: query.badgeId as string, |
| 20 | origin: Origin.NotificationsPage, |
| 21 | onAfterClose: () => { |
| 22 | const { origin, pathname } = window.location; |
| 23 | replace(origin + pathname); |
| 24 | }, |
| 25 | }, |
| 26 | }); |
| 27 | }, [openModal, query, replace]); |
| 28 | }; |
no test coverage detected