Implement comprehensive report system with detailed viewing and AI enhancements
- Add detailed report viewing with full-screen ReportDetail component for both company and employee reports - Fix company wiki to display onboarding Q&A in card format matching Figma designs - Exclude company owners from employee submission counts (owners contribute to wiki, not employee data) - Fix employee report generation to include company context (wiki + company report + employee answers) - Fix company report generation to use filtered employee submissions only - Add proper error handling for submission data format variations - Update Firebase functions to use gpt-4o model instead of deprecated gpt-4.1 - Fix UI syntax errors and improve report display functionality - Add comprehensive logging for debugging report generation flow 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -70,9 +70,9 @@ export const UserOrganizationsProvider: React.FC<{ children: React.ReactNode }>
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize selected org from session storage
|
||||
// Initialize selected org from localStorage (persistent across sessions)
|
||||
useEffect(() => {
|
||||
const savedOrgId = sessionStorage.getItem('auditly_selected_org');
|
||||
const savedOrgId = localStorage.getItem('auditly_selected_org');
|
||||
if (savedOrgId) {
|
||||
setSelectedOrgId(savedOrgId);
|
||||
}
|
||||
@@ -83,9 +83,48 @@ export const UserOrganizationsProvider: React.FC<{ children: React.ReactNode }>
|
||||
loadOrganizations();
|
||||
}, [user]);
|
||||
|
||||
// Listen for organization updates (e.g., onboarding completion)
|
||||
useEffect(() => {
|
||||
const handleOrgUpdate = (event: CustomEvent) => {
|
||||
const { orgId, onboardingCompleted } = event.detail;
|
||||
console.log('UserOrganizationsContext received org update:', { orgId, onboardingCompleted });
|
||||
|
||||
if (onboardingCompleted && orgId) {
|
||||
// Update the specific organization in the list to reflect onboarding completion
|
||||
setOrganizations(prev => {
|
||||
const updated = prev.map(org =>
|
||||
org.orgId === orgId
|
||||
? { ...org, onboardingCompleted: true }
|
||||
: org
|
||||
);
|
||||
console.log('Updated organizations after onboarding completion:', updated);
|
||||
return updated;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('organizationUpdated', handleOrgUpdate as EventListener);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('organizationUpdated', handleOrgUpdate as EventListener);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const selectOrganization = (orgId: string) => {
|
||||
console.log('Switching to organization:', orgId);
|
||||
|
||||
// Clear any cached data when switching organizations for security
|
||||
sessionStorage.removeItem('auditly_cached_employees');
|
||||
sessionStorage.removeItem('auditly_cached_submissions');
|
||||
sessionStorage.removeItem('auditly_cached_reports');
|
||||
|
||||
setSelectedOrgId(orgId);
|
||||
sessionStorage.setItem('auditly_selected_org', orgId);
|
||||
localStorage.setItem('auditly_selected_org', orgId);
|
||||
|
||||
// Dispatch event to notify other contexts about the org switch
|
||||
window.dispatchEvent(new CustomEvent('organizationChanged', {
|
||||
detail: { newOrgId: orgId }
|
||||
}));
|
||||
};
|
||||
|
||||
const createOrganization = async (name: string): Promise<{ orgId: string; requiresSubscription?: boolean }> => {
|
||||
|
||||
Reference in New Issue
Block a user