-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addL Update Wallet Detail page & Collective page for active donation …
…streams #220
- Loading branch information
Showing
18 changed files
with
280 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { VStack, HStack, Text, Button } from 'native-base'; | ||
import { styles } from './WalletCards/styles'; | ||
import { StopDonationActionButton } from './StopDonationActionButton'; | ||
import { DonorCollective } from '../models/models'; | ||
import { formatFlowRate } from '../lib/formatFlowRate'; | ||
import { formatTime } from '../lib/formatTime'; | ||
import { useGetTokenBalance } from '../hooks/useGetTokenBalance'; | ||
import { GDToken } from '../models/constants'; | ||
|
||
export interface DonationStatusCardProps { | ||
donorCollective: DonorCollective; | ||
} | ||
|
||
export const ActiveStreamCard = React.memo(({ donorCollective }: DonationStatusCardProps) => { | ||
const donorBalance = useGetTokenBalance(GDToken.address, donorCollective.donor as any); | ||
const secondsLeft = Number(BigInt(donorBalance) / BigInt(donorCollective.flowRate)); | ||
const endDate = formatTime(Date.now() / 1000 + secondsLeft); | ||
|
||
return ( | ||
<VStack space={4}> | ||
{/* Stream Rate */} | ||
<VStack space={1}> | ||
<Text {...styles.description}>Donation Streaming Rate</Text> | ||
<Text {...styles.text}>G$ {formatFlowRate(donorCollective.flowRate)} / Monthly</Text> | ||
</VStack> | ||
|
||
{/* Dates */} | ||
<HStack justifyContent="space-between" marginBottom={4}> | ||
<VStack> | ||
<Text {...styles.description}>Date Initiated</Text> | ||
<Text {...styles.text}>{formatTime(donorCollective.timestamp)}</Text> | ||
</VStack> | ||
<VStack> | ||
<Text {...styles.description}>Estimated End Date</Text> | ||
<Text {...styles.text}>{endDate}</Text> | ||
</VStack> | ||
</HStack> | ||
|
||
{/* Stop Button */} | ||
<StopDonationActionButton donorCollective={donorCollective} /> | ||
</VStack> | ||
); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState } from 'react'; | ||
import ErrorModal from './modals/ErrorModal'; | ||
import StopDonationModal from './modals/StopDonationModal'; | ||
import ProcessingModal from './modals/ProcessingModal'; | ||
import { useDeleteFlow } from '../hooks/useContractCalls/useDeleteFlow'; | ||
import RoundedButton from './RoundedButton'; | ||
import { Colors } from '../utils/colors'; | ||
import { DonorCollective } from '../models/models'; | ||
import { useAccount } from 'wagmi'; | ||
|
||
export const StopDonationActionButton = ({ donorCollective }: { donorCollective: DonorCollective }) => { | ||
const { address: maybeAddress } = useAccount(); | ||
const [stopDonationModalVisible, setStopDonationModalVisible] = useState(false); | ||
const [processingModalVisible, setProcessingModalVisible] = useState(false); | ||
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined); | ||
|
||
const handleStopDonation = useDeleteFlow( | ||
donorCollective.collective, | ||
(error: string) => setErrorMessage(error), | ||
(value: boolean) => setStopDonationModalVisible(value), | ||
(value: boolean) => setProcessingModalVisible(value) | ||
); | ||
if (maybeAddress?.toLowerCase() !== donorCollective.donor.toLowerCase()) return null; | ||
return ( | ||
<> | ||
<RoundedButton | ||
title="Stop Your Donation Stream" | ||
backgroundColor={Colors.orange[100]} | ||
color={Colors.orange[300]} | ||
onPress={handleStopDonation} | ||
/> | ||
<ErrorModal | ||
openModal={!!errorMessage} | ||
setOpenModal={() => setErrorMessage(undefined)} | ||
message={errorMessage ?? ''} | ||
/> | ||
<StopDonationModal openModal={stopDonationModalVisible} setOpenModal={setStopDonationModalVisible} /> | ||
<ProcessingModal openModal={processingModalVisible} /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.