"use client"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import type { TransitionCondition } from "@/lib/types"; const TRANSITION_TYPES = [ { value: "strategy_complete", label: "Strategy Completes" }, { value: "actions_count", label: "Actions Count" }, { value: "timer", label: "Timer (seconds)" }, { value: "inventory_full", label: "Inventory Full" }, { value: "inventory_item_count", label: "Inventory Item Count" }, { value: "bank_item_count", label: "Bank Item Count" }, { value: "skill_level", label: "Skill Level" }, { value: "gold_amount", label: "Gold Amount" }, ] as const; const OPERATORS = [ { value: ">=", label: ">=" }, { value: "<=", label: "<=" }, { value: "==", label: "==" }, { value: ">", label: ">" }, { value: "<", label: "<" }, ] as const; const SKILLS = [ "mining", "woodcutting", "fishing", "weaponcrafting", "gearcrafting", "jewelrycrafting", "cooking", "alchemy", ] as const; interface TransitionEditorProps { value: TransitionCondition | null; onChange: (condition: TransitionCondition | null) => void; } export function TransitionEditor({ value, onChange }: TransitionEditorProps) { const condType = value?.type ?? ""; const needsValue = condType === "actions_count" || condType === "inventory_item_count" || condType === "bank_item_count" || condType === "skill_level" || condType === "gold_amount"; const needsItemCode = condType === "inventory_item_count" || condType === "bank_item_count"; const needsSkill = condType === "skill_level"; const needsSeconds = condType === "timer"; function update(partial: Partial) { const base: TransitionCondition = value ?? { type: "strategy_complete", operator: ">=", value: 0, item_code: "", skill: "", seconds: 0, }; onChange({ ...base, ...partial }); } return (
{needsValue && (
update({ value: Number(e.target.value) })} />
)} {needsItemCode && (
update({ item_code: e.target.value })} />
)} {needsSkill && (
)} {needsSeconds && (
update({ seconds: Number(e.target.value) })} />
)}
); }