Files
k-tv/k-tv-frontend/lib/channel-export.ts

21 lines
658 B
TypeScript

import type { ChannelResponse } from "@/lib/types";
export function exportChannel(channel: ChannelResponse): void {
const payload = {
name: channel.name,
description: channel.description ?? undefined,
timezone: channel.timezone,
day_blocks: channel.schedule_config.day_blocks,
recycle_policy: channel.recycle_policy,
};
const blob = new Blob([JSON.stringify(payload, null, 2)], {
type: "application/json",
});
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `${channel.name.toLowerCase().replace(/\s+/g, "-")}.json`;
a.click();
URL.revokeObjectURL(url);
}