- Updated import paths for various components to align with new directory structure. - Changed imports from 'row-actions', 'confirm-dialog', 'image-preview-button', and 'file-upload' to their respective new locations in 'data-display', 'dialogs', and 'inputs'. - Adjusted imports in multiple pages including purchase, restock, transaction, category, customer, product, raw-material, supplier, roles, and settings. - Ensured all relevant components are imported from their new locations to maintain functionality.
41 lines
962 B
TypeScript
41 lines
962 B
TypeScript
import { router } from '@inertiajs/react';
|
|
import { Switch } from '@/components/ui/switch';
|
|
|
|
type ToggleStatusProps = {
|
|
url: string;
|
|
checked: boolean;
|
|
onToggle?: () => void;
|
|
label?: string;
|
|
wrapperClassName?: string;
|
|
};
|
|
|
|
export function ToggleStatus({
|
|
url,
|
|
checked,
|
|
onToggle,
|
|
label,
|
|
wrapperClassName = 'flex items-center gap-2',
|
|
}: ToggleStatusProps) {
|
|
function handleToggle() {
|
|
onToggle?.();
|
|
router.post(url, {}, { preserveScroll: true });
|
|
}
|
|
|
|
return (
|
|
<div className={wrapperClassName}>
|
|
<Switch
|
|
size="sm"
|
|
checked={checked}
|
|
onCheckedChange={handleToggle}
|
|
/>
|
|
{label && (
|
|
<span
|
|
className={`text-xs font-medium ${checked ? 'text-green-700' : 'text-red-700'}`}
|
|
>
|
|
{label}
|
|
</span>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|