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]: boolean
|
||||
}
|
||||
|
||||
interface Props {
|
||||
label?:string
|
||||
name: string
|
||||
valueInit?: boolean,
|
||||
onChange: (value: boolean) => void
|
||||
}
|
||||
|
||||
export const InputCheckbox = ({ label, valueInit, onChange, name }: Props) => {
|
||||
|
||||
const [checked, setChecked] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (valueInit) {
|
||||
setChecked(valueInit);
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const obj = { [name]: checked };
|
||||
onChange(checked);
|
||||
}, [checked])
|
||||
|
||||
return (
|
||||
<div className="border-1 border-gray-100 p-2 mb-1 mt-1 bg-green-100 flex items-center">
|
||||
<input type="checkbox" className=" p-1 me-2 w-8 h-8 " name={name} value={label} checked={checked} onChange={(e) => setChecked((pre)=>!pre)} />
|
||||
{label && <div className="text-sm font-bold text-black font-mono ps-1">{label}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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