|
|
|
|
@ -17,24 +17,29 @@ export const load: PageServerLoad = async (event) => {
|
|
|
|
|
display_code: number | null;
|
|
|
|
|
assignees: string[];
|
|
|
|
|
}> = [];
|
|
|
|
|
let hasMore: boolean = false;
|
|
|
|
|
|
|
|
|
|
// Filtros desde la query (?q=&soonDays=)
|
|
|
|
|
const q = (event.url.searchParams.get('q') || '').trim();
|
|
|
|
|
const soonDaysStr = (event.url.searchParams.get('soonDays') || '').trim();
|
|
|
|
|
const pageStr = (event.url.searchParams.get('page') || '1').trim();
|
|
|
|
|
const page = Math.max(1, parseInt(pageStr, 10) || 1);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
let fetchUrl = '/api/me/tasks?limit=20';
|
|
|
|
|
if (q) fetchUrl += `&search=${encodeURIComponent(q)}`;
|
|
|
|
|
if (soonDaysStr) fetchUrl += `&soonDays=${encodeURIComponent(soonDaysStr)}`;
|
|
|
|
|
fetchUrl += `&page=${encodeURIComponent(String(page))}`;
|
|
|
|
|
|
|
|
|
|
const res = await event.fetch(fetchUrl);
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
const json = await res.json();
|
|
|
|
|
tasks = Array.isArray(json?.items) ? json.items : [];
|
|
|
|
|
hasMore = Boolean(json?.hasMore);
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
// Ignorar errores y dejar lista vacía
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { userId, tasks, q, soonDays: soonDaysStr ? Number(soonDaysStr) : null };
|
|
|
|
|
return { userId, tasks, q, soonDays: soonDaysStr ? Number(soonDaysStr) : null, page, hasMore };
|
|
|
|
|
};
|
|
|
|
|
|