feat: refine channel management UI
This commit is contained in:
+31
-27
@@ -19,7 +19,9 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import type { QueryClient } from '@tanstack/react-query'
|
||||
import i18next from 'i18next'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import { formatCurrencyFromUSD } from '@/lib/currency'
|
||||
|
||||
import {
|
||||
copyChannel,
|
||||
deleteChannel,
|
||||
@@ -129,7 +131,7 @@ export async function handleEnableChannel(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
}
|
||||
@@ -154,7 +156,7 @@ export async function handleDisableChannel(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
}
|
||||
@@ -192,7 +194,7 @@ export async function handleDeleteChannel(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t(ERROR_MESSAGES.DELETE_FAILED))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t(ERROR_MESSAGES.DELETE_FAILED))
|
||||
}
|
||||
}
|
||||
@@ -224,7 +226,7 @@ export async function handleUpdateChannelField(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
}
|
||||
@@ -258,7 +260,7 @@ export async function handleUpdateTagField(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t(ERROR_MESSAGES.UPDATE_FAILED))
|
||||
}
|
||||
}
|
||||
@@ -355,7 +357,7 @@ export async function handleCopyChannel(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t('Failed to copy channel'))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to copy channel'))
|
||||
}
|
||||
}
|
||||
@@ -425,7 +427,7 @@ export async function handleBatchDelete(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t(ERROR_MESSAGES.DELETE_FAILED))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t(ERROR_MESSAGES.DELETE_FAILED))
|
||||
}
|
||||
}
|
||||
@@ -444,10 +446,7 @@ export async function handleBatchEnable(
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await batchUpdateChannelStatus(
|
||||
ids,
|
||||
CHANNEL_STATUS.ENABLED
|
||||
)
|
||||
const response = await batchUpdateChannelStatus(ids, CHANNEL_STATUS.ENABLED)
|
||||
const successCount = response.success ? response.data || 0 : 0
|
||||
const failCount = ids.length - successCount
|
||||
|
||||
@@ -466,7 +465,7 @@ export async function handleBatchEnable(
|
||||
i18next.t('{{count}} channel(s) failed to enable', { count: failCount })
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to enable channels'))
|
||||
}
|
||||
}
|
||||
@@ -509,7 +508,7 @@ export async function handleBatchDisable(
|
||||
})
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to disable channels'))
|
||||
}
|
||||
}
|
||||
@@ -537,7 +536,7 @@ export async function handleBatchSetTag(
|
||||
} else {
|
||||
toast.error(response.message || i18next.t('Failed to set tag'))
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to set tag'))
|
||||
}
|
||||
}
|
||||
@@ -567,7 +566,7 @@ export async function handleEnableTagChannels(
|
||||
response.message || i18next.t('Failed to enable tag channels')
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to enable tag channels'))
|
||||
}
|
||||
}
|
||||
@@ -593,7 +592,7 @@ export async function handleDisableTagChannels(
|
||||
response.message || i18next.t('Failed to disable tag channels')
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to disable tag channels'))
|
||||
}
|
||||
}
|
||||
@@ -624,13 +623,13 @@ export async function handleDeleteAllDisabled(
|
||||
response.message || i18next.t('Failed to delete disabled channels')
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to delete disabled channels'))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix channel abilities
|
||||
* Repair channel consistency
|
||||
*/
|
||||
export async function handleFixAbilities(
|
||||
queryClient?: QueryClient,
|
||||
@@ -640,18 +639,23 @@ export async function handleFixAbilities(
|
||||
const response = await fixChannelAbilities()
|
||||
if (response.success && response.data) {
|
||||
toast.success(
|
||||
i18next.t('Fixed abilities: {{success}} succeeded, {{fails}} failed', {
|
||||
success: response.data.success,
|
||||
fails: response.data.fails,
|
||||
})
|
||||
i18next.t(
|
||||
'Channel consistency repaired: {{success}} succeeded, {{fails}} failed',
|
||||
{
|
||||
success: response.data.success,
|
||||
fails: response.data.fails,
|
||||
}
|
||||
)
|
||||
)
|
||||
queryClient?.invalidateQueries({ queryKey: channelsQueryKeys.lists() })
|
||||
onSuccess?.(response.data)
|
||||
} else {
|
||||
toast.error(response.message || i18next.t('Failed to fix abilities'))
|
||||
toast.error(
|
||||
response.message || i18next.t('Failed to repair channel consistency')
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
toast.error(i18next.t('Failed to fix abilities'))
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to repair channel consistency'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,7 +681,7 @@ export async function handleTestAllChannels(
|
||||
response.message || i18next.t('Failed to start testing all channels')
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to test all channels'))
|
||||
}
|
||||
}
|
||||
@@ -704,7 +708,7 @@ export async function handleUpdateAllBalances(
|
||||
response.message || i18next.t('Failed to update all balances')
|
||||
)
|
||||
}
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
toast.error(i18next.t('Failed to update all balances'))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user