Skip to content

Commit

Permalink
token staking improved,onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohitkk432 committed Jul 28, 2023
1 parent cf54d9d commit 6cfdc68
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/assets/images/undraw_instant_analysis_re_mid5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/images/undraw_programmer_re_owql.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 56 additions & 3 deletions src/components/issues/open-issues-expand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { onLoading, onFailure, onSuccess } from '@/store/callLoaderSlice';
import EmptyList from '@/components/icons/EmptyList';
import PRSlider from '@/components/issues/pr-slider';

import { uploadMetadataToIPFS } from '@/lib/helpers/metadata';
import { uploadMetadataToIPFS, getTokenBalance } from '@/lib/helpers/metadata';

import { ChevronDown } from '@/components/icons/chevron-down';
import { Listbox } from '@/components/ui/listbox';
Expand Down Expand Up @@ -131,6 +131,9 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
const [selectedPR, setSelectedPR] = useState<any>();

const userInfo = useAppSelector((state) => state.userInfo.githubInfo);
const [userTokenInfo, setUserTokenInfo] = useState<any>(null);

const refetchPart = useAppSelector((state)=> state.refetch.refetchPart);

const [PRSort, setPRSort] = useState<any>([
{
Expand Down Expand Up @@ -747,11 +750,25 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
setPRSort(_listPRs);
};

const setTokenStakingState = async () => {
const tokenBalanceData = await getTokenBalance(issueTokenAddress);
setUserTokenInfo(tokenBalanceData);
};

useEffect(() => {
setTokenStakingState();
if (!link.includes('github.com')) return;
getPRsToSelect();
}, [link]);

useEffect(() => {
if(refetchPart==='issue'){
setTokenStakingState();
setStakeAmount(0);
setPRStakeAmount(0);
}
}, [refetchPart]);

return (
<div className="mt-4 flex w-full flex-col">
<div className="flex items-center gap-4">
Expand Down Expand Up @@ -788,7 +805,7 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
</div>
<div className="flex w-1/2 flex-col gap-3">
<div className="flex-flex-col w-full">
<div className="mb-2">stake on the issue</div>
<div className="mb-2">stake project token on the issue</div>
<div className="flex w-full items-center justify-center gap-2">
<Input
type="text"
Expand All @@ -805,6 +822,12 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
shape="rounded"
onClick={handleIssueStake}
isLoading={stateLoading === 'loading'}
disabled={
userTokenInfo === null ||
parseInt(userTokenInfo.amount) /
10 ** userTokenInfo.decimals ===
0
}
>
Stake
</Button>
Expand All @@ -814,10 +837,21 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
shape="rounded"
onClick={handleIssueUnstake}
isLoading={stateLoading === 'loading'}
disabled={userTokenInfo === null}
>
Unstake
</Button>
</div>
<div className="mt-3">
{userTokenInfo === null
? "User doesn't have tokens."
: userTokenInfo.amount && userTokenInfo.decimals
? `Balance: ${
parseInt(userTokenInfo.amount) /
10 ** userTokenInfo.decimals
}`
: null}
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -845,7 +879,9 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
<div className="flex w-full items-end justify-center gap-5">
{PRData.length > 0 && (
<div className="flex-flex-col w-full">
<div className="mb-2">stake on the pull request</div>
<div className="mb-2">
stake project tokens on the pull request
</div>
<div className="flex items-center gap-2">
<Input
type="text"
Expand All @@ -862,6 +898,12 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
shape="rounded"
onClick={handlePRStake}
isLoading={stateLoading === 'loading'}
disabled={
userTokenInfo === null ||
parseInt(userTokenInfo.amount) /
10 ** userTokenInfo.decimals ===
0
}
>
Stake
</Button>
Expand All @@ -871,10 +913,21 @@ const OpenIssueExpand: React.FC<OpenIssueExpandProps> = ({
shape="rounded"
onClick={handlePRUnstake}
isLoading={stateLoading === 'loading'}
disabled={userTokenInfo === null}
>
Unstake
</Button>
</div>
<div className="mt-3">
{userTokenInfo === null
? "User doesn't have tokens."
: userTokenInfo.amount && userTokenInfo.decimals
? `Balance: ${
parseInt(userTokenInfo.amount) /
10 ** userTokenInfo.decimals
}`
: null}
</div>
</div>
)}
<div className="flex-flex-col w-full">
Expand Down
1 change: 1 addition & 0 deletions src/config/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const routes = {
onboarding: '/onboarding',
home: '/home',
projects: '/projects',
swap: '/swap',
Expand Down
1 change: 1 addition & 0 deletions src/layouts/_root-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function RootLayout({
mixpanel.people.set({
Name: res.data.name,
github_name: res.data.login,
user_type: localStorage.getItem('user_type'),
});
dispatch(setGithub(res.data));
})
Expand Down
Loading

0 comments on commit 6cfdc68

Please sign in to comment.