Refactor logging and clean up unused console statements across multiple files

This commit is contained in:
mohamad 2025-06-07 17:02:19 +02:00
parent d6c7fde40c
commit 397cf28673
6 changed files with 33 additions and 54 deletions

View File

@ -46,15 +46,14 @@ test.beforeAll(async ({ browser }) => {
await page.goto(`${BASE_URL}/groups`);
const firstGroupCard = page.locator('.neo-group-card h1.neo-group-header').first();
if (await firstGroupCard.isVisible()) {
const name = await firstGroupCard.textContent();
if (name) groupNameForListTests = name.trim();
else console.warn("Could not determine group name for list tests, using default or generated.");
const name = await firstGroupCard.textContent();
if (name) groupNameForListTests = name.trim();
else console.warn("Could not determine group name for list tests, using default or generated.");
} else {
console.warn("No groups found for list tests, creating a new one might be needed or tests will fail.");
// If no groups, these tests might not be able to proceed correctly.
// For now, we'll assume `groupNameForListTests` is somewhat valid or will be set.
console.warn("No groups found for list tests, creating a new one might be needed or tests will fail.");
// If no groups, these tests might not be able to proceed correctly.
// For now, we'll assume `groupNameForListTests` is somewhat valid or will be set.
}
console.log(`Using group: "${groupNameForListTests}" for list tests.`);
await page.close();
});

View File

@ -308,16 +308,13 @@ const selectGroup = (group: Group) => {
};
const openCreateListDialog = (group: Group) => {
console.log('Opening create list dialog for group:', group);
// Ensure we have the latest groups data
fetchGroups().then(() => {
console.log('Setting up modal with group:', group);
availableGroupsForModal.value = [{
label: group.name,
value: group.id
}];
showCreateListModal.value = true;
console.log('Modal should be visible now:', showCreateListModal.value);
});
};

View File

@ -59,15 +59,6 @@ const authStore = useAuthStore();
const notificationStore = useNotificationStore();
const { t, locale, messages } = useI18n();
// Debug output
console.log('=== i18n Debug Info ===');
console.log('Current locale:', locale.value);
console.log('Available messages:', messages.value);
console.log('English messages:', messages.value.en);
console.log('LoginPage messages:', messages.value.en?.loginPage);
console.log('Test translation:', t('loginPage.emailLabel'));
console.log('Test fallback:', t('message.hello'));
const email = ref('');
const password = ref('');
const isPwdVisible = ref(false);

View File

@ -57,25 +57,20 @@ export const useAuthStore = defineStore('auth', () => {
const fetchCurrentUser = async () => {
if (!accessToken.value) {
console.log('No access token found, clearing tokens')
clearTokens()
return null
}
try {
console.log('Fetching current user profile...')
const response = await api.get(API_ENDPOINTS.USERS.PROFILE)
console.log('User profile fetched:', response.data)
setUser(response.data)
return response.data
} catch (error: any) {
console.error('AuthStore: Failed to fetch current user:', error)
clearTokens()
return null
}
}
const login = async (email: string, password: string) => {
console.log('Attempting login...')
const formData = new FormData()
formData.append('username', email)
formData.append('password', password)
@ -86,10 +81,8 @@ export const useAuthStore = defineStore('auth', () => {
},
})
console.log('Login successful, setting tokens...')
const { access_token, refresh_token } = response.data
setTokens({ access_token, refresh_token })
// Fetch profile data after login
await fetchCurrentUser()
return response.data
}

View File

@ -70,7 +70,6 @@ export const useListDetailStore = defineStore('listDetail', {
// Call the actual API endpoint using generic post method
const endpoint = `/financials/expense_splits/${payload.expense_split_id}/settle`
const response = await apiClient.post(endpoint, payload.activity_data)
console.log('Settlement activity created:', response.data)
// Refresh list data to show updated statuses
if (payload.list_id_for_refetch) {
@ -111,31 +110,31 @@ export const useListDetailStore = defineStore('listDetail', {
},
getPaidAmountForSplit:
(state: ListDetailState) =>
(splitId: number): number => {
let totalPaid = 0
if (state.currentList && state.currentList.expenses) {
for (const expense of state.currentList.expenses) {
const split = expense.splits.find((s) => s.id === splitId)
if (split && split.settlement_activities) {
totalPaid = split.settlement_activities.reduce((sum, activity) => {
return sum + parseFloat(activity.amount_paid)
}, 0)
break
(splitId: number): number => {
let totalPaid = 0
if (state.currentList && state.currentList.expenses) {
for (const expense of state.currentList.expenses) {
const split = expense.splits.find((s) => s.id === splitId)
if (split && split.settlement_activities) {
totalPaid = split.settlement_activities.reduce((sum, activity) => {
return sum + parseFloat(activity.amount_paid)
}, 0)
break
}
}
}
}
return totalPaid
},
return totalPaid
},
getExpenseSplitById:
(state: ListDetailState) =>
(splitId: number): ExpenseSplit | undefined => {
if (!state.currentList || !state.currentList.expenses) return undefined
for (const expense of state.currentList.expenses) {
const split = expense.splits.find((s) => s.id === splitId)
if (split) return split
}
return undefined
},
(splitId: number): ExpenseSplit | undefined => {
if (!state.currentList || !state.currentList.expenses) return undefined
for (const expense of state.currentList.expenses) {
const split = expense.splits.find((s) => s.id === splitId)
if (split) return split
}
return undefined
},
},
})

View File

@ -33,7 +33,7 @@ const initializeSW = async () => {
try {
await self.skipWaiting();
clientsClaim();
console.log('Service Worker initialized successfully');
// console.log('Service Worker initialized successfully');
} catch (error) {
console.error('Error during service worker initialization:', error);
}