Skip to content

Commit

Permalink
Merge pull request #517 from Itheum/stg
Browse files Browse the repository at this point in the history
V1.22 : AI Workforce + NFMe ID Ranking View
  • Loading branch information
newbreedofgeek authored Sep 4, 2024
2 parents 36ea880 + 5fe71f6 commit b6b5f38
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "explorer-dapp",
"description": "Itheum Explorer is a DApp for the public to explore and visualize data within the Itheum protocol",
"version": "1.21.1",
"version": "1.22.2",
"author": "Itheum",
"license": "GPL-3.0-or-later",
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions src/components/Layout/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ export const Navbar = () => {
Gamer Passport
</Link>
</NavigationMenuItem>
<NavigationMenuItem className="cursor-pointer">
<Link
to={routeNames.aiworkforce}
className={navigationMenuTriggerStyle() + "dark:text-white dark:hover:!text-white text-black hover:!text-black !no-underline px-4"}>
AI Workforce
</Link>
</NavigationMenuItem>
<NavigationMenuItem className="cursor-pointer">
<Link
to={routeNames.analytics}
Expand Down
16 changes: 12 additions & 4 deletions src/libs/backend-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ import axios from "axios";
import { TrendingNft } from "./types";
import { uxConfig } from "./utils/constant";

export const backendApi = (chainID: string) => {
const envKey = chainID === "1" ? "VITE_ENV_BACKEND_MAINNET_API" : "VITE_ENV_BACKEND_API";
const defaultUrl = chainID === "1" ? "https://production-itheum-api.up.railway.app" : "https://staging-itheum-api.up.railway.app";
export const backendApi = (chainID?: string) => {
if (!chainID) {
if (import.meta.env.VITE_ENV_NETWORK === "mainnet") {
return "https://production-itheum-api.up.railway.app";
} else {
return "https://staging-itheum-api.up.railway.app";
}
} else {
const envKey = chainID === "1" ? "VITE_ENV_BACKEND_MAINNET_API" : "VITE_ENV_BACKEND_API";
const defaultUrl = chainID === "1" ? "https://production-itheum-api.up.railway.app" : "https://staging-itheum-api.up.railway.app";

return import.meta.env[envKey] || defaultUrl;
return import.meta.env[envKey] || defaultUrl;
}
};

export async function getHealthCheckFromBackendApi(chainID: string): Promise<boolean> {
Expand Down
22 changes: 11 additions & 11 deletions src/libs/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ export const APP_MAPPINGS = [
appName: "Get <BiTz> Points",
appDescription: "Collect Itheum <BiTz> Points",
routeKey: "getbitz",
desc: "Open this app to get <BiTz> XP by playing a simple meme burning gaming. <BiTz> XP is a proof-of-activity system for the Itheum Protocol can swap to ITHEUM airdrops in future ;)",
desc: "Use this app to get <BiTz> XP by playing a simple meme burning game. <BiTz> XP is a proof-of-activity system for the Itheum Protocol.",
img: iconGetBitz,
},
{
appName: "TrailBlazer",
appDescription: "TrailBlazer Quest App",
routeKey: "itheumtrailblazer",
desc: "Hardcore community members unlock Project Alpha by owning their favorite project's TrailBlazer Data NFTs. Unlock and visualize these TrailBlazer Data NFTs by using this app.",
desc: "Hardcore community members unlock Project Alpha by owning TrailBlazer Data NFTs that unlock private quests.",
img: iconTrailblazer,
},
{
appName: "NF-Tunes",
appDescription: "Listen to Music Playlists",
routeKey: "nftunes",
desc: "Listen to music from indie musicians with this app. All music is unlocked from Music Data NFTs. Like what you hear? why not support the musician by owning a Music Data NFT.",
desc: "Listen to music from indie musicians with this app. Like what you hear? why not support the musician by owning a Music Data NFT.",
img: iconNFTunes,
},
{
appName: "Deep Forest Music Data NFT Player",
appName: "Deep Forest Music",
appDescription: "The Chronicles of Deep Forest",
routeKey: "deepforestmusic",
desc: "Experience Grammy Award winner Deep Forest's timeless music reimagined in a limited edition 90-piece Music Data NFT collection.",
desc: "Experience Grammy Award winner Deep Forest's timeless music re-imagined in a limited edition 90-piece Music Data NFT collection.",
img: iconDeepForest,
},
{
appName: "Time Capsule",
appDescription: "Preserve Memories Forever",
routeKey: "timecapsule",
desc: "Capture, archive, and relive historic social media events through photos and videos, preserving memories for future generations. Join the nostalgia journey!",
desc: "Capture, archive, and relive historic events through photos and videos, preserving memories for future generations.",
img: iconTimeCapsule,
},
{
Expand All @@ -66,35 +66,35 @@ export const APP_MAPPINGS = [
appName: "Bober Game Room",
appDescription: "Play a fun Bober Video Game",
routeKey: "bobergameroom",
desc: "Annoying memes are flooding the forest! Use your trusty water cannon to blast them away before they reach the dam! It's a beaver battle against cringe!",
desc: "Annoying memes are flooding the forest! Use your trusty water cannon to blast them away before they reach the dam!",
img: iconBober,
},
{
appName: "MultiversX ESDT Bubbles",
appDescription: "MultiversX ESDT Bubbles Data NFT",
routeKey: "esdtBubble",
desc: "ESDT is the native token standard of the MultiversX blockchain. This app visualizes the dynamic data stream of various ESDT token insights as bubble graphs.",
desc: "This app visualizes the dynamic data stream of various ESDT token insights as bubble graphs.",
img: "https://itheum-static.s3.ap-southeast-2.amazonaws.com/expl-app-esdt-bubbles-icon.png",
},
{
appName: "MultiversX Bubbles",
appDescription: "MultiversX Datasets Visualized",
routeKey: "multiversxbubbles",
desc: "This app visualizes dynamic data streams of various MultiversX ecosystem metrics and insights as bubble graphs. Get MultiversX ecosystem alpha today!",
desc: "This app visualizes dynamic data streams of various MultiversX ecosystem metrics and insights as bubble graphs.",
img: iconBubbleMaps,
},
{
appName: "PlayStation Gamer Passport",
appDescription: "PlayStation Gamer Passport Data NFT",
routeKey: "playstationgamerpassport",
desc: "There are over 110 million active Sony Playstation gamers, and now, they can own some of their data. Unlock these PlatStation gamers Data NFTs by using this app.",
desc: "There are over 110 million active Sony Playstation gamers, and now, they can own some of their data.",
img: "https://itheum-static.s3.ap-southeast-2.amazonaws.com/expl-app-playstation-icon.png",
},
{
appName: "MultiversX Infographics",
appDescription: "View Dynamic Infographic PDFs",
routeKey: "multiversxinfographics",
desc: 'This app visualizes dynamic and evolving data streams rendered into PDF files that showcase unique MultiversX ecosystem "alpha", insights, and education.',
desc: "This app visualizes dynamic and evolving data streams rendered into PDF files.",
img: iconInfrographics,
},
];
Expand Down
213 changes: 213 additions & 0 deletions src/pages/AIWorkforce/AIWorkforce.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import React, { useEffect, useState } from "react";
import axios from "axios";
import { Link } from "react-router-dom";
import { Button } from "libComponents/Button";
import { backendApi } from "libs/backend-api";
import { WorkersSnapShotGrid } from "./SharedComps";

// const rankedWorkforce = [
// {
// "uuid": 358,
// "address": "erd1eweqykxcrhh5nps4fzktu9eftf7rxpa8xdfkypwz0k4huhl0s04sa6tqyd",
// "rankScore": 10,
// "bondAmount": 566,
// "livelinessScore": 1,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-024b",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmUHzpCRRLguzjAEnXB33Ar2FbR4EE18KRCChjUPyLyCUo",
// "creationTime": "2024-09-02T08:18:32.000Z",
// "lastUpdated": 1725277510,
// },
// {
// "uuid": 359,
// "address": "erd1rzjsadakpqfqm2umcv96d7d95zcwzm7pac8g4kmcp6kdfgzmuhgs2kyrzv",
// "rankScore": 0,
// "bondAmount": 1001,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0244",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmWxrgB4o6QTJUsbCmZXSSPc3WvFvh4RBrLs9pwJSpEGUw",
// "creationTime": "2024-08-27T07:13:14.000Z",
// "lastUpdated": 1725277508,
// },
// {
// "uuid": 360,
// "address": "erd1rzjsadakpqfqm2umcv96d7d95zcwzm7pac8g4kmcp6kdfgzmuhgs2kyrzv",
// "rankScore": 0,
// "bondAmount": 1001,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0249",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmRicYzifHSQP9xk6FaA7QqnRQN3qgd4WqLhqGxrJJqto9",
// "creationTime": "2024-08-27T07:23:56.000Z",
// "lastUpdated": 1725277509,
// },
// {
// "uuid": 361,
// "address": "erd1mywl5r9ptxurzhnz2ztrjdjswssd44l05n3l5ly3795gf777ujmqma76gx",
// "rankScore": 0,
// "bondAmount": 811,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0242",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmWDyB3mQMEgJ2cfNS2yWf8AmZ7CRs52eDmvtqqgELuLnK",
// "creationTime": "2024-08-27T07:05:56.000Z",
// "lastUpdated": 1725277507,
// },
// {
// "uuid": 362,
// "address": "erd1cyp3c6plhrmlwzue7f7cg8kqs6jf0c6temmh6gsh3tfj3de3a7csddfm6t",
// "rankScore": 0,
// "bondAmount": 722,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0248",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmPgQ3brZgf8izBNYKAERiaKDnmxeGhUZQYXhCLJ2kqvFV",
// "creationTime": "2024-08-27T07:20:44.000Z",
// "lastUpdated": 1725277509,
// },
// {
// "uuid": 363,
// "address": "erd1cyp3c6plhrmlwzue7f7cg8kqs6jf0c6temmh6gsh3tfj3de3a7csddfm6t",
// "rankScore": 0,
// "bondAmount": 722,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-024a",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmRSRLEcPJ2hgeAJ6bey83AWgg3QVjojVwi5CCYLj7R82h",
// "creationTime": "2024-08-27T07:58:32.000Z",
// "lastUpdated": 1725277509,
// },
// {
// "uuid": 364,
// "address": "erd1fet6nrput6ujj0yf4cj70ex0sldxsf79ruxsucapeuf5k4acmldqwkkgp2",
// "rankScore": 0,
// "bondAmount": 522,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-023b",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmNXaJen63E65Qvzc2j4guZ3chUmUUJwtfsyj31gk9317i",
// "creationTime": "2024-08-23T04:43:32.000Z",
// "lastUpdated": 1725277504,
// },
// {
// "uuid": 365,
// "address": "erd1fj4v79xn96ew4fu05e9m2hxzuw0d03txsj7ptn2ls0pa7y56hhksexjhxj",
// "rankScore": 0,
// "bondAmount": 380,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0243",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmVBAHqgRCSWi6ZAH1D4bMBBmsfvsiXLMdngNZQCSTKwb1",
// "creationTime": "2024-08-27T07:09:44.000Z",
// "lastUpdated": 1725277507,
// },
// {
// "uuid": 366,
// "address": "erd1fj4v79xn96ew4fu05e9m2hxzuw0d03txsj7ptn2ls0pa7y56hhksexjhxj",
// "rankScore": 0,
// "bondAmount": 380,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0245",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmVGN1ptYoccudhB66jKvs6puFyaWJp9mmB2MybtEM1nf9",
// "creationTime": "2024-08-27T07:16:32.000Z",
// "lastUpdated": 1725277509,
// },
// {
// "uuid": 367,
// "address": "erd1yz6vqzlv6zw70u2rq5sdljnq59tn2ue879xxrfpyfts4wy09rd0qpnctn8",
// "rankScore": 0,
// "bondAmount": 299,
// "livelinessScore": 0,
// "bitzXp": 0,
// "vault": "DATANFTFT-e0b917-0234",
// "vaultImg": "https://devnet-media.elrond.com/nfts/asset/QmNkuz9Xx9pCibCFxaDwZvnd3KbxYQ7HTWruzpQwonJwsf",
// "creationTime": "2024-08-22T10:36:26.000Z",
// "lastUpdated": 1725277500,
// },
// ];

export const AIWorkforce = () => {
const [appBootingUp, setAppBootingUp] = useState<boolean>(true);
const [rankedWorkforce, setRankedWorkforce] = useState<any[]>([]);

useEffect(() => {
window.scrollTo({
top: 0,
behavior: "smooth",
});

async function getDataAndInitGraphData() {
setAppBootingUp(true);
const workforceDataList = await getWorkforceData();
setRankedWorkforce(workforceDataList);
setAppBootingUp(false);
}

getDataAndInitGraphData();
}, []);

async function getWorkforceData() {
const apiResponse = await axios.get(`${backendApi()}/workforce?size=50`);
const dataResponse = apiResponse.data;

return dataResponse;
}

return (
<div className="w-[100%] py-2">
<div id="hero" className="mt-2 pt-3 h-[200px] md:h-[180px] rounded-3xl">
<div className="flex flex-col h-[100%] justify-center items-center">
<div className="w-80% md:w-[60%]">
<h1 className="!text-xl text-center md:!text-2xl">Join the Itheum AI Workforce</h1>
<h2 className="!text-sm md:!text-xl text-center mt-2">
Mint Your NFMe ID, Boost Your Liveliness, Farm Staking Rewards and Join the Itheum AI Workforce as a Data Provider
</h2>
</div>

<Link to="https://datadex.itheum.io/nfmeid" target="_blank" className="my-5 text-base hover:!no-underline hover:text-black">
<Button className="!text-black text-sm tracking-tight relative px-[2.35rem] left-2 bottom-1.5 bg-gradient-to-r from-yellow-300 to-orange-500 transition ease-in-out delay-150 duration-300 hover:translate-y-1.5 hover:-translate-x-[8px] hover:scale-100">
Mint NFMe ID Now
</Button>
</Link>
</div>
</div>

<div className="mt-5 mb-20">
<div className="flex flex-col justify-center items-center">{appBootingUp ? <>Loading</> : <WorkersSnapShotGrid snapShotData={rankedWorkforce} />}</div>
</div>
</div>
);
};

export const AIWorkforceTopN = ({ showItems }: { showItems?: number }) => {
const [appBootingUp, setAppBootingUp] = useState<boolean>(true);
const [rankedWorkforce, setRankedWorkforce] = useState<any[]>([]);

useEffect(() => {
async function getDataAndInitGraphData() {
setAppBootingUp(true);
const workforceDataList = await getWorkforceData();
setRankedWorkforce(workforceDataList);
setAppBootingUp(false);
}

getDataAndInitGraphData();
}, []);

async function getWorkforceData() {
const apiResponse = await axios.get(`${backendApi()}/workforce?size=${showItems || 5}`);
const dataResponse = apiResponse.data;

return dataResponse;
}

return (
<div className="w-[100%] py-2">
<div className="mt-1 mb-10">
<div className="flex flex-col justify-center items-center">{appBootingUp ? <>Loading</> : <WorkersSnapShotGrid snapShotData={rankedWorkforce} />}</div>
</div>
</div>
);
};
37 changes: 37 additions & 0 deletions src/pages/AIWorkforce/SharedComps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from "react";

export function WorkersSnapShotGrid({ snapShotData }: { snapShotData: any[] }) {
const flattenedFixedData: any[] = [];

if (snapShotData) {
snapShotData.map((worker: any) => {
flattenedFixedData.push(worker);
});
}

return (
<div className="grid grid-cols-2 md:grid-cols-5 gap-8">
{flattenedFixedData &&
flattenedFixedData.length > 0 &&
flattenedFixedData.map((worker: any, idx: number) => (
<div key={idx}>
<div className="flex justify-center">
<span className="bg-yellow-100 text-yellow-800 text-xs md:text-sm font-medium rounded dark:bg-yellow-900 dark:text-yellow-300 p-1">
Rank: {idx + 1}
</span>
</div>
<div className="group">
<img className="h-auto max-w-full" src={worker.vaultImg} alt={worker.vault} />
<div className="h-[95px] -mt-[95px] bg-black opacity-75 p-[10px] pl-[15px] rounded-b-3xl text-white hidden group-hover:block">
<p className="text-[10px]">{worker.vault}</p>
<p className="text-[10px]">Rank Score: {worker.rankScore?.toLocaleString()}</p>
<p className="text-[10px]">Total Bond: {worker.bondAmount?.toLocaleString()}</p>
<p className="text-[10px]">Liveliness Score: {worker.livelinessScore?.toLocaleString()}</p>
<p className="text-[10px]">BiTz XP: {worker.bitzXp?.toLocaleString()}</p>
</div>
</div>
</div>
))}
</div>
);
}
Loading

0 comments on commit b6b5f38

Please sign in to comment.