generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,698 additions
and
74 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
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,58 @@ | ||
import { useState } from "react"; | ||
// Importiere hier weitere benötigte Hooks und Bibliotheken | ||
|
||
type DonateModalProps = { | ||
onClose: () => void; | ||
}; | ||
|
||
const DonateModal: React.FC<DonateModalProps> = ({ onClose }) => { | ||
const [currency, setCurrency] = useState<string>("DFI"); | ||
const [amount, setAmount] = useState<string>(""); | ||
const [isApproved, setIsApproved] = useState<boolean>(true); // Annahme: DFI benötigt keine Genehmigung | ||
|
||
const handleCurrencyChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
setCurrency(e.target.value); | ||
setIsApproved(e.target.value === "DFI"); // Setze isApproved auf false für ERC20-Token | ||
}; | ||
|
||
const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setAmount(e.target.value); | ||
}; | ||
|
||
const handleApprove = async () => { | ||
// Füge hier die Logik für die Token-Genehmigung hinzu | ||
setIsApproved(true); // Nach erfolgreicher Genehmigung | ||
}; | ||
|
||
const handleDonate = async () => { | ||
if (currency === "DFI") { | ||
// Rufe hier die donateDFI Funktion auf | ||
} else { | ||
// Rufe hier die donateWithToken Funktion auf | ||
} | ||
onClose(); // Schließe das Modal nach der Transaktion | ||
}; | ||
|
||
return ( | ||
<div className="modal"> | ||
<div className="modal-content"> | ||
<select value={currency} onChange={handleCurrencyChange}> | ||
<option value="DFI">DFI</option> | ||
<option value="USDT">USDT</option> | ||
<option value="USDC">USDC</option> | ||
<option value="EURC">EURC</option> | ||
<option value="jUSD">jUSD</option> | ||
</select> | ||
<input type="text" value={amount} onChange={handleAmountChange} placeholder="Betrag" /> | ||
{isApproved ? ( | ||
<button onClick={handleDonate}>Senden</button> | ||
) : ( | ||
<button onClick={handleApprove}>Approve</button> | ||
)} | ||
<button onClick={onClose}>Schließen</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DonateModal; |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.