ADD: Belonging Transactions To Menu

FIX: Upload Document and Image system completely
FIX: ImageGallery and ImageGallery components bugs
FORCE: Dark Mode
FIX: Minor bug in login page
This commit is contained in:
2025-04-27 16:15:26 +03:30
parent 47de2bf54c
commit 2ef8f81f79
11 changed files with 699 additions and 91 deletions
+147
View File
@@ -0,0 +1,147 @@
import axios from 'axios';
export const TransactionService = {
/**
* Get a single transaction by ID
* @param {string} transactionId - The transaction ID
* @returns {Promise<Object>} - Transaction data
*/
getTransaction: async (transactionId) => {
const config = {
method: 'get',
url: '/api/transactions/admin/get-one/' + transactionId,
withCredentials: true
};
try {
const response = await axios(config);
return response.data.data;
} catch (err) {
console.log(err);
throw err;
}
},
/**
* Get all transactions
* @returns {Promise<Array>} - List of all transactions
*/
getAllTransactions: async () => {
const config = {
method: 'get',
url: '/api/transactions/admin/get-all',
withCredentials: true
};
try {
const response = await axios(config);
return response.data.data;
} catch (err) {
console.log(err);
throw err;
}
},
/**
* Get transactions related to a specific belonging
* @param {string} belongingId - The belonging ID
* @returns {Promise<Array>} - List of transactions for the belonging
*/
getTransactionsByBelongingId: async (belongingId) => {
const config = {
method: 'get',
url: `/api/transactions/admin/get-all-by-belonging/${belongingId}`,
withCredentials: true
};
try {
const response = await axios(config);
console.log(response.data);
return response.data.data;
} catch (err) {
console.log(err);
throw err;
}
},
/**
* Get stock of a belonging ID
* @param {string} belongingId - The belonging ID
* @returns {Promise<Array>} - List of transactions for the belonging
*/
getStockByBelongingId: async (belongingId) => {
const config = {
method: 'get',
url: `/api/transactions/admin/get-stock-by-belonging/${belongingId}`,
withCredentials: true
};
try {
const response = await axios(config);
console.log(response.data);
return response.data.data;
} catch (err) {
console.log(err);
throw err;
}
},
/**
* Create a new transaction
* @param {Object} data - Transaction data
* @returns {Promise<string>} - Success message or error
*/
createTransaction: async (data) => {
const config = {
method: 'post',
url: '/api/transactions/admin/create',
withCredentials: true,
data
};
try {
const response = await axios(config);
return 'success';
} catch (err) {
console.log(err);
return err.response?.data?.message || 'Error creating transaction';
}
},
/**
* Update an existing transaction
* @param {string} transactionId - The transaction ID
* @param {Object} data - Updated transaction data
* @returns {Promise<string>} - Success message or error
*/
updateTransaction: async (transactionId, data) => {
const config = {
method: 'put',
url: '/api/transactions/admin/update/' + transactionId,
withCredentials: true,
data
};
try {
const response = await axios(config);
return 'success';
} catch (err) {
console.log(err);
return err.response?.data?.message || 'Error updating transaction';
}
},
/**
* Delete a transaction
* @param {string} transactionId - The transaction ID
* @returns {Promise<string>} - Success message or error
*/
deleteTransaction: async (transactionId) => {
const config = {
method: 'delete',
url: '/api/transactions/admin/delete/' + transactionId,
withCredentials: true
};
try {
const response = await axios(config);
return 'success';
} catch (err) {
console.log(err);
return err.response?.data?.message || 'Error deleting transaction';
}
}
};