update next, try fix next nav issue, minor improvements
# Conflicts: # apps/dashboard/src/middleware.ts # packages/db/src/services/organization.service.ts # pnpm-lock.yaml
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
04375807d0
commit
4b50fed1dc
54
apps/dashboard/src/components/forms/checkbox-item.tsx
Normal file
54
apps/dashboard/src/components/forms/checkbox-item.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { forwardRef } from 'react';
|
||||
import { cn } from '@/utils/cn';
|
||||
import { slug } from '@/utils/slug';
|
||||
import type { LucideIcon } from 'lucide-react';
|
||||
import type { ControllerRenderProps } from 'react-hook-form';
|
||||
|
||||
import { Switch } from '../ui/switch';
|
||||
|
||||
type Props = {
|
||||
label: string;
|
||||
description: string;
|
||||
Icon: LucideIcon;
|
||||
children?: React.ReactNode;
|
||||
error?: string;
|
||||
} & ControllerRenderProps;
|
||||
|
||||
export const CheckboxItem = forwardRef<HTMLButtonElement, Props>(
|
||||
(
|
||||
{ label, description, Icon, children, onChange, value, disabled, error },
|
||||
ref
|
||||
) => {
|
||||
const id = slug(label);
|
||||
return (
|
||||
<div>
|
||||
<label
|
||||
className={cn(
|
||||
'flex items-center gap-4 px-4 py-6 transition-colors hover:bg-slate-100',
|
||||
disabled && 'cursor-not-allowed opacity-50'
|
||||
)}
|
||||
htmlFor={id}
|
||||
>
|
||||
{Icon && <div className="w-6 shrink-0">{<Icon />}</div>}
|
||||
<div className="flex-1">
|
||||
<div className="font-medium">{label}</div>
|
||||
<div className="text-sm text-muted-foreground">{description}</div>
|
||||
{error && <div className="text-xs text-red-600">{error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<Switch
|
||||
ref={ref}
|
||||
disabled={disabled}
|
||||
checked={!!value}
|
||||
onCheckedChange={onChange}
|
||||
id={id}
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
CheckboxItem.displayName = 'CheckboxItem';
|
||||
Reference in New Issue
Block a user