Skip to content

Commit

Permalink
Faked the send money API
Browse files Browse the repository at this point in the history
  • Loading branch information
Valsuh45 committed Mar 25, 2024
1 parent 6a175a8 commit c868058
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 32 deletions.
91 changes: 91 additions & 0 deletions power-pay-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions power-pay-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand All @@ -23,15 +24,15 @@
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.18",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"gh-pages": "^6.1.1",
"typescript": "^5.2.2",
"sass": "^1.71.1",
"vite": "^5.1.4",
"tailwindcss":"^3.4.1",
"postcss": "^8.4.35",
"autoprefixer": "^10.4.18"
"sass": "^1.71.1",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.1.4"
}
}
57 changes: 57 additions & 0 deletions power-pay-frontend/src/component/okpage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//faking the API
import React, { useEffect, useState } 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,
timeout: 5000,
});

// Mock function to simulate a succesful API call
const mockSend_MoneyAPI = async (
senderPhoneNumber: string,
recipientPhoneNumber: string,
amount: number
) => {
try {
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) => {
console.log("Mock API Response", response);
})
.catch((error) => {
console.error("Mock API Error", error);
});
}, []);
}


//building the ok page for successful transfer
const OKPage = () => {
return (
<div className="card">
<div className="ok-page">
<h1>Success!</h1>
<br></br>
<p>The money was successfully transfered.</p>
<br></br>
</div>
<button className ="okbtn">OK</button>
</div>
);
};

export default OKPage;
3 changes: 2 additions & 1 deletion power-pay-frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'

import './component/okpage.tsx'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
{/* <OKPage /> */}
</React.StrictMode>,
)
26 changes: 0 additions & 26 deletions power-pay-frontend/src/okpage.tsx

This file was deleted.

0 comments on commit c868058

Please sign in to comment.