import type { BotFace } from "@/src/dict/bot-dict"; import botStoneProps from "@/src/utils/bot-stone-props"; import type { CronJobWithNames } from "@/src/types"; import SettingsListRow from "@/src/pages/admin/settings/(partials)/settings-list-row"; import SettingsRowAction from "@/src/pages/admin/settings/(partials)/settings-row-action"; import routineSubtitle from "@/src/utils/routine-subtitle"; import BotAvatar from "./bot-avatar"; type Props = { cron_job: CronJobWithNames; busy?: boolean; onToggle: () => void; onEdit: () => void; onDelete: () => void; /** * In a conversation's own modal the Chat link and the bot's and * workspace's names are already the ones on screen. */ compact?: boolean; }; /** * One routine: its bot's avatar, its name (Paused or Done when it is), * whose it is and when it runs, then Chat, Pause or Resume, Edit, Delete. */ export default function RoutineRow({ cron_job, busy, onToggle, onEdit, onDelete, compact }: Props) { const title = cron_job.title || `Routine ${cron_job.id}`; const done = Boolean(cron_job.max_runs && Number(cron_job.run_count || 0) >= cron_job.max_runs); const chat_url = cron_job.workspace_id ? `/admin/workspaces/${cron_job.workspace_id}/bots/${cron_job.bot_id}` : `/admin/bots/${cron_job.bot_id}`; return ( } title={title} badge={cron_job.enabled ? undefined : done ? "Done" : "Paused"} subtitle={routineSubtitle({ cron_job, show_bot: !compact, show_workspace: !compact, })} > {compact ? null : ( )} ); }