mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Some checks failed
CI/CD Pipeline / backend-lint (push) Failing after 31s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-lint (push) Failing after 1m37s
CI/CD Pipeline / frontend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
- Replace all 'any' types with proper TypeScript interfaces - Fix React hooks setState in useEffect issues with lazy initialization - Remove unused variables and imports across all files - Fix React Compiler memoization dependency issues - Add comprehensive i18n translation keys for admin interfaces - Apply consistent prettier formatting throughout codebase - Clean up unused bulk editing functionality - Improve type safety and code quality across frontend Files changed: 39 - ImpactMetrics.tsx: Fixed any types and interfaces - AdminVerificationQueuePage.tsx: Added i18n keys, removed unused vars - LocalizationUIPage.tsx: Fixed memoization, added translations - LocalizationDataPage.tsx: Added type safety and translations - And 35+ other files with various lint fixes
83 lines
3.0 KiB
TypeScript
83 lines
3.0 KiB
TypeScript
import Badge from '@/components/ui/Badge';
|
|
import Button from '@/components/ui/Button';
|
|
import { Card } from '@/components/ui/Card';
|
|
import { useAuth } from '@/contexts/AuthContext';
|
|
import { useTranslation } from '@/hooks/useI18n';
|
|
import type { BackendResourceFlow } from '@/schemas/backend/resource-flow';
|
|
import { Search } from 'lucide-react';
|
|
import React from 'react';
|
|
import { formatQualityInfo, formatQuantity } from './utils';
|
|
|
|
interface ResourceFlowCardProps {
|
|
resourceFlow: BackendResourceFlow;
|
|
onViewMatches?: (resourceId: string) => void;
|
|
}
|
|
|
|
const ResourceFlowCard: React.FC<ResourceFlowCardProps> = ({ resourceFlow, onViewMatches }) => {
|
|
const { t } = useTranslation();
|
|
const { isAuthenticated } = useAuth();
|
|
|
|
// use shared format helpers
|
|
const formattedQuantity = formatQuantity(resourceFlow.Quantity);
|
|
const formattedQuality = formatQualityInfo(resourceFlow.Quality);
|
|
|
|
const getTypeLabel = () => {
|
|
return t(`resourceTypes.${resourceFlow.Type}`) || resourceFlow.Type;
|
|
};
|
|
|
|
return (
|
|
<Card className="shadow-none">
|
|
<div className="p-4 space-y-3">
|
|
<div className="flex items-start justify-between">
|
|
<div className="flex-1">
|
|
<div className="flex items-center gap-2 mb-2">
|
|
<Badge variant={resourceFlow.Direction === 'input' ? 'destructive' : 'default'}>
|
|
{resourceFlow.Direction === 'input'
|
|
? t('resourceFlows.input')
|
|
: t('resourceFlows.output')}
|
|
</Badge>
|
|
<Badge variant="outline">{getTypeLabel()}</Badge>
|
|
{resourceFlow.PrecisionLevel && (
|
|
<Badge variant="outline" className="text-xs">
|
|
{resourceFlow.PrecisionLevel}
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
<h4 className="font-semibold text-base mb-1">{getTypeLabel()}</h4>
|
|
<p className="text-sm text-muted-foreground mb-2">{formattedQuantity}</p>
|
|
{formattedQuality && (
|
|
<p className="text-xs text-muted-foreground">{formattedQuality}</p>
|
|
)}
|
|
{resourceFlow.EconomicData && (
|
|
<div className="mt-2 text-xs text-muted-foreground">
|
|
{resourceFlow.EconomicData.cost_out !== undefined && (
|
|
<span>
|
|
{t('resourceFlow.cost', {
|
|
cost: resourceFlow.EconomicData.cost_out.toFixed(2),
|
|
})}
|
|
</span>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
{onViewMatches && resourceFlow.Direction === 'output' && isAuthenticated && (
|
|
<div className="flex gap-2 pt-2 border-t">
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => onViewMatches(resourceFlow.ID)}
|
|
className="flex-1"
|
|
>
|
|
<Search className="h-4 w-4 mr-2" />
|
|
{t('resourceFlows.findMatches')}
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</Card>
|
|
);
|
|
};
|
|
|
|
export default React.memo(ResourceFlowCard);
|