'use client';
import { useEffect, useState, useCallback } from 'react';
import Link from 'next/link';
import type { Banner } from '@/lib/types';
import { resolveUploadUrl, cn } from '@/lib/utils';
const INTERVAL = 5000;
export function BannerCarousel({ banners }: { banners: Banner[] }) {
const [idx, setIdx] = useState(0);
const total = banners.length;
const next = useCallback(() => {
setIdx((p) => (total === 0 ? 0 : (p + 1) % total));
}, [total]);
useEffect(() => {
if (total <= 1) return;
const t = setInterval(next, INTERVAL);
return () => clearInterval(t);
}, [next, total]);
if (total === 0) {
return
懂物业,更懂“省”心。一站式物业管理平台,覆盖缴费、报修、公告、巡检全流程。