Spaces:
Build error
Build error
Download components/TransferCard.jsx from mehdabdelkader/anycoder-199dccbb: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/spaces/mehdabdelkader/anycoder-199dccbb/resolve/main/components/TransferCard.jsx
- Command line
-
hf download hf://spaces/mehdabdelkader/anycoder-199dccbb/components/TransferCard.jsx
-
curl -L -o TransferCard.jsx https://huggingface.co/spaces/mehdabdelkader/anycoder-199dccbb/resolve/main/components/TransferCard.jsx
4.14 kB
| import { useState } from "react"; | |
| import { FaExchangeAlt, FaUser, FaPhone, FaMoneyBillWave } from "react-icons/fa"; | |
| export default function TransferCard() { | |
| const [amount, setAmount] = useState(""); | |
| const [phone, setPhone] = useState(""); | |
| const [fromApp, setFromApp] = useState("Waafi"); | |
| const [toApp, setToApp] = useState("DMoney"); | |
| const [isLoading, setIsLoading] = useState(false); | |
| const [success, setSuccess] = useState(false); | |
| const handleSubmit = (e) => { | |
| e.preventDefault(); | |
| setIsLoading(true); | |
| // Simulate API call | |
| setTimeout(() => { | |
| setIsLoading(false); | |
| setSuccess(true); | |
| setAmount(""); | |
| setPhone(""); | |
| // Reset success message after 3 seconds | |
| setTimeout(() => setSuccess(false), 3000); | |
| }, 1500); | |
| }; | |
| return ( | |
| <div className="bg-white rounded-xl shadow-lg p-6 max-w-md w-full"> | |
| <div className="flex justify-center mb-6"> | |
| <div className="bg-gray-100 p-3 rounded-full"> | |
| <FaExchangeAlt className="text-accent text-3xl" /> | |
| </div> | |
| </div> | |
| <form onSubmit={handleSubmit} className="space-y-4"> | |
| <div className="flex justify-between items-center bg-gray-50 p-3 rounded-lg"> | |
| <div className="flex items-center space-x-2"> | |
| <FaUser className="text-gray-400" /> | |
| <span className="font-medium">De</span> | |
| </div> | |
| <select | |
| value={fromApp} | |
| onChange={(e) => setFromApp(e.target.value)} | |
| className="bg-transparent border-none focus:ring-0" | |
| > | |
| <option value="Waafi">Waafi</option> | |
| <option value="DMoney">DMoney</option> | |
| </select> | |
| </div> | |
| <div className="flex justify-center"> | |
| <div className="bg-gray-200 rounded-full p-1"> | |
| <FaExchangeAlt className="text-gray-500 rotate-90" /> | |
| </div> | |
| </div> | |
| <div className="flex justify-between items-center bg-gray-50 p-3 rounded-lg"> | |
| <div className="flex items-center space-x-2"> | |
| <FaUser className="text-gray-400" /> | |
| <span className="font-medium">Vers</span> | |
| </div> | |
| <select | |
| value={toApp} | |
| onChange={(e) => setToApp(e.target.value)} | |
| className="bg-transparent border-none focus:ring-0" | |
| > | |
| <option value="DMoney">DMoney</option> | |
| <option value="Waafi">Waafi</option> | |
| </select> | |
| </div> | |
| <div className="space-y-2"> | |
| <label className="flex items-center space-x-2 text-gray-700"> | |
| <FaPhone /> | |
| <span>Numéro de téléphone</span> | |
| </label> | |
| <input | |
| type="tel" | |
| value={phone} | |
| onChange={(e) => setPhone(e.target.value)} | |
| placeholder="77 123 4567" | |
| className="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" | |
| required | |
| /> | |
| </div> | |
| <div className="space-y-2"> | |
| <label className="flex items-center space-x-2 text-gray-700"> | |
| <FaMoneyBillWave /> | |
| <span>Montant (DJF)</span> | |
| </label> | |
| <input | |
| type="number" | |
| value={amount} | |
| onChange={(e) => setAmount(e.target.value)} | |
| placeholder="1000" | |
| className="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" | |
| min="1" | |
| required | |
| /> | |
| </div> | |
| <button | |
| type="submit" | |
| disabled={isLoading} | |
| className={`w-full py-3 px-4 rounded-lg font-medium text-white transition ${ | |
| isLoading ? "bg-gray-400" : "bg-primary hover:bg-blue-700" | |
| }`} | |
| > | |
| {isLoading ? "Traitement..." : "Transférer"} | |
| </button> | |
| {success && ( | |
| <div className="mt-4 p-3 bg-green-100 text-green-700 rounded-lg text-center"> | |
| Transfert réussi! {amount} DJF envoyés à {phone}. | |
| </div> | |
| )} | |
| </form> | |
| </div> | |
| ); | |
| } |