Hello, we are using React-admin and Firestore throught React admin firestore, actually we are intenting to write a sub collection but we failed. below you'll find our code, anyone can help or explain how do this ? :
import {
DeleteWithConfirmIconButton,
EditableDatagrid,
} from "@react-admin/ra-editable-datagrid";
import { Fragment } from "react";
import React, { useEffect, useState } from "react";
import firebase from "firebase/compat/app";
import {
Create,
CreateButton,
List,
SimpleForm,
TextField,
TextInput,
ShowButton,
EditButton,
ReferenceManyField,
ReferenceArrayInput,
ChipField,
SelectArrayInput,
ReferenceInput,
SelectInput,
} from "react-admin";
import { db } from "./config";
import selectedIds from "./company";
import { collection, getDocs } from "firebase/firestore";
export const CreateGroupe = (props) => {
const [users, setUsers] = useState([]);
const messageRef = db
.collection("company")
.document("id")
.collection("grou")
.document("name_group");
useEffect(() => {
const getUsers = async () => {
const data = await getDocs(messageRef);
setUsers(data.docs.map((doc) => ({ ...doc.data(), id: doc.id })));
};
getUsers();
}, []);
Hello, we are using React-admin and Firestore throught React admin firestore, actually we are intenting to write a sub collection but we failed. below you'll find our code, anyone can help or explain how do this ? :
import { DeleteWithConfirmIconButton, EditableDatagrid, } from "@react-admin/ra-editable-datagrid"; import { Fragment } from "react"; import React, { useEffect, useState } from "react"; import firebase from "firebase/compat/app"; import { Create, CreateButton, List, SimpleForm, TextField, TextInput, ShowButton, EditButton, ReferenceManyField, ReferenceArrayInput, ChipField, SelectArrayInput, ReferenceInput, SelectInput, } from "react-admin"; import { db } from "./config"; import selectedIds from "./company"; import { collection, getDocs } from "firebase/firestore"; export const CreateGroupe = (props) => { const [users, setUsers] = useState([]); const messageRef = db .collection("company") .document("id") .collection("grou") .document("name_group"); useEffect(() => { const getUsers = async () => { const data = await getDocs(messageRef); setUsers(data.docs.map((doc) => ({ ...doc.data(), id: doc.id }))); }; getUsers(); }, []);
return (
Name: {user.name_group}
); }; export const GroupeList = (props) => { return ( <List {...props} hasCreate empty={false}>
); };