You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
893 B
34 lines
893 B
2 years ago
|
import styles from './styles.module.css'
|
||
|
import {useContext, useEffect, useState} from "react";
|
||
|
import Context, {ContextInterface} from "../command/context";
|
||
|
|
||
|
export interface ArgumentInterface {
|
||
|
name: string,
|
||
|
description: string|null,
|
||
|
default: any,
|
||
|
isArray: boolean,
|
||
|
isRequired: boolean,
|
||
|
}
|
||
|
|
||
|
export default function Argument(argument: ArgumentInterface) {
|
||
|
let {argumentList, setArgumentList} = useContext<ContextInterface>(Context)
|
||
|
let [value, setValue] = useState('')
|
||
|
|
||
|
useEffect(() => {
|
||
|
let temp = {
|
||
|
...argumentList,
|
||
|
}
|
||
|
temp[argument.name] = value
|
||
|
setArgumentList(temp)
|
||
|
}, [value])
|
||
|
|
||
|
let onInput = (event: any) => {
|
||
|
setValue(event.target.value)
|
||
|
}
|
||
|
return (
|
||
|
<span>
|
||
|
<input onInput={onInput} placeholder={argument.name} value={value} type="text"/>
|
||
|
</span>
|
||
|
)
|
||
|
}
|