import { useState } from 'react' import { Badge, Button } from '@/components/ui' import { Container } from '@/components/shared' import { Dialog, Notification, toast } from '@/components/ui' import type { BranchSeedResultDto } from '@/proxy/branch/seed' import { runBranchSeed } from '@/services/branch.service' function BranchSeed({ open, onDialogClose, id, name, }: { open: boolean onDialogClose: () => void id: string name: string }) { const [isLoading, setIsLoading] = useState(false) const [result, setResult] = useState(null) const handleRunSeed = async () => { if (!id) return setIsLoading(true) try { const data = await runBranchSeed(id) setResult(data) if (data.success) { toast.push(, { placement: 'top-end', }) } else { toast.push(, { placement: 'top-end', }) } } catch (error) { console.error(error) setResult({ success: false, message: 'Seed işlemi sırasında hata oluştu.', totalInsertedCount: 0, details: [], }) toast.push(, { placement: 'top-end', }) } finally { setIsLoading(false) } } return (
Branch Seed - {name}

{/* Başlık ve buton aynı satırda */}
{result && (result.success ? ( ✅ Seed İşlemi Başarılı ) : ( ❌ Seed İşlemi Başarısız ))}
{/* Sonuç Detayları */} {result && ( <>

{result.message}

Toplam eklenen kayıt:{' '} {result.totalInsertedCount}

{/* Detay Tablosu */} {result.details.length > 0 && (
{result.details.map((d) => ( {/* Eklenen kolonunu tek satır formatında göster */} ))}
Entity Eklenen Uyarılar Hatalar
{d.entityName}
{d.insertedItems.join(', ')} {d.warnings.join(', ')} {d.errors.join(', ')}
)} {!result.details.length && (

Hiç detay bilgisi bulunamadı.

)} )}
) } export default BranchSeed