/** * Add/Edit dialog for a ComponentAssignment row. * * Maps a component (techniques/claims_extract/etc) to a primary provider+model * with optional fallback provider+model. Models dropdown filters to only show * models belonging to the currently-selected provider. * * Fallback section is fully optional — empty fallback_provider_id disables * the fallback model dropdown. */ import React from 'react'; import { Box, Dialog, DialogTitle, DialogContent, DialogActions, TextField, FormControl, InputLabel, Select, MenuItem, FormControlLabel, Checkbox, Button, Typography, } from '@mui/material'; import type { ComponentAssignment, LlmProvider, LlmModel } from '../ProvidersManagement.types'; interface Props { open: boolean; data: Partial | null; providers: LlmProvider[]; models: LlmModel[]; onClose: () => void; onChange: (data: Partial) => void; onSave: () => void; } export const AssignmentDialog: React.FC = ({ open, data, providers, models, onClose, onChange, onSave }) => { if (!data) return null; const isEdit = 'assignment_id' in data && !!data.assignment_id; const filteredModels = models.filter((m) => m.provider_id === data.provider_id); const filteredFallbackModels = models.filter((m) => m.provider_id === data.fallback_provider_id); return ( {isEdit ? 'Edit Assignment' : 'Add Assignment'} onChange({ ...data, component_code: e.target.value })} required fullWidth placeholder="techniques, claims_extract, etc." /> onChange({ ...data, component_name: e.target.value })} required fullWidth /> Primary Provider/Model Provider Model Fallback Provider/Model (Optional) Fallback Provider Fallback Model Settings onChange({ ...data, temperature: parseFloat(e.target.value) })} sx={{ flex: 1 }} inputProps={{ step: 0.1, min: 0, max: 2 }} /> onChange({ ...data, max_tokens: parseInt(e.target.value) })} sx={{ flex: 1 }} /> onChange({ ...data, timeout_ms: parseInt(e.target.value) })} sx={{ flex: 1 }} /> onChange({ ...data, description: e.target.value })} multiline rows={2} fullWidth /> onChange({ ...data, is_enabled: e.target.checked })} />} label="Enabled" /> ); };