Skip to content

Commit

Permalink
Merge commit '4f0e8c8fda09170cdc65ee9d54425e9a7328017f' into checkpoi…
Browse files Browse the repository at this point in the history
…nt/main_from_release_2.0.0_4f0e8c8fda09170cdc65ee9d54425e9a7328017f
  • Loading branch information
paninaro committed Aug 9, 2023
2 parents 6ee3970 + 4f0e8c8 commit 92ca8ad
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
12 changes: 10 additions & 2 deletions packages/gui/src/components/plot/add/PlotAddForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function PlotAddForm(props: Props) {
const [createNewPoolWallet] = useCreateNewPoolWalletMutation();
const addNFTref = useRef();
const { state } = useLocation();
const [showingPoolDetails, setShowingPoolDetails] = useState<boolean>(false);

const otherDefaults = {
plotCount: 1,
Expand Down Expand Up @@ -214,14 +215,21 @@ export default function PlotAddForm(props: Props) {
}
};

function adjustStepCount() {
if (showingPoolDetails) {
step++;
}
return step++;
}

return (
<Form methods={methods} onSubmit={handleSubmit}>
<Flex flexDirection="column" gap={3}>
<Back variant="h5" form>
<Trans>Add a Plot</Trans>
</Back>
<PlotAddNFT ref={addNFTref} step={step++} />
<PlotAddChoosePlotter step={step++} onChange={handlePlotterChanged} />
<PlotAddNFT ref={addNFTref} step={step++} setShowingPoolDetails={setShowingPoolDetails} />
<PlotAddChoosePlotter step={adjustStepCount()} onChange={handlePlotterChanged} />
<PlotAddChooseKeys step={step++} currencyCode={currencyCode} fingerprint={fingerprint} />
<PlotAddChooseSize step={step++} plotter={plotter} />
<PlotAddSelectFinalDirectory step={step++} plotter={plotter} />
Expand Down
10 changes: 9 additions & 1 deletion packages/gui/src/components/plot/add/PlotAddNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ import PlotNFTSelectPool from '../../plotNFT/select/PlotNFTSelectPool';

type Props = {
step: number;
setShowingPoolDetails?: (showing: boolean) => void;
};

const PlotAddNFT = forwardRef((props: Props, ref) => {
const { step } = props;
const { step, setShowingPoolDetails } = props;
const { nfts, external, loading } = usePlotNFTs();
const [showCreatePlotNFT, setShowCreatePlotNFT] = useState<boolean>(false);
const { setValue } = useFormContext();

const hasNFTs = !!nfts?.length || !!external?.length;

React.useEffect(() => {
if (!showCreatePlotNFT && setShowingPoolDetails) {
setShowingPoolDetails(false);
}
}, [showCreatePlotNFT, setShowingPoolDetails]);

function handleJoinPool() {
setShowCreatePlotNFT(true);
setValue('createNFT', true);
Expand All @@ -37,6 +44,7 @@ const PlotAddNFT = forwardRef((props: Props, ref) => {
onCancel={handleCancelPlotNFT}
ref={ref}
title={<Trans>Create a Plot NFT</Trans>}
setShowingPoolDetails={setShowingPoolDetails}
description={
<Trans>
Join a pool and get consistent XCH farming rewards. The average returns are the same, but it is much less
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ type Props = {
description?: ReactNode;
hideFee?: boolean;
feeDescription?: ReactNode;
setShowingPoolDetails?: (showing: boolean) => void;
};

export default function PlotNFTSelectBase(props: Props) {
const { step, onCancel, title, description, hideFee = false, feeDescription } = props;
const { step, onCancel, title, description, hideFee = false, feeDescription, setShowingPoolDetails } = props;
// const { nfts } = usePlotNFTs();
const { setValue } = useFormContext();
const self: boolean = useWatch({
Expand Down Expand Up @@ -59,6 +60,12 @@ export default function PlotNFTSelectBase(props: Props) {

const showPoolInfo = !self && !!poolUrl;

React.useEffect(() => {
if (setShowingPoolDetails) {
setShowingPoolDetails(showPoolInfo);
}
}, [showPoolInfo, setShowingPoolDetails]);

return (
<>
<CardStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type Props = {
poolUrl?: string;
};
feeDescription?: ReactNode;
setShowingPoolDetails?: (showing: boolean) => void;
};

const PlotNFTSelectPool = forwardRef((props: Props, ref) => {
Expand All @@ -79,6 +80,7 @@ const PlotNFTSelectPool = forwardRef((props: Props, ref) => {
submitTitle = <Trans>Create</Trans>,
hideFee = false,
feeDescription,
setShowingPoolDetails,
} = props;
const [loading, setLoading] = useState<boolean>(false);
const { balance, loading: walletLoading } = useStandardWallet();
Expand Down Expand Up @@ -161,6 +163,7 @@ const PlotNFTSelectPool = forwardRef((props: Props, ref) => {
description={description}
hideFee={hideFee}
feeDescription={feeDescription}
setShowingPoolDetails={setShowingPoolDetails}
/>
{exceededNFTLimit && (
<Alert severity="error">
Expand Down

0 comments on commit 92ca8ad

Please sign in to comment.