card balance on homepage

This commit is contained in:
2025-07-08 17:00:17 +05:00
parent 7f49211680
commit 23ca758917
4 changed files with 335 additions and 13 deletions

View File

@@ -370,6 +370,47 @@ class AuthService {
const query = `start_date=${encodeURIComponent(startDate)}&end_date=${encodeURIComponent(endDate)}`;
return this.makeRequest(`/card-transactions-download/${orderId}?${query}`, null, true, 'GET');
}
// ================================
// Card balance quick check (Kart galyndysy)
// ================================
async getCardBalanceQuickCheck(cardNumber = null, cardMonth = null, cardYear = null, passportSerie = null, passportId = null) {
// Fallback to stored user profile for missing fields
let serie = passportSerie;
let pid = passportId;
let cNumber = cardNumber;
let cMonth = cardMonth;
let cYear = cardYear;
if (!serie || !pid || !cNumber || !cMonth || !cYear) {
const user = await this.getStoredUser();
serie = serie || user?.passport_serie;
pid = pid || user?.passport_id;
cNumber = cNumber || user?.card_number;
cMonth = cMonth || user?.card_month;
cYear = cYear || user?.card_year;
}
if (!serie || !pid || !cNumber || !cMonth || !cYear) {
throw new Error('Card or passport details are missing');
}
// Ensure values are properly formatted
const plainCardNumber = String(cNumber).replace(/[^0-9]/g, '').slice(0, 16);
const monthStr = String(cMonth).padStart(2, '0');
const payload = {
passport_serie: serie,
passport_id: pid,
card_number: plainCardNumber,
card_month: monthStr,
card_year: String(cYear),
};
// POST request authenticated (token header will be included if available)
return this.makeRequest('/card-balance-quick-check', payload, true, 'POST');
}
}
export default new AuthService();