Skip to content

Commit

Permalink
Add blocked local storage (#618)
Browse files Browse the repository at this point in the history
* update blocked localStorage

* Fix blocked ui

* Fix blocked data

---------

Co-authored-by: lq0-github <1441665200@qq.com>
  • Loading branch information
xieqiancaosissi and lq0-github authored Oct 10, 2024
1 parent e8dce17 commit aa3f065
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions src/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,37 @@ export function Content() {
// const blockFeatureEnabled = false;
useEffect(() => {
if (blockFeatureEnabled) {
getUserIsBlocked().then((res) => {
if (res.blocked === true) {
checkBlockedStatus();
}
}, [blockFeatureEnabled]);
function checkBlockedStatus() {
getUserIsBlocked().then((res) => {
if (res.blocked === true) {
const blockConfirmationTime = localStorage.getItem(
'blockConfirmationTime'
);
if (blockConfirmationTime) {
const currentTime = new Date().getTime();
const weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
if (
currentTime - parseInt(blockConfirmationTime, 10) <
weekInMilliseconds
) {
setIsBlocked(false);
} else {
setIsBlocked(true);
}
} else {
setIsBlocked(true);
}
});
}
}, []);

}
});
}
function handleBlockConfirmation() {
const currentTime = new Date().getTime();
localStorage.setItem('blockConfirmationTime', currentTime.toString());
setIsBlocked(false);
}
const getAccount = useCallback(async (): Promise<Account | null> => {
if (!accountId) {
return;
Expand Down Expand Up @@ -213,13 +236,19 @@ export function Content() {
style={{ zIndex: '99999', backdropFilter: 'blur(6px)' }}
>
<div
className="text-white text-center bg-swapCardGradient p-6 rounded-lg"
style={{ width: '250px' }}
className="text-white text-center px-5 pt-9 pb-7 rounded-md"
style={{ width: '278px', background: '#1B242C' }}
>
<p className="text-base">
<p className="text-sm">
You are prohibited from accessing app.ref.finance due to your
location or other infringement of the Terms of Services.
</p>
<div
onClick={handleBlockConfirmation}
className="mt-4 bg-primaryGradient h-9 flex items-center justify-center rounded-md text-sm text-black text-white cursor-pointer ml-1.5 mr-1.5"
>
Confirm
</div>
</div>
</div>
)}
Expand Down

0 comments on commit aa3f065

Please sign in to comment.