"use client"; import {Card} from "@/components/ui/card"; import {NotificationChannelWith} from "@/db/schema/09_notification-channel"; import {Badge} from "@/components/ui/badge"; import {OrganizationWithMembers} from "@/db/schema/03_organization"; import {truncateWords} from "@/utils/text"; import {useIsMobile} from "@/hooks/use-mobile"; import {StorageChannelWith} from "@/db/schema/12_storage-channel"; import { EditChannelButton } from "@/features/channel/channel-edit-button"; import {ChannelKind, getChannelIcon} from "@/features/channel/channels-helpers"; import { DeleteChannelButton } from "@/features/channel/channel-delete-button"; export type ChannelCardProps = { data: NotificationChannelWith | StorageChannelWith; organization?: OrganizationWithMembers; organizations?: OrganizationWithMembers[]; adminView?: boolean; kind?: ChannelKind; defaultStorageChannelId?: string | null | undefined }; export const ChannelCard = (props: ChannelCardProps) => { const {data, organization, kind, adminView, defaultStorageChannelId} = props; const isMobile = useIsMobile() const isDefaultSystemStorage = defaultStorageChannelId === data.id; const isOwned = data.organizationId ? true : !organization; const isLocalSystem = data.provider == "local"; return (
{getChannelIcon(data.provider)}

{isMobile ? truncateWords(data.name, 2) : data.name}

{data.provider} {isDefaultSystemStorage && ( default )}
{kind && (
{(isOwned) && ( <> {!isLocalSystem && ( )} )}
)}
); };