Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/features/sync/hooks/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,15 @@ export const useRemoveChannelSync = () => {
const { user } = useAuthContext()
const { setUserChannel, tempMapList } = useUserChannel()

const [removeId, setRemoveId] = useState<string | undefined>()
const { setDialogAttributes, toggleDialog } = useDialogContext()

const removeChannelSync = async () => {
const removeChannelSync = async (channelSyncId?: string) => {
toggleDialog(false)

const localMapList = tempMapList
setUserChannel((prev) => ({
...prev,
tempMapList: prev.tempMapList.filter((item) => item.id !== removeId),
tempMapList: prev.tempMapList.filter((item) => item.id !== channelSyncId),
}))

try {
Expand All @@ -246,7 +245,7 @@ export const useRemoveChannelSync = () => {
{},
{
body: JSON.stringify({
channelSyncId: removeId,
channelSyncId,
}),
},
)
Expand All @@ -260,14 +259,12 @@ export const useRemoveChannelSync = () => {
}

const openConfirmDialog = (id?: string) => {
setRemoveId(id)

setDialogAttributes((prev) => ({
...prev,
isOpen: true,
title: 'Remove channel sync',
description: 'Are you sure you want to remove this channel sync?',
onConfirm: () => removeChannelSync(),
onConfirm: () => removeChannelSync(id),
}))
}

Expand Down