refac channel about page settings, #852

This commit is contained in:
Simon
2025-01-03 19:05:25 +07:00
parent 1f74e02c92
commit 1177aa5699
4 changed files with 263 additions and 280 deletions

View File

@@ -0,0 +1,33 @@
import defaultHeaders from '../../configuration/defaultHeaders';
import getApiUrl from "../../configuration/getApiUrl"
import getFetchCredentials from '../../configuration/getFetchCredentials';
import getCookie from "../../functions/getCookie";
const updateChannelOverwrites = async (channelId: string, configKey: string, configValue: any) => {
const apiUrl = getApiUrl();
const csrfCookie = getCookie('csrftoken');
const data = {
channel_overwrites: {
[configKey]: configValue
}
};
const response = await fetch(`${apiUrl}/api/channel/${channelId}/`, {
method: 'POST',
headers: {
...defaultHeaders,
'X-CSRFToken': csrfCookie || '',
},
credentials: getFetchCredentials(),
body: JSON.stringify(data),
});
const channelSubscription = await response.json();
console.log('updateChannelOverwrites', channelSubscription);
return channelSubscription;
}
export default updateChannelOverwrites;