Skip to content

Commit 0dded80

Browse files
committed
fix: code improvement in court branch section and field component
1 parent 1fa8d3e commit 0dded80

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

web/src/components/DisputeView/DisputeInfo/DisputeInfoCard.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import React, { useMemo } from "react";
22
import styled, { css } from "styled-components";
33

4-
import { Link } from "react-router-dom";
5-
64
import LawBalanceIcon from "svgs/icons/law-balance.svg";
75

8-
import { useScrollTop } from "hooks/useScrollTop";
96
import { useCourtTree } from "hooks/queries/useCourtTree";
107

118
import { landscapeStyle } from "styles/landscapeStyle";
@@ -67,19 +64,6 @@ const StyledField = styled(Field)`
6764
}
6865
`;
6966

70-
const StyledLink = styled(Link)`
71-
width: 100%;
72-
:hover {
73-
label {
74-
&.value {
75-
cursor: pointer;
76-
color: ${({ theme }) => theme.primaryBlue};
77-
text-decoration: underline;
78-
}
79-
}
80-
}
81-
`;
82-
8367
type IDisputeInfoCard = { fieldItems: FieldItem[] } & IDisputeInfo;
8468

8569
const DisputeInfoCard: React.FC<IDisputeInfoCard> = ({
@@ -91,7 +75,6 @@ const DisputeInfoCard: React.FC<IDisputeInfoCard> = ({
9175
disputeID,
9276
round,
9377
}) => {
94-
const scrollTop = useScrollTop();
9578
const { data } = useCourtTree();
9679
const courtPath = getCourtsPath(data?.court, courtId);
9780
const items = useMemo(
@@ -104,9 +87,13 @@ const DisputeInfoCard: React.FC<IDisputeInfoCard> = ({
10487
<Container>
10588
{court && courtId && isOverview && (
10689
<CourtBranchFieldContainer>
107-
<StyledLink to={`/courts/${courtId}`} onClick={() => scrollTop()}>
108-
<StyledField icon={LawBalanceIcon} name="Court Branch" value={courtBranchValue} {...{ isOverview }} />
109-
</StyledLink>
90+
<StyledField
91+
link={`/courts/${courtId}`}
92+
icon={LawBalanceIcon}
93+
name="Court Branch"
94+
value={courtBranchValue}
95+
{...{ isOverview }}
96+
/>
11097
</CourtBranchFieldContainer>
11198
)}
11299
<RestOfFieldsContainer {...{ isOverview }}>

web/src/components/Field.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from "react";
22
import styled, { css } from "styled-components";
3+
import { landscapeStyle } from "styles/landscapeStyle";
34

45
import { Link } from "react-router-dom";
56

6-
import { landscapeStyle } from "styles/landscapeStyle";
7+
import { useScrollTop } from "hooks/useScrollTop";
78

89
const FieldContainer = styled.div<FieldContainerProps>`
910
display: flex;
@@ -61,6 +62,8 @@ const LinkContainer = styled.div``;
6162

6263
const StyledLink = styled(Link)`
6364
color: ${({ theme }) => theme.primaryBlue};
65+
text-wrap: auto;
66+
justify-content: end;
6467
`;
6568

6669
type FieldContainerProps = {
@@ -93,6 +96,8 @@ const Field: React.FC<IField> = ({
9396
isJurorBalance,
9497
className,
9598
}) => {
99+
const scrollTop = useScrollTop();
100+
96101
return (
97102
<FieldContainer isList={displayAsList} {...{ isOverview, isJurorBalance, width, className }}>
98103
<Icon />
@@ -103,6 +108,7 @@ const Field: React.FC<IField> = ({
103108
to={link}
104109
onClick={(event) => {
105110
event.stopPropagation();
111+
scrollTop();
106112
}}
107113
>
108114
{value}

0 commit comments

Comments
 (0)