NamH fa35aa6e14
feat: dynamically register extension settings (#2494)
* feat: add extesion settings

Signed-off-by: James <james@jan.ai>

---------

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
Co-authored-by: Louis <louis@jan.ai>
2024-03-29 15:44:46 +07:00

46 lines
1.0 KiB
TypeScript

import { SettingComponentProps } from '@janhq/core'
import SettingDetailTextInputItem from './SettingDetailTextInputItem'
type Props = {
componentProps: SettingComponentProps[]
onValueUpdated: (key: string, value: string | number | boolean) => void
}
const SettingDetailItem: React.FC<Props> = ({
componentProps,
onValueUpdated,
}) => {
const components = componentProps.map((data) => {
switch (data.controllerType) {
case 'input': {
return (
<SettingDetailTextInputItem
key={data.key}
settingProps={data}
onValueChanged={(value) => onValueUpdated(data.key, value)}
/>
)
}
default:
return null
}
})
return (
<div className="flex w-full flex-col">
{components.map((component, index) => (
<div
className={`mx-6 ${index === components.length - 1 ? '' : 'border-b border-border'}`}
key={index}
>
{component}
</div>
))}
</div>
)
}
export default SettingDetailItem