Skip to content

Commit

Permalink
Changing methods to properly connect with backend
Browse files Browse the repository at this point in the history
Related to issue #4

Signed-off-by: João Paulo Ferreira <[email protected]>
  • Loading branch information
iamferreirajp committed Apr 17, 2017
1 parent 55dfb0c commit 9d60c64
Showing 1 changed file with 64 additions and 7 deletions.
71 changes: 64 additions & 7 deletions src/Categories/Owners.js
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>
);

0 comments on commit 9d60c64

Please sign in to comment.