Initial commit: NestJS NextJS pnpm monorepo
This commit is contained in:
commit
610dcf202b
175 files changed
+25172
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
interface ChangeValue {
|
||||
[key: string]: string
|
||||
}
|
||||
|
||||
interface Props {
|
||||
label?:string
|
||||
name: string
|
||||
valueInit?: string,
|
||||
onTxtChange: (txt: ChangeValue) => void
|
||||
}
|
||||
|
||||
export const InputText = ({ label, valueInit, onTxtChange, name }: Props) => {
|
||||
|
||||
const [txt, setTxt] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (valueInit) {
|
||||
setTxt(valueInit);
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const obj = { [name]: txt };
|
||||
onTxtChange(obj);
|
||||
}, [txt])
|
||||
|
||||
return (
|
||||
<div className="border-1 border-gray-100 p-2 mb-1 mt-1 bg-green-100">
|
||||
{label && <div className="text-sm font-bold text-black font-mono ps-1">{label}</div>}
|
||||
<input className="bg-white border-1 rounded p-1 w-full" name={name} value={txt} onChange={(e) => setTxt(e.target.value)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user