This commit is contained in:
hamid zarghami
2025-01-29 15:01:30 +03:30
parent 9c8b15a2cf
commit 018737df4e
7 changed files with 189 additions and 51 deletions
@@ -0,0 +1,28 @@
import { FC, useState } from 'react'
import { useToggleStatusService } from '../hooks/useServiceData'
import SwitchComponent from '../../../components/Switch'
type Props = {
id: string,
status: boolean,
}
const ToggleStatusService: FC<Props> = (props: Props) => {
const [isActive, setIsActive] = useState<boolean>(props.status)
const toggleStatus = useToggleStatusService()
const handleChange = (value: boolean) => {
setIsActive(value)
toggleStatus.mutate(props.id)
}
return (
<SwitchComponent
active={isActive}
onChange={handleChange}
/>
)
}
export default ToggleStatusService