Q:

Save data to two different resources

I'm trying to save a user's full record, but I depend on two separate tables. Profile data is saved in one resource, and the address in another. How can I write the code so that it saves the profile first, and from the generated id, save the address? It's possible?
Profile form
Address form
Here is my Create User code:
export const BarberCreate = (props) => {
  return (
    <Create {...props}>
      <TabbedForm toolbar={<BarberCreateToolbar />}>
        <FormTab label="Perfil">
          <TextInput source="name" />
          <TextInput source="email" />
          <DateInput source="birthday" />
          <TextInput source="phone" placeholder="(99) 99999-9999" />
          <TextInput source="transport" />
        </FormTab>

        <FormTab label="Endereço">
          <TextInput source="street" label="Rua" />
          <TextInput source="city" label="Cidade" />
          <TextInput source="district" label="Bairro" />
        </FormTab>
      </TabbedForm>
    </Create>
  );
};```

A:

The best would be do that on the backend, possibly with transaction support, but if you can't, one way to go on react-admin side is decorating the dataProvider.
v3
const userSaverDataProvider = dataProvider => ({
    ...dataProvider,
    create: async (resource, params) => {

        if (resource === 'users') {

            const profile = await dataProvider.create('profile', {data: {
                name: params.data.name,
                ....
            }})

            await dataProvider.create('address', {data: {
                profileID: profile.data.id,
                street: params.data.street,
                ...
            }})

            return profile        

        }        

        return dataProvider.create(resource, params)
    }
})

Maybe necessary decorate createMany too if you do bulk creating of users on react-admin. Also, checkout https://github.com/FusionWorks/react-admin-google-maps, it migtht be useful

