#How to sync customer record in customer list widget when admin add new customer

1 messages · Page 1 of 1 (latest)

atomic hollow
#

I have implemented "add new customer" custom feature in customers UI route. when user successfully created new customer, that customer should be directly added to the customer list widget.

Note: "Add new customer" feature implemented using medusa-react hook. i.e. useCreateCustomer()

when use click on "create" button, the created customer should be added in customer list widget.

marble carbon
#

Please read the post guidelines and stop ragging. You description is not clear has 0 information to help on. Describe your issue, provide logs etc

knotty crest
#

@atomic hollow when you refresh, then it shows the new user?

atomic hollow
#

@knotty crest yes. But, it should auto add without a refreshing page.

knotty crest
#

@atomic hollow which version are you using?

knotty crest
#

somehow I don't have this feature on my production instance, and this is most likely a bug

#

I will try working on it hopefully tomorrow, it is not invalidating cache or the pagination is not working properly!

atomic hollow
#

Remember: this "Add new customer" feature is custom implementation.

knotty crest
#

oh, ok, then just invalidate cache

#

const {client} = useMedusa()

#

client should have a invalidateCache method

#

this is the query key I believe, admin_customers

#

my bad, I don't think client has invalidateCache, that is used to get the js client

knotty crest
#
import { useQueryClient } from '@tanstack/react-query';
const queryClient = useQueryClient();

<form
  onSubmit={() => {
    ...

    queryClient.invalidateQueries({
      queryKey: ["admin_customers"],
    });
  }}
>
atomic hollow
knotty crest
atomic hollow
#

@knotty crest where to find all queryKeys? OR is there any hack to find it?