Some the users of my app have access to multiple ‘organisations’. However they are only ever logged into a single organanisation at one time.
I have created a way for users to switch between organisations, which updates their assigned OrgId in my supabase user table. This OrgId filters any supabase collection that is fetched in my app.
What I’m looking for is advice on how to go about re-fetching collections on the current page so that it displays the correct data. Currently I’m forcing a logout, which then prompts users to log back. This then fetches all relevant collections and the user can continue using the app.
But it’s not the best user experience. Ideally I’d want WeWeb to re-fetch all collections for the specific page that the user is currently on.
Has anyone got any insights into how you might solve this problem?
Correct, but I don’t want to switch pages.
Let’s say a user is logged into organisation A and is on a specific page – let’s say the customer page.
When the page loads a supabase collection was fetched for the customers table. The collection was filtered by the OrgID for Organisation A, so that the user only sees customers relevant to OrganisationA.
But the user wants to switch to Organisation B, so navigates to the navbar and opens a dropdown that displays all the organisaitons that they’re authorised to access. They select Organisation B. A workflow updates the users’s current OrgID to Organisation B.
I’m looking for a way to refresh/refetch the customers collection so that it refilters by the OrgID and displays all customers that are associated with the different organisation.
I want this to be dynamic so that it only refetches/reloads the collections that are relevant to the current page that the user is on.
Thanks for the reply. I haven’t, as there doesn’t seem to be a way to fetch the collections that are relevant to this page. The collections will change depending on what page the user is on.
i.e. I’ll only want to refresh the customer collection if the user switched organisations on the customer page. If they’re on a different page, then I’ll need to refresh different collections relevant to that page instead.
What I’m trying to do is get WeWeb to programatically refresh the collections that are relevant to the specific page that the user is on.