%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/src/components/views/
Upload File :
Create Path :
Current File : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/src/components/views/PembayaranView.tsx

import React, { useState } from 'react';
import {
  CreditCard, Calendar, Clock, AlertCircle, RefreshCw, Receipt,
  Search, Filter, ChevronDown, ChevronLeft, ChevronRight, Eye, MoreVertical,
  Send, RotateCcw, Check, ExternalLink, CalendarDays, ArrowUpRight, ArrowDownRight
} from 'lucide-react';

interface PembayaranViewProps {
  triggerToast: (msg: string) => void;
}

interface TransactionItem {
  id: string; // e.g. INV-2025-0521-0001
  refId: string; // #8421
  tenantName: string;
  tenantDomain: string;
  tenantLogoText: string;
  tenantLogoBg: string;
  packageType: string;
  packageBadgeBg: string;
  packageBadgeColor: string;
  date: string;
  dueDate: string;
  dueDateStatus?: string;
  dueDateStatusColor?: string;
  method: string;
  methodType?: 'visa' | 'qris' | 'mandiri' | 'bca' | 'ovo' | 'dana' | 'none';
  status: 'Berhasil' | 'Pending' | 'Gagal' | 'Refund';
  amount: string;
  period: string;
  subtotal: string;
  ppn: string;
  total: string;
  timeline: { title: string; time: string; completed: boolean }[];
}

export const PembayaranView: React.FC<PembayaranViewProps> = ({ triggerToast }) => {
  const [activeTab, setActiveTab] = useState<'Semua Transaksi' | 'Berlangganan Aktif' | 'Pending' | 'Gagal' | 'Refund'>('Semua Transaksi');
  const [statusFilter, setStatusFilter] = useState('Semua Status');
  const [methodFilter, setMethodFilter] = useState('Semua Metode');
  const [packageFilter, setPackageFilter] = useState('Semua Paket');
  const [searchQuery, setSearchQuery] = useState('');
  const [activeMenuId, setActiveMenuId] = useState<string | null>(null);

  // Mock Transactions List matching reference image
  const transactionList: TransactionItem[] = [
    {
      id: 'INV-2025-0521-0001',
      refId: '#8421',
      tenantName: 'Glow Bridal Studio',
      tenantDomain: 'glowbridal.muakita.com',
      tenantLogoText: 'Glow',
      tenantLogoBg: 'bg-slate-900 text-white',
      packageType: 'Enterprise',
      packageBadgeBg: 'bg-purple-100',
      packageBadgeColor: 'text-purple-700',
      date: '21 Mei 2025 10:24',
      dueDate: '21 Mei 2025',
      dueDateStatus: 'Lunas',
      dueDateStatusColor: 'text-slate-400',
      method: '•••• 4242',
      methodType: 'visa',
      status: 'Berhasil',
      amount: 'Rp599.000',
      period: '21 Mei 2025 - 21 Jun 2025',
      subtotal: 'Rp599.000',
      ppn: 'Rp59.900',
      total: 'Rp599.000',
      timeline: [
        { title: 'Invoice dibuat', time: '21 Mei 2025, 10:24', completed: true },
        { title: 'Menunggu pembayaran', time: '21 Mei 2025, 10:24', completed: true },
        { title: 'Pembayaran berhasil', time: '21 Mei 2025, 10:25', completed: true },
      ]
    },
    {
      id: 'INV-2025-0520-0002',
      refId: '#8420',
      tenantName: 'Lovely Makeup Artist',
      tenantDomain: 'lovely.muakita.com',
      tenantLogoText: 'Lovely',
      tenantLogoBg: 'bg-pink-100 text-pink-600',
      packageType: 'Pro',
      packageBadgeBg: 'bg-pink-100',
      packageBadgeColor: 'text-pink-600',
      date: '20 Mei 2025 16:45',
      dueDate: '20 Mei 2025',
      dueDateStatus: 'Lunas',
      dueDateStatusColor: 'text-slate-400',
      method: 'QRIS',
      methodType: 'qris',
      status: 'Berhasil',
      amount: 'Rp299.000',
      period: '20 Mei 2025 - 20 Jun 2025',
      subtotal: 'Rp299.000',
      ppn: 'Rp29.900',
      total: 'Rp299.000',
      timeline: [
        { title: 'Invoice dibuat', time: '20 Mei 2025, 16:45', completed: true },
        { title: 'Menunggu pembayaran', time: '20 Mei 2025, 16:45', completed: true },
        { title: 'Pembayaran berhasil', time: '20 Mei 2025, 16:46', completed: true },
      ]
    },
    {
      id: 'INV-2025-0520-0003',
      refId: '#8419',
      tenantName: 'Cantik Salon & Beauty',
      tenantDomain: 'cantiksalon.muakita.com',
      tenantLogoText: 'Cantik',
      tenantLogoBg: 'bg-amber-100 text-amber-800',
      packageType: 'Pro',
      packageBadgeBg: 'bg-pink-100',
      packageBadgeColor: 'text-pink-600',
      date: '20 Mei 2025 09:12',
      dueDate: '20 Mei 2025',
      dueDateStatus: 'Telat 2 hari',
      dueDateStatusColor: 'text-rose-600 font-bold',
      method: '•••• 8888',
      methodType: 'mandiri',
      status: 'Pending',
      amount: 'Rp299.000',
      period: '20 Mei 2025 - 20 Jun 2025',
      subtotal: 'Rp299.000',
      ppn: 'Rp29.900',
      total: 'Rp299.000',
      timeline: [
        { title: 'Invoice dibuat', time: '20 Mei 2025, 09:12', completed: true },
        { title: 'Menunggu pembayaran', time: '20 Mei 2025, 09:12', completed: true },
        { title: 'Proses verifikasi bank', time: '20 Mei 2025, 09:15', completed: false },
      ]
    },
    {
      id: 'INV-2025-0518-0004',
      refId: '#8418',
      tenantName: 'Aura Wedding Organizer',
      tenantDomain: 'aura.muakita.com',
      tenantLogoText: 'Aura',
      tenantLogoBg: 'bg-sky-100 text-sky-700',
      packageType: 'Enterprise',
      packageBadgeBg: 'bg-purple-100',
      packageBadgeColor: 'text-purple-700',
      date: '18 Mei 2025 08:50',
      dueDate: '18 Mei 2025',
      dueDateStatus: 'Lunas',
      dueDateStatusColor: 'text-slate-400',
      method: '•••• 1111',
      methodType: 'bca',
      status: 'Berhasil',
      amount: 'Rp599.000',
      period: '18 Mei 2025 - 18 Jun 2025',
      subtotal: 'Rp599.000',
      ppn: 'Rp59.900',
      total: 'Rp599.000',
      timeline: [
        { title: 'Invoice dibuat', time: '18 Mei 2025, 08:50', completed: true },
        { title: 'Menunggu pembayaran', time: '18 Mei 2025, 08:50', completed: true },
        { title: 'Pembayaran berhasil', time: '18 Mei 2025, 08:51', completed: true },
      ]
    },
    {
      id: 'INV-2025-0517-0005',
      refId: '#8417',
      tenantName: 'Naya Makeup Studio',
      tenantDomain: 'naya.muakita.com',
      tenantLogoText: 'Naya',
      tenantLogoBg: 'bg-slate-800 text-slate-100',
      packageType: 'Basic',
      packageBadgeBg: 'bg-blue-100',
      packageBadgeColor: 'text-blue-700',
      date: '17 Mei 2025 14:30',
      dueDate: '20 Mei 2025',
      dueDateStatus: 'Telat 3 hari',
      dueDateStatusColor: 'text-rose-600 font-bold',
      method: 'OVO',
      methodType: 'ovo',
      status: 'Gagal',
      amount: 'Rp149.000',
      period: '17 Mei 2025 - 17 Jun 2025',
      subtotal: 'Rp149.000',
      ppn: 'Rp14.900',
      total: 'Rp149.000',
      timeline: [
        { title: 'Invoice dibuat', time: '17 Mei 2025, 14:30', completed: true },
        { title: 'Menunggu pembayaran', time: '17 Mei 2025, 14:30', completed: true },
        { title: 'Pembayaran kedaluwarsa', time: '20 Mei 2025, 14:30', completed: false },
      ]
    },
    {
      id: 'INV-2025-0515-0006',
      refId: '#8416',
      tenantName: 'Elegant MUA',
      tenantDomain: 'elegantmua.muakita.com',
      tenantLogoText: 'Elegant',
      tenantLogoBg: 'bg-emerald-100 text-emerald-700',
      packageType: 'Pro',
      packageBadgeBg: 'bg-pink-100',
      packageBadgeColor: 'text-pink-600',
      date: '15 Mei 2025 11:08',
      dueDate: '15 Mei 2025',
      dueDateStatus: 'Lunas',
      dueDateStatusColor: 'text-slate-400',
      method: 'DANA',
      methodType: 'dana',
      status: 'Berhasil',
      amount: 'Rp299.000',
      period: '15 Mei 2025 - 15 Jun 2025',
      subtotal: 'Rp299.000',
      ppn: 'Rp29.900',
      total: 'Rp299.000',
      timeline: [
        { title: 'Invoice dibuat', time: '15 Mei 2025, 11:08', completed: true },
        { title: 'Menunggu pembayaran', time: '15 Mei 2025, 11:08', completed: true },
        { title: 'Pembayaran berhasil', time: '15 Mei 2025, 11:09', completed: true },
      ]
    },
    {
      id: 'INV-2025-0512-0007',
      refId: '#8415',
      tenantName: 'Beauty Classy',
      tenantDomain: 'beautyclassy.muakita.com',
      tenantLogoText: 'Beauty',
      tenantLogoBg: 'bg-[#EC167F] text-white',
      packageType: 'Enterprise',
      packageBadgeBg: 'bg-purple-100',
      packageBadgeColor: 'text-purple-700',
      date: '12 Mei 2025 10:12',
      dueDate: '12 Mei 2025',
      dueDateStatus: 'Lunas',
      dueDateStatusColor: 'text-slate-400',
      method: '•••• 5555',
      methodType: 'visa',
      status: 'Berhasil',
      amount: 'Rp599.000',
      period: '12 Mei 2025 - 12 Jun 2025',
      subtotal: 'Rp599.000',
      ppn: 'Rp59.900',
      total: 'Rp599.000',
      timeline: [
        { title: 'Invoice dibuat', time: '12 Mei 2025, 10:12', completed: true },
        { title: 'Menunggu pembayaran', time: '12 Mei 2025, 10:12', completed: true },
        { title: 'Pembayaran berhasil', time: '12 Mei 2025, 10:13', completed: true },
      ]
    },
    {
      id: 'INV-2025-0510-0008',
      refId: '#8414',
      tenantName: 'Test Tenant',
      tenantDomain: 'test.muakita.com',
      tenantLogoText: 'T',
      tenantLogoBg: 'bg-slate-200 text-slate-700',
      packageType: 'Trial',
      packageBadgeBg: 'bg-slate-100',
      packageBadgeColor: 'text-slate-600',
      date: '10 Mei 2025 09:00',
      dueDate: '10 Mei 2025',
      dueDateStatus: 'Lunas',
      dueDateStatusColor: 'text-slate-400',
      method: '-',
      methodType: 'none',
      status: 'Berhasil',
      amount: 'Rp0',
      period: '10 Mei 2025 - 24 Mei 2025',
      subtotal: 'Rp0',
      ppn: 'Rp0',
      total: 'Rp0',
      timeline: [
        { title: 'Invoice trial dibuat', time: '10 Mei 2025, 09:00', completed: true },
        { title: 'Aktivasi trial berhasil', time: '10 Mei 2025, 09:00', completed: true },
      ]
    }
  ];

  // Selected Transaction for right detail sidebar
  const [selectedTrx, setSelectedTrx] = useState<TransactionItem>(transactionList[0]);

  // Filter logic
  const filteredTransactions = transactionList.filter((trx) => {
    // Tab filter
    if (activeTab === 'Berlangganan Aktif' && trx.status !== 'Berhasil') return false;
    if (activeTab === 'Pending' && trx.status !== 'Pending') return false;
    if (activeTab === 'Gagal' && trx.status !== 'Gagal') return false;
    if (activeTab === 'Refund' && trx.status !== 'Refund') return false;

    // Dropdown filters
    const matchesStatus = statusFilter === 'Semua Status' || trx.status === statusFilter;
    const matchesMethod = methodFilter === 'Semua Metode' || trx.method.toLowerCase().includes(methodFilter.toLowerCase());
    const matchesPackage = packageFilter === 'Semua Paket' || trx.packageType === packageFilter;

    // Search filter
    const matchesSearch =
      searchQuery === '' ||
      trx.id.toLowerCase().includes(searchQuery.toLowerCase()) ||
      trx.tenantName.toLowerCase().includes(searchQuery.toLowerCase()) ||
      trx.tenantDomain.toLowerCase().includes(searchQuery.toLowerCase());

    return matchesStatus && matchesMethod && matchesPackage && matchesSearch;
  });

  // Render Method Logo or Label
  const renderMethodBadge = (trx: TransactionItem) => {
    switch (trx.methodType) {
      case 'visa':
        return (
          <div className="flex items-center gap-1 text-xs font-extrabold text-slate-800">
            <span className="text-blue-700 italic font-black text-[11px] tracking-tight">VISA</span>
            <span className="text-[11px] font-semibold text-slate-600">{trx.method}</span>
          </div>
        );
      case 'qris':
        return (
          <span className="font-extrabold text-slate-900 text-xs tracking-tight">QRIS</span>
        );
      case 'mandiri':
        return (
          <div className="flex items-center gap-1 text-xs font-bold">
            <span className="text-amber-500 font-extrabold text-[11px]">mandırı</span>
            <span className="text-[11px] font-semibold text-slate-600">{trx.method}</span>
          </div>
        );
      case 'bca':
        return (
          <div className="flex items-center gap-1 text-xs font-bold">
            <span className="text-blue-600 font-black italic text-[11px]">BCA</span>
            <span className="text-[11px] font-semibold text-slate-600">{trx.method}</span>
          </div>
        );
      case 'ovo':
        return (
          <span className="font-black text-purple-700 text-xs tracking-tight">OVO</span>
        );
      case 'dana':
        return (
          <span className="font-black text-sky-500 text-xs tracking-tight">DANA</span>
        );
      default:
        return <span className="text-slate-400 text-xs">-</span>;
    }
  };

  return (
    <div className="space-y-5 animate-in fade-in duration-200 text-slate-800 pb-12">
      
      {/* ========================================================= */}
      {/* 1. TOP METRIC CARDS (6 Cards with Sparklines) */}
      {/* ========================================================= */}
      <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3">
        
        {/* Card 1: Total Pendapatan */}
        <div className="bg-white p-3.5 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-col justify-between space-y-2">
          <div className="flex items-center gap-2.5">
            <div className="w-9 h-9 rounded-xl bg-pink-50 text-pink-500 flex items-center justify-center shrink-0 border border-pink-100">
              <CreditCard className="w-4 h-4" />
            </div>
            <div className="min-w-0">
              <span className="text-[10px] font-bold text-slate-400 block truncate">Total Pendapatan</span>
              <span className="text-sm font-black text-slate-900 leading-tight block truncate">Rp358.750.000</span>
            </div>
          </div>
          <div className="flex items-center justify-between pt-1">
            <span className="text-[10px] font-extrabold text-emerald-600 flex items-center gap-0.5">
              ↑ 18.6% <span className="text-slate-400 font-normal">vs bulan lalu</span>
            </span>
            {/* Sparkline SVG */}
            <svg className="w-12 h-4 text-pink-500 stroke-current fill-none stroke-[2]" viewBox="0 0 50 15">
              <path d="M0,12 L10,8 L20,13 L30,5 L40,9 L50,2" />
            </svg>
          </div>
        </div>

        {/* Card 2: Pembayaran Berhasil */}
        <div className="bg-white p-3.5 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-col justify-between space-y-2">
          <div className="flex items-center gap-2.5">
            <div className="w-9 h-9 rounded-xl bg-purple-50 text-purple-600 flex items-center justify-center shrink-0 border border-purple-100">
              <Calendar className="w-4 h-4" />
            </div>
            <div className="min-w-0">
              <span className="text-[10px] font-bold text-slate-400 block truncate">Pembayaran Berhasil</span>
              <span className="text-base font-black text-slate-900 leading-tight block">312</span>
            </div>
          </div>
          <div className="flex items-center justify-between pt-1">
            <span className="text-[10px] font-extrabold text-emerald-600 flex items-center gap-0.5">
              ↑ 11.3% <span className="text-slate-400 font-normal">vs bulan lalu</span>
            </span>
            <svg className="w-12 h-4 text-purple-500 stroke-current fill-none stroke-[2]" viewBox="0 0 50 15">
              <path d="M0,14 L10,10 L20,11 L30,4 L40,7 L50,1" />
            </svg>
          </div>
        </div>

        {/* Card 3: Pembayaran Pending */}
        <div className="bg-white p-3.5 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-col justify-between space-y-2">
          <div className="flex items-center gap-2.5">
            <div className="w-9 h-9 rounded-xl bg-amber-50 text-amber-500 flex items-center justify-center shrink-0 border border-amber-100">
              <Clock className="w-4 h-4" />
            </div>
            <div className="min-w-0">
              <span className="text-[10px] font-bold text-slate-400 block truncate">Pembayaran Pending</span>
              <span className="text-base font-black text-slate-900 leading-tight block">24</span>
            </div>
          </div>
          <div className="flex items-center justify-between pt-1">
            <span className="text-[10px] font-extrabold text-amber-600 flex items-center gap-0.5">
              ↓ 6.8% <span className="text-slate-400 font-normal">vs bulan lalu</span>
            </span>
            <svg className="w-12 h-4 text-amber-500 stroke-current fill-none stroke-[2]" viewBox="0 0 50 15">
              <path d="M0,5 L10,12 L20,8 L30,13 L40,7 L50,10" />
            </svg>
          </div>
        </div>

        {/* Card 4: Pembayaran Gagal */}
        <div className="bg-white p-3.5 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-col justify-between space-y-2">
          <div className="flex items-center gap-2.5">
            <div className="w-9 h-9 rounded-xl bg-rose-50 text-rose-500 flex items-center justify-center shrink-0 border border-rose-100">
              <AlertCircle className="w-4 h-4" />
            </div>
            <div className="min-w-0">
              <span className="text-[10px] font-bold text-slate-400 block truncate">Pembayaran Gagal</span>
              <span className="text-base font-black text-slate-900 leading-tight block">6</span>
            </div>
          </div>
          <div className="flex items-center justify-between pt-1">
            <span className="text-[10px] font-extrabold text-rose-500 flex items-center gap-0.5">
              ↓ 20% <span className="text-slate-400 font-normal">vs bulan lalu</span>
            </span>
            <svg className="w-12 h-4 text-rose-500 stroke-current fill-none stroke-[2]" viewBox="0 0 50 15">
              <path d="M0,3 L10,8 L20,4 L30,12 L40,9 L50,14" />
            </svg>
          </div>
        </div>

        {/* Card 5: Refund */}
        <div className="bg-white p-3.5 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-col justify-between space-y-2">
          <div className="flex items-center gap-2.5">
            <div className="w-9 h-9 rounded-xl bg-blue-50 text-blue-500 flex items-center justify-center shrink-0 border border-blue-100">
              <RefreshCw className="w-4 h-4" />
            </div>
            <div className="min-w-0">
              <span className="text-[10px] font-bold text-slate-400 block truncate">Refund</span>
              <span className="text-xs font-black text-slate-900 leading-tight block truncate">Rp12.450.000</span>
            </div>
          </div>
          <div className="flex items-center justify-between pt-1">
            <span className="text-[10px] font-extrabold text-blue-600 flex items-center gap-0.5">
              ↑ 7.2% <span className="text-slate-400 font-normal">vs bulan lalu</span>
            </span>
            <svg className="w-12 h-4 text-blue-500 stroke-current fill-none stroke-[2]" viewBox="0 0 50 15">
              <path d="M0,12 L10,10 L20,13 L30,7 L40,8 L50,3" />
            </svg>
          </div>
        </div>

        {/* Card 6: Rata-rata Nilai Invoice */}
        <div className="bg-white p-3.5 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-col justify-between space-y-2">
          <div className="flex items-center gap-2.5">
            <div className="w-9 h-9 rounded-xl bg-teal-50 text-teal-600 flex items-center justify-center shrink-0 border border-teal-100">
              <Receipt className="w-4 h-4" />
            </div>
            <div className="min-w-0">
              <span className="text-[10px] font-bold text-slate-400 block truncate">Rata-rata Nilai Invoice</span>
              <span className="text-xs font-black text-slate-900 leading-tight block truncate">Rp1.151.762</span>
            </div>
          </div>
          <div className="flex items-center justify-between pt-1">
            <span className="text-[10px] font-extrabold text-teal-600 flex items-center gap-0.5">
              ↑ 8.4% <span className="text-slate-400 font-normal">vs bulan lalu</span>
            </span>
            <svg className="w-12 h-4 text-teal-500 stroke-current fill-none stroke-[2]" viewBox="0 0 50 15">
              <path d="M0,13 L10,11 L20,12 L30,6 L40,9 L50,2" />
            </svg>
          </div>
        </div>

      </div>

      {/* ========================================================= */}
      {/* 2. NAVIGATION TABS (5 Tabs) */}
      {/* ========================================================= */}
      <div className="flex items-center gap-6 border-b border-slate-200/80 px-1 pt-1">
        {[
          { id: 'Semua Transaksi', label: 'Semua Transaksi' },
          { id: 'Berlangganan Aktif', label: 'Berlangganan Aktif' },
          { id: 'Pending', label: 'Pending' },
          { id: 'Gagal', label: 'Gagal' },
          { id: 'Refund', label: 'Refund' },
        ].map((tab) => (
          <button
            key={tab.id}
            onClick={() => setActiveTab(tab.id as any)}
            className={`pb-3 text-xs font-extrabold transition-all relative cursor-pointer ${
              activeTab === tab.id
                ? 'text-[#EC167F]'
                : 'text-slate-500 hover:text-slate-800'
            }`}
          >
            {tab.label}
            {activeTab === tab.id && (
              <span className="absolute bottom-0 left-0 right-0 h-0.5 bg-[#EC167F] rounded-full" />
            )}
          </button>
        ))}
      </div>

      {/* ========================================================= */}
      {/* 3. MAIN CONTAINER: TABLE & DETAIL SIDEBAR */}
      {/* ========================================================= */}
      <div className="grid grid-cols-1 lg:grid-cols-12 gap-5 items-start">
        
        {/* LEFT COLUMN: FILTER BAR + TABLE + PAGINATION (Spans 8 columns in lg) */}
        <div className="lg:col-span-8 space-y-4">
          
          {/* FILTER BAR */}
          <div className="bg-white p-3 rounded-2xl border border-slate-200/80 shadow-2xs flex flex-wrap items-center justify-between gap-2.5">
            
            {/* Dropdowns & Date Range */}
            <div className="flex flex-wrap items-center gap-2 flex-1 min-w-[280px]">
              
              {/* Status Filter */}
              <div className="relative">
                <select
                  value={statusFilter}
                  onChange={(e) => setStatusFilter(e.target.value)}
                  className="appearance-none bg-slate-50 border border-slate-200 text-slate-700 text-xs font-semibold py-2 pl-3 pr-8 rounded-xl focus:outline-none focus:border-pink-500 cursor-pointer"
                >
                  <option value="Semua Status">Semua Status</option>
                  <option value="Berhasil">Berhasil</option>
                  <option value="Pending">Pending</option>
                  <option value="Gagal">Gagal</option>
                  <option value="Refund">Refund</option>
                </select>
                <ChevronDown className="w-3.5 h-3.5 text-slate-400 absolute right-2.5 top-2.5 pointer-events-none" />
              </div>

              {/* Metode Pembayaran Filter */}
              <div className="relative">
                <select
                  value={methodFilter}
                  onChange={(e) => setMethodFilter(e.target.value)}
                  className="appearance-none bg-slate-50 border border-slate-200 text-slate-700 text-xs font-semibold py-2 pl-3 pr-8 rounded-xl focus:outline-none focus:border-pink-500 cursor-pointer"
                >
                  <option value="Semua Metode">Semua Metode</option>
                  <option value="Visa">Visa</option>
                  <option value="QRIS">QRIS</option>
                  <option value="Mandiri">Mandiri</option>
                  <option value="BCA">BCA</option>
                  <option value="OVO">OVO</option>
                  <option value="DANA">DANA</option>
                </select>
                <ChevronDown className="w-3.5 h-3.5 text-slate-400 absolute right-2.5 top-2.5 pointer-events-none" />
              </div>

              {/* Paket Filter */}
              <div className="relative">
                <select
                  value={packageFilter}
                  onChange={(e) => setPackageFilter(e.target.value)}
                  className="appearance-none bg-slate-50 border border-slate-200 text-slate-700 text-xs font-semibold py-2 pl-3 pr-8 rounded-xl focus:outline-none focus:border-pink-500 cursor-pointer"
                >
                  <option value="Semua Paket">Semua Paket</option>
                  <option value="Enterprise">Enterprise</option>
                  <option value="Pro">Pro</option>
                  <option value="Basic">Basic</option>
                  <option value="Trial">Trial</option>
                </select>
                <ChevronDown className="w-3.5 h-3.5 text-slate-400 absolute right-2.5 top-2.5 pointer-events-none" />
              </div>

              {/* Rentang Tanggal Picker */}
              <div className="bg-slate-50 border border-slate-200 text-slate-700 text-xs font-semibold py-2 px-3 rounded-xl flex items-center gap-2 cursor-pointer hover:bg-slate-100 transition-colors">
                <CalendarDays className="w-3.5 h-3.5 text-slate-500" />
                <span>01 Mei 2025 - 31 Mei 2025</span>
              </div>

              {/* Search Input Box */}
              <div className="relative flex-1 min-w-[170px]">
                <Search className="w-3.5 h-3.5 text-slate-400 absolute left-3 top-2.5" />
                <input
                  type="text"
                  placeholder="Cari invoice, tenant, email..."
                  value={searchQuery}
                  onChange={(e) => setSearchQuery(e.target.value)}
                  className="w-full bg-slate-50 border border-slate-200 text-slate-800 placeholder-slate-400 text-xs font-medium py-2 pl-8 pr-3 rounded-xl focus:outline-none focus:border-pink-500"
                />
              </div>

            </div>

            {/* Filter Action Button */}
            <button
              onClick={() => triggerToast('Filter pembayaran diterapkan')}
              className="px-3.5 py-2 bg-white hover:bg-slate-50 border border-slate-200 text-slate-700 text-xs font-bold rounded-xl flex items-center gap-1.5 transition-colors cursor-pointer shadow-2xs"
            >
              <Filter className="w-3.5 h-3.5 text-slate-500" />
              <span>Filter</span>
            </button>

          </div>

          {/* TABLE AREA */}
          <div className="bg-white rounded-2xl border border-slate-200/80 shadow-2xs overflow-hidden">
            <div className="overflow-x-auto">
              <table className="w-full text-left border-collapse">
                <thead>
                  <tr className="bg-slate-50/70 border-b border-slate-100 text-[11px] font-bold text-slate-500 tracking-wider">
                    <th className="py-3 px-4">Invoice</th>
                    <th className="py-3 px-3">Tenant</th>
                    <th className="py-3 px-3">Paket</th>
                    <th className="py-3 px-3">Tanggal</th>
                    <th className="py-3 px-3">Jatuh Tempo</th>
                    <th className="py-3 px-3">Metode</th>
                    <th className="py-3 px-3">Status</th>
                    <th className="py-3 px-3">Jumlah</th>
                    <th className="py-3 px-4 text-center">Aksi</th>
                  </tr>
                </thead>
                <tbody className="divide-y divide-slate-100 text-xs font-medium">
                  {filteredTransactions.map((trx) => {
                    const isSelected = selectedTrx.id === trx.id;

                    return (
                      <tr
                        key={trx.id}
                        onClick={() => setSelectedTrx(trx)}
                        className={`transition-colors cursor-pointer ${
                          isSelected ? 'bg-pink-50/40 hover:bg-pink-50/60' : 'hover:bg-slate-50/80'
                        }`}
                      >
                        {/* Invoice & Ref */}
                        <td className="py-3.5 px-4 whitespace-nowrap">
                          <div>
                            <span className="font-extrabold text-slate-900 block leading-tight">{trx.id}</span>
                            <span className="text-[10px] text-slate-400 block">{trx.refId}</span>
                          </div>
                        </td>

                        {/* Tenant Logo & Name & Domain */}
                        <td className="py-3.5 px-3 min-w-[180px]">
                          <div className="flex items-center gap-2.5">
                            <div className={`w-8 h-8 rounded-full ${trx.tenantLogoBg} font-extrabold text-[11px] flex items-center justify-center shrink-0`}>
                              {trx.tenantLogoText.charAt(0)}
                            </div>
                            <div className="min-w-0">
                              <span className="font-extrabold text-slate-900 block leading-tight truncate">{trx.tenantName}</span>
                              <span className="text-[10px] text-slate-400 block truncate">{trx.tenantDomain}</span>
                            </div>
                          </div>
                        </td>

                        {/* Paket Badge */}
                        <td className="py-3.5 px-3 whitespace-nowrap">
                          <span className={`px-2 py-0.5 rounded-md text-[10px] font-bold ${trx.packageBadgeBg} ${trx.packageBadgeColor}`}>
                            {trx.packageType}
                          </span>
                        </td>

                        {/* Tanggal */}
                        <td className="py-3.5 px-3 whitespace-nowrap text-[11px]">
                          <div>
                            <span className="font-bold text-slate-900 block leading-tight">{trx.date.split(' ')[0]} {trx.date.split(' ')[1]} {trx.date.split(' ')[2]}</span>
                            <span className="text-[10px] text-slate-400 block">{trx.date.split(' ')[3]}</span>
                          </div>
                        </td>

                        {/* Jatuh Tempo */}
                        <td className="py-3.5 px-3 whitespace-nowrap text-[11px]">
                          <div>
                            <span className="font-bold text-slate-900 block leading-tight">{trx.dueDate}</span>
                            <span className={`text-[10px] block ${trx.dueDateStatusColor}`}>{trx.dueDateStatus}</span>
                          </div>
                        </td>

                        {/* Metode */}
                        <td className="py-3.5 px-3 whitespace-nowrap">
                          {renderMethodBadge(trx)}
                        </td>

                        {/* Status Badge */}
                        <td className="py-3.5 px-3 whitespace-nowrap">
                          <span className={`px-2.5 py-0.5 rounded-full text-[10px] font-bold inline-flex items-center gap-1 ${
                            trx.status === 'Berhasil'
                              ? 'bg-emerald-100 text-emerald-700'
                              : trx.status === 'Pending'
                              ? 'bg-amber-100 text-amber-700'
                              : 'bg-rose-100 text-rose-700'
                          }`}>
                            <span className={`w-1.5 h-1.5 rounded-full ${
                              trx.status === 'Berhasil'
                                ? 'bg-emerald-500'
                                : trx.status === 'Pending'
                                ? 'bg-amber-500'
                                : 'bg-rose-500'
                            }`} />
                            {trx.status}
                          </span>
                        </td>

                        {/* Jumlah */}
                        <td className="py-3.5 px-3 whitespace-nowrap font-extrabold text-slate-900">
                          {trx.amount}
                        </td>

                        {/* Aksi Action Buttons */}
                        <td className="py-3.5 px-4 text-center whitespace-nowrap" onClick={(e) => e.stopPropagation()}>
                          <div className="flex items-center justify-center gap-1 relative">
                            <button
                              onClick={() => setSelectedTrx(trx)}
                              className={`p-1.5 rounded-lg border transition-colors cursor-pointer ${
                                isSelected ? 'border-pink-300 bg-pink-100 text-[#EC167F]' : 'border-slate-200 text-blue-600 hover:bg-blue-50'
                              }`}
                              title="Lihat Detail Transactions"
                            >
                              <Eye className="w-3.5 h-3.5" />
                            </button>

                            <button
                              onClick={() => setActiveMenuId(activeMenuId === trx.id ? null : trx.id)}
                              className="p-1.5 rounded-lg border border-slate-200 text-slate-400 hover:bg-slate-100 transition-colors cursor-pointer"
                            >
                              <MoreVertical className="w-3.5 h-3.5" />
                            </button>

                            {activeMenuId === trx.id && (
                              <div className="absolute right-0 top-full mt-1 w-36 bg-white rounded-xl shadow-xl border border-slate-200 py-1.5 z-20 text-left text-xs animate-in fade-in zoom-in-95">
                                <button
                                  onClick={() => {
                                    triggerToast(`Cetak invoice ${trx.id}`);
                                    setActiveMenuId(null);
                                  }}
                                  className="w-full px-3 py-1.5 text-slate-700 hover:bg-slate-50 flex items-center gap-2 font-medium cursor-pointer"
                                >
                                  <Send className="w-3.5 h-3.5 text-pink-500" />
                                  <span>Kirim Invoice</span>
                                </button>
                              </div>
                            )}
                          </div>
                        </td>

                      </tr>
                    );
                  })}
                </tbody>
              </table>
            </div>

            {/* TABLE FOOTER / PAGINATION */}
            <div className="p-3 bg-slate-50/50 border-t border-slate-100 flex flex-col sm:flex-row items-center justify-between gap-3 text-xs text-slate-500">
              <span>Menampilkan 1 - 8 dari 312 transaksi</span>

              <div className="flex items-center gap-4">
                <div className="flex items-center gap-1">
                  <button className="w-7 h-7 rounded-lg border border-slate-200 flex items-center justify-center text-slate-400 hover:bg-white transition-colors cursor-not-allowed">
                    <ChevronLeft className="w-4 h-4" />
                  </button>
                  <button className="w-7 h-7 rounded-lg bg-[#EC167F] text-white font-bold flex items-center justify-center shadow-2xs">
                    1
                  </button>
                  <button className="w-7 h-7 rounded-lg border border-slate-200 flex items-center justify-center text-slate-600 hover:bg-white transition-colors">
                    2
                  </button>
                  <button className="w-7 h-7 rounded-lg border border-slate-200 flex items-center justify-center text-slate-600 hover:bg-white transition-colors">
                    3
                  </button>
                  <span className="text-slate-400 px-1">...</span>
                  <button className="w-7 h-7 rounded-lg border border-slate-200 flex items-center justify-center text-slate-600 hover:bg-white transition-colors">
                    39
                  </button>
                  <button className="w-7 h-7 rounded-lg border border-slate-200 flex items-center justify-center text-slate-600 hover:bg-white transition-colors">
                    <ChevronRight className="w-4 h-4" />
                  </button>
                </div>

                <div className="relative">
                  <select className="appearance-none bg-white border border-slate-200 text-slate-700 text-xs font-semibold py-1 pl-2.5 pr-6 rounded-lg focus:outline-none">
                    <option>10 / halaman</option>
                    <option>25 / halaman</option>
                    <option>50 / halaman</option>
                  </select>
                  <ChevronDown className="w-3.5 h-3.5 text-slate-400 absolute right-1.5 top-1.5 pointer-events-none" />
                </div>
              </div>
            </div>

          </div>

        </div>

        {/* RIGHT COLUMN: DETAIL PEMBAYARAN SIDEBAR (Spans 4 columns in lg) */}
        <div className="lg:col-span-4 bg-white rounded-2xl border border-slate-200/80 shadow-2xs p-5 space-y-5 sticky top-4">
          
          {/* Header Title & Status Badge */}
          <div className="flex items-center justify-between pb-2 border-b border-slate-100">
            <h3 className="text-xs font-extrabold text-slate-900 tracking-wide uppercase">
              Detail Pembayaran
            </h3>
            <span className={`px-2.5 py-0.5 rounded-full text-[10px] font-bold ${
              selectedTrx.status === 'Berhasil'
                ? 'bg-emerald-100 text-emerald-700'
                : selectedTrx.status === 'Pending'
                ? 'bg-amber-100 text-amber-700'
                : 'bg-rose-100 text-rose-700'
            }`}>
              {selectedTrx.status}
            </span>
          </div>

          {/* Invoice Header Box */}
          <div className="space-y-1">
            <h4 className="text-base font-black text-slate-900 leading-tight">{selectedTrx.id}</h4>
            <p className="text-[11px] text-slate-400">Dibuat pada {selectedTrx.date}</p>
            <div className="pt-2">
              <span className="text-xl font-black text-slate-900 leading-none block">{selectedTrx.amount}</span>
              <span className="text-[11px] text-slate-500 font-medium block mt-0.5">{selectedTrx.packageType} • Bulanan</span>
            </div>
          </div>

          {/* Section: Informasi Tenant */}
          <div className="space-y-2.5 pt-3 border-t border-slate-100">
            <span className="text-[11px] font-extrabold text-slate-900 block">Informasi Tenant</span>

            <div className="flex items-center justify-between gap-2 p-2 bg-slate-50/80 rounded-xl border border-slate-100">
              <div className="flex items-center gap-2.5 min-w-0">
                <div className={`w-8 h-8 rounded-full ${selectedTrx.tenantLogoBg} font-extrabold text-xs flex items-center justify-center shrink-0`}>
                  {selectedTrx.tenantLogoText.charAt(0)}
                </div>
                <div className="min-w-0">
                  <span className="font-extrabold text-slate-900 text-xs block truncate">{selectedTrx.tenantName}</span>
                  <span className="text-[10px] text-slate-400 block truncate">{selectedTrx.tenantDomain}</span>
                </div>
              </div>

              <button
                onClick={() => triggerToast(`Navigasi ke tenant ${selectedTrx.tenantName}`)}
                className="px-2.5 py-1 bg-white border border-slate-200 text-slate-700 hover:bg-slate-50 text-[10px] font-bold rounded-lg transition-colors shrink-0 shadow-2xs"
              >
                Lihat Tenant
              </button>
            </div>
          </div>

          {/* Section: Informasi Pembayaran Key-Values */}
          <div className="space-y-2 text-xs pt-3 border-t border-slate-100">
            <span className="text-[11px] font-extrabold text-slate-900 block">Informasi Pembayaran</span>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">Status</span>
              <span className={`font-bold ${
                selectedTrx.status === 'Berhasil' ? 'text-emerald-600' : 'text-amber-600'
              }`}>
                ● {selectedTrx.status}
              </span>
            </div>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">Metode Pembayaran</span>
              <div className="font-bold text-slate-900">
                {renderMethodBadge(selectedTrx)}
              </div>
            </div>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">Tanggal Pembayaran</span>
              <span className="font-bold text-slate-900">{selectedTrx.date}</span>
            </div>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">Invoice</span>
              <span className="font-bold text-slate-900">{selectedTrx.id}</span>
            </div>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">Periode</span>
              <span className="font-bold text-slate-900">{selectedTrx.period}</span>
            </div>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">Jatuh Tempo</span>
              <span className="font-bold text-slate-900">{selectedTrx.dueDate}</span>
            </div>

            <div className="flex items-center justify-between py-0.5 pt-1 border-t border-dashed border-slate-100">
              <span className="text-slate-400 font-medium">Subtotal</span>
              <span className="font-bold text-slate-900">{selectedTrx.subtotal}</span>
            </div>

            <div className="flex items-center justify-between py-0.5">
              <span className="text-slate-400 font-medium">PPN (11%)</span>
              <span className="font-bold text-slate-900">{selectedTrx.ppn}</span>
            </div>

            <div className="flex items-center justify-between py-0.5 pt-1 border-t border-slate-200">
              <span className="text-slate-900 font-black">Total</span>
              <span className="font-black text-slate-900 text-xs">{selectedTrx.total}</span>
            </div>
          </div>

          {/* Section: Riwayat Timeline */}
          <div className="space-y-2.5 pt-3 border-t border-slate-100">
            <span className="text-[11px] font-extrabold text-slate-900 block">Riwayat</span>

            <div className="space-y-3 relative pl-4 border-l-2 border-emerald-100 ml-1.5">
              {selectedTrx.timeline.map((step, idx) => (
                <div key={idx} className="relative flex items-start justify-between gap-2 text-xs">
                  {/* Circle Checkmark Dot */}
                  <span className={`absolute -left-[23px] top-0.5 w-4 h-4 rounded-full flex items-center justify-center text-[10px] ${
                    step.completed ? 'bg-emerald-500 text-white' : 'bg-slate-200 text-slate-500'
                  }`}>
                    {step.completed ? '✓' : '•'}
                  </span>

                  <div>
                    <span className="font-bold text-slate-900 block leading-tight text-[11px]">{step.title}</span>
                  </div>
                  <span className="text-[10px] text-slate-400 shrink-0 font-medium">{step.time}</span>
                </div>
              ))}
            </div>
          </div>

          {/* Action Buttons */}
          <div className="space-y-2 pt-2">
            <button
              onClick={() => triggerToast(`Invoice ${selectedTrx.id} telah dikirim ulang ke ${selectedTrx.tenantName}`)}
              className="w-full py-2.5 bg-[#EC167F] hover:bg-pink-600 text-white font-extrabold text-xs rounded-xl shadow-md transition-all flex items-center justify-center gap-2 cursor-pointer active:scale-98"
            >
              <Send className="w-3.5 h-3.5" />
              <span>Kirim Invoice Ulang</span>
            </button>

            <button
              onClick={() => triggerToast(`Proses refund untuk invoice ${selectedTrx.id} diinisiasi`)}
              className="w-full py-2.5 bg-white hover:bg-slate-50 text-slate-700 font-extrabold text-xs rounded-xl border border-slate-200 transition-colors flex items-center justify-center gap-2 cursor-pointer shadow-2xs"
            >
              <RotateCcw className="w-3.5 h-3.5 text-slate-500" />
              <span>Refund Pembayaran</span>
            </button>
          </div>

        </div>

      </div>

    </div>
  );
};

Zerion Mini Shell 1.0