Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web/src/components/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ const Popup: React.FC<PopupProps & IPopup> = ({
const closePopup = () => {
setIsOpen(false);
resetValue();
// dispute data is cleared, so if popup is closed the preview will show empty,
// instead redirect to start point.
if (popupType === PopupType.DISPUTE_CREATED) navigate("/resolver");
};

return (
Expand Down
9 changes: 6 additions & 3 deletions web/src/context/NewDisputeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface INewDisputeContext {
setIsPolicyUploading: (isPolicyUploading: boolean) => void;
}

const initialDisputeData: IDisputeData = {
const getInitialDisputeData = (): IDisputeData => ({
numberOfJurors: 3,
title: "",
description: "",
Expand All @@ -72,7 +72,9 @@ const initialDisputeData: IDisputeData = {
],
aliasesArray: [{ name: "", address: "", id: "1" }],
version: "1.0",
};
});

const initialDisputeData = getInitialDisputeData();

const NewDisputeContext = createContext<INewDisputeContext | undefined>(undefined);

Expand All @@ -92,7 +94,8 @@ export const NewDisputeProvider: React.FC<{ children: React.ReactNode }> = ({ ch
const disputeTemplate = useMemo(() => constructDisputeTemplate(disputeData), [disputeData]);

const resetDisputeData = useCallback(() => {
setDisputeData(initialDisputeData);
const freshData = getInitialDisputeData();
setDisputeData(freshData);
}, [setDisputeData]);

const contextValues = useMemo(
Expand Down
6 changes: 5 additions & 1 deletion web/src/pages/Resolver/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react";
import React, { useEffect } from "react";
import styled, { css } from "styled-components";

import { Navigate, Route, Routes, useLocation } from "react-router-dom";
import { useToggle } from "react-use";
import { useAccount } from "wagmi";

import { useNewDisputeContext } from "context/NewDisputeContext";

import { MAX_WIDTH_LANDSCAPE, landscapeStyle } from "styles/landscapeStyle";
import { responsiveSize } from "styles/responsiveSize";

Expand Down Expand Up @@ -79,7 +81,9 @@ const DisputeResolver: React.FC = () => {
const [isDisputeResolverMiniGuideOpen, toggleDisputeResolverMiniGuide] = useToggle(false);
const { isConnected } = useAccount();
const isPreviewPage = location.pathname.includes("/preview");
const { resetDisputeData } = useNewDisputeContext();

useEffect(() => resetDisputeData(), []);
return (
<Wrapper>
<HeroImage />
Expand Down
Loading