Skip to content

Commit

Permalink
refactor: clear naming and query params
Browse files Browse the repository at this point in the history
  • Loading branch information
nhestrompia committed Sep 15, 2023
1 parent 28547bb commit 5127f0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
6 changes: 6 additions & 0 deletions web/src/hooks/queries/useCounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import { graphqlQueryFnHelper } from "utils/graphqlQueryFnHelper";
const counterQuery = graphql(`
query Counter {
counter(id: "0") {
id
cases
casesRuled
casesVoting
casesAppealing
stakedPNK
redistributedPNK
paidETH
activeJurors
}
}
`);
Expand Down
12 changes: 6 additions & 6 deletions web/src/pages/Cases/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ export const calculatePages = (
return 0;
}

let totalPages = 0;
let totalCases = 0;

switch (status) {
case 1:
totalPages =
totalCases =
"counter" in data
? data?.counter?.cases - data?.counter?.casesRuled
: (data as CourtDetailsQuery).court?.numberDisputes - (data as CourtDetailsQuery).court?.numberClosedDisputes;
break;
case 2:
totalPages =
totalCases =
"counter" in data ? data?.counter?.casesRuled : (data as CourtDetailsQuery).court?.numberClosedDisputes;
break;
case 3:
totalPages =
totalCases =
"counter" in data ? data?.counter?.casesAppealing : (data as CourtDetailsQuery).court?.numberAppealingDisputes;
break;
default:
totalPages = "counter" in data ? numberDisputes ?? 0 : (data as CourtDetailsQuery).court?.numberDisputes;
totalCases = "counter" in data ? numberDisputes ?? 0 : (data as CourtDetailsQuery).court?.numberDisputes;
}

return totalPages / casesPerPage;
return totalCases / casesPerPage;
};

const Cases: React.FC = () => {
Expand Down
12 changes: 6 additions & 6 deletions web/src/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ const calculatePages = (status: number, data: UserQuery | undefined, casesPerPag
return 0;
}

let totalPages = 0;
let totalCases = 0;

switch (status) {
case 1:
totalPages = data.user?.totalDisputes - data.user?.totalResolvedDisputes;
totalCases = data.user?.totalDisputes - data.user?.totalResolvedDisputes;
break;
case 2:
totalPages = data.user?.totalResolvedDisputes ?? 0;
totalCases = data.user?.totalResolvedDisputes ?? 0;
break;
case 3:
totalPages = myAppeals ?? 0;
totalCases = myAppeals ?? 0;
break;
default:
totalPages = data.user?.totalDisputes ?? 0;
totalCases = data.user?.totalDisputes ?? 0;
}

return totalPages / casesPerPage;
return totalCases / casesPerPage;
};

const Dashboard: React.FC = () => {
Expand Down
8 changes: 2 additions & 6 deletions web/src/styles/global-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const GlobalStyle = createGlobalStyle`
.react-loading-skeleton {
z-index: 0;
--base-color: ${({ theme }) => theme.lightGrey};
--highlight-color: ${({ theme }) => theme.stroke};
--base-color: ${({ theme }) => theme.skeletonBackground};
--highlight-color: ${({ theme }) => theme.skeletonHighlight};
}
body {
Expand Down Expand Up @@ -105,8 +105,4 @@ export const GlobalStyle = createGlobalStyle`
}
}
.react-loading-skeleton {
--base-color: ${({ theme }) => theme.skeletonBackground};
--highlight-color: ${({ theme }) => theme.skeletonHighlight};
}
`;

0 comments on commit 5127f0f

Please sign in to comment.