This commit is contained in:
2024-10-18 19:29:44 +05:00
parent 681d87236a
commit 0e436b0680
6 changed files with 149 additions and 3 deletions

View File

@@ -3,6 +3,69 @@ function csrf_token()
return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
}
async function fetchLoanHistory(containerID, passport_serie, passport_id) {
if (! passport_serie || ! passport_id) {
Nova.error('Maglumat ýetmezçiligi bar');
return;
}
let cardHistoryDetailContainer = document.getElementById(containerID);
var headers = new Headers();
headers.append('Accept', 'application/json');
var formdata = new FormData();
formdata.append('passport_serie', passport_serie);
formdata.append('passport_id', passport_id);
Nova.$progress.start()
fetch('/api/fetch-loan-history', {
method: 'POST',
headers: headers,
body: formdata,
redirect: 'follow'
})
.then(response => response.json())
.then(result => {
console.log({result: result})
if (result.errCode != 0) {
Nova.error(result.message)
}
// cardHistoryDetailContainer.innerHTML = `
// <h4>Müşderi: <strong>${result.clientName}</strong></h4>
// <h4>Şahamça: <strong>${result.depName}</strong></h4>
// <h4 class="mb-4">Şertnama belgisi: <strong>${result.cardAccountNumber}</strong></h4>
// <p>
// <ul>
// ${Array.from(result.transactions).map(transaction => {
// return `<li style="background: #a3c1f5;color: black;" class="p-3 relative rounded-lg">
// <strong>${transaction['actionName']}</strong> <strong>${transaction['opersum']}</strong> <strong>${transaction['currency']}</strong>
// <strong style="top: 0; right: 0;" class="absolute p-2">${transaction['opername']}</strong>
// <p><strong>${
// new Date(transaction['trandate']).toLocaleDateString('en-GB', {
// year: 'numeric',
// month: '2-digit',
// day: '2-digit',
// }).replaceAll('/', '.')
// }</strong></p>
// </li>`;
// })}
// </ul>
// </p>
// `;
})
.catch(error => console.log('error', error))
.finally(() => {
Nova.$progress.done()
});
}
async function fetchCardHistory(passport_serie, passport_id, card_number, card_expiry_date, containerID) {
if (! passport_serie || ! passport_id || ! card_number || ! card_expiry_date) {
Nova.error('Maglumat ýetmezçiligi bar');

View File

@@ -0,0 +1,20 @@
@php
@endphp
<div class="loan-history-container">
<button
type="button"
class="border text-left appearance-none cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 relative disabled:cursor-not-allowed inline-flex items-center justify-center shadow h-9 px-3 bg-primary-500 border-primary-500 hover:[&amp;:not(:disabled)]:bg-primary-400 hover:[&amp;:not(:disabled)]:border-primary-400 text-white dark:text-gray-900"
onclick="fetchLoanHistory(
'loan-history-container',
'{{ $resource->passport_serie }}',
'{{ $resource->passport_id }}',
)">
<span class="flex items-center gap-1">Karz taryhyny ýükle</span>
</button>
<div id="loan-history-container">
</div>
</div>