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:
Ra
2025-08-18 19:08:29 -07:00
parent 557b113196
commit 1a9e92d7bd
20 changed files with 1793 additions and 635 deletions

23
App.tsx
View File

@@ -41,16 +41,28 @@ const RequireOrgSelection: React.FC<{ children: React.ReactNode }> = ({ children
const RequireOnboarding: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const { org } = useOrg();
const { user } = useAuth();
const { organizations } = useUserOrganizations();
const { organizations, selectedOrgId } = useUserOrganizations();
if (!org) return <div className="p-8">Loading organization...</div>;
if (!org.onboardingCompleted) {
// Only org owners should be redirected to onboarding
const userOrgRelation = organizations.find(o => o.orgId === org.orgId);
const isOrgOwner = userOrgRelation?.role === 'owner';
// Get the user's relationship to this organization
const userOrgRelation = organizations.find(o => o.orgId === selectedOrgId);
const isOrgOwner = userOrgRelation?.role === 'owner';
// SINGLE SOURCE OF TRUTH: Organization onboarding completion is the authoritative source
// User organization records are updated to reflect this, but org.onboardingCompleted is primary
const onboardingCompleted = org.onboardingCompleted === true;
console.log('RequireOnboarding check:', {
orgId: selectedOrgId,
orgOnboardingCompleted: org.onboardingCompleted,
userRole: userOrgRelation?.role,
finalDecision: onboardingCompleted
});
if (!onboardingCompleted) {
if (isOrgOwner) {
console.log('Redirecting owner to onboarding');
return <Navigate to="/onboarding" replace />;
} else {
// Non-owners should see a waiting message
@@ -104,6 +116,7 @@ function App() {
{/* Employee questionnaire - no auth needed, uses invite code */}
<Route path="/employee-form/:inviteCode" element={<EmployeeQuestionnaire />} />
<Route path="/questionnaire/:inviteCode" element={<EmployeeQuestionnaire />} />
{/* Organization Selection - after auth, before entering app */}
<Route