import React, { useState } from 'react' import { Button } from './ui/8bit/button' import { Input } from './ui/8bit/input' interface MissingVariableItemProps { variable: { name: string configured: boolean hasValue: boolean valid: boolean errors: string[] sensitive?: boolean type?: 'client' | 'server' description?: string } groupKey: string currentProject: any selectedBranch: string onSuccess: () => void playSound: (type: string) => void } export default function MissingVariableItem({ variable, groupKey, currentProject, selectedBranch, onSuccess, playSound }: MissingVariableItemProps) { const [tempValue, setTempValue] = useState('') const [isAdding, setIsAdding] = useState(false) // Use the sensitivity from config, don't allow toggling const isSensitive = variable.sensitive ?? true const handleAdd = async () => { setIsAdding(true) try { const res = await fetch(`/api/variables?projectPath=${encodeURIComponent(currentProject?.path || '')}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: variable.name, value: tempValue, description: variable.description || '', sensitive: isSensitive, category: groupKey, branch: selectedBranch }) }) if (res.ok) { onSuccess() setTempValue('') playSound('powerup') } else { playSound('error') } } catch (err) { console.error('Failed to add variable:', err) playSound('error') } setIsAdding(false) } return (
{variable.name}
{variable.description}
)}