mirror of
https://github.com/complexcaresolutions/payload-contracts.git
synced 2026-03-17 16:23:47 +00:00
fix: remove broken type filter from navigation API
The navigations collection has no top-level 'type' field — each tenant has one document with mainMenu and footerMenu arrays. The previous where[type][equals] query caused HTTP 400 on every call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c168832a12
commit
a0eea9649d
1 changed files with 7 additions and 4 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Navigation API functions
|
* Navigation API functions
|
||||||
|
*
|
||||||
|
* Each tenant has ONE navigation document with mainMenu (header) and footerMenu arrays.
|
||||||
|
* There is no top-level 'type' field — access nav.mainMenu / nav.footerMenu directly.
|
||||||
*/
|
*/
|
||||||
import type { Navigation } from '../types/collections'
|
import type { Navigation } from '../types/collections'
|
||||||
import type { PaginatedResponse, CollectionQueryParams } from '../types/api'
|
import type { PaginatedResponse, CollectionQueryParams } from '../types/api'
|
||||||
|
|
@ -8,19 +11,19 @@ import type { PayloadClient } from './client'
|
||||||
export function createNavigationApi(client: PayloadClient) {
|
export function createNavigationApi(client: PayloadClient) {
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get navigation by type (header, footer, mobile, etc.)
|
* Get the navigation document for the current tenant.
|
||||||
|
* Returns a single document with `mainMenu` and `footerMenu` arrays.
|
||||||
*/
|
*/
|
||||||
async getNavigation(type: string, options?: Pick<CollectionQueryParams, 'locale' | 'depth'>): Promise<Navigation | null> {
|
async getNavigation(options?: Pick<CollectionQueryParams, 'locale' | 'depth'>): Promise<Navigation | null> {
|
||||||
const result = await client.getCollection<Navigation>('navigations', {
|
const result = await client.getCollection<Navigation>('navigations', {
|
||||||
...options,
|
...options,
|
||||||
where: { 'type][equals': type },
|
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
return result.docs[0] ?? null
|
return result.docs[0] ?? null
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all navigations
|
* Get all navigations (multi-tenant admin usage)
|
||||||
*/
|
*/
|
||||||
async getNavigations(options?: CollectionQueryParams): Promise<PaginatedResponse<Navigation>> {
|
async getNavigations(options?: CollectionQueryParams): Promise<PaginatedResponse<Navigation>> {
|
||||||
return client.getCollection<Navigation>('navigations', options)
|
return client.getCollection<Navigation>('navigations', options)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue