import type { FieldInfo as MetadataFieldInfo } from '@shumai/dtos' import React from 'react' interface FieldProps { value: boolean config: MetadataFieldInfo['config'] onSave: (value: boolean) => void readOnly?: boolean } const ToggleField: React.FC = ({ value, onSave, readOnly }) => { // Toggle is instant edit, doesn't really have a separate "Edit mode" UI structure other than interaction. const handleToggle = (e: React.MouseEvent) => { e.stopPropagation() if (!readOnly) { const newValue = !value onSave(newValue) } } return (
) } export default ToggleField