mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 05:11:14 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
85
src-old/components/history/EntityHistoryTabs.tsx
Normal file
85
src-old/components/history/EntityHistoryTabs.tsx
Normal file
@@ -0,0 +1,85 @@
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { EntityTimelineManager } from '@/components/timeline/EntityTimelineManager';
|
||||
import { EntityVersionHistory } from '@/components/versioning/EntityVersionHistory';
|
||||
import { FormerNamesSection } from './FormerNamesSection';
|
||||
import { RideNameHistory } from '@/types/database';
|
||||
import type { EntityType } from '@/types/timeline';
|
||||
|
||||
interface EntityHistoryTabsProps {
|
||||
entityType: EntityType;
|
||||
entityId: string;
|
||||
entityName: string;
|
||||
formerNames?: RideNameHistory[];
|
||||
currentName?: string;
|
||||
}
|
||||
|
||||
const getHistoryLabel = (entityType: string) => {
|
||||
switch (entityType) {
|
||||
case 'park':
|
||||
return 'Park History';
|
||||
case 'ride':
|
||||
return 'Ride History';
|
||||
case 'company':
|
||||
return 'Company History';
|
||||
default:
|
||||
return 'History';
|
||||
}
|
||||
};
|
||||
|
||||
const getHistoryValue = (entityType: string) => {
|
||||
switch (entityType) {
|
||||
case 'park':
|
||||
return 'park-history';
|
||||
case 'ride':
|
||||
return 'ride-history';
|
||||
case 'company':
|
||||
return 'company-history';
|
||||
default:
|
||||
return 'entity-history';
|
||||
}
|
||||
};
|
||||
|
||||
export function EntityHistoryTabs({
|
||||
entityType,
|
||||
entityId,
|
||||
entityName,
|
||||
formerNames,
|
||||
currentName,
|
||||
}: EntityHistoryTabsProps) {
|
||||
const historyValue = getHistoryValue(entityType);
|
||||
const historyLabel = getHistoryLabel(entityType);
|
||||
|
||||
return (
|
||||
<Tabs defaultValue={historyValue} className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value={historyValue}>{historyLabel}</TabsTrigger>
|
||||
<TabsTrigger value="version-history">Version History</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value={historyValue} className="mt-6 space-y-6">
|
||||
{formerNames && formerNames.length > 0 && currentName && (
|
||||
<FormerNamesSection
|
||||
currentName={currentName}
|
||||
formerNames={formerNames}
|
||||
entityType={entityType}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Dynamic Timeline Manager with Edit/Delete */}
|
||||
<EntityTimelineManager
|
||||
entityType={entityType}
|
||||
entityId={entityId}
|
||||
entityName={entityName}
|
||||
/>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="version-history" className="mt-6">
|
||||
<EntityVersionHistory
|
||||
entityType={entityType}
|
||||
entityId={entityId}
|
||||
entityName={entityName}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user