Skip to content

Commit

Permalink
refactor(web): fix-code-smells
Browse files Browse the repository at this point in the history
  • Loading branch information
Harman-singh-waraich committed Jan 5, 2024
1 parent 13412f5 commit e69f849
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions web/src/components/DisputePreview/Alias.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ interface IAlias {
alias: Alias;
}

const Alias: React.FC<IAlias> = ({ alias }) => {
let address: string | `0x${string}`;
const AliasDisplay: React.FC<IAlias> = ({ alias }) => {
let address: string;

const { data: addressFromENS, isLoading } = useEnsAddress({
enabled: !isAddress(alias.address), //if alias.address is not an Address, we treat it as ENS and try to fetch address from there
Expand All @@ -49,4 +49,4 @@ const Alias: React.FC<IAlias> = ({ alias }) => {
);
};

export default Alias;
export default AliasDisplay;
10 changes: 5 additions & 5 deletions web/src/components/DisputePreview/DisputeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import ReactMarkdown from "components/ReactMarkdown";
import styled from "styled-components";
import { StyledSkeleton } from "components/StyledSkeleton";
import { isUndefined } from "utils/index";
import { Answer, IDisputeTemplate } from "context/NewDisputeContext";
import Alias from "./Alias";
import { Answer as IAnswer, IDisputeTemplate } from "context/NewDisputeContext";
import AliasDisplay from "./Alias";

const StyledH1 = styled.h1`
margin: 0;
Expand Down Expand Up @@ -81,8 +81,8 @@ export const DisputeContext: React.FC<IDisputeContext> = ({ disputeTemplate }) =
<VotingOptions>
{isUndefined(disputeTemplate) ? null : <h3>Voting Options</h3>}
<AnswersContainer>
{disputeTemplate?.answers?.map((answer: Answer, i: number) => (
<Answer key={i}>
{disputeTemplate?.answers?.map((answer: IAnswer, i: number) => (
<Answer key={`${answer.title}-${i}`}>
<small>Option {i + 1}:</small>
<label>{answer.title}</label>
</Answer>
Expand All @@ -95,7 +95,7 @@ export const DisputeContext: React.FC<IDisputeContext> = ({ disputeTemplate }) =
<Divider />
<AliasesContainer>
{disputeTemplate.aliases.map((alias, index) => (
<Alias alias={alias} key={index} />
<AliasDisplay alias={alias} key={`${alias.address}-${index}`} />
))}
</AliasesContainer>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StyledButton = styled(Button)``;
const SubmitDisputeButton: React.FC = () => {
const publicClient = usePublicClient();
const [isPopupOpen, setIsPopupOpen] = useState(false);
const [disputeId, setDisputeID] = useState<number>();
const [disputeId, setDisputeId] = useState<number>();

const { disputeTemplate, disputeData, resetDisputeData, isSubmittingCase, setIsSubmittingCase } =
useNewDisputeContext();
Expand Down Expand Up @@ -54,7 +54,7 @@ const SubmitDisputeButton: React.FC = () => {
if (res.status === "success") {
//TODO: better way or maybe log decoding to get the disputeID
const id = parseInt(res.logs[0].topics[1], 16);
setDisputeID(id);
setDisputeId(id);
setIsPopupOpen(true);
}

Expand Down
3 changes: 1 addition & 2 deletions web/src/pages/Resolver/Preview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from "react";
import styled from "styled-components";
import styled, { css } from "styled-components";
import { useCourtPolicy } from "queries/useCourtPolicy";
import DisputeInfo from "components/DisputeCard/DisputeInfo";
import { responsiveSize } from "styles/responsiveSize";
import { DisputeContext } from "components/DisputePreview/DisputeContext";
import { Policies } from "components/DisputePreview/Policies";
import { Card } from "@kleros/ui-components-library";
import { landscapeStyle } from "styles/landscapeStyle";
import { css } from "styled-components";
import NavigationButtons from "../NavigationButtons";
import { useNewDisputeContext } from "context/NewDisputeContext";

Expand Down

0 comments on commit e69f849

Please sign in to comment.