import apiClient from './client'; // Types export interface RequiredChannel { id: number; channel_id: string; channel_link: string | null; title: string | null; is_active: boolean; sort_order: number; disable_trial_on_leave: boolean; disable_paid_on_leave: boolean; } export interface ChannelListResponse { items: RequiredChannel[]; total: number; } export interface CreateChannelRequest { channel_id: string; channel_link?: string; title?: string; disable_trial_on_leave?: boolean; disable_paid_on_leave?: boolean; } export interface UpdateChannelRequest { channel_id?: string; channel_link?: string; title?: string; is_active?: boolean; sort_order?: number; disable_trial_on_leave?: boolean; disable_paid_on_leave?: boolean; } export const adminChannelsApi = { list: async (): Promise => { const { data } = await apiClient.get( '/cabinet/admin/channel-subscriptions', ); return data; }, create: async (req: CreateChannelRequest): Promise => { const { data } = await apiClient.post( '/cabinet/admin/channel-subscriptions', req, ); return data; }, update: async (id: number, req: UpdateChannelRequest): Promise => { const { data } = await apiClient.patch( `/cabinet/admin/channel-subscriptions/${id}`, req, ); return data; }, toggle: async (id: number): Promise => { const { data } = await apiClient.post( `/cabinet/admin/channel-subscriptions/${id}/toggle`, ); return data; }, delete: async (id: number): Promise => { await apiClient.delete(`/cabinet/admin/channel-subscriptions/${id}`); }, }; export default adminChannelsApi;