§22 S2: collection-scoped frontend path + API helpers
useCollectionId() hook; listRFCs/getRFC/proposeRFC take an optional collection id and target the /collections/<cid>/ routes; add listCollections + createCollection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// project-scoped, so the builders emit the default collection segment; the
|
||||
// collection-aware link layer (named collections) lands in S2. Components build
|
||||
// links via these helpers so that flip happens in one place.
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useProject } from '../components/ProjectLayout.jsx'
|
||||
import { useDeployment } from '../context/DeploymentProvider'
|
||||
|
||||
@@ -37,3 +38,10 @@ export function useProjectId() {
|
||||
const { defaultProjectId } = useDeployment()
|
||||
return (ctx && ctx.projectId) || defaultProjectId
|
||||
}
|
||||
|
||||
// §22 S2 — the collection id a component should scope to: the `/c/:collectionId/`
|
||||
// route segment when present, else the project's default collection.
|
||||
export function useCollectionId() {
|
||||
const { collectionId } = useParams()
|
||||
return collectionId || DEFAULT_COLLECTION
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user