mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-15 21:11:02 +00:00
fix: fetch tiki/role data from People Chain instead of Relay Chain
This commit is contained in:
+14
-14
@@ -18,7 +18,7 @@ import { ReferralDashboard } from '@/components/referral/ReferralDashboard';
|
|||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { api, isApiReady, selectedAccount } = usePezkuwi();
|
const { api, isApiReady, peopleApi, isPeopleReady, selectedAccount } = usePezkuwi();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [profile, setProfile] = useState<Record<string, unknown> | null>(null);
|
const [profile, setProfile] = useState<Record<string, unknown> | null>(null);
|
||||||
@@ -101,40 +101,40 @@ export default function Dashboard() {
|
|||||||
|
|
||||||
const fetchScoresAndTikis = useCallback(async () => {
|
const fetchScoresAndTikis = useCallback(async () => {
|
||||||
|
|
||||||
if (!selectedAccount || !api) return;
|
if (!selectedAccount || !api || !peopleApi) return;
|
||||||
|
|
||||||
setLoadingScores(true);
|
setLoadingScores(true);
|
||||||
try {
|
try {
|
||||||
// Fetch all scores from blockchain (includes trust, referral, staking, tiki)
|
// Fetch all scores from blockchain (includes trust, referral, staking, tiki)
|
||||||
const allScores = await getAllScores(api, selectedAccount.address);
|
// Note: Trust and referral are on People Chain, staking is on Relay Chain
|
||||||
|
// For now, we use peopleApi for scores as most score pallets are on People Chain
|
||||||
|
const allScores = await getAllScores(peopleApi, selectedAccount.address);
|
||||||
setScores(allScores);
|
setScores(allScores);
|
||||||
|
|
||||||
// Also fetch tikis separately for role display (needed for role details)
|
// Fetch tikis from People Chain (tiki pallet is on People Chain)
|
||||||
const userTikis = await fetchUserTikis(api, selectedAccount.address);
|
const userTikis = await fetchUserTikis(peopleApi, selectedAccount.address);
|
||||||
setTikis(userTikis);
|
setTikis(userTikis);
|
||||||
|
|
||||||
// Fetch NFT details including collection/item IDs
|
// Fetch NFT details from People Chain
|
||||||
const details = await getAllTikiNFTDetails(api, selectedAccount.address);
|
const details = await getAllTikiNFTDetails(peopleApi, selectedAccount.address);
|
||||||
setNftDetails(details);
|
setNftDetails(details);
|
||||||
|
|
||||||
// Fetch KYC status to determine if user is a citizen
|
// Fetch KYC status from People Chain (identityKyc pallet is on People Chain)
|
||||||
const status = await getKycStatus(api, selectedAccount.address);
|
const status = await getKycStatus(peopleApi, selectedAccount.address);
|
||||||
setKycStatus(status);
|
setKycStatus(status);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (import.meta.env.DEV) console.error('Error fetching scores and tikis:', error);
|
if (import.meta.env.DEV) console.error('Error fetching scores and tikis:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingScores(false);
|
setLoadingScores(false);
|
||||||
}
|
}
|
||||||
}, [selectedAccount, api]);
|
}, [selectedAccount, api, peopleApi]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchProfile();
|
fetchProfile();
|
||||||
if (selectedAccount && api && isApiReady) {
|
if (selectedAccount && api && isApiReady && peopleApi && isPeopleReady) {
|
||||||
fetchScoresAndTikis();
|
fetchScoresAndTikis();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [user, selectedAccount, api, isApiReady, fetchProfile, fetchScoresAndTikis]);
|
}, [user, selectedAccount, api, isApiReady, peopleApi, isPeopleReady, fetchProfile, fetchScoresAndTikis]);
|
||||||
|
|
||||||
const sendVerificationEmail = async () => {
|
const sendVerificationEmail = async () => {
|
||||||
if (!user?.email) {
|
if (!user?.email) {
|
||||||
|
|||||||
Reference in New Issue
Block a user