Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] #303 : Added Payment Confirmation Modal #304

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions submissions/chiconnect-bank-api-payout/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,36 @@ function App() {
const [error, setError] = useState('')
const [info, setInfo] = useState('')
const [banks, setBanks] = useState([])
const [showConfirmation, setShowConfirmation] = useState(false);
const [confirmationData, setConfirmationData] = useState(null);

const [paymentData, setPaymentData] = useState({
bank: '',
accountNumber: '',
amount: ''
})

const handlePaymentSuccess = (data) => {
setInfo('Payment successful');
setShowConfirmation(true);
setConfirmationData(data);
}


useEffect(() => {
const displayConfirmation = () => {
// Display the modal after a delay (you can adjust the delay time)
setTimeout(() => {
setShowConfirmation(false); // Close the modal after another delay (you can adjust the delay time)
setInfo('Payment successful'); // Show "Payment Successful" message
}, 2000); // Adjust the delay time (in milliseconds)
};

if (showConfirmation && confirmationData) {
displayConfirmation();
}
}, [showConfirmation, confirmationData]);

const handleFormChange = (event) => {
const { name, value } = event.target
setPaymentData(prevData => {
Expand Down Expand Up @@ -150,12 +173,22 @@ function App() {
</span>
}

<button onClick={handlePayClick}
className={`${error.length === 0 ? 'mt-8' : 'mt-2'} px-12 py-2 border shadow-sm text-white rounded-xl
font-semibold bg-purple-500 hover:border-purple-500 tracking-wider
hover:bg-purple-50 hover:text-purple-500 hover:scale-95 transition-all`}>
PAY NOW
</button>
<button
onClick={handlePayClick}
className={`${error.length === 0 ? 'mt-8' : 'mt-2'} px-12 py-2 border shadow-sm text-white rounded-xl
font-semibold bg-purple-500 hover:border-purple-500 tracking-wider
hover:bg-purple-50 hover:text-purple-500 hover:scale-95 transition-all`}
>
PAY NOW
</button>

{showConfirmation && confirmationData && (
<div className="modal">
<h2>Payment Confirmation</h2>
<p>{`Payment of ${confirmationData.valueInUSD} USD has been successfully sent to ${confirmationData.account_number}`}</p>
<button onClick={() => setShowConfirmation(false)}>Close</button>
</div>
)}

<p className='mt-2 text-xs'>Powered by <span className='font-semibold text-purple-500'>Chimoney</span></p>

Expand All @@ -166,4 +199,4 @@ function App() {
)
}

export default App
export default App