import { useState } from 'react' import { IconMovie } from '@tabler/icons-react' import api from '~/lib/api' import useCreatorPacks from '~/hooks/useCreatorPacks' import useDownloads from '~/hooks/useDownloads' import { useNotifications } from '~/context/NotificationContext' import CreatorPackCard from '~/components/CreatorPackCard' import StyledModal from '~/components/StyledModal' import { formatBytes } from '~/lib/util' import type { CreatorPackWithStatus } from '../../types/collections' // Canonical Creator Pack License (one license across the seed packs). Opened in a // new tab from the install modal; install is an online action so an external link // is fine. A per-pack catalog `license_url` can supersede this later if needed. const LICENSE_URL = 'https://github.com/Crosstalk-Solutions/project-nomad/blob/main/collections/creator-pack-license.md' export interface CreatorPacksSectionProps { /** Show uninstall controls on installed packs (the settings "manage" surface). */ allowUninstall?: boolean } /** * Install-on-click grid of Creator Packs + confirm modals. Shared by the Content * Explorer block and the /settings/creator-packs page. Renders NOTHING when the * build isn't configured (fork / key unset) — a fork never sees a broken install * button. The Easy Setup wizard does NOT use this (it needs selection semantics, * not install-on-click) and drives CreatorPackCard itself. */ const CreatorPacksSection: React.FC = ({ allowUninstall }) => { const { configured, packs, invalidate: invalidateCreatorPacks } = useCreatorPacks() const { invalidate: invalidateDownloads } = useDownloads({ filetype: 'zim' }) const { addNotification } = useNotifications() const [packToInstall, setPackToInstall] = useState(null) const [installing, setInstalling] = useState(false) const [packToUninstall, setPackToUninstall] = useState(null) const [uninstalling, setUninstalling] = useState(false) if (!configured) return null const handleConfirmInstall = async () => { if (!packToInstall) return setInstalling(true) try { await api.installCreatorPack(packToInstall.id) addNotification({ message: `Started installing "${packToInstall.name}"`, type: 'success' }) invalidateCreatorPacks() invalidateDownloads() setPackToInstall(null) } catch (error) { console.error('Error installing creator pack:', error) addNotification({ message: 'An error occurred while starting the install.', type: 'error' }) } finally { setInstalling(false) } } const handleConfirmUninstall = async () => { if (!packToUninstall) return setUninstalling(true) try { await api.uninstallCreatorPack(packToUninstall.id) addNotification({ message: `Uninstalled "${packToUninstall.name}"`, type: 'success' }) invalidateCreatorPacks() invalidateDownloads() setPackToUninstall(null) } catch (error) { console.error('Error uninstalling creator pack:', error) addNotification({ message: 'An error occurred while uninstalling.', type: 'error' }) } finally { setUninstalling(false) } } return ( <>

Creator Packs

Branded video collections from creators, for offline viewing

{packs.length > 0 ? (
{packs.map((pack) => ( ))}
) : (

No creator packs available.

)} !installing && setPackToInstall(null)} onCancel={() => setPackToInstall(null)} onConfirm={handleConfirmInstall} confirmText={packToInstall?.available_update_version ? 'Update pack' : 'Install pack'} confirmIcon="IconDownload" confirmLoading={installing} icon={} > {packToInstall && (

{packToInstall.video_count} videos from {packToInstall.creator}, about{' '} {formatBytes(packToInstall.size_mb * 1024 * 1024, 0)}. It will download in the background and appear in Kiwix when ready.

Licensed content — personal use, not for redistribution.{' '} e.stopPropagation()} > View license

)}
!uninstalling && setPackToUninstall(null)} onCancel={() => setPackToUninstall(null)} onConfirm={handleConfirmUninstall} confirmText="Uninstall pack" confirmIcon="IconTrash" confirmVariant="danger" confirmLoading={uninstalling} icon={} > {packToUninstall && (

This removes the downloaded videos ( {formatBytes(packToUninstall.size_mb * 1024 * 1024, 0)}) from this NOMAD. You can reinstall the pack anytime.

)}
) } export default CreatorPacksSection