From 81d289584879499d725ce7af696734e77ccb7227 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:01:35 -0400 Subject: [PATCH 1/6] remove leftover navigate --- src/components/pages/Roles/forms/RoleFormPaymentStream.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx index 9f00d6aa62..6cf071a6b6 100644 --- a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx +++ b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx @@ -24,7 +24,6 @@ import { ArrowLeft, ArrowRight, Minus, Plus } from '@phosphor-icons/react'; import { Field, FieldProps, FormikErrors, useFormikContext } from 'formik'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { useNavigate } from 'react-router-dom'; import { getAddress } from 'viem'; import { CARD_SHADOW } from '../../../../constants/common'; import { useRolesStore } from '../../../../store/roles'; @@ -366,7 +365,6 @@ export default function RoleFormPaymentStream({ formIndex }: { formIndex: number const { t } = useTranslation(['roles']); const { values, errors, setFieldValue } = useFormikContext(); const { hatsTree, getPayment } = useRolesStore(); - const navigate = useNavigate(); const roleEditingPaymentsErrors = (errors.roleEditing as FormikErrors)?.payments; return ( { - const currentPath = location.pathname + location.search; - navigate(`${currentPath}#tab1`); setFieldValue('roleEditing.roleEditingPaymentIndex', undefined); }} > From 1c4a5ac975c223c455ee3448d327d8bedc2ecf31 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:02:42 -0400 Subject: [PATCH 2/6] update existing payment logic --- .../pages/Roles/forms/RoleFormPaymentStream.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx index 6cf071a6b6..b8a1c1eb26 100644 --- a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx +++ b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx @@ -390,16 +390,12 @@ export default function RoleFormPaymentStream({ formIndex }: { formIndex: number onClick={() => { if (!values?.roleEditing?.payments || !hatsTree) return; - let isExistingPayment: boolean = false; - if (values?.roleEditing?.payments?.[formIndex].streamId) { - const foundPayment = getPayment( + const isExistingPayment = + values?.roleEditing?.payments?.[formIndex].streamId && + getPayment( values.roleEditing.id, getAddress(values.roleEditing.payments[formIndex].streamId), ); - if (foundPayment) { - isExistingPayment = true; - } - } // if payment is new, and unedited, remove it if ( formIndex === values.roleEditing.payments.length - 1 && From 6d39b500751a73fa55b1596329cef0d9fdada83a Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:18:31 -0400 Subject: [PATCH 3/6] chore: Disable button when payment is not available for editing --- src/components/pages/Roles/forms/RoleFormPaymentStream.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx index b8a1c1eb26..dd489ee8df 100644 --- a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx +++ b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx @@ -387,11 +387,12 @@ export default function RoleFormPaymentStream({ formIndex }: { formIndex: number }} mb="1rem" leftIcon={} + isDisabled={!values?.roleEditing?.payments?.[formIndex]} onClick={() => { - if (!values?.roleEditing?.payments || !hatsTree) return; + if (!values?.roleEditing?.payments?.[formIndex]) return; const isExistingPayment = - values?.roleEditing?.payments?.[formIndex].streamId && + values.roleEditing.payments[formIndex].streamId && getPayment( values.roleEditing.id, getAddress(values.roleEditing.payments[formIndex].streamId), From f8ee6435bc5a0553d24d7bed4ae86afd8f0951a9 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:30:41 -0400 Subject: [PATCH 4/6] update usd price logic --- src/components/pages/Roles/RolePaymentDetails.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/pages/Roles/RolePaymentDetails.tsx b/src/components/pages/Roles/RolePaymentDetails.tsx index f36601bf68..0225030a14 100644 --- a/src/components/pages/Roles/RolePaymentDetails.tsx +++ b/src/components/pages/Roles/RolePaymentDetails.tsx @@ -111,15 +111,14 @@ export function RolePaymentDetails({ payment, onClick, showWithdraw }: RolePayme if (!payment.amount) { return; } - const totalAmount = payment.amount.bigintValue; // @todo add price support for tokens not found in assetsFungible const foundAsset = assetsFungible.find( asset => getAddress(asset.tokenAddress) === payment.asset.address, ); - if (!foundAsset || foundAsset.usdPrice === undefined || totalAmount === undefined) { + if (!foundAsset || foundAsset.usdPrice === undefined) { return; } - return totalAmount * BigInt(foundAsset.usdPrice); + return Number(payment.amount.value) * foundAsset.usdPrice; }, [payment.amount, payment.asset.address, assetsFungible]); const openWithdrawModal = () => { @@ -148,7 +147,12 @@ export function RolePaymentDetails({ payment, onClick, showWithdraw }: RolePayme color="white-0" > {payment.amount.bigintValue - ? formatCoin(payment.amount.bigintValue, false, payment.asset.decimals) + ? formatCoin( + payment.amount.bigintValue, + false, + payment.asset.decimals, + payment.asset?.symbol, + ) : undefined} Date: Fri, 16 Aug 2024 15:30:46 -0400 Subject: [PATCH 5/6] add todos --- src/hooks/DAO/loaders/useHatsTree.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hooks/DAO/loaders/useHatsTree.ts b/src/hooks/DAO/loaders/useHatsTree.ts index 12a4aa31aa..fca6c1916d 100644 --- a/src/hooks/DAO/loaders/useHatsTree.ts +++ b/src/hooks/DAO/loaders/useHatsTree.ts @@ -246,6 +246,8 @@ const useHatsTree = () => { cliffDuration, }, scheduleType: 'duration', + // @todo - factor in cliff date. + // @todo - handle cancelled streams isActive: secondsTimestampToDate(lockupLinearStream.endTime).getTime() > new Date().getTime(), From f07c64c2015f60c110f261f35677a9ac70770bb8 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:39:24 -0400 Subject: [PATCH 6/6] remove unneeded conditionals --- src/components/pages/Roles/forms/RoleFormPaymentStream.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx index dd489ee8df..0468411332 100644 --- a/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx +++ b/src/components/pages/Roles/forms/RoleFormPaymentStream.tsx @@ -364,7 +364,7 @@ function DurationTabs({ formIndex }: { formIndex: number }) { export default function RoleFormPaymentStream({ formIndex }: { formIndex: number }) { const { t } = useTranslation(['roles']); const { values, errors, setFieldValue } = useFormikContext(); - const { hatsTree, getPayment } = useRolesStore(); + const { getPayment } = useRolesStore(); const roleEditingPaymentsErrors = (errors.roleEditing as FormikErrors)?.payments; return (