Skip to content

Commit

Permalink
Merge pull request #161 from PotLock:payout-update
Browse files Browse the repository at this point in the history
Payout-update
  • Loading branch information
M-Rb3 authored Jul 10, 2024
2 parents d960c63 + 92353ee commit 2ff7217
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/pages/Pot/components/PayoutsModal/PayoutsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Big, useMemo, useState, Tooltip, OverlayTrigger, context, Near } from "
import PotSDK from "@app/SDK/pot";
import Button from "@app/components/Button";
import Text from "@app/components/Inputs/Text/Text";
import TextArea from "@app/components/Inputs/TextArea/TextArea";
import Alert from "@app/modals/ModalDonation/Banners/Alert";
import ModalOverlay from "@app/modals/ModalOverlay";
import { CalculatedPayout } from "@app/types";
Expand All @@ -23,6 +24,7 @@ const PayoutsModal = ({
const [qfWeight, setQfWeight] = useState("100");
const [jdgWeight, setJdgWeight] = useState("0");
const [error, setError] = useState("");
const [message, setMessage] = useState("");

const calcNear = (amount: string) => Big(amount).div(Big(10).pow(24)).toNumber().toFixed(2);
const calcYoctos = (amount: string) => new Big(amount).mul(new Big(10).pow(24)).toString();
Expand Down Expand Up @@ -73,6 +75,7 @@ const PayoutsModal = ({
const [finalPayoutList, finalAmountNear, sumAssignedWeightsCalc, remainder, post] = useMemo(() => {
let finalAmount = Big(0);
let sumAssignedWeightsCalc = 0;

let post = `Pot Id: ${potId}\\n\\nTotal Pot: 11149.11\\n\\nQF Weight:${qfWeight}%\\n\\nJudges Weights:${jdgWeight}%\\n\\n| Project | Actual QF | QF Override | QF Weight Adjusted | Assigned Weight (%) | Assigned Weight Calculation | Final Calculation |\\n| --- | --- | --- | --- | --- | --- | --- |\\n`;

const payoutList = Object.entries(payouts).map(([projectId, { matchingAmount }], idx: any) => {
Expand Down Expand Up @@ -110,6 +113,8 @@ const PayoutsModal = ({
}, [assigendWeights, payoutsList, qfWeight, jdgWeight]);

const handlePayout = () => {
const notes = `${message}\\n${post}`;

let payoutsArr = finalPayoutList.filter((payout) => payout.amount !== "0");

let yoctos = sumAmount(payoutsArr);
Expand All @@ -135,7 +140,7 @@ const PayoutsModal = ({
data: {
[context.accountId || ""]: {
post: {
main: `{\"type\":\"md\",\"text\":\"${post}\"}`,
main: `{\"type\":\"md\",\"text\":\"${notes}\"}`,
},
index: {
post: '{"key":"main","value":{"type":"md"}}',
Expand Down Expand Up @@ -219,6 +224,7 @@ const PayoutsModal = ({
value={jdgWeight}
/>
</div>
<TextArea label="message" onChange={(value: any) => setMessage(value)} value={message} placeholder="Notes" />
<TableHeader>
{payoutDescription.map(({ title, description }) =>
description ? (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Pot/components/PayoutsModal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const Container = styled.div`
gap: 1rem;
position: relative;
overflow-x: scroll;
height: 80vh;
height: 100%;
`;

export const Title = styled.div`
Expand Down

0 comments on commit 2ff7217

Please sign in to comment.