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;
|
checked: boolean;
|
||||||
onToggle?: () => void;
|
onToggle?: () => void;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
disabled?: boolean;
|
||||||
wrapperClassName?: string;
|
wrapperClassName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ export function ToggleStatus({
|
|||||||
checked,
|
checked,
|
||||||
onToggle,
|
onToggle,
|
||||||
label,
|
label,
|
||||||
|
disabled = false,
|
||||||
wrapperClassName = 'flex items-center gap-2',
|
wrapperClassName = 'flex items-center gap-2',
|
||||||
}: ToggleStatusProps) {
|
}: ToggleStatusProps) {
|
||||||
function handleToggle() {
|
function handleToggle() {
|
||||||
@ -27,6 +29,7 @@ export function ToggleStatus({
|
|||||||
size="sm"
|
size="sm"
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onCheckedChange={handleToggle}
|
onCheckedChange={handleToggle}
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
{label && (
|
{label && (
|
||||||
<span
|
<span
|
||||||
|
|||||||
@ -166,6 +166,7 @@ export function ProductCardRow({
|
|||||||
url={toggleStatusUrl(product.id)}
|
url={toggleStatusUrl(product.id)}
|
||||||
checked={isChecked}
|
checked={isChecked}
|
||||||
label={getStatusLabel(product.status)}
|
label={getStatusLabel(product.status)}
|
||||||
|
disabled={!can('products.toggle_status')}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span
|
<span
|
||||||
@ -182,6 +183,7 @@ export function ProductCardRow({
|
|||||||
url={toggleFeaturedUrl(product.id)}
|
url={toggleFeaturedUrl(product.id)}
|
||||||
checked={product.is_featured}
|
checked={product.is_featured}
|
||||||
label={product.is_featured ? 'Ditampilkan di Halaman Depan' : 'Tidak Ditampilkan'}
|
label={product.is_featured ? 'Ditampilkan di Halaman Depan' : 'Tidak Ditampilkan'}
|
||||||
|
disabled={!can('products.toggle_featured')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user