Refactor duplicate handling to allow any authenticated user to check for duplicates, update API methods to require general authentication, and enhance expense fetching with improved error handling and logging.
This commit is contained in:
@@ -41,15 +41,15 @@ const showBanner = ref(true);
|
||||
const duplicateCount = ref(0);
|
||||
const loading = ref(false);
|
||||
|
||||
// Check for duplicates on mount (admin only)
|
||||
// Check for duplicates on mount (any authenticated user)
|
||||
const checkForDuplicates = async () => {
|
||||
if (!isAdmin() || loading.value) return;
|
||||
if (loading.value) return;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
const response = await $fetch('/api/admin/duplicates/find', {
|
||||
method: 'POST',
|
||||
body: { threshold: 80 }
|
||||
method: 'GET',
|
||||
query: { threshold: 0.8 }
|
||||
});
|
||||
|
||||
if (response.success && response.data?.duplicateGroups) {
|
||||
@@ -82,10 +82,8 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// Only check for duplicates if user is admin
|
||||
if (isAdmin()) {
|
||||
// Small delay to let other components load first
|
||||
setTimeout(checkForDuplicates, 2000);
|
||||
}
|
||||
// Check for duplicates for any authenticated user
|
||||
// Small delay to let other components load first
|
||||
setTimeout(checkForDuplicates, 2000);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user