mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 17:51:12 -05:00
Refactor versioning utility functions
This commit is contained in:
@@ -10,9 +10,10 @@ import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { VersionComparisonDialog } from './VersionComparisonDialog';
|
||||
import { RollbackDialog } from './RollbackDialog';
|
||||
import { useEntityVersions } from '@/hooks/useEntityVersions';
|
||||
import type { EntityType } from '@/types/versioning';
|
||||
|
||||
interface EntityVersionHistoryProps {
|
||||
entityType: string;
|
||||
entityType: EntityType;
|
||||
entityId: string;
|
||||
entityName: string;
|
||||
}
|
||||
@@ -97,13 +98,13 @@ export function EntityVersionHistory({ entityType, entityId, entityName }: Entit
|
||||
|
||||
{versions.map((version, index) => (
|
||||
<Card
|
||||
key={version.id}
|
||||
key={version.version_id}
|
||||
className={`relative pl-16 pr-4 py-4 cursor-pointer transition-colors ${
|
||||
selectedVersions.includes(version.id)
|
||||
selectedVersions.includes(version.version_id)
|
||||
? 'border-primary bg-accent'
|
||||
: 'hover:border-primary/50'
|
||||
} ${version.is_current ? 'border-primary shadow-md' : ''}`}
|
||||
onClick={() => handleVersionSelect(version.id)}
|
||||
onClick={() => handleVersionSelect(version.version_id)}
|
||||
>
|
||||
{/* Timeline dot */}
|
||||
<div
|
||||
@@ -133,7 +134,7 @@ export function EntityVersionHistory({ entityType, entityId, entityName }: Entit
|
||||
variant="ghost"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleRollback(version.id);
|
||||
handleRollback(version.version_id);
|
||||
}}
|
||||
>
|
||||
<RotateCcw className="h-4 w-4 mr-1" />
|
||||
@@ -146,17 +147,17 @@ export function EntityVersionHistory({ entityType, entityId, entityName }: Entit
|
||||
<div className="flex items-center gap-4 text-sm text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<Avatar className="h-6 w-6">
|
||||
<AvatarImage src={version.changer_profile?.avatar_url || undefined} />
|
||||
<AvatarImage src={version.profiles?.avatar_url || undefined} />
|
||||
<AvatarFallback>
|
||||
<User className="h-3 w-3" />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<span>{version.changer_profile?.username || 'Unknown'}</span>
|
||||
<span>{version.profiles?.display_name || version.profiles?.username || 'Unknown'}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="h-4 w-4" />
|
||||
<span>{formatDistanceToNow(new Date(version.changed_at), { addSuffix: true })}</span>
|
||||
<span>{formatDistanceToNow(new Date(version.created_at), { addSuffix: true })}</span>
|
||||
</div>
|
||||
|
||||
{version.submission_id && (
|
||||
|
||||
Reference in New Issue
Block a user