Skip to content

Commit

Permalink
fix: Refactor OKPage component and fix API call (ADORSYS-GIS#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogenbertrand authored Apr 12, 2024
1 parent 98b9979 commit 079256f
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions power-pay-frontend/src/components/okpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,50 @@ import React, { useEffect } from 'react';
import axios from 'axios';

const OKPage: React.FC = () => {
const baseURL = 'http://localhost:5000'; // specifying the base URL with the desired port
const api = axios.create({
baseURL,
const baseURL = 'http://localhost:5000';
const api = axios.create({
baseURL,
timeout: 5000,
});

// Mock function to simulate a successful API call
const mockSend_MoneyAPI = async (
senderPhoneNumber: string,
recipientPhoneNumber: string,
const mockSend_MoneyAPI = async (
senderPhoneNumber: string,
recipientPhoneNumber: string,
amount: number
) => {
try {
const response = await api.post('/send_money', {
senderPhoneNumber,
recipientPhoneNumber,
amount
const response = await api.post('/send_money', {
senderPhoneNumber,
recipientPhoneNumber,
amount
});
return response.data;
} catch (error) {
throw error;
}
};

// Handle API call when component mounts
useEffect(() => {
mockSend_MoneyAPI('12347656', '1234567890', 100)
.then((response) => {
const sendMoney = async () => {
try {
const response = await mockSend_MoneyAPI('12347656', '1234567890', 100);
console.log("Mock API Response", response);
})
.catch((error) => {
} catch (error) {
console.error("Mock API Error", error);
});
}
};

sendMoney();
}, []);

return (
<div className="flex justify-center items-center p-10 mb-34 border border-white rounded-3xl bg--500 text-white">
<div className="card">
<div className="ok-page">
<h1>Success!</h1>
<br />
<br></br>
<p>The money was successfully transferred.</p>
</div>
</div>
<div className="mt-16">
<button className="w-96 mt-16 bg-Gray10-color rounded-3xl p-2 text-center text-white bg-green-500">OK</button>
</div>
Expand Down

0 comments on commit 079256f

Please sign in to comment.