few changes
This commit is contained in:
@@ -164,6 +164,114 @@ class AuthService {
|
||||
async deleteAccount() {
|
||||
return this.makeRequest('/user/delete-account', null, true, 'DELETE');
|
||||
}
|
||||
|
||||
// ================================
|
||||
// Loan Remaining Order (Karzyň galyndysy)
|
||||
// ================================
|
||||
|
||||
// Helper to read cached user data (for passport details)
|
||||
async getStoredUser() {
|
||||
try {
|
||||
const raw = await AsyncStorage.getItem('user_data');
|
||||
return raw ? JSON.parse(raw) : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// LIST orders
|
||||
async getLoanRemainingOrders() {
|
||||
return this.makeRequest('/loan-remaining-order', null, true, 'GET');
|
||||
}
|
||||
|
||||
// CREATE order (requires only account number – passport details are fetched from user profile)
|
||||
async createLoanRemainingOrder(accountNumber) {
|
||||
const user = await this.getStoredUser();
|
||||
if (!user?.passport_serie || !user?.passport_id) {
|
||||
throw new Error('Passport details are missing from profile');
|
||||
}
|
||||
const payload = {
|
||||
passport_serie: user.passport_serie,
|
||||
passport_id: user.passport_id,
|
||||
account_number: accountNumber,
|
||||
};
|
||||
return this.makeRequest('/loan-remaining-order', payload, true, 'POST');
|
||||
}
|
||||
|
||||
// SHOW order details
|
||||
async getLoanRemainingOrder(orderId) {
|
||||
return this.makeRequest(`/loan-remaining-order/${orderId}`, null, true, 'GET');
|
||||
}
|
||||
|
||||
// UPDATE order (only account number can change; passport details stay the same)
|
||||
async updateLoanRemainingOrder(orderId, accountNumber) {
|
||||
const user = await this.getStoredUser();
|
||||
if (!user?.passport_serie || !user?.passport_id) {
|
||||
throw new Error('Passport details are missing from profile');
|
||||
}
|
||||
const payload = {
|
||||
passport_serie: user.passport_serie,
|
||||
passport_id: user.passport_id,
|
||||
account_number: accountNumber,
|
||||
};
|
||||
return this.makeRequest(`/loan-remaining-order/${orderId}`, payload, true, 'POST');
|
||||
}
|
||||
|
||||
// DELETE order
|
||||
async deleteLoanRemainingOrder(orderId) {
|
||||
return this.makeRequest(`/loan-remaining-order/${orderId}`, null, true, 'DELETE');
|
||||
}
|
||||
|
||||
// ================================
|
||||
// Loan remaining quick check (returns remaining balance info)
|
||||
// ================================
|
||||
|
||||
async getLoanRemainingBalance(accountNumber, passportSerie = null, passportId = null) {
|
||||
let serie = passportSerie;
|
||||
let pid = passportId;
|
||||
|
||||
if (!serie || !pid) {
|
||||
const user = await this.getStoredUser();
|
||||
serie = user?.passport_serie;
|
||||
pid = user?.passport_id;
|
||||
}
|
||||
|
||||
if (!serie || !pid) {
|
||||
throw new Error('Passport details are missing');
|
||||
}
|
||||
|
||||
const query = `passport_serie=${encodeURIComponent(serie)}&passport_id=${encodeURIComponent(pid)}&account_number=${encodeURIComponent(accountNumber)}`;
|
||||
return this.makeRequest(`/loan-remaining?${query}`, null, true, 'GET');
|
||||
}
|
||||
|
||||
// ================================
|
||||
// Loan Paid-Off Letter Orders
|
||||
// ================================
|
||||
|
||||
// LIST
|
||||
async getLoanPaidOffLetterOrders() {
|
||||
return this.makeRequest('/loan-paid-off-letter-orders', null, true, 'GET');
|
||||
}
|
||||
|
||||
// CREATE
|
||||
async createLoanPaidOffLetterOrder(data) {
|
||||
return this.makeRequest('/loan-paid-off-letter-orders', data, true, 'POST');
|
||||
}
|
||||
|
||||
// SHOW
|
||||
async getLoanPaidOffLetterOrder(orderId) {
|
||||
return this.makeRequest(`/loan-paid-off-letter-orders/${orderId}`, null, true, 'GET');
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
async updateLoanPaidOffLetterOrder(orderId, data) {
|
||||
return this.makeRequest(`/loan-paid-off-letter-orders/${orderId}`, data, true, 'POST');
|
||||
}
|
||||
|
||||
// DELETE
|
||||
async deleteLoanPaidOffLetterOrder(orderId) {
|
||||
return this.makeRequest(`/loan-paid-off-letter-orders/${orderId}`, null, true, 'DELETE');
|
||||
}
|
||||
}
|
||||
|
||||
export default new AuthService();
|
||||
Reference in New Issue
Block a user