refactor: init

This commit is contained in:
Ibrahima G. Coulibaly
2025-04-05 04:36:22 +00:00
parent 3014443163
commit ab503c642d
18 changed files with 197 additions and 238 deletions

View File

@@ -40,7 +40,7 @@ const FormikListenerComponent = <T,>({
interface ToolContentProps<T, I> extends ToolComponentProps {
inputComponent?: ReactNode;
resultComponent: ReactNode;
resultComponent?: ReactNode;
renderCustomInput?: (
values: T,
setFieldValue: (fieldName: string, value: any) => void

View File

@@ -6,18 +6,20 @@ export default function ToolInputAndResult({
result
}: {
input?: ReactNode;
result: ReactNode;
result?: ReactNode;
}) {
return (
<Grid id="tool" container spacing={2}>
{input && (
<Grid item xs={12} md={6}>
{input}
if (input || result) {
return (
<Grid id="tool" container spacing={2}>
{input && (
<Grid item xs={12} md={6}>
{input}
</Grid>
)}
<Grid item xs={12} md={input ? 6 : 12}>
{result}
</Grid>
)}
<Grid item xs={12} md={input ? 6 : 12}>
{result}
</Grid>
</Grid>
);
);
}
}

View File

@@ -20,7 +20,7 @@ export default function NumericInputWithUnit(props: {
value: { value: number; unit: string };
disabled?: boolean;
disableChangingUnit?: boolean;
onOwnChange: (value: { value: number; unit: string }) => void;
onOwnChange?: (value: { value: number; unit: string }) => void;
defaultPrefix?: string;
}) {
const [inputValue, setInputValue] = useState(props.value.value);