Skip to content

Commit

Permalink
fix: add missing setDuration when estimating it
Browse files Browse the repository at this point in the history
  • Loading branch information
L03TJ3 committed Nov 24, 2024
1 parent 87ef6a3 commit 585a14f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/app/src/components/DonateComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const DonateComponent = ({ collective }: DonateComponentProps) => {
}

const [frequency, setFrequency] = useState<Frequency>(Frequency.OneTime);
const [streamRate, setRate] = useState(0);
const [streamRate, setRate] = useState<number | undefined>(undefined);
const [duration, setDuration] = useState(12);
const [decimalDonationAmount, setDecimalDonationAmount] = useState<any | number>(0);

Expand Down Expand Up @@ -341,6 +341,7 @@ const DonateComponent = ({ collective }: DonateComponentProps) => {
const estimatedEndDate = moment().add(estDuration, 'months').format('DD.MM.YY HH:mm');

setEstimatedDuration({ duration: estDuration, endDate: estimatedEndDate });
setDuration(estDuration);
}, []);

const onChangeAmount = useCallback(
Expand All @@ -356,7 +357,7 @@ const DonateComponent = ({ collective }: DonateComponentProps) => {
const estDuration = parseFloat(donorCurrencyBalance) / parseFloat(v);
estimateDuration(estDuration);
} else if (frequency === Frequency.Monthly) {
const estDuration = parseFloat(v) / streamRate;
const estDuration = parseFloat(v) / (streamRate as number);
estimateDuration(estDuration);

const gdValue = parseFloat(v) / tokenPrice;
Expand Down Expand Up @@ -442,7 +443,6 @@ const DonateComponent = ({ collective }: DonateComponentProps) => {
/>

<VStack space={6}>
{/* Modals */}
<VStack space={2}>
<Text variant="bold" fontSize="xl">
Donate
Expand Down Expand Up @@ -508,7 +508,7 @@ const DonateComponent = ({ collective }: DonateComponentProps) => {
<NumberInput
type="duration"
dropdownValue={currency}
inputValue={streamRate.toString()}
inputValue={streamRate?.toString() ?? '1'}
onSelect={onChangeCurrency}
onChangeAmount={onChangeRate}
/>{' '}
Expand Down

0 comments on commit 585a14f

Please sign in to comment.