feat(MoneyHistoryView): load branch names for enhanced activity display
All checks were successful
Deploy to production / deploy (push) Successful in 2m12s
All checks were successful
Deploy to production / deploy (push) Successful in 2m12s
- Added a new method to load branch names from the API and map them by ID for better display in money history activities. - Updated the component's data structure to include a mapping of branch names, improving the clarity of tax-related activity translations.
This commit is contained in:
@@ -72,6 +72,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
filter: '',
|
||||
branchNameById: {},
|
||||
moneyHistory: {
|
||||
data: [],
|
||||
currentPage: 1,
|
||||
@@ -80,9 +81,27 @@ export default {
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
await this.loadBranchNames();
|
||||
await this.fetchMoneyHistory(1);
|
||||
},
|
||||
methods: {
|
||||
async loadBranchNames() {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/branches');
|
||||
const map = {};
|
||||
for (const branch of Array.isArray(data) ? data : []) {
|
||||
const id = Number(branch?.id);
|
||||
if (!Number.isFinite(id)) continue;
|
||||
const cityName = String(branch?.region?.name || '').trim();
|
||||
const branchType = String(branch?.branchType?.labelTr || '').trim();
|
||||
map[id] = cityName || branchType || `#${id}`;
|
||||
}
|
||||
this.branchNameById = map;
|
||||
} catch (error) {
|
||||
console.error('Error loading branch names for money history:', error);
|
||||
this.branchNameById = {};
|
||||
}
|
||||
},
|
||||
async fetchMoneyHistory(page) {
|
||||
try {
|
||||
const response = await apiClient.post('/api/falukant/moneyhistory', {
|
||||
@@ -98,8 +117,10 @@ export default {
|
||||
if (typeof activity === 'string') {
|
||||
const taxMatch = activity.match(/^tax from sales branch\s+(\d+)$/i);
|
||||
if (taxMatch) {
|
||||
const branchId = Number(taxMatch[1]);
|
||||
const branchName = this.branchNameById[branchId] || `#${taxMatch[1]}`;
|
||||
return this.$t('falukant.moneyHistory.activities.taxFromSalesBranch', {
|
||||
branchId: taxMatch[1],
|
||||
branchId: branchName,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user