filters={[
{
name: "name",
label: t("channel.filterName"),
placeholder: t("channel.filterName"),
defaultValue: "",
trim: true,
className: "w-full sm:w-56",
},
{
name: "channelId",
label: t("channel.filterChannelId"),
placeholder: t("channel.filterChannelId"),
defaultValue: "",
trim: true,
className: "w-full sm:w-72",
},
{
name: "channelType",
label: t("channel.allTypes"),
type: "select",
defaultValue: "all",
allValue: "all",
options: channelTypeOptions,
className: "w-full sm:w-40",
},
{
name: "status",
label: t("status.all"),
type: "select",
defaultValue: "all",
allValue: "all",
options: statusOptions,
className: "w-full sm:w-36",
},
]}
columns={[
{
key: "channel",
label: t("channel.columnChannel"),
render: (item) => (
{item.name}
{getChannelTypeLabel(item.channelType, t)}
),
},
{
key: "type",
label: t("channel.columnType"),
render: (item) => (
{getChannelTypeLabel(item.channelType, t)}
),
},
{
key: "channelId",
label: "ChannelID",
render: (item) => (
{item.channelId || "-"}
),
},
{
key: "agent",
label: t("channel.columnAgent"),
render: (item) => item.aiAgentName || "-",
},
{
key: "status",
label: t("channel.columnStatus"),
render: (item, { actionLoading, reload, setActionLoadingId }) => (
{
void (async () => {
setActionLoadingId(item.id)
try {
const nextStatus =
item.status === Status.Ok ? Status.Disabled : Status.Ok
await updateChannelStatus(item.id, nextStatus)
toast.success(
t(
nextStatus === Status.Ok
? "channel.statusEnabled"
: "channel.statusDisabled",
{ name: item.name }
)
)
await reload()
} catch (error) {
toast.error(
error instanceof Error
? error.message
: t("channel.statusUpdateFailed")
)
} finally {
setActionLoadingId(null)
}
})()
}}
aria-label={t("channel.toggleStatus", { name: item.name })}
/>
{getStatusLabel(item.status as Status, t)}
),
},
]}
fetchList={fetchChannels}
getItemId={(item) => item.id}
createItem={createChannel}
updateItem={(item, payload) => updateChannel({ id: item.id, ...payload })}
deleteItem={(item) => deleteChannel(item.id)}
renderEditDialog={({ open, saving, itemId, onOpenChange, onSubmit }) => (
)}
labels={{
refresh: t("channel.refresh"),
create: t("channel.new"),
query: t("channel.query"),
loading: t("channel.loading"),
empty: t("channel.empty"),
actions: t("channel.columnActions"),
edit: t("channel.edit"),
delete: t("channel.delete"),
processing: t("channel.processing"),
moreActions: (item) => t("channel.moreActions", { name: item.name }),
loadFailed: t("channel.loadFailed"),
saveFailed: t("channel.saveFailed"),
deleteFailed: t("channel.deleteFailed"),
created: (payload) => t("channel.created", { name: payload.name }),
updated: (_item, payload) => t("channel.updated", { name: payload.name }),
deleted: (item) => t("channel.deleted", { name: item.name }),
}}
/>
)
}