Files
mtdb_movie/resources/client/channels/channel-header/use-channel-layouts.ts
T
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02:00

22 lines
857 B
TypeScript
Executable File

import {Channel} from '@common/channels/channel';
import {channelContentConfig} from '@app/admin/channels/channel-content-config';
import {useCookie} from '@common/utils/hooks/use-cookie';
export function useChannelLayouts(channel: Channel) {
const config = channelContentConfig.models[channel.config.contentModel];
const availableLayouts = config?.layoutMethods
.filter(m => channelContentConfig.userSelectableLayouts.includes(m))
.map(method => ({
key: method,
label: channelContentConfig.layoutMethods[method].label,
icon: channelContentConfig.layoutMethods[method].icon,
}));
const [selectedLayout, setSelectedLayout] = useCookie(
`channel-layout-${channel.config.contentModel}`,
channel.config.selectedLayout || channel.config.layout
);
return {selectedLayout, setSelectedLayout, availableLayouts};
}