11import { Panel } from "@namada/components" ;
2+ import { routes } from "App/routes" ;
3+ import { defaultAccountAtom } from "atoms/accounts" ;
4+ import { useAtomValue } from "jotai" ;
25import { useEffect , useState } from "react" ;
6+ import { useNavigate } from "react-router-dom" ;
37import { getReferralsFromSupabase } from "../../utils/supabase" ;
48import { ReferralsTable } from "./ReferralsTable" ;
59
@@ -15,7 +19,15 @@ export const Referrals = (): JSX.Element => {
1519 const [ referrals , setReferrals ] = useState < Referral [ ] > ( [ ] ) ;
1620 const [ loading , setLoading ] = useState ( true ) ;
1721 const [ error , setError ] = useState < string | null > ( null ) ;
22+ const defaultAccount = useAtomValue ( defaultAccountAtom ) ;
23+ const isValidityOps =
24+ defaultAccount . data ?. address &&
25+ [
26+ "tnam1q8lhvxys53dlc8wzlg7dyqf9avd0vff6wvav4amt" ,
27+ "tnam1qr0e06vqhw9u0yqy9d5zmtq0q8ekckhe2vkqc3ky" ,
28+ ] . includes ( defaultAccount . data ?. address ) ;
1829
30+ const navigate = useNavigate ( ) ;
1931 useEffect ( ( ) => {
2032 const fetchReferrals = async ( ) : Promise < void > => {
2133 try {
@@ -35,10 +47,14 @@ export const Referrals = (): JSX.Element => {
3547 setLoading ( false ) ;
3648 }
3749 } ;
38-
50+ if ( ! isValidityOps ) return navigate ( routes . root ) ;
3951 fetchReferrals ( ) ;
4052 } , [ ] ) ;
4153
54+ if ( ! isValidityOps ) {
55+ return < div > You are not authorized to view this page</ div > ;
56+ }
57+
4258 return (
4359 < Panel className = "min-h-600" >
4460 < div className = "flex flex-col gap-4" >
0 commit comments