import { ProgressBar } from "@/components/ui/ProgressBar";
import type { DashboardResponse } from "@/lib/types";
import styles from "./ScheduleProgressCard.module.css";

interface ScheduleProgressCardProps {
  progress: DashboardResponse["schedule_progress"];
}

/**
 * スケジュール進捗カード（モック514〜523行相当）。
 *
 * ★rate が null のときはバーを描画しない（D-049）★
 *   planned が0（全施設が定休日）のときに 0% のバーを出すと
 *   「予定件数分の清掃がまだ0件しか終わっていない」と誤読される。
 *   「本日の清掃予定はありません」という別メッセージに置き換える。
 */
export function ScheduleProgressCard({ progress }: ScheduleProgressCardProps) {
  return (
    <div className={styles.card}>
      <div className={styles.heading}>スケジュール進捗</div>
      {progress.rate === null ? (
        <div className={styles.empty}>本日の清掃予定はありません</div>
      ) : (
        <>
          <span className={styles.count}>{progress.completed}</span>
          <span className={styles.unit}> / {progress.planned} 完了</span>
          <ProgressBar percent={progress.rate} tone="ok" />
        </>
      )}
    </div>
  );
}
