Restructure progress

This commit is contained in:
Roman Krček
2025-07-08 12:07:43 +02:00
parent 635f507e23
commit ed317feae7
32 changed files with 257 additions and 594 deletions

View File

@@ -0,0 +1,23 @@
// Client-side Sheets functions (use fetch to call protected API endpoints)
/**
* Fetch recent spreadsheets via protected endpoint
*/
export async function getRecentSpreadsheetsClient(refreshToken: string, limit: number = 10) {
const response = await fetch(`/private/api/google/sheets/recent?limit=${limit}`, {
headers: { Authorization: `Bearer ${refreshToken}` }
});
if (!response.ok) throw new Error('Failed to fetch recent sheets');
return await response.json();
}
/**
* Fetch spreadsheet data via protected endpoint
*/
export async function getSpreadsheetDataClient(refreshToken: string, sheetId: string, range: string = 'A1:Z10') {
const response = await fetch(`/private/api/google/sheets/${sheetId}/data?range=${encodeURIComponent(range)}`, {
headers: { Authorization: `Bearer ${refreshToken}` }
});
if (!response.ok) throw new Error('Failed to fetch spreadsheet data');
return await response.json();
}