Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
229
useCollectionCreate.ts1.4 kB
import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { mutate } from "swr"; import { z } from "zod"; import { getCollectionListKey } from "src/api/openapi-client/collections"; import { UseDisclosureProps } from "src/utils/useDisclosure"; import { handle } from "@/api/client"; import { Account } from "@/api/openapi-schema"; import { useCollectionMutations } from "@/lib/collection/mutation"; export const FormSchema = z.object({ name: z.string().min(1, "Please enter a name for the collection."), description: z.string().optional(), }); export type Form = z.infer<typeof FormSchema>; export type Props = UseDisclosureProps & { session: Account; }; export function useCollectionCreate({ session, ...props }: Props) { const { register, handleSubmit } = useForm<Form>({ resolver: zodResolver(FormSchema), }); const { create, revalidate } = useCollectionMutations(session); const onSubmit = handleSubmit(async (data) => { await handle( async () => { await create(data); props.onClose?.(); mutate(getCollectionListKey()); }, { promiseToast: { loading: "Creating collection...", success: "Collection created!", }, async cleanup() { await revalidate(); }, }, ); }); return { onSubmit, register, }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server