Files
mtdb_movie/resources/client/channels/channel-header/use-channel-layouts.ts
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01: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};
}