import React, { useState } from 'react' import { Link } from 'react-router-dom' import { useQuery } from '@tanstack/react-query' import { FaTruck, FaPlus, FaSearch, FaFilter, FaDownload, FaEdit, FaEye, FaPhone, FaEnvelope, FaMapMarkerAlt, FaStar, FaExclamationTriangle, FaArrowUp, FaUsers, FaBuilding, } from 'react-icons/fa' import classNames from 'classnames' import { SupplierTypeEnum } from '../../../types/mm' import { mockBusinessParties } from '../../../mocks/mockBusinessParties' import { PartyType } from '../../../types/common' import { getSupplierTypeColor, getSupplierTypeText, getRatingColor } from '../../../utils/erp' import { Container } from '@/components/shared' import { ROUTES_ENUM } from '@/routes/route.constant' const SupplierList: React.FC = () => { const [searchTerm, setSearchTerm] = useState('') const [filterType, setFilterType] = useState('all') const [showFilters, setShowFilters] = useState(false) const { data: suppliers, isLoading, error, } = useQuery({ queryKey: ['suppliers', searchTerm, filterType], queryFn: async () => { await new Promise((resolve) => setTimeout(resolve, 500)) const filtredSuppliers = mockBusinessParties.filter((a) => a.partyType === PartyType.Supplier) return filtredSuppliers.filter((supplier) => { const matchesSearch = supplier.code.toLowerCase().includes(searchTerm.toLowerCase()) || supplier.name.toLowerCase().includes(searchTerm.toLowerCase()) const matchesType = filterType === 'all' || supplier.supplierType === filterType return matchesSearch && matchesType }) }, }) if (isLoading) { return (
Tedarikçiler yükleniyor...
) } if (error) { return (
Tedarikçiler yüklenirken hata oluştu.
) } return (
{/* Header Actions */}
setSearchTerm(e.target.value)} className="pl-10 pr-4 py-1.5 w-80 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
Yeni Tedarikçi
{/* Filters Panel */} {showFilters && (
)} {/* Statistics Cards */}

Toplam Tedarikçi

{suppliers?.length || 0}

Aktif Tedarikçi

{suppliers?.filter((s) => s.isActive).length || 0}

Ortalama Puan

{suppliers?.length ? ( suppliers.reduce( (acc, s) => acc + (s.performanceMetrics?.overallScore ?? 0), 0, ) / suppliers.length ).toFixed(1) : '0.0'}

Yüksek Performans

{suppliers?.filter((s) => (s.performanceMetrics?.overallScore ?? 0) >= 4.5) .length || 0}

{/* Suppliers Table */}

Tedarikçi Listesi

{suppliers?.map((supplier) => ( ))}
Tedarikçi Bilgileri İletişim Tür / Konum Performans Kredi Limiti Durum İşlemler
{supplier.code}
{supplier.name}
{supplier.taxNumber && (
VKN: {supplier.taxNumber}
)}
{supplier.primaryContact && (
{supplier.primaryContact.fullName}
)} {supplier.email && (
{supplier.email}
)} {supplier.phone && (
{supplier.phone}
)}
{getSupplierTypeText(supplier.supplierType!)}
{supplier.address?.city}, {supplier.address?.country}
{(supplier.performanceMetrics?.overallScore ?? 0).toFixed(1)}
K: {(supplier.performanceMetrics?.qualityRating ?? 0).toFixed(1)} T: {(supplier.performanceMetrics?.deliveryPerformance ?? 0).toFixed(1)} F: {(supplier.performanceMetrics?.priceCompetitiveness ?? 0).toFixed(1)}
{supplier.certifications && supplier.certifications.length > 0 && (
{supplier.certifications.join(', ')}
)}
₺{supplier.creditLimit.toLocaleString()}
{supplier.paymentTerms}
{supplier.isActive ? 'Aktif' : 'Pasif'}
{(!suppliers || suppliers.length === 0) && (

Tedarikçi bulunamadı

Yeni tedarikçi ekleyerek başlayın.

Yeni Tedarikçi Ekle
)}
) } export default SupplierList