Update admin components from hooks

default discord avatar
kulczylast year
2

hi there, i call external api from the 'beforeChange' hook, and i would like to update admin panel to display current status of this operation, something like "syncing with the API", "syncing complete", somewhere in header or sidebar. Could anyone give any tips on how to go about this?

  • default discord avatar
    notchrlast year

    @kulczy Morning! You could start by creating a custom Admin Component. This will allow you to add it somewhere that makes sense. The component would make a request to the external data and report status (loading indicator?). This is how I see it working, but others might have better solutions.

  • discord user avatar
    jesschow
    last year

    @kulczy for a slightly different approach you can checkout this

    syncDocs

    button:

    https://github.com/payloadcms/website-cms/blob/main/src/payload.config.ts#L156

    It adds a component to

    afterNavLinks

    that hits a custom endpoint to fetch data from GitHub.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.