-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing methods to properly connect with backend
Related to issue #4 Signed-off-by: João Paulo Ferreira <[email protected]>
- Loading branch information
1 parent
55dfb0c
commit 9d60c64
Showing
1 changed file
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,69 @@ | ||
import React from 'react'; | ||
import { List, Datagrid, EmailField, TextField } from 'admin-on-rest/lib/mui'; | ||
import { List, Responsive, SimpleList, Edit, Create, Datagrid, TextField, Filter, EditButton, DeleteButton, ReferenceInput, SelectInput, SimpleForm, TextInput } from 'admin-on-rest/lib/mui'; | ||
|
||
const OwnerFilter = props => ( | ||
<Filter {...props}> | ||
<TextInput label="Pesquisar" source="q" alwaysOn /> | ||
<ReferenceInput label="Proprietário" source="id" reference="owner" allowEmpty> | ||
<SelectInput source="id" optionText="ownerName" /> | ||
</ReferenceInput> | ||
</Filter> | ||
); | ||
|
||
export const OwnerList = props => ( | ||
<List {...props} title={'Relatório Financeiro'}> | ||
<Datagrid> | ||
<TextField source="id" label="ID" /> | ||
<TextField source="name" label="Nome" /> | ||
<EmailField source="email" label="Email" /> | ||
</Datagrid> | ||
<List {...props} filters={<OwnerFilter />} title={'Lista de proprietários'}> | ||
<Responsive | ||
small={ | ||
<SimpleList | ||
primaryText={record => record.title} | ||
secondaryText={record => `${record.views} views`} | ||
tertiaryText={record => new Date(record.published_at).toLocaleDateString()} | ||
/> | ||
} | ||
medium={ | ||
<Datagrid> | ||
<TextField source="id" label="ID" /> | ||
<TextField source="ownerName" label="Nome Completo" /> | ||
<TextField source="ownerPhoneNumber" label="Telefone" /> | ||
<EditButton /> | ||
<DeleteButton /> | ||
</Datagrid> | ||
} | ||
/> | ||
</List> | ||
); | ||
export const OwnerCreate = props => ( | ||
<Create {...props}> | ||
<SimpleForm> | ||
<TextInput source="ownerID" label="ID" /> | ||
<TextInput source="cpf" label="CPF" /> | ||
<TextInput source="ownerName" label="Primeiro Nome" /> | ||
<TextInput source="ownerLastName" label="Sobrenome" /> | ||
<TextInput source="phoneNumber" label="Telefone" /> | ||
<TextInput source="zipCode" label="Código Postal" /> | ||
<TextInput source="district" label="Estado" /> | ||
<TextInput source="publicPlace" label="Endereço" /> | ||
<TextInput source="addressNumber" label="Número" /> | ||
</SimpleForm> | ||
</Create> | ||
); | ||
|
||
const OwnerName = ({ record }) => { | ||
return <span>Proprietário {record ? `"${record.ownerName}"` : ''}</span>; | ||
}; | ||
|
||
export const OwnerEdit = props => ( | ||
<Edit title={<OwnerName />} {...props}> | ||
<SimpleForm> | ||
<TextInput source="ownerID" label="ID" /> | ||
<TextInput source="cpf" label="CPF" /> | ||
<TextInput source="ownerName" label="Primeiro Nome" /> | ||
<TextInput source="ownerLastName" label="Sobrenome" /> | ||
<TextInput source="phoneNumber" label="Telefone" /> | ||
<TextInput source="zipCode" label="Código Postal" /> | ||
<TextInput source="district" label="Estado" /> | ||
<TextInput source="publicPlace" label="Endereço" /> | ||
<TextInput source="addressNumber" label="Número" /> | ||
</SimpleForm> | ||
</Edit> | ||
); |