Skip to content

Commit

Permalink
[CRM] Remove any type in functionField
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed May 7, 2021
1 parent d14fffd commit c498478
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions examples/crm/src/companies/CompanyAside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'react-admin';
import { Box, Typography, Divider, Link } from '@material-ui/core';

import { Company } from '../types';
import { Company, Sale } from '../types';

export const CompanyAside = ({
record,
Expand Down Expand Up @@ -92,10 +92,12 @@ export const CompanyAside = ({
source="sales_id"
reference="sales"
>
<FunctionField
<FunctionField<Sale>
source="last_name"
render={(record: any) =>
`${record.first_name} ${record.last_name}`
render={record =>
record
? `${record.first_name} ${record.last_name}`
: ''
}
/>
</ReferenceField>
Expand Down
8 changes: 5 additions & 3 deletions examples/crm/src/contacts/ContactAside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
import { Box, Typography, Divider, List, ListItem } from '@material-ui/core';
import { TagsListEdit } from './TagsListEdit';

import { Sale } from '../types';

export const ContactAside = ({ record, link = 'edit' }: any) => (
<Box ml={4} width={250} minWidth={250}>
<Box textAlign="center" mb={2}>
Expand Down Expand Up @@ -89,10 +91,10 @@ export const ContactAside = ({ record, link = 'edit' }: any) => (
source="sales_id"
reference="sales"
>
<FunctionField
<FunctionField<Sale>
source="last_name"
render={(record: any) =>
`${record.first_name} ${record.last_name}`
render={record =>
record ? `${record.first_name} ${record.last_name}` : ''
}
/>
</ReferenceField>
Expand Down
8 changes: 5 additions & 3 deletions examples/crm/src/dashboard/LatestNotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from 'react-admin';
import { formatDistance } from 'date-fns';

import { Contact as ContactType } from '../types';

const useStyles = makeStyles(theme => ({
note: {
marginBottom: theme.spacing(2),
Expand Down Expand Up @@ -148,10 +150,10 @@ const Contact = ({ note }: any) => (
basePath="/contacts"
link="show"
>
<FunctionField
<FunctionField<ContactType>
variant="body1"
render={(contact: any) =>
`${contact.first_name} ${contact.last_name}`
render={contact =>
contact ? `${contact.first_name} ${contact.last_name}` : ''
}
/>
</ReferenceField>
Expand Down

0 comments on commit c498478

Please sign in to comment.