Files
bedolaga-cabinet/src/api/adminChannels.ts
Fringg 48be067d1b feat: add per-channel disable settings and global settings to channel admin
- Add global settings section (CHANNEL_IS_REQUIRED_SUB, trial/paid toggles)
  at top of AdminChannelSubscriptions page
- Add per-channel disable_trial_on_leave and disable_paid_on_leave toggles
  in each channel card with inline Toggle controls
- Update RequiredChannel type and API request interfaces with new fields
- Add translations for globalSettings and perChannel in en/ru/fa/zh locales
2026-02-25 00:24:36 +03:00

75 lines
1.8 KiB
TypeScript

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<ChannelListResponse> => {
const { data } = await apiClient.get<ChannelListResponse>(
'/cabinet/admin/channel-subscriptions',
);
return data;
},
create: async (req: CreateChannelRequest): Promise<RequiredChannel> => {
const { data } = await apiClient.post<RequiredChannel>(
'/cabinet/admin/channel-subscriptions',
req,
);
return data;
},
update: async (id: number, req: UpdateChannelRequest): Promise<RequiredChannel> => {
const { data } = await apiClient.patch<RequiredChannel>(
`/cabinet/admin/channel-subscriptions/${id}`,
req,
);
return data;
},
toggle: async (id: number): Promise<RequiredChannel> => {
const { data } = await apiClient.post<RequiredChannel>(
`/cabinet/admin/channel-subscriptions/${id}/toggle`,
);
return data;
},
delete: async (id: number): Promise<void> => {
await apiClient.delete(`/cabinet/admin/channel-subscriptions/${id}`);
},
};
export default adminChannelsApi;