"use client" import {Pencil, Plus} from "lucide-react"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import {Button} from "@/components/ui/button"; import {OrganizationWithMembers} from "@/db/schema/03_organization"; import {NotificationChannelWith} from "@/db/schema/09_notification-channel"; import {useIsMobile} from "@/hooks/use-mobile"; import {useEffect, useState} from "react"; import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs"; import {StorageChannelWith} from "@/db/schema/12_storage-channel"; import {ChannelForm} from "@/features/channel/components/channel-form"; import {ChannelKind, getChannelTextBasedOnKind} from "@/features/channel/components/channels-helpers"; import { ChannelOrganisationForm } from "@/features/organizations/components/channels-organization-form"; type ChannelAddModalProps = { channel?: NotificationChannelWith | StorageChannelWith organization?: OrganizationWithMembers; open?: boolean; onOpenChangeAction?: (open: boolean) => void; adminView?: boolean; organizations?: OrganizationWithMembers[] trigger?: boolean; kind: ChannelKind; } export const ChannelAddEditModal = ({ organization, channel, open = false, onOpenChangeAction, adminView, organizations, trigger = true, kind }: ChannelAddModalProps) => { const isMobile = useIsMobile(); const [openInternal, setOpen] = useState(open); const isLocalSystem = channel?.provider === "local"; const isCreate = !Boolean(channel); useEffect(() => { setOpen(open); }, [open]) const channelText = getChannelTextBasedOnKind(kind) return ( { onOpenChangeAction?.(state); setOpen(state); }}> {trigger && ( {isCreate ? : } )} e.preventDefault()}> {isCreate ? "Add" : "Edit"} {channelText} Channel Configure your {channelText.toLowerCase()} channel preferences.
<> {!isLocalSystem ? ( <> {adminView ? Configuration Organizations { onOpenChangeAction?.(false) setOpen(false); }} /> : <> { onOpenChangeAction?.(false) setOpen(false); }} /> } ) : <> }
) }