Spaces:
Build error
Build error
File size: 4,135 Bytes
0a92d75 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | 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>
);
} |