Skip to content

Commit

Permalink
Kudos UI (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 authored Aug 8, 2023
1 parent f140954 commit cfdbbc2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/components/common/TokensGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { ImageSrc, ReducerNames } from '../../utils/constants';
import { Item, TokenDetails, ValidTokenComponent } from './TokenDetails';

const TokensGrid = () => {
const { fvToken, kycToken, ogToken, vibeToken, regenToken } = useSelector(
(state) => state[ReducerNames.SBT]
);
const { fvToken, kycToken, ogToken, vibeToken, regenToken, kudosToken } =
useSelector((state) => state[ReducerNames.SBT]);

return (
<div className="flex flex-col gap-y-10 flex-wrap gap-5">
Expand Down Expand Up @@ -54,6 +53,15 @@ const TokensGrid = () => {
<TokenDetails data={regenToken} />
</Item>
)}
{kudosToken && (
<Item imageSrc={ImageSrc.ProofOfKudos}>
<ValidTokenComponent />
<h2 className="font-bold text-3xl my-1 mb-5">
My Kudos Soul Bound Token
</h2>
<TokenDetails data={kudosToken} />
</Item>
)}
</div>
);
};
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Activate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import ImageTextBlock from '../components/common/ImageTextBlock';
import { useDispatch } from 'react-redux';
import { updateTrackerStatus } from '../redux/reducer/tracker';
import { ImageSrc } from '../utils/constants';
import { ImageSrc, Links } from '../utils/constants';

const ActivatePage = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -83,7 +83,8 @@ const ActivatePage = () => {
/>
<ImageTextBlock
imageSrc={ImageSrc.NDCKudos}
isAvailable={false}
onClick={() => window.open(Links.KUDOS_WIDGET, '_blank')}
isAvailable={true}
title="NDC Kudos"
description='The NDC Kudos platform aims to create a reputation point system where humans can give each other recognition known as "Kudos." With enough social proof, you can mint a "Proof of Kudos" Soul Bound Token to display your contribution and your reputation in the NEAR ecosystem.'
buttonText="Give a Kudo"
Expand Down
4 changes: 3 additions & 1 deletion src/pages/CommunitySBT.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { updateTrackerStatus } from '../redux/reducer/tracker';
import ImageTextBlock from '../components/common/ImageTextBlock';
import { ImageSrc } from '../utils/constants';
import { ImageSrc, Links } from '../utils/constants';

const CommunitySBTPage = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -70,6 +70,8 @@ const CommunitySBTPage = () => {
description="This SBT is a unique badge earned by attending special events and passing vibe checks. It grants exclusive access to high-caliber gatherings, turning them into celebrations of our collective spirit."
/>
<ImageTextBlock
isAvailable={true}
onClick={() => window.open(Links.KUDOS_WIDGET, '_blank')}
imageSrc={ImageSrc.ProofOfKudos}
title="Proof of Kudos"
description="This SBT is an electrifying badge bestowed upon individuals who have garnered immense praise, backed by overwhelming social proof."
Expand Down
25 changes: 25 additions & 0 deletions src/pages/auth/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Home = () => {
og_contract,
regen_issuer_contract,
vibe_issuer_contract,
kudos_issuer_contract,
} = getConfig();
useEffect(() => {
// fetching only when logged in (without steps) state active
Expand All @@ -34,6 +35,7 @@ const Home = () => {
fetchTokens();
fetchRegenToken();
fetchVibeToken();
fetchKudosToken();
}
}, [activePageIndex]);

Expand Down Expand Up @@ -108,6 +110,29 @@ const Home = () => {
}
};

const fetchKudosToken = async () => {
try {
const data = await wallet.viewMethod({
contractId: app_contract,
method: 'sbt_tokens_by_owner',
args: {
account: wallet.accountId,
issuer: kudos_issuer_contract,
},
});
if (data?.[0]?.[1]) {
for (const token of data[0][1]) {
// if class = 1 => Kudos token
if (token.metadata.class === 1) {
dispatch(updateTokens({ type: TokenTypes.KUDOS, value: token }));
}
}
}
} catch (error) {
toast.error('An error occured while fetching Kudos SBT details');
}
};

const fetchTokens = async () => {
try {
const data = await wallet.viewMethod({
Expand Down
8 changes: 7 additions & 1 deletion src/redux/reducer/sbtsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const sbtReducer = createSlice({
tokenRemoveSuccess: false,
continueLoop: false, // for transfer and burn
isUserHuman: false, // true if user has any SBT Token
kudosToken: null,
},
reducers: {
updateTokens: (state, action) => {
Expand All @@ -74,6 +75,9 @@ export const sbtReducer = createSlice({
case TokenTypes.REGEN:
state.regenToken = value;
break;
case TokenTypes.KUDOS:
state.kudosToken = value;
break;
default:
break;
}
Expand All @@ -82,7 +86,8 @@ export const sbtReducer = createSlice({
state.kycToken ||
state.ogToken ||
state.vibeToken ||
state.regenToken;
state.regenToken ||
state.kudosToken;
},
handleErrorMessage: (state, action) => {
state.error = action.payload;
Expand All @@ -94,6 +99,7 @@ export const sbtReducer = createSlice({
state.ogToken = null;
state.vibeToken = null;
state.regenToken = null;
state.kudosToken = null;
},
updateTokenRemoveStatus: (state, action) => {
state.tokenRemoveSuccess = !state.tokenRemoveSuccess;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function getConfig() {
fractal_api: 'https://back.justfortestinc.site',
fractal_link: 'https://app.fractal.id',
fractal_client_id: '6l6ze953tTjsog6VjZaCsCJ8LgiL_UqySA-E2f3ljPw',
kudos_issuer_contract: 'kudos.ndctools.near',
...commonConfig,
};
case 'dev':
Expand All @@ -35,6 +36,7 @@ export function getConfig() {
fractal_api: 'https://staging.justfortestinc.site',
fractal_link: 'https://app.next.fractal.id',
fractal_client_id: 'D6SgXZQdWYk0D8ILkIGpNK75ufFpxD0Mp9sHFb_2oM8',
kudos_issuer_contract: 'kudos-v1.gwg.testnet',
// fractal_client_id: '2KdWlqCWoyMtfIHTEI60NgqDA015d0Uy2r5KieoZS3M', // for http://localhost:3000
...commonConfig,
};
Expand Down
5 changes: 5 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const TokenTypes = {
FV: 'FV',
VIBE: 'Vibe',
REGEN: 'Regen',
KUDOS: 'Kudos',
};

export const ReducerNames = {
Expand Down Expand Up @@ -96,3 +97,7 @@ export const ImageSrc = {
CommunityFund:
'https://bafkreicvwvjtybib7nodjus5ynomjasp3xskz2et5tkrx6k7t3h7dsq2za.ipfs.nftstorage.link/',
};

export const Links = {
KUDOS_WIDGET: 'https://near.org/kudos.ndctools.near/widget/NDC.Kudos.Main',
};

0 comments on commit cfdbbc2

Please sign in to comment.