Compare commits

..

4 Commits

Author SHA1 Message Date
xds
fb60c69846 fix tx isdone checkbox text size 2026-03-10 15:54:34 +03:00
xds
a5f4d75306 fix tx isdone checkbox text size 2026-03-10 15:41:46 +03:00
xds
fbb3909531 fix tx isdone checkbox text size 2026-03-10 15:37:36 +03:00
xds
853d5111e2 fix tx isdone checkbox text size 2026-03-10 15:33:50 +03:00
4 changed files with 62 additions and 6 deletions

View File

@@ -176,13 +176,13 @@ onMounted(async () => {
<div class="flex flex-row !w-full justify-between items-center">
<div class="flex flex-col">
<span>Google Drive</span>
<span class="text-xs text-gray-500" v-if="userStore.user?.isGoogleDriveLinked">Connected</span>
<span class="text-xs text-gray-500" v-if="userStore.user?.isGoogleDriveConnected">Connected</span>
<span class="text-xs text-gray-500" v-else>Not connected</span>
</div>
<Button
:label="userStore.user?.isGoogleDriveLinked ? 'Reconnect' : 'Connect'"
:icon="userStore.user?.isGoogleDriveLinked ? 'pi pi-refresh' : 'pi pi-google'"
:severity="userStore.user?.isGoogleDriveLinked ? 'secondary' : 'primary'"
:label="userStore.user?.isGoogleDriveConnected? 'Reconnect' : 'Connect'"
:icon="userStore.user?.isGoogleDriveConnected ? 'pi pi-refresh' : 'pi pi-google'"
:severity="userStore.user?.isGoogleDriveConnected ? 'secondary' : 'primary'"
size="small"
@click="linkGoogleDrive"
/>

View File

@@ -173,6 +173,31 @@ const fetchData = async (fetchPlanned: boolean = true, fetchInstant: boolean = t
}
const downloadTransactions = async () => {
if (!spaceStore.selectedSpaceId) return
try {
await transactionService.exportTransactions(spaceStore.selectedSpaceId, {
query: searchQuery.value || null,
categoriesIds: selectedCategoryIds.value.length > 0 ? selectedCategoryIds.value : null,
dateFrom: filterDateFrom.value ? toDateOnly(filterDateFrom.value) : null,
dateTo: filterDateTo.value ? toDateOnly(filterDateTo.value) : null,
} as TransactionFilters)
toast.add({
severity: 'success',
summary: 'Success',
detail: 'Transactions exported successfully',
life: 3000,
})
} catch (e) {
toast.add({
severity: 'error',
summary: 'Failed to export transactions.',
detail: String(e),
life: 3000,
})
}
}
onMounted(async () => {
await fetchCategories()
await fetchData()
@@ -194,6 +219,7 @@ onMounted(async () => {
<InputIcon class="pi pi-search"> </InputIcon>
<InputText v-model="searchQuery" placeholder="Search" class="!w-full !bg-white !text-left" />
</IconField>
<Button icon="pi pi-download" @click="downloadTransactions" text rounded aria-label="Download" />
<Button icon="pi pi-filter" @click="isFilterSheetVisible = true" text rounded aria-label="Filter" />
</div>
<div class="flex flex-row justify-between">

View File

@@ -5,5 +5,5 @@ export interface User {
tgId: number
tdUserName: string;
roles: string[];
isGoogleDriveLinked?: boolean;
isGoogleDriveConnected?: boolean;
}

View File

@@ -80,6 +80,36 @@ async function deleteTransaction(spaceId: number, txId: number): Promise<void> {
}
}
export const TransactionService = {
getTransactions, getTransaction, createTransaction, updateTransaction, deleteTransaction,
async function exportTransactions(spaceId: number, filters: TransactionFilters): Promise<void> {
try {
let response = await api.post(`/spaces/${spaceId}/transactions/_export`, filters, {
responseType: 'blob'
});
const contentDisposition = response.headers['content-disposition'];
let fileName = `transactions_${spaceId}_${toDateOnly(new Date())}.csv`;
if (contentDisposition) {
const fileNameMatch = contentDisposition.match(/filename\*?=['"]?(?:UTF-8'')?([^; '"]+)['"]?/i);
if (fileNameMatch && fileNameMatch[1]) {
fileName = decodeURIComponent(fileNameMatch[1]);
}
}
const url = window.URL.createObjectURL(response.data);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
} catch (error) {
console.error(error);
throw error;
}
}
export const TransactionService = {
getTransactions, getTransaction, createTransaction, updateTransaction, deleteTransaction, exportTransactions
}