Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom rootRef #232

Open
Samir-R opened this issue Jun 11, 2022 · 0 comments
Open

Custom rootRef #232

Samir-R opened this issue Jun 11, 2022 · 0 comments

Comments

@Samir-R
Copy link

Samir-R commented Jun 11, 2022

Hello,

I want to make a backoffice for a marketplace to allow sellers to manage their products, orders, customers...
For exemple, sellers will login to www.mywebsite.com/admin (the backoffice that I develop with the react-admin library)
Each seller will have his firestore collections, for example :

  • root-collection
    ---- seller1 (document, "seller1" is equivalent to the "seller 1" uid )
    ---------- products (collection)
    ---------- categories (collection)
    ---------- orders (collection)
    ---- seller2 (document)
    ---------- products (collection)
    ---------- categories (collection)
    ---------- orders (collection)
    ....

For example, when "seller 1" log in and go to www.mywebsite.com/admin/products, he will see the list of his products, I want react-admin-firebase to retrieve the documents(products) of "root-collection/seller1/products" collection, when he create product, I want this new product to be stored in "root-collection/seller1/products". If "seller 2" create new category, I want the category to be stored in "root-collection/seller2/categories" ...

I try this, in options of FirebaseDataProvider, but not working :

...
const options = {
  logging: true,
  rootRef: () => {
      const auth = getAuth();
      const user = auth.currentUser;    
      if (user) {
        // User is signed in
        return 'root-collection/' + user.uid;
      } else {
        // No user is signed in.
        return 'root-collection/foo';
      }
  },
  app: firebaseApp,
...

it return always 'root-collection/foo' even if I signed in.

Do you have a solution for my use case ?

Thank you.
Sorry for my english.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant