Skip to content

Commit

Permalink
fix public view page
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-torabiv committed Dec 11, 2024
1 parent 156e424 commit 08aa132
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/pages/reputation-score/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function ReputationScore() {
color='primary'
onClick={() =>
router.push(
`/${dynamicNFTModuleInfo?.metadata[0]?.tokenId}/${address}/score`
`/reputation-score/score?tokenId=${dynamicNFTModuleInfo?.metadata[0]?.tokenId}&address=${address}`
)
}
disabled={!isConnected}
Expand Down
23 changes: 11 additions & 12 deletions src/pages/[...score].tsx → src/pages/reputation-score/score.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import React, { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import { FiShare2 } from 'react-icons/fi';

import GaugeChart from '@/components/global/GaugeChart';
Expand All @@ -16,7 +15,6 @@ import { useSnackbar } from '@/context/SnackbarContext';
const ScorePage = () => {
const { showMessage } = useSnackbar();
const { retrieveReputationScore } = useAppStore();
const router = useRouter();

const [communityName, setCommunityName] = useState<string | null>(null);
const [reputationScore, setReputationScore] = useState<number | null>(null);
Expand All @@ -41,18 +39,19 @@ const ScorePage = () => {
}
};

if (router.isReady) {
const { score } = router.query; // Retrieve query params from URL
if (!score || !Array.isArray(score) || score.length < 2) {
setError('Invalid URL format. Missing tokenId or address.');
setLoading(false);
return;
}
// Use URLSearchParams to extract query parameters
const params = new URLSearchParams(window.location.search);
const tokenId = params.get('tokenId');
const address = params.get('address');

const [tokenId, address] = score;
fetchReputationScore(tokenId, address);
if (!tokenId || !address) {
setError('Invalid URL format. Missing tokenId or address.');
setLoading(false);
return;
}
}, [router.isReady, router.query, retrieveReputationScore]);

fetchReputationScore(tokenId, address);
}, [retrieveReputationScore]);

const gaugeOptions = {
chart: {
Expand Down

0 comments on commit 08aa132

Please sign in to comment.