feat: add disabled state to toggle status and featured components based on permissions

This commit is contained in:
Yoga Pangestu 2026-08-13 18:14:12 +07:00
parent 867517f034
commit 74a76168ab
2 changed files with 5 additions and 0 deletions

View File

@ -6,6 +6,7 @@ type ToggleStatusProps = {
checked: boolean;
onToggle?: () => void;
label?: string;
disabled?: boolean;
wrapperClassName?: string;
};
@ -14,6 +15,7 @@ export function ToggleStatus({
checked,
onToggle,
label,
disabled = false,
wrapperClassName = 'flex items-center gap-2',
}: ToggleStatusProps) {
function handleToggle() {
@ -27,6 +29,7 @@ export function ToggleStatus({
size="sm"
checked={checked}
onCheckedChange={handleToggle}
disabled={disabled}
/>
{label && (
<span

View File

@ -166,6 +166,7 @@ export function ProductCardRow({
url={toggleStatusUrl(product.id)}
checked={isChecked}
label={getStatusLabel(product.status)}
disabled={!can('products.toggle_status')}
/>
) : (
<span
@ -182,6 +183,7 @@ export function ProductCardRow({
url={toggleFeaturedUrl(product.id)}
checked={product.is_featured}
label={product.is_featured ? 'Ditampilkan di Halaman Depan' : 'Tidak Ditampilkan'}
disabled={!can('products.toggle_featured')}
/>
</div>
)}