From 10a9d5291bd427a549eb8b8788054d759ab7381a Mon Sep 17 00:00:00 2001 From: John Doe Date: Sat, 9 Sep 2023 17:25:49 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Refactor=20Checkbox=20component?= =?UTF-8?q?=20=F0=9F=93=A6=20Improve=20code=20structure=20and=20readabilit?= =?UTF-8?q?y=20=F0=9F=93=9D=20Add=20defaultChecked=20prop=20=F0=9F=94=84?= =?UTF-8?q?=20Simplify=20onChange=20callback=20=F0=9F=A7=B9=20Remove=20unu?= =?UTF-8?q?sed=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/Checkbox.tsx | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/shared/Checkbox.tsx diff --git a/src/shared/Checkbox.tsx b/src/shared/Checkbox.tsx new file mode 100644 index 0000000..ca723c1 --- /dev/null +++ b/src/shared/Checkbox.tsx @@ -0,0 +1,51 @@ +"use client"; + +import React, { FC } from "react"; + +export interface CheckboxProps { + label?: string; + subLabel?: string; + className?: string; + name: string; + defaultChecked?: boolean; + onChange?: (checked: boolean) => void; +} + +const Checkbox: FC = ({ + subLabel = "", + label = "", + name, + className = "", + defaultChecked, + onChange, +}) => { + return ( +
+ onChange && onChange(e.target.checked)} + /> + {label && ( + + )} +
+ ); +}; + +export default Checkbox;