-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdashboard.html
More file actions
202 lines (176 loc) · 10 KB
/
Copy pathdashboard.html
File metadata and controls
202 lines (176 loc) · 10 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AQUINEX</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 min-h-screen">
<nav class="bg-gradient-to-r from-purple-600 to-blue-600 text-white p-4 shadow-lg">
<div class="max-w-7xl mx-auto flex justify-between items-center">
<h1 class="text-2xl font-bold">🏦 Aquinex Bank</h1>
<div class="flex gap-4 items-center">
<button onclick="showNotifications()" class="relative text-2xl">🔔 <span id="notifBadge" class="absolute -top-2 -right-2 bg-red-500 rounded-full w-5 h-5 text-xs hidden flex items-center justify-center"></span></button>
<span id="userName" class="font-semibold"></span>
<button onclick="logout()" class="bg-white/20 px-4 py-2 rounded-lg hover:bg-white/30">Logout</button>
</div>
</div>
</nav>
<div class="max-w-7xl mx-auto p-4 mt-6">
<div class="bg-gradient-to-r from-purple-600 to-blue-600 text-white rounded-3xl p-8 mb-6 shadow-xl">
<p class="text-purple-200 mb-2">Account: <span id="accountNumber" class="font-mono"></span></p>
<p class="text-sm text-purple-200 mb-4">Available Balance</p>
<p class="text-5xl font-bold">$<span id="balance">0.00</span></p>
<p class="text-sm text-purple-200 mt-4">⚠️ Deposits & Withdrawals require admin approval</p>
</div>
<div class="grid md:grid-cols-3 gap-6 mb-6">
<div class="bg-white rounded-2xl p-6 shadow-lg">
<h3 class="text-xl font-bold mb-4">💰 Request Deposit</h3>
<p class="text-sm text-gray-600 mb-3">Submit request to admin</p>
<input type="number" id="depositAmount" placeholder="Amount" class="w-full px-4 py-2 border rounded-lg mb-3 focus:ring-2 focus:ring-green-500 outline-none">
<button onclick="requestDeposit()" class="w-full bg-green-600 text-white py-2 rounded-lg hover:bg-green-700">Request Deposit</button>
</div>
<div class="bg-white rounded-2xl p-6 shadow-lg">
<h3 class="text-xl font-bold mb-4">🏧 Request Withdrawal</h3>
<p class="text-sm text-gray-600 mb-3">Submit request to admin</p>
<input type="number" id="withdrawAmount" placeholder="Amount" class="w-full px-4 py-2 border rounded-lg mb-3 focus:ring-2 focus:ring-red-500 outline-none">
<button onclick="requestWithdrawal()" class="w-full bg-red-600 text-white py-2 rounded-lg hover:bg-red-700">Request Withdrawal</button>
</div>
<div class="bg-white rounded-2xl p-6 shadow-lg">
<h3 class="text-xl font-bold mb-4">📤 Transfer Money</h3>
<p class="text-sm text-gray-600 mb-3">Instant transfer to any account</p>
<input type="text" id="transferAccount" placeholder="Account Number" class="w-full px-4 py-2 border rounded-lg mb-2 focus:ring-2 focus:ring-blue-500 outline-none">
<input type="number" id="transferAmount" placeholder="Amount" class="w-full px-4 py-2 border rounded-lg mb-3 focus:ring-2 focus:ring-blue-500 outline-none">
<button onclick="transfer()" class="w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700">Transfer Now</button>
</div>
</div>
<div class="bg-white rounded-2xl p-6 shadow-lg">
<h3 class="text-xl font-bold mb-4">📊 Transaction History</h3>
<div id="transactions" class="space-y-3"></div>
</div>
</div>
<div id="notifModal" class="hidden fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50">
<div class="bg-white rounded-2xl p-6 max-w-md w-full max-h-96 overflow-y-auto">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">🔔 Notifications</h3>
<button onclick="closeNotifications()" class="text-3xl hover:text-gray-600">×</button>
</div>
<div id="notifications"></div>
</div>
</div>
<script>
const userId = parseInt(localStorage.getItem('userId'));
if (!userId) window.location.href = 'index.html';
async function loadData() {
try {
const [profile, account, transactions, notifications] = await Promise.all([
fetch(`api.php?action=getProfile&userId=${userId}`).then(r => r.json()),
fetch(`api.php?action=getAccount&userId=${userId}`).then(r => r.json()),
fetch(`api.php?action=getTransactions&userId=${userId}`).then(r => r.json()),
fetch(`api.php?action=getNotifications&userId=${userId}`).then(r => r.json())
]);
document.getElementById('userName').textContent = profile.name;
document.getElementById('accountNumber').textContent = account.accountNumber;
document.getElementById('balance').textContent = account.balance.toFixed(2);
const unread = notifications.filter(n => !n.read).length;
const badge = document.getElementById('notifBadge');
if (unread > 0) {
badge.textContent = unread;
badge.classList.remove('hidden');
} else {
badge.classList.add('hidden');
}
document.getElementById('transactions').innerHTML = transactions.length ?
transactions.reverse().slice(0, 15).map(t => `
<div class="flex justify-between items-center p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition">
<div>
<p class="font-semibold text-gray-800">${t.description}</p>
<p class="text-sm text-gray-500">${new Date(t.date).toLocaleString()}</p>
</div>
<p class="font-bold text-lg ${t.type === 'deposit' || t.type === 'received' ? 'text-green-600' : 'text-red-600'}">
${t.type === 'deposit' || t.type === 'received' ? '+' : '-'}${parseFloat(t.amount).toFixed(2)}
</p>
</div>
`).join('') : '<p class="text-gray-500 text-center py-8">No transactions yet</p>';
} catch (error) {
console.error('Error loading data:', error);
}
}
async function requestDeposit() {
const amount = parseFloat(document.getElementById('depositAmount').value);
if (!amount || amount <= 0) {
alert('Enter a valid amount');
return;
}
const response = await fetch('api.php?action=requestDeposit', {
method: 'POST',
body: JSON.stringify({ userId, amount })
});
const result = await response.json();
alert(result.message);
document.getElementById('depositAmount').value = '';
loadData();
}
async function requestWithdrawal() {
const amount = parseFloat(document.getElementById('withdrawAmount').value);
if (!amount || amount <= 0) {
alert('Enter a valid amount');
return;
}
const response = await fetch('api.php?action=requestWithdrawal', {
method: 'POST',
body: JSON.stringify({ userId, amount })
});
const result = await response.json();
alert(result.message);
document.getElementById('withdrawAmount').value = '';
loadData();
}
async function transfer() {
const toAccount = document.getElementById('transferAccount').value;
const amount = parseFloat(document.getElementById('transferAmount').value);
if (!toAccount || !amount || amount <= 0) {
alert('Fill all fields correctly');
return;
}
const response = await fetch('api.php?action=transfer', {
method: 'POST',
body: JSON.stringify({ userId, toAccount, amount })
});
const result = await response.json();
alert(result.success ? 'Transfer successful!' : result.message);
if (result.success) {
document.getElementById('transferAccount').value = '';
document.getElementById('transferAmount').value = '';
loadData();
}
}
async function showNotifications() {
const notifications = await fetch(`api.php?action=getNotifications&userId=${userId}`).then(r => r.json());
document.getElementById('notifications').innerHTML = notifications.length ?
notifications.reverse().map(n => `
<div class="p-4 mb-3 rounded-lg ${n.read ? 'bg-gray-50' : 'bg-blue-50 border border-blue-200'}">
<p class="text-gray-800">${n.message}</p>
<p class="text-xs text-gray-500 mt-2">${new Date(n.createdAt).toLocaleString()}</p>
</div>
`).join('') : '<p class="text-gray-500 text-center py-4">No notifications</p>';
document.getElementById('notifModal').classList.remove('hidden');
}
function closeNotifications() {
document.getElementById('notifModal').classList.add('hidden');
}
function logout() {
localStorage.clear();
window.location.href = 'index.html';
}
loadData();
setInterval(loadData, 10000);
</script>
<footer>
<p>
<center><small>© 2025 AQUINEX Bank. All rights reserved.</small></center>
</p>
</footer>
</body>
</html>