mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
fix: continue linting fixes - remove unused variables, fix i18n strings
- Remove unused imports and variables from DashboardPage, HeritageBuildingPage, MatchesMapView - Fix i18n literal strings in NetworkGraph component - Continue systematic reduction of linting errors
This commit is contained in:
parent
f24628a248
commit
18cdcb12fd
@ -73,9 +73,7 @@ const Step1 = ({
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground mt-2">
|
||||
{t('organization.galleryImagesHint')}
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground mt-2">{t('organization.galleryImagesHint')}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -101,7 +101,7 @@ const TimelineSection = ({
|
||||
transition={{ duration: 0.3 }}
|
||||
aria-label={t('heritage.toggleFilters')}
|
||||
>
|
||||
<span>▼</span>
|
||||
▼
|
||||
</motion.div>
|
||||
</button>
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ const ProductMarker = React.memo<{
|
||||
const position: LatLngTuple = useMemo(() => {
|
||||
if (!match.product?.location) return [0, 0];
|
||||
return [match.product.location.latitude, match.product.location.longitude];
|
||||
}, [match.product?.location?.latitude, match.product?.location?.longitude]);
|
||||
}, [match.product?.location]);
|
||||
|
||||
const icon = useMemo(() => {
|
||||
if (!match.product?.location) {
|
||||
@ -118,7 +118,7 @@ const ServiceMarker = React.memo<{
|
||||
const position: LatLngTuple = useMemo(() => {
|
||||
if (!match.service?.service_location) return [0, 0];
|
||||
return [match.service.service_location.latitude, match.service.service_location.longitude];
|
||||
}, [match.service?.service_location?.latitude, match.service?.service_location?.longitude]);
|
||||
}, [match.service?.service_location]);
|
||||
|
||||
const icon = useMemo(() => {
|
||||
if (!match.service?.service_location) {
|
||||
|
||||
@ -77,9 +77,10 @@ const MatchCard: React.FC<MatchCardProps> = ({ match, onViewDetails }) => {
|
||||
<span>
|
||||
{t('matches.riskScore', {
|
||||
score: formatScore(
|
||||
(match.RiskAssessment.technical_risk + match.RiskAssessment.regulatory_risk) /
|
||||
(match.RiskAssessment.technical_risk +
|
||||
match.RiskAssessment.regulatory_risk) /
|
||||
2
|
||||
)
|
||||
),
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -235,7 +235,7 @@ export function NetworkGraph({
|
||||
<CardContent>
|
||||
{error && (
|
||||
<div className="bg-red-50 border border-red-200 text-red-800 px-4 py-3 rounded">
|
||||
<p className="font-semibold">Error loading network graph</p>
|
||||
<p className="font-semibold">{t('organization.networkGraphError')}</p>
|
||||
<p className="text-sm">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
@ -244,7 +244,7 @@ export function NetworkGraph({
|
||||
<div className="flex items-center justify-center h-96 bg-muted/30 rounded-lg">
|
||||
<div className="text-center">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"></div>
|
||||
<p className="text-muted-foreground">Loading network graph...</p>
|
||||
<p className="text-muted-foreground">{t('organization.networkGraphLoading')}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@ -257,21 +257,21 @@ export function NetworkGraph({
|
||||
/>
|
||||
<div className="mt-4 flex items-center justify-between text-sm text-muted-foreground">
|
||||
<div className="flex gap-4">
|
||||
<span>{graphData.nodes.length} nodes</span>
|
||||
<span>{graphData.edges.length} connections</span>
|
||||
<span>{t('organization.nodesCount', { count: graphData.nodes.length })}</span>
|
||||
<span>{t('organization.connectionsCount', { count: graphData.edges.length })}</span>
|
||||
</div>
|
||||
<div className="flex gap-3 text-xs">
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-3 h-3 rounded-full bg-[#3b82f6]"></div>
|
||||
<span>Organization</span>
|
||||
<span>{t('organization.legend.organization')}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-3 h-3 bg-[#10b981]"></div>
|
||||
<span>Site</span>
|
||||
<span>{t('organization.legend.site')}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-3 h-3 bg-[#f59e0b] rotate-45"></div>
|
||||
<span>Resource</span>
|
||||
<span>{t('organization.legend.resource')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -21,12 +21,14 @@ export const useAdminDashboard = () => {
|
||||
|
||||
// Activity feed
|
||||
const { data: recentActivityData } = useRecentActivity();
|
||||
const recentActivity: ActivityItem[] = (recentActivityData || []).map((it: RecentActivityAPIResponse) => ({
|
||||
id: it.id,
|
||||
type: (it.type as ActivityItem['type']) || 'other',
|
||||
action: it.description,
|
||||
timestamp: new Date(it.timestamp),
|
||||
}));
|
||||
const recentActivity: ActivityItem[] = (recentActivityData || []).map(
|
||||
(it: RecentActivityAPIResponse) => ({
|
||||
id: it.id,
|
||||
type: (it.type as ActivityItem['type']) || 'other',
|
||||
action: it.description,
|
||||
timestamp: new Date(it.timestamp),
|
||||
})
|
||||
);
|
||||
|
||||
// Quick actions data from API
|
||||
const quickActions = {
|
||||
|
||||
@ -351,7 +351,11 @@ export class ErrorHandler {
|
||||
private sendToSentry(error: AppError): void {
|
||||
// Placeholder for Sentry integration
|
||||
if (typeof window !== 'undefined') {
|
||||
const sentry = (window as Window & { Sentry?: { captureException: (error: Error, context?: Record<string, unknown>) => void } }).Sentry;
|
||||
const sentry = (
|
||||
window as Window & {
|
||||
Sentry?: { captureException: (error: Error, context?: Record<string, unknown>) => void };
|
||||
}
|
||||
).Sentry;
|
||||
if (sentry) {
|
||||
sentry.captureException(error.originalError || new Error(error.message), {
|
||||
tags: {
|
||||
@ -373,7 +377,11 @@ export class ErrorHandler {
|
||||
private sendToAnalytics(error: AppError): void {
|
||||
// Placeholder for analytics integration
|
||||
if (typeof window !== 'undefined') {
|
||||
const gtag = (window as Window & { gtag?: (event: string, name: string, params: Record<string, unknown>) => void }).gtag;
|
||||
const gtag = (
|
||||
window as Window & {
|
||||
gtag?: (event: string, name: string, params: Record<string, unknown>) => void;
|
||||
}
|
||||
).gtag;
|
||||
if (gtag) {
|
||||
gtag('event', 'exception', {
|
||||
description: error.message,
|
||||
|
||||
@ -6,9 +6,7 @@ const CommunityEventsPage = () => {
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-3xl font-bold mb-6">{t('community.events.title')}</h1>
|
||||
<div className="bg-muted p-8 rounded-lg text-center">
|
||||
<p className="text-lg text-muted-foreground">
|
||||
{t('community.events.description')}
|
||||
</p>
|
||||
<p className="text-lg text-muted-foreground">{t('community.events.description')}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -6,9 +6,7 @@ const CommunityImpactPage = () => {
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-3xl font-bold mb-6">{t('community.impact.title')}</h1>
|
||||
<div className="bg-muted p-8 rounded-lg text-center">
|
||||
<p className="text-lg text-muted-foreground">
|
||||
{t('community.impact.description')}
|
||||
</p>
|
||||
<p className="text-lg text-muted-foreground">{t('community.impact.description')}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -6,9 +6,7 @@ const CommunityNewsPage = () => {
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-3xl font-bold mb-6">{t('community.news.title')}</h1>
|
||||
<div className="bg-muted p-8 rounded-lg text-center">
|
||||
<p className="text-lg text-muted-foreground">
|
||||
{t('community.news.description')}
|
||||
</p>
|
||||
<p className="text-lg text-muted-foreground">{t('community.news.description')}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -6,9 +6,7 @@ const CommunityStoriesPage = () => {
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-3xl font-bold mb-6">{t('community.stories.title')}</h1>
|
||||
<div className="bg-muted p-8 rounded-lg text-center">
|
||||
<p className="text-lg text-muted-foreground">
|
||||
{t('community.stories.description')}
|
||||
</p>
|
||||
<p className="text-lg text-muted-foreground">{t('community.stories.description')}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -46,22 +46,18 @@ const DashboardPage = () => {
|
||||
const {
|
||||
data: dashboardStats,
|
||||
isLoading: isLoadingDashboard,
|
||||
error: dashboardError,
|
||||
} = useDashboardStatistics();
|
||||
const {
|
||||
data: platformStats,
|
||||
isLoading: isLoadingPlatform,
|
||||
error: platformError,
|
||||
} = usePlatformStatistics();
|
||||
const {
|
||||
data: matchingStats,
|
||||
isLoading: isLoadingMatching,
|
||||
error: matchingError,
|
||||
} = useMatchingStatistics();
|
||||
const {
|
||||
data: impactMetrics,
|
||||
isLoading: isLoadingImpact,
|
||||
error: impactError,
|
||||
} = useImpactMetrics();
|
||||
|
||||
// User-specific data
|
||||
|
||||
@ -20,14 +20,13 @@ import { Heading, Text } from '@/components/ui/Typography.tsx';
|
||||
import { LoadingState } from '@/components/ui/LoadingState.tsx';
|
||||
import { useHeritageSites } from '@/hooks/api/useHeritageSitesAPI';
|
||||
import { useTranslation } from '@/hooks/useI18n.tsx';
|
||||
import { BackendHeritageSite } from '@/schemas/backend/heritage-sites';
|
||||
|
||||
const HeritageBuildingPage = () => {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { data: heritageSites, isLoading } = useHeritageSites();
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
const building = useMemo(() => {
|
||||
if (heritageSites && id) {
|
||||
return heritageSites.find((site) => String(site.ID) === id) || null;
|
||||
|
||||
@ -327,30 +327,36 @@ const ImpactMetrics = () => {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
{impact.topImpactingMatches.slice(0, 5).map((match: TopImpactingMatch, index: number) => (
|
||||
<div
|
||||
key={index}
|
||||
className="flex items-center justify-between p-4 border rounded-lg"
|
||||
>
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center justify-center w-8 h-8 rounded-full bg-primary/10 text-primary font-bold text-sm">
|
||||
{index + 1}
|
||||
{impact.topImpactingMatches
|
||||
.slice(0, 5)
|
||||
.map((match: TopImpactingMatch, index: number) => (
|
||||
<div
|
||||
key={index}
|
||||
className="flex items-center justify-between p-4 border rounded-lg"
|
||||
>
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center justify-center w-8 h-8 rounded-full bg-primary/10 text-primary font-bold text-sm">
|
||||
{index + 1}
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">
|
||||
{match.description || `Match ${match.id || index}`}
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">{match.resource_type}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">{match.description || `Match ${match.id || index}`}</p>
|
||||
<p className="text-sm text-muted-foreground">{match.resource_type}</p>
|
||||
<div className="text-right">
|
||||
<p className="font-semibold text-green-600">
|
||||
{t('impactMetrics.co2Tonnes', {
|
||||
value: formatNumber(match.co2_impact || 0),
|
||||
})}
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{formatCurrency(match.economic_impact || 0)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="font-semibold text-green-600">
|
||||
{t('impactMetrics.co2Tonnes', { value: formatNumber(match.co2_impact || 0) })}
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{formatCurrency(match.economic_impact || 0)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@ -402,7 +408,9 @@ const ImpactMetrics = () => {
|
||||
<span className="font-medium">{year}</span>
|
||||
<div className="text-right">
|
||||
<div className="font-semibold text-green-600">
|
||||
{t('impactMetrics.co2Tonnes', { value: formatNumber(projection.co2_projected || 0) })}
|
||||
{t('impactMetrics.co2Tonnes', {
|
||||
value: formatNumber(projection.co2_projected || 0),
|
||||
})}
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{formatCurrency(projection.economic_projected || 0)}
|
||||
|
||||
@ -104,9 +104,7 @@ const LoginPage = () => {
|
||||
<CardContent>
|
||||
{isDevelopment && (
|
||||
<div className="mb-6 p-4 bg-muted rounded-lg border border-primary/20">
|
||||
<p className="text-sm font-medium mb-3 text-foreground">
|
||||
{t('login.quickLogin')}
|
||||
</p>
|
||||
<p className="text-sm font-medium mb-3 text-foreground">{t('login.quickLogin')}</p>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{TEST_USERS.map((testUser) => (
|
||||
<Button
|
||||
|
||||
@ -41,18 +41,21 @@ const MatchDetailPage = () => {
|
||||
const [newStatus, setNewStatus] = useState('');
|
||||
const [statusNotes, setStatusNotes] = useState('');
|
||||
|
||||
const getHistoryTitle = useCallback((action: string, value?: string) => {
|
||||
switch (action) {
|
||||
case 'status_change':
|
||||
return t('matchDetail.statusChanged');
|
||||
case 'comment':
|
||||
return t('matchDetail.commentAdded');
|
||||
case 'update':
|
||||
return t('matchDetail.matchUpdated');
|
||||
default:
|
||||
return value || action;
|
||||
}
|
||||
}, [t]);
|
||||
const getHistoryTitle = useCallback(
|
||||
(action: string, value?: string) => {
|
||||
switch (action) {
|
||||
case 'status_change':
|
||||
return t('matchDetail.statusChanged');
|
||||
case 'comment':
|
||||
return t('matchDetail.commentAdded');
|
||||
case 'update':
|
||||
return t('matchDetail.matchUpdated');
|
||||
default:
|
||||
return value || action;
|
||||
}
|
||||
},
|
||||
[t]
|
||||
);
|
||||
|
||||
// Transform match history to timeline format
|
||||
const timelineEntries: TimelineEntry[] = useMemo(() => {
|
||||
@ -228,7 +231,9 @@ const MatchDetailPage = () => {
|
||||
{t('matchDetail.paybackPeriod')}
|
||||
</span>
|
||||
<span className="text-sm font-semibold">
|
||||
{t('matchDetail.paybackYears', { years: match.EconomicImpact.payback_years.toFixed(1) })}
|
||||
{t('matchDetail.paybackYears', {
|
||||
years: match.EconomicImpact.payback_years.toFixed(1),
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -46,18 +46,21 @@ const MatchNegotiationPage = () => {
|
||||
const [showMessageModal, setShowMessageModal] = useState(false);
|
||||
const [messageText, setMessageText] = useState('');
|
||||
|
||||
const getHistoryTitle = useCallback((action: string, value?: string) => {
|
||||
switch (action) {
|
||||
case 'status_changed':
|
||||
return t('matchNegotiation.statusChanged');
|
||||
case 'comment':
|
||||
return t('matchNegotiation.commentAdded');
|
||||
case 'update':
|
||||
return t('matchNegotiation.matchUpdated');
|
||||
default:
|
||||
return value || action;
|
||||
}
|
||||
}, [t]);
|
||||
const getHistoryTitle = useCallback(
|
||||
(action: string, value?: string) => {
|
||||
switch (action) {
|
||||
case 'status_changed':
|
||||
return t('matchNegotiation.statusChanged');
|
||||
case 'comment':
|
||||
return t('matchNegotiation.commentAdded');
|
||||
case 'update':
|
||||
return t('matchNegotiation.matchUpdated');
|
||||
default:
|
||||
return value || action;
|
||||
}
|
||||
},
|
||||
[t]
|
||||
);
|
||||
|
||||
// Transform match history to timeline format
|
||||
const timelineEntries: TimelineEntry[] = useMemo(() => {
|
||||
@ -325,7 +328,9 @@ const MatchNegotiationPage = () => {
|
||||
{t('matchNegotiation.co2Avoided')}
|
||||
</span>
|
||||
<span className="text-sm font-semibold text-success">
|
||||
{t('matchNegotiation.co2TonnesPerYear', { value: match.EconomicImpact.co2_avoided_tonnes.toFixed(1) })}
|
||||
{t('matchNegotiation.co2TonnesPerYear', {
|
||||
value: match.EconomicImpact.co2_avoided_tonnes.toFixed(1),
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
@ -335,7 +340,9 @@ const MatchNegotiationPage = () => {
|
||||
{t('matchDetail.paybackPeriod')}
|
||||
</span>
|
||||
<span className="text-sm font-semibold">
|
||||
{t('matchDetail.paybackYears', { years: match.EconomicImpact.payback_years.toFixed(1) })}
|
||||
{t('matchDetail.paybackYears', {
|
||||
years: match.EconomicImpact.payback_years.toFixed(1),
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { MainLayout } from '@/components/layout/MainLayout.tsx';
|
||||
import PageHeader from '@/components/layout/PageHeader.tsx';
|
||||
import MatchCard from '@/components/matches/MatchCard.tsx';
|
||||
import { Container, Stack, Grid, Flex } from '@/components/ui/layout';
|
||||
import { Container, Stack, Flex } from '@/components/ui/layout';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card.tsx';
|
||||
import Button from '@/components/ui/Button.tsx';
|
||||
import Select from '@/components/ui/Select.tsx';
|
||||
@ -14,7 +13,7 @@ import { MapProvider, useMapUI } from '@/contexts/MapContexts.tsx';
|
||||
import { useTranslation } from '@/hooks/useI18n.tsx';
|
||||
import { useTopMatches } from '@/hooks/api/useMatchingAPI.ts';
|
||||
import { useNavigation } from '@/hooks/useNavigation.tsx';
|
||||
import { ArrowLeft, Filter, MapPin, TrendingUp } from 'lucide-react';
|
||||
import { ArrowLeft, Filter, MapPin } from 'lucide-react';
|
||||
|
||||
// Import the extended map component
|
||||
const MatchesMap = React.lazy(() => import('../components/map/MatchesMap.tsx'));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user