Update admin components from hooks

default discord avatar
kulczy
6 months ago
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
    notchr
    6 months ago

    @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
    Payload Team
    3 months ago

    @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.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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