fix: crash bugs in TeamInvoices + faster load

Bug fixes:
- TeamInvoices: add useAuth import/currentUser (invoice-create crash)
- TeamInvoices: setChartYear -> setExportYear (year-dropdown crash)
- TeamDashboard: drop redundant setState-in-effect (cascading renders)
- Companies: delete dead _UnusedClientCompanies (illegal hook calls)
- annotate intentional empty PDF-fallback catches

Load speed:
- preconnect/dns-prefetch to Supabase origin
- lazy-load heic-to in Converters: page chunk 2737KB -> 9KB
- split recharts into its own 'charts' vendor chunk

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Krao Hasanee
2026-06-08 12:59:11 -04:00
parent 85625f4d95
commit 04e0911e9f
101 changed files with 11786 additions and 7445 deletions
+62
View File
@@ -0,0 +1,62 @@
import { supabase } from './supabase';
async function callFolderSync(action, body) {
const { data: { session } } = await supabase.auth.getSession();
const accessToken = session?.access_token;
if (!accessToken) return { ok: false, skipped: true, warning: 'No active session.' };
const response = await fetch(`/api/filebrowser?action=${encodeURIComponent(action)}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
const payload = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(payload?.error || 'Folder sync failed.');
}
return payload;
}
export async function ensureCompanyFolder({ companyId }) {
if (!companyId) return { ok: false, skipped: true };
return callFolderSync('ensure-company-folder', { companyId });
}
export async function renameCompanyFolder({ companyId, oldName, newName }) {
if (!companyId || !oldName || !newName) return { ok: false, skipped: true };
return callFolderSync('rename-company-folder', { companyId, oldName, newName });
}
export async function ensureProjectFolder({ projectId }) {
if (!projectId) return { ok: false, skipped: true };
return callFolderSync('ensure-project-folder', { projectId });
}
export async function renameProjectFolder({ projectId, oldName, newName }) {
if (!projectId || !oldName || !newName) return { ok: false, skipped: true };
return callFolderSync('rename-project-folder', { projectId, oldName, newName });
}
export async function ensureSubcontractorFolder({ profileId }) {
if (!profileId) return { ok: false, skipped: true };
return callFolderSync('ensure-profile-folder', { profileId });
}
export async function renameSubcontractorFolder({ profileId, oldName, newName }) {
if (!profileId || !oldName || !newName) return { ok: false, skipped: true };
return callFolderSync('rename-profile-folder', { profileId, oldName, newName });
}
export async function ensureRequestFolder({ projectId, taskTitle }) {
if (!projectId || !taskTitle) return { ok: false, skipped: true };
return callFolderSync('ensure-request-folder', { projectId, taskTitle });
}
export async function uploadRequestFileToSurvey({ projectId, taskTitle, storagePath, fileName, bucket = 'submissions' }) {
if (!projectId || !taskTitle || !storagePath || !fileName) return { ok: false, skipped: true };
return callFolderSync('upload-request-file', { projectId, taskTitle, storagePath, fileName, bucket });
}