tercul-frontend/client/src/components/annotation/annotation-browser.tsx
Damir Mukimov ea2ef8fa6d
Fix/typescript testing issues (#12)
* feat: Add missing shared schema types and fix TypeScript imports

- Add AuthorWithStats and AnnotationWithUser schemas with relations
- Add corresponding TypeScript type exports
- Update tsconfig.json with @shared/* path mapping
- Fix @shared/schema import issues across components
- Resolve major TypeScript compilation errors

Next: Fix remaining type mismatches and component prop issues

* fix: resolve major TypeScript errors and type mismatches

- Add AuthorWithStats and AnnotationWithUser schemas with proper relations
- Fix AnnotationSystem component type issues (string IDs, nested user objects)
- Update component props to match schema expectations
- Fix function parameter types for annotation operations
- Resolve null/undefined type assignments
- Add missing required properties (type, isOfficial) to annotations

Remaining issues: Test ES module configuration and some component prop type mismatches

* fix: resolve remaining TypeScript errors and improve type safety

- Fix tag-manager component to work with string IDs from schema
- Update author-stats component to use schema-based AuthorWithStats type
- Add missing utility functions (formatNumber, formatRating) to author utils
- Fix WorkCard test to use correct schema types with string IDs
- Resolve type mismatches in component props and form handling
- Update interface definitions to match schema requirements

Linting:  90%+ resolved, remaining minor issues
Testing: ⚠️ ES module configuration needs refinement

* fix: complete TypeScript fixes and testing refinements

- Fix remaining AnnotationSystem component type issues
- Update FilterSidebar to use string tag IDs
- Resolve all major TypeScript compilation errors
- Testing infrastructure fully functional with Jest + ES modules
- Linting errors reduced to minor unused variable warnings

All critical type safety and testing issues resolved!

* Fix annotation types and author utils

* Fix TypeScript and testing infrastructure issues

- Fix AnnotationSystem component types (string IDs, user objects, liked/likes properties)
- Add formatNumber and formatRating utilities for author components
- Update FilterSidebar to use correct tag ID types (string vs number)
- Fix EnhancedReadingView translation and work ID type mismatches
- Resolve Playwright dependency issues in testing setup
- Update Jest configuration for ES module compatibility
- Fix import paths and type conflicts across components

All unit tests now pass and major TypeScript compilation errors resolved.

* Fix Vite build configuration for CI

- Set root to 'client' directory to find index.html
- Configure path aliases (@/* and @shared/*) for proper module resolution
- Set build output directory to '../dist' to place files in frontend root

Resolves CI build failure: 'Could not resolve entry module index.html'

* Fix Docker build for Yarn v4

- Replace deprecated 'yarn install --immutable --production' with 'yarn workspaces focus --production'
- This resolves the YN0050 error in CI Docker builds

Yarn v4 deprecated the --production flag on install command.
2025-11-30 15:39:18 +01:00

54 lines
1.6 KiB
TypeScript

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Heading } from "@/components/ui/typography/heading";
import { Paragraph } from "@/components/ui/typography/paragraph";
import type { AnnotationWithUser } from "@shared/schema";
import { AnnotationFilters } from "./annotation-filters";
interface AnnotationBrowserProps {
annotations: AnnotationWithUser[];
onSelect?: (annotation: AnnotationWithUser) => void;
}
export function AnnotationBrowser({
annotations,
onSelect,
}: AnnotationBrowserProps) {
// TODO: Add filter state and logic
return (
<div className="space-y-4">
<AnnotationFilters />
{annotations.map((annotation) => (
<Card
key={annotation.id}
className="cursor-pointer hover:shadow-md"
onClick={() => onSelect?.(annotation)}
>
<CardHeader className="flex flex-row items-center gap-3 p-4">
<Avatar>
<AvatarImage
src={annotation.user.avatar || ""}
alt={annotation.user.name}
/>
<AvatarFallback>
{annotation.user.name.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
<div>
<Heading level="h4" className="mb-1">
{annotation.user.name}
</Heading>
<Paragraph size="xs" variant="muted">
{new Date(annotation.createdAt).toLocaleString()}
</Paragraph>
</div>
</CardHeader>
<CardContent className="p-4 pt-0">
<Paragraph size="sm">{annotation.content}</Paragraph>
</CardContent>
</Card>
))}
</div>
);
}