Skip to content

Commit

Permalink
Add is blocked (#611)
Browse files Browse the repository at this point in the history
* Update blocked

* Fix blockFeatureEnabled

---------

Co-authored-by: lq0-github <[email protected]>
  • Loading branch information
xieqiancaosissi and lq0-github authored Sep 29, 2024
1 parent 320756c commit 0eb0144
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, {
useCallback,
useEffect,
useReducer,
useState,
} from 'react';
import Loading from 'src/components/layout/Loading';

Expand Down Expand Up @@ -33,6 +34,7 @@ import getConfig from './services/config';
import { REF_FARM_BOOST_CONTRACT_ID } from './services/near';
import { useGlobalPopUp } from './state/popUp';
import { globalStateReducer, WalletContext } from './utils/wallets-integration';
import { getUserIsBlocked } from './services/api';

export type Account = AccountView & {
account_id: string;
Expand Down Expand Up @@ -70,6 +72,18 @@ export function Content() {
const [globalState, globalStatedispatch] = GlobalStateReducer;

const { selector, accountId } = useWalletSelector();
const [isBlocked, setIsBlocked] = useState(false);
const blockFeatureEnabled = true;
// const blockFeatureEnabled = false;
useEffect(() => {
if (blockFeatureEnabled) {
getUserIsBlocked().then((res) => {
if (res.blocked === true) {
setIsBlocked(true);
}
});
}
}, []);

const getAccount = useCallback(async (): Promise<Account | null> => {
if (!accountId) {
Expand Down Expand Up @@ -193,6 +207,22 @@ export function Content() {
</Switch>
</Suspense>
</OrderlyContextProvider>
{isBlocked && blockFeatureEnabled && (
<div
className="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center"
style={{ zIndex: '99999', backdropFilter: 'blur(6px)' }}
>
<div
className="text-white text-center bg-swapCardGradient p-6 rounded-lg"
style={{ width: '250px' }}
>
<p className="text-base">
You are prohibited from accessing app.ref.finance due to your
location or other infringement of the Terms of Services.
</p>
</div>
</div>
)}
</WalletContext.Provider>
);
}
Expand Down
7 changes: 7 additions & 0 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,10 @@ export const getMemeFarmingAssetsList = async (
return [];
});
};

export const getUserIsBlocked = async (): Promise<any> => {
return await fetch('https://geo.deltarpc.com/api/is-blocked', {
method: 'GET',
headers: { 'Content-type': 'application/json; charset=UTF-8' },
}).then((res) => res.json());
};

0 comments on commit 0eb0144

Please sign in to comment.