feat: add disabled state to toggle status and featured components based on permissions
This commit is contained in:
parent
867517f034
commit
74a76168ab
@ -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
|
||||
|
||||
@ -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>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user