diff --git a/app/components/FUX/WorkstreamModal/index.tsx b/app/components/FUX/WorkstreamModal/index.tsx index 716a116..8e5a2df 100644 --- a/app/components/FUX/WorkstreamModal/index.tsx +++ b/app/components/FUX/WorkstreamModal/index.tsx @@ -1,3 +1,4 @@ +import { UserDocument } from "../../../.graphclient"; import { useMintWorkstream } from "../../../hooks/workstream"; import { useConstants } from "../../../utils/constants"; import { AddIcon } from "@chakra-ui/icons"; @@ -31,11 +32,13 @@ import { BigNumber, ethers } from "ethers"; import { DateTime } from "luxon"; import { useState, useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; +import { useQuery } from "urql"; type FormData = { name: string; duration: string; funding: number; + fuxGiven: number; }; const WorkstreamModal: React.FC<{ onCloseAction: () => void }> = ({ @@ -46,6 +49,19 @@ const WorkstreamModal: React.FC<{ onCloseAction: () => void }> = ({ const addWorkstream = useMintWorkstream(); const { nativeToken } = useConstants(); + const [result, reexecuteQuery] = useQuery({ + query: UserDocument, + variables: { + address: user?.toLowerCase() || "", + }, + }); + + const { data, fetching, error } = result; + + const fuxBalance = data?.user?.balances?.find( + (balance) => balance.token.name === "FUX" + )?.balance; + const [ethBalance, setEthBalance] = useState(BigNumber.from(0)); useEffect(() => { @@ -71,6 +87,7 @@ const WorkstreamModal: React.FC<{ onCloseAction: () => void }> = ({ name: "", duration: "7", funding: 0, + fuxGiven: fuxBalance, }, }); @@ -85,8 +102,16 @@ const WorkstreamModal: React.FC<{ onCloseAction: () => void }> = ({ const deadline = Number( DateTime.fromISO(form.duration).endOf("day").toSeconds().toFixed() ); + + const _fuxGiven = form.fuxGiven; if (user) { - addWorkstream(form.name, [user], deadline, funding).then(handleOnClose); + addWorkstream( + form.name, + [user], + _fuxGiven, + deadline, + funding + ).then(handleOnClose); } }; @@ -167,6 +192,45 @@ const WorkstreamModal: React.FC<{ onCloseAction: () => void }> = ({ )} /> + ( + <> + + How many FUX do you give? + + + + + + + + + + + FUX + + + + {`${fuxBalance} FUX to give`} + + + )} + /> diff --git a/app/hooks/workstream.ts b/app/hooks/workstream.ts index aac65af..29fe9dc 100644 --- a/app/hooks/workstream.ts +++ b/app/hooks/workstream.ts @@ -36,9 +36,10 @@ export const useMintWorkstream = () => { return async ( name: string, contributors: string[], + fux: number, deadline: number, value?: string - ) => mutate(name, contributors, deadline, { value }); + ) => mutate(name, contributors, fux, deadline, { value }); }; export const useCommitToWorkstream = () => {