import { useStore } from "zustand"; import { useContext } from "react"; import type { AttachmentStore } from "../store/attachment-store"; import { StoreContext } from "../providers/store-provider"; export const useAttachmentStore = ( selector: (store: AttachmentStore) => T, ): T => { const store = useContext(StoreContext); if (!store) { throw new Error("useAttachmentStore must be used within StoreProvider"); } return useStore(store.attachmentStore, selector); };