import type { TransferListingDetail } from './chuyen-nhuong-api';

const API_URL = process.env['NEXT_PUBLIC_API_URL'] ?? 'http://localhost:3001/api/v1';

export async function fetchTransferListingById(id: string): Promise<TransferListingDetail | null> {
  try {
    const res = await fetch(`${API_URL}/transfer/listings/${id}`, {
      next: { revalidate: 300 },
    });
    if (!res.ok) return null;
    return res.json() as Promise<TransferListingDetail>;
  } catch {
    return null;
  }
}
