Skip to content

Commit 2ad8ec2

Browse files
Ni-2alsakhaev
authored andcommitted
fix: fix capability switchers (issue#197)
1 parent dbc89cb commit 2ad8ec2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/xen-tg-app/src/components/Agent.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useMemo } from 'react'
1+
import { FC, useEffect, useMemo } from 'react'
22
// import UnlinkOutlineIcon from '../assets/unlink-outline'
33
import ArrowForwardIcon from '@/assets/arrow-forward'
44
import { Switch } from '@/components/ui/switch'
@@ -65,6 +65,8 @@ const Agent: FC<TAgentProps> = ({ capabilitiy }) => {
6565
},
6666
})
6767

68+
useEffect(() => handleToggleCapability.reset(), [capabilitiy])
69+
6870
// const handleRemoveCapability = useMutation({
6971
// mutationFn,
7072
// onSuccess: () => {
@@ -90,7 +92,11 @@ const Agent: FC<TAgentProps> = ({ capabilitiy }) => {
9092
</div>
9193
</button>
9294

93-
<Switch onCheckedChange={handleChangeStatus} checked={capabilitiy.isEnabled} />
95+
<Switch
96+
onCheckedChange={handleChangeStatus}
97+
checked={capabilitiy.isEnabled}
98+
disabled={handleToggleCapability.isPending || handleToggleCapability.isSuccess}
99+
/>
94100
{/* <button
95101
className="mr-1 flex cursor-pointer p-1.5 text-[#7A818B] transition hover:text-(--color-main-text)"
96102
onClick={() =>

0 commit comments

Comments
 (0)