import { Switch } from '@/components/ui/switch'
import { FC, useState } from 'react'
import { useToggleStatus } from '../hooks/useAddressData'

const ToggleStatus: FC<{ defaultStatus: boolean, id: string }> = ({ defaultStatus, id }) => {
    const [isActive, setIsActive] = useState(defaultStatus)
    const { mutate: toggleStatus } = useToggleStatus()

    const handleToggleStatus = () => {
        toggleStatus(id)
        setIsActive(!isActive)
    }
    return (
        <Switch checked={isActive} onCheckedChange={handleToggleStatus} />
    )
}

export default ToggleStatus