Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/curly-colts-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@example/erp": patch
"@genseki/react": patch
---

fix: custom list api
4 changes: 4 additions & 0 deletions examples/erp/genseki/collections/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ export const postsCollection = createPlugin('posts', (app) => {
},
layout: Layout,
page: CustomListPage,
api: async (args) => {
console.log('This is from custom list api')
return args.defaultApi(args)
},
})
)
.addPageAndApiRouter(collection.create(fields, { options: options, page: CustomCreatePage }))
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/core/collection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@

export type CollectionUpdateDefaultApiHandler<
TContext extends AnyContextable,
TFields extends Fields,

Check warning on line 384 in packages/react/src/core/collection/index.tsx

View workflow job for this annotation

GitHub Actions / ci

'TFields' is defined but never used. Allowed unused vars must match /^_/u
> = (
args: CollectionUpdateDefaultApiArgs<TContext, TFields> & {
defaultApi: CollectionUpdateDefaultApiHandler<TContext, TFields>
Expand Down Expand Up @@ -560,7 +560,7 @@
config: CollectionListConfig<TContext, TFields> = { columns: [] }
) {
return (appOptions: GensekiAppOptions) => {
const route = this.listApiRouter(fields, config.configuration)
const route = this.listApiRouter(fields, config)

const ui = createGensekiUiRoute({
path: `${this.config.uiPathPrefix}/${this.slug}`,
Expand Down Expand Up @@ -613,14 +613,15 @@

listApiRouter<TFields extends Fields>(
fields: TFields,
listConfiguration?: ListConfiguration<TFields>
config?: CollectionListConfig<TContext, TFields>
) {
const { route } = getCollectionDefaultListApiRoute({
slug: this.slug,
context: this.context,
schema: this.schema,
fields: fields,
listConfiguration: listConfiguration,
listConfiguration: config?.configuration,
customHandler: config?.api,
})

return {
Expand Down
Loading