import { SettingComponentProps, InputComponentProps, CheckboxComponentProps, SliderComponentProps, } from '@janhq/core' import { useAtomValue } from 'jotai/react' import Checkbox from '@/containers/Checkbox' import ModelConfigInput from '@/containers/ModelConfigInput' import SliderRightPanel from '@/containers/SliderRightPanel' import { activeThreadAtom } from '@/helpers/atoms/Thread.atom' type Props = { componentProps: SettingComponentProps[] disabled?: boolean onValueUpdated: (key: string, value: string | number | boolean) => void } const SettingComponent: React.FC = ({ componentProps, disabled = false, onValueUpdated, }) => { const activeThread = useAtomValue(activeThreadAtom) const components = componentProps.map((data) => { switch (data.controllerType) { case 'slider': { const { min, max, step, value } = data.controllerProps as SliderComponentProps return ( onValueUpdated(data.key, value)} /> ) } case 'input': { const { placeholder, value: textValue } = data.controllerProps as InputComponentProps return ( onValueUpdated(data.key, value)} /> ) } case 'checkbox': { const { value } = data.controllerProps as CheckboxComponentProps return ( onValueUpdated(data.key, value)} /> ) } default: return null } }) return
{components}
} export default SettingComponent