135087e096
- Implemented Graph token lifecycle management with 60s safety buffer - Added automatic token refresh scheduled 5min before expiry - Fixed token expiration handling with env variable fallback - Resolved SharePoint link parsing for both URL formats (RootFolder param and direct pathname) - Handled URL-encoded spaces in file paths with proper decoding - Implemented internal file viewer modal staying within app context - Added file categorization system (Manager Info, Contracts, Plans, Submittals, Other) - Integrated SVG icons for file types (PDF, Word, Excel, Presentation, Images) - Added search/filter capability for files in folder view - Enhanced auth module with improved button click debugging - Fixed mobile responsiveness for file listing Changes: - Mode2Svelte/src/routes/+page.svelte: Complete component rewrite with token management - Mode2Svelte/src/lib/auth/frontend.ts: Added comprehensive logging for auth flow - Mode2Svelte/src/routes/api/job-files/+server.ts: Created file access endpoint - Mode2Svelte/src/routes/api/jobs/list/+server.ts: Added jobs list endpoint Status: Files now load and display in grouped categories with internal viewer Next: Fix mobile app authentication issue and further refinements
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import type { RequestHandler } from '@sveltejs/kit';
|
|
import PocketBase from 'pocketbase';
|
|
|
|
const PB_DB = process.env.PB_DB || 'https://pocketbase.ccllc.pro';
|
|
|
|
export const GET: RequestHandler = async ({ params }) => {
|
|
try {
|
|
const pb = new PocketBase(PB_DB);
|
|
const record = await pb.collection('pbc_1407612689').getOne(params.id!);
|
|
|
|
return new Response(JSON.stringify(record), {
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
} catch (error) {
|
|
return new Response(
|
|
JSON.stringify({
|
|
error: error instanceof Error ? error.message : 'Job not found',
|
|
}),
|
|
{ status: 404, headers: { 'Content-Type': 'application/json' } }
|
|
);
|
|
}
|
|
};
|
|
|
|
export const PATCH: RequestHandler = async ({ params, request }) => {
|
|
try {
|
|
const pb = new PocketBase(PB_DB);
|
|
const data = await request.json();
|
|
|
|
const updated = await pb.collection('pbc_1407612689').update(params.id!, data);
|
|
|
|
return new Response(JSON.stringify(updated), {
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
} catch (error) {
|
|
return new Response(
|
|
JSON.stringify({
|
|
error: error instanceof Error ? error.message : 'Failed to update job',
|
|
}),
|
|
{ status: 500, headers: { 'Content-Type': 'application/json' } }
|
|
);
|
|
}
|
|
};
|