card requisite done

This commit is contained in:
2025-07-09 10:14:40 +05:00
parent 7ce0b92f92
commit 90d9a7b309
12 changed files with 614 additions and 29 deletions

View File

@@ -15,9 +15,17 @@ class AuthService {
const requestId = Math.random().toString(36).substr(2, 9);
try {
const headers = {
...API_CONFIG.HEADERS,
};
const headers = { ...API_CONFIG.HEADERS };
// Determine body and adjust headers for FormData
let bodyToSend;
if (data instanceof FormData) {
bodyToSend = data;
// Let fetch set correct Content-Type with boundary
if (headers['Content-Type']) delete headers['Content-Type'];
} else {
bodyToSend = data ? JSON.stringify(data) : undefined;
}
// Auto-include token for authenticated requests
if (requiresAuth) {
@@ -45,7 +53,7 @@ class AuthService {
const response = await fetch(fullUrl, {
method,
headers,
body: data ? JSON.stringify(data) : undefined,
body: bodyToSend,
});
const endTime = Date.now();
@@ -189,7 +197,7 @@ class AuthService {
let serie = passportSerie;
let pid = passportId;
if (!serie || !pid) {
const user = await this.getStoredUser();
const user = await this.getStoredUser();
serie = serie || user?.passport_serie;
pid = pid || user?.passport_id;
}
@@ -214,7 +222,7 @@ class AuthService {
let serie = passportSerie;
let pid = passportId;
if (!serie || !pid) {
const user = await this.getStoredUser();
const user = await this.getStoredUser();
serie = serie || user?.passport_serie;
pid = pid || user?.passport_id;
}
@@ -491,6 +499,41 @@ class AuthService {
async downloadCardBalances(orderId) {
return this.makeRequest(`/card-balances-download/${orderId}`, null, true, 'GET');
}
// ================================
// Card Requisites Orders (Kart rekwizitler)
// ================================
// LIST
async getCardRequisiteOrders() {
return this.makeRequest('/card-requisites', null, true, 'GET');
}
// CREATE (passport + card info)
async createCardRequisiteOrder(payload) {
/* payload expected keys: passport_serie, passport_id, card_number, card_month, card_year, maybe card_name */
return this.makeRequest('/card-requisites', payload, true, 'POST');
}
// SHOW
async getCardRequisiteOrder(orderId) {
return this.makeRequest(`/card-requisites/${orderId}`, null, true, 'GET');
}
// UPDATE
async updateCardRequisiteOrder(orderId, payload) {
return this.makeRequest(`/card-requisites/${orderId}`, payload, true, 'POST');
}
// DELETE
async deleteCardRequisiteOrder(orderId) {
return this.makeRequest(`/card-requisites/${orderId}`, null, true, 'DELETE');
}
// DOWNLOAD
async downloadCardRequisites(orderId) {
return this.makeRequest(`/card-requisites-download/${orderId}`, null, true, 'GET');
}
}
export default new AuthService();