This commit is contained in:
hamid zarghami
2025-02-16 11:20:25 +03:30
parent 8f39afeb48
commit df8c000aa6
7 changed files with 349 additions and 80 deletions
+28
View File
@@ -0,0 +1,28 @@
import { FC, useState } from 'react'
import SwitchComponent from '../../../components/Switch'
import { useToggleStatusAds } from '../hooks/useAdsData'
type Props = {
defaultActive: boolean,
id: string
}
const ToggleStatusAds: FC<Props> = (props: Props) => {
const [isActive, setIsActive] = useState<boolean>(props.defaultActive)
const toggleStatus = useToggleStatusAds()
const handleChange = (value: boolean) => {
setIsActive(value)
toggleStatus.mutate(props.id)
}
return (
<SwitchComponent
active={isActive}
onChange={handleChange}
/>
)
}
export default ToggleStatusAds