import { CollectionAccessType } from '@semble/types'; import { Button, Container, Group, Modal, Select, Stack, Textarea, Text, TextInput, ThemeIcon, } from '@mantine/core'; import { useForm } from '@mantine/form'; import { notifications } from '@mantine/notifications'; import useUpdateCollection from '../../lib/mutations/useUpdateCollection'; import { UPDATE_OVERLAY_PROPS } from '@/styles/overlays'; import { FaSeedling } from 'react-icons/fa6'; import { isMarginUri, getMarginUrl } from '@/lib/utils/margin'; import MarginLogo from '@/components/MarginLogo'; import { BsExclamation } from 'react-icons/bs'; interface Props { isOpen: boolean; onClose: () => void; collection: { id: string; rkey: string; name: string; description?: string; accessType?: CollectionAccessType; uri?: string; authorHandle?: string; }; } export default function EditCollectionModal(props: Props) { const updateCollection = useUpdateCollection(); const isMargin = isMarginUri(props.collection.uri); const marginUrl = getMarginUrl( props.collection.uri, props.collection.authorHandle, ); const form = useForm({ initialValues: { name: props.collection.name, description: props.collection.description, accessType: props.collection.accessType || CollectionAccessType.CLOSED, }, }); const handleUpdateCollection = (e: React.FormEvent) => { e.preventDefault(); updateCollection.mutate( { collectionId: props.collection.id, rkey: props.collection.rkey, name: form.values.name, description: form.values.description, accessType: form.values.accessType, }, { onError: () => { notifications.show({ message: 'Could not update collection', position: 'top-center', color: 'red', title: 'Error', loading: false, autoClose: false, withCloseButton: true, icon: , }); }, onSettled: () => { props.onClose(); }, }, ); }; return ( Edit Collection {isMargin && ( )} } centered overlayProps={UPDATE_OVERLAY_PROPS} >