You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we may need to create one more query file (in the queries folder) for solving this,
So this new query file useJurorStakedCourts.ts would be:
importuseSWRfrom"swr";import{graphql}from"src/graphql";constjurorStakedCourtsQuery=graphql(` query JurorStakedCourtsQuery($id: ID!) { user(id: $id) { tokens { court { id name } } } }`);exportconstuseJurorStakedCourts=(id?: string)=>{returnuseSWR(id
? {query: jurorStakedCourtsQuery,variables: { id },}
: null);};
Dashboard/Courts/index.tsx is the component that generates the CourtCard.tsx component. We need to do a map with all the courts the user is staked on.
so
modify the Dashboard/Courts/index.tsx component to use the query. then do a mapping and generate CourtCards dinamically. This is where the problem arises, useJurorStakedCourts(address?.toLowerCase()) returns undefined, and for reference, I also called the graphql query useCourtDetails next to it, which works correctly and returns the court data.
I have also tried the same query on TheGraph's playground and it works just fine:
modify CourtCard.tsx for something like this:
importReactfrom"react";importstyledfrom"styled-components";import{useAccount}from"wagmi";import{formatEther}from"viem";import{Cardas_Card,Breadcrumb}from"@kleros/ui-components-library";importWithHelpTooltipfrom"../WithHelpTooltip";import{isUndefined}from"utils/index";import{useKlerosCoreGetJurorBalance}from"hooks/contracts/generated";constCard=styled(_Card)` height: auto; width: 100%; padding: 12px 24px; border-left: 5px solid ${({ theme })=>theme.secondaryPurple};`;constValueContainer=styled.div` width: 100%; display: flex; align-items: center; justify-content: space-between;`;constStyledBreadcrumb=styled(Breadcrumb)` margin-bottom: 12px;`;consttooltipMsg="When a juror is selected to arbitrate a case, part of their stake (PNK) is "+"locked until the case is resolved. Jurors whose vote is coherent with the "+"final jury decision have their locked stake released. Jurors whose vote "+"is not coherent with the final jury decision, lose their locked stake. "+"The locked stake of incoherent jurors is redistributed as incentives for "+"the coherent jurors.";constformat=(value: bigint|undefined): string=>(value!==undefined ? formatEther(value) : "0");interfaceICourtCard{id: string;name: string;}constCourtCard: React.FC<ICourtCard>=({ id, name })=>{const{ address }=useAccount();const{data: jurorBalance}=useKlerosCoreGetJurorBalance({enabled: !isUndefined(address),args: [address,id],watch: true,});return(<Card><StyledBreadcrumbitems={[{text: name,value: 0}]}/><ValueContainer><label>Stake: </label><small>{`${format(jurorBalance?.[0])} PNK`}</small></ValueContainer><ValueContainer><WithHelpTooltip{...{place: "bottom", tooltipMsg }}><label>LockedStake: </label></WithHelpTooltip><small>{`${format(jurorBalance?.[1])} PNK`}</small></ValueContainer></Card>);};exportdefaultCourtCard;
The text was updated successfully, but these errors were encountered:
jaybuidl
changed the title
"10,000 PNK" and "1,000 PNK" on CourtCards on pages/Dashboard/Courts/CourtCard.tsx
Hardcoded values: "10,000 PNK" and "1,000 PNK" on CourtCards.tsx
Apr 14, 2023
we may need to create one more query file (in the
queries
folder) for solving this,So this new query file
useJurorStakedCourts.ts
would be:Dashboard/Courts/index.tsx
is the component that generates theCourtCard.tsx
component. We need to do a map with all the courts the user is staked on.so
Dashboard/Courts/index.tsx
component to use the query. then do a mapping and generateCourtCard
s dinamically. This is where the problem arises,useJurorStakedCourts(address?.toLowerCase())
returns undefined, and for reference, I also called the graphql queryuseCourtDetails
next to it, which works correctly and returns the court data.I have also tried the same query on TheGraph's playground and it works just fine:

CourtCard.tsx
for something like this:The text was updated successfully, but these errors were encountered: