import type { IndustrialParkDetail } from './khu-cong-nghiep-api';

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

export async function fetchIndustrialParkBySlug(slug: string): Promise<IndustrialParkDetail | null> {
  try {
    const res = await fetch(`${API_URL}/industrial/parks/${slug}`, {
      next: { revalidate: 300 },
    });
    if (!res.ok) return null;
    return res.json() as Promise<IndustrialParkDetail>;
  } catch {
    return null;
  }
}
