Skip to content

Commit 881a9c8

Browse files
authored
Merge pull request #1949 from kleros/fix/courts-page-name
fix: court name
2 parents a791baa + 29a0082 commit 881a9c8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

web/src/pages/Courts/CourtDetails/StakePanel/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const InputArea = styled(TagArea)`
4444
flex-direction: column;
4545
`;
4646

47-
const StakePanel: React.FC<{ courtName: string }> = ({ courtName = "Unknown Court" }) => {
47+
const StakePanel: React.FC<{ courtName: string | undefined }> = ({ courtName }) => {
4848
const [amount, setAmount] = useState("");
4949
const [isActive, setIsActive] = useState<boolean>(true);
5050
const [action, setAction] = useState<ActionType>(ActionType.stake);
@@ -65,7 +65,7 @@ const StakePanel: React.FC<{ courtName: string }> = ({ courtName = "Unknown Cour
6565
<TextArea>
6666
<strong>{`${isStaking ? "Stake" : "Withdraw"} PNK`}</strong> {`${isStaking ? "to join the" : "from"}`}{" "}
6767
{courtName}
68-
{courtName.toLowerCase().endsWith("court") || courtName.toLowerCase().startsWith("corte") ? null : " Court"}
68+
{courtName?.toLowerCase().endsWith("court") || courtName?.toLowerCase().startsWith("corte") ? null : " Court"}
6969
</TextArea>
7070
<InputArea>
7171
<InputDisplay {...{ action, amount, setAmount }} />

web/src/pages/Courts/CourtDetails/index.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Card, Breadcrumb } from "@kleros/ui-components-library";
88

99
import { isProductionDeployment } from "consts/index";
1010

11-
import { useCourtPolicy } from "queries/useCourtPolicy";
1211
import { useCourtTree, CourtTreeQuery } from "queries/useCourtTree";
1312

1413
import { landscapeStyle } from "styles/landscapeStyle";
@@ -99,7 +98,6 @@ const StakePanelAndStats = styled.div`
9998

10099
const CourtDetails: React.FC = () => {
101100
const { id } = useParams();
102-
const { data: policy } = useCourtPolicy(id);
103101
const { data } = useCourtTree();
104102
const [isStakingMiniGuideOpen, toggleStakingMiniGuide] = useToggle(false);
105103
const navigate = useNavigate();
@@ -112,13 +110,16 @@ const CourtDetails: React.FC = () => {
112110
value: node.id,
113111
})) ?? [];
114112

113+
const currentCourt = courtPath?.[courtPath.length - 1];
114+
const courtName = currentCourt?.name;
115+
115116
return (
116117
<Container>
117118
<TopSearch />
118119
<StyledCard>
119120
<CourtHeader>
120121
<CourtInfo>
121-
{policy ? policy.name : <StyledSkeleton width={200} />}
122+
{data ? courtName : <StyledSkeleton width={200} />}
122123
{breadcrumbItems.length > 1 ? (
123124
<StyledBreadcrumb
124125
items={breadcrumbItems}
@@ -138,7 +139,7 @@ const CourtDetails: React.FC = () => {
138139
</CourtHeader>
139140
<Divider />
140141
<StakePanelAndStats>
141-
<StakePanel courtName={policy?.name} />
142+
<StakePanel {...{ courtName }} />
142143
<Stats />
143144
</StakePanelAndStats>
144145
</StyledCard>

0 commit comments

Comments
 (0)