Skip to content

Commit 2861d39

Browse files
authored
Merge pull request #825 from kleros/feat(web)/add-function-return-types
feat: add return types for functions
2 parents 2739c3e + 2e7547d commit 2861d39

19 files changed

+52
-109
lines changed

web/src/components/DisputeCard/DisputeInfo.tsx

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react";
22
import styled from "styled-components";
33
import { Periods } from "consts/periods";
4-
import LawBalanceIcon from "svgs/icons/law-balance.svg";
54
import BookmarkIcon from "svgs/icons/bookmark.svg";
6-
import PileCoinsIcon from "svgs/icons/pile-coins.svg";
75
import CalendarIcon from "svgs/icons/calendar.svg";
6+
import LawBalanceIcon from "svgs/icons/law-balance.svg";
7+
import PileCoinsIcon from "svgs/icons/pile-coins.svg";
88
import Field from "../Field";
99

1010
const Container = styled.div`
@@ -13,7 +13,7 @@ const Container = styled.div`
1313
gap: 8px;
1414
`;
1515

16-
const getPeriodPhrase = (period: Periods) => {
16+
const getPeriodPhrase = (period: Periods): string => {
1717
switch (period) {
1818
case Periods.evidence:
1919
return "Voting Starts";
@@ -35,36 +35,14 @@ export interface IDisputeInfo {
3535
date?: number;
3636
}
3737

38-
const DisputeInfo: React.FC<IDisputeInfo> = ({
39-
courtId,
40-
court,
41-
category,
42-
rewards,
43-
period,
44-
date,
45-
}) => {
38+
const DisputeInfo: React.FC<IDisputeInfo> = ({ courtId, court, category, rewards, period, date }) => {
4639
return (
4740
<Container>
48-
{category && (
49-
<Field icon={BookmarkIcon} name="Category" value={category} />
50-
)}
51-
{court && courtId && (
52-
<Field
53-
icon={LawBalanceIcon}
54-
name="Court"
55-
value={court}
56-
link={`/courts/${courtId}`}
57-
/>
58-
)}
59-
{rewards && (
60-
<Field icon={PileCoinsIcon} name="Juror Rewards" value={rewards} />
61-
)}
41+
{category && <Field icon={BookmarkIcon} name="Category" value={category} />}
42+
{court && courtId && <Field icon={LawBalanceIcon} name="Court" value={court} link={`/courts/${courtId}`} />}
43+
{rewards && <Field icon={PileCoinsIcon} name="Juror Rewards" value={rewards} />}
6244
{typeof period !== "undefined" && date && (
63-
<Field
64-
icon={CalendarIcon}
65-
name={getPeriodPhrase(period)}
66-
value={new Date(date * 1000).toLocaleString()}
67-
/>
45+
<Field icon={CalendarIcon} name={getPeriodPhrase(period)} value={new Date(date * 1000).toLocaleString()} />
6846
)}
6947
</Container>
7048
);

web/src/components/DisputeCard/PeriodBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const Container = styled.div<Omit<IPeriodBanner, "id">>`
5454
}};
5555
`;
5656

57-
const getPeriodLabel = (period: Periods) => {
57+
const getPeriodLabel = (period: Periods): string => {
5858
switch (period) {
5959
case Periods.appeal:
6060
return "Crowdfunding Appeal";

web/src/hooks/queries/useCasesQuery.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ export type { CasesPageQuery };
55

66
const casesQuery = gql`
77
query CasesPage($skip: Int) {
8-
disputes(
9-
first: 3
10-
skip: $skip
11-
orderBy: lastPeriodChange
12-
orderDirection: desc
13-
) {
8+
disputes(first: 3, skip: $skip, orderBy: lastPeriodChange, orderDirection: desc) {
149
id
1510
arbitrated {
1611
id
@@ -30,7 +25,7 @@ const casesQuery = gql`
3025
}
3126
`;
3227

33-
export const useCasesQuery = (skip: number) => {
28+
export const useCasesQuery = (skip: number): { data: typeof result; error: any; isValidating: boolean } => {
3429
const { data, error, isValidating } = useSWR({
3530
query: casesQuery,
3631
variables: { skip: skip },

web/src/hooks/queries/useClassicAppealQuery.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const classicAppealQuery = gql`
2929
}
3030
`;
3131

32-
export const useClassicAppealQuery = (id?: string | number) => {
32+
export const useClassicAppealQuery = (
33+
id?: string | number
34+
): { data: typeof result; error: any; isValidating: boolean } => {
3335
const { data, error, isValidating } = useSWR(() =>
3436
typeof id !== "undefined"
3537
? {

web/src/hooks/queries/useCourtDetails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const courtDetailsQuery = gql`
1818
}
1919
`;
2020

21-
export const useCourtDetails = (id?: string) => {
21+
export const useCourtDetails = (id?: string): { data: typeof result; error: any; isValidating: boolean } => {
2222
const { data, error, isValidating } = useSWR(
2323
id
2424
? {

web/src/hooks/queries/useCourtPolicyURI.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const courtPolicyURIQuery = gql`
1111
}
1212
`;
1313

14-
export const useCourtPolicyURI = (id?: string | number) => {
14+
export const useCourtPolicyURI = (id?: string | number): { data: typeof result; error: any; isValidating: boolean } => {
1515
const { data, error, isValidating } = useSWRImmutable(() =>
1616
typeof id !== "undefined"
1717
? {
@@ -20,8 +20,6 @@ export const useCourtPolicyURI = (id?: string | number) => {
2020
}
2121
: false
2222
);
23-
const result = data
24-
? (data.court.policy as CourtPolicyUriQuery.court.policy)
25-
: undefined;
23+
const result = data ? (data.court.policy as CourtPolicyUriQuery.court.policy) : undefined;
2624
return { data: result, error, isValidating };
2725
};

web/src/hooks/queries/useCourtTree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const courtTreeQuery = gql`
3232
}
3333
`;
3434

35-
export const useCourtTree = () => {
35+
export const useCourtTree = (): { data: typeof result; error: any; isValidating: boolean } => {
3636
const { data, error, isValidating } = useSWR({
3737
query: courtTreeQuery,
3838
});

web/src/hooks/queries/useDisputeDetailsQuery.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ const disputeDetailsQuery = gql`
2222
}
2323
`;
2424

25-
export const useDisputeDetailsQuery = (id?: string | number) => {
25+
export const useDisputeDetailsQuery = (
26+
id?: string | number
27+
): { data: typeof result; error: any; isValidating: boolean } => {
2628
const { data, error, isValidating } = useSWR(() =>
2729
typeof id !== "undefined"
2830
? {

web/src/hooks/queries/useDisputeKitClassicMultipliers.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ export const useDisputeKitClassicMultipliers = () => {
88
() => (disputeKitClassic ? `Multipliers` : false),
99
async () => {
1010
if (!disputeKitClassic) return;
11-
const winner_stake_multiplier =
12-
await disputeKitClassic.WINNER_STAKE_MULTIPLIER();
13-
const loser_stake_multiplier =
14-
await disputeKitClassic.LOSER_STAKE_MULTIPLIER();
15-
const loser_appeal_period_multiplier =
16-
await disputeKitClassic.LOSER_APPEAL_PERIOD_MULTIPLIER();
11+
const winner_stake_multiplier = await disputeKitClassic.WINNER_STAKE_MULTIPLIER();
12+
const loser_stake_multiplier = await disputeKitClassic.LOSER_STAKE_MULTIPLIER();
13+
const loser_appeal_period_multiplier = await disputeKitClassic.LOSER_APPEAL_PERIOD_MULTIPLIER();
1714
return {
1815
winner_stake_multiplier,
1916
loser_stake_multiplier,

web/src/hooks/queries/useDrawQuery.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ const drawQuery = gql`
1111
}
1212
`;
1313

14-
export const useDrawQuery = (address?: string | null, disputeID?: string) => {
14+
export const useDrawQuery = (
15+
address?: string | null,
16+
disputeID?: string
17+
): { data: typeof result; error: any; isValidating: boolean } => {
1518
const { data, error, isValidating } = useSWR({
1619
query: drawQuery,
1720
variables: { address, disputeID },

0 commit comments

Comments
 (0)