Skip to content

Commit

Permalink
fix loading app issue
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamejason committed Feb 6, 2024
1 parent aca35b6 commit 41cc7ad
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/builder/src/components/rounds/ViewApplication.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { useDataLayer } from "data-layer";
import { RoundApplicationAnswers } from "data-layer/dist/roundApplication.types";
import { useEffect } from "react";
import { shallowEqual, useDispatch, useSelector } from "react-redux";
import { useNavigate, useParams } from "react-router-dom";
import { useDataLayer } from "data-layer";
import { RoundApplicationAnswers } from "data-layer/dist/roundApplication.types";
import {
fetchApplicationData,
submitApplication,
} from "../../actions/roundApplication";
import { loadRound, unloadRounds } from "../../actions/rounds";
import { RootState } from "../../reducers";
import Button, { ButtonVariants } from "../base/Button";
import { Status as ApplicationStatus } from "../../reducers/roundApplication";
import { Status as RoundStatus } from "../../reducers/rounds";
import { grantsPath, projectPathByID } from "../../routes";
import colors from "../../styles/colors";
import { isInfinite } from "../../utils/components";
import { ROUND_PAYOUT_DIRECT } from "../../utils/utils";
import Form from "../application/Form";
import Button, { ButtonVariants } from "../base/Button";
import ErrorModal from "../base/ErrorModal";
import LoadingSpinner from "../base/LoadingSpinner";
import Cross from "../icons/Cross";
import { isInfinite } from "../../utils/components";
import { ROUND_PAYOUT_DIRECT } from "../../utils/utils";

const formatDate = (unixTS: number) =>
new Date(unixTS).toLocaleDateString(undefined);
Expand Down Expand Up @@ -52,11 +52,10 @@ function ViewApplication() {

const publishedApplicationMetadata = applicationState
? applicationState.metadataFromIpfs![ipfsHash!]
: null;
: undefined;

const roundApplicationStatus =
applicationState?.metadataFromIpfs![ipfsHash!].publishedApplicationData
.status;
publishedApplicationMetadata?.status ?? "IN_REVIEW";

const web3ChainId = state.web3.chainID;
const roundChainId = Number(chainId);
Expand All @@ -83,9 +82,9 @@ function ViewApplication() {
}, shallowEqual);

useEffect(() => {
if (roundId !== undefined) {
if (roundId !== undefined || !props.publishedApplicationMetadata) {
dispatch(unloadRounds());
dispatch(loadRound(roundId, dataLayer, props.roundChainId));
dispatch(loadRound(roundId!, dataLayer, props.roundChainId));
}
}, [dispatch, roundId]);

Expand Down Expand Up @@ -123,15 +122,14 @@ function ViewApplication() {
}

const isDirectRound = props.round?.payoutStrategy === ROUND_PAYOUT_DIRECT;

const roundInReview = props.roundApplicationStatus === "IN_REVIEW";
const roundApproved = props.roundApplicationStatus === "APPROVED";
const hasProperStatus = roundInReview || roundApproved;

if (
props.roundState === undefined ||
props.round === undefined ||
props.publishedApplicationMetadata === null
props.publishedApplicationMetadata === undefined
) {
return (
<LoadingSpinner
Expand Down

0 comments on commit 41cc7ad

Please sign in to comment.