Skip to content

Commit

Permalink
fix proposalOffering to eval based on sponsorThreshold (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
santteegt authored Sep 6, 2022
1 parent 6cb6f28 commit eb9e5ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apps/core-app/src/components/customFields/ProposalOffering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@daohaus/common-utilities';
import { useConnectedMembership, useDao } from '@daohaus/dao-context';
import { Buildable, ParMd, TintSecondary } from '@daohaus/ui';
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import { useParams } from 'react-router-dom';

Expand All @@ -14,25 +14,27 @@ export const ProposalOffering = (props: Buildable<{ id?: string }>) => {
const { daochain } = useParams();
const { dao } = useDao();
const { connectedMembership } = useConnectedMembership();
const { setValue } = useFormContext();
const { register, setValue } = useFormContext();
const [requiresOffering, setRequiresOffering] = useState(false);

const networkTokenSymbol =
isValidNetwork(daochain) && NETWORK_DATA[daochain]?.symbol;

register(id);

useEffect(() => {
if (!dao || !id) return;

if (
!connectedMembership ||
dao.proposalOffering > connectedMembership.shares
dao.sponsorThreshold > connectedMembership.shares
) {
setRequiresOffering(true);
setValue(id, dao.proposalOffering);
return;
}

setValue(id, '');
setValue(id, '0');
setRequiresOffering(false);
return;
}, [dao, connectedMembership, setValue, id]);
Expand Down

0 comments on commit eb9e5ed

Please sign in to comment.