Skip to content

Commit bec289b

Browse files
authored
Merge pull request #10140 from marmelab/atomic-crm-backport
Feat(demo): Backport Atomic CRM to RA repo
2 parents 19c951e + 2bb14b9 commit bec289b

File tree

88 files changed

+2214
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2214
-863
lines changed
Lines changed: 14 additions & 0 deletions
Loading

examples/crm/src/App.tsx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
import { CRM } from './root/CRM';
2-
import {
3-
defaultCompanySectors,
4-
defaultContactGender,
5-
defaultDealCategories,
6-
defaultDealStages,
7-
defaultLogo,
8-
defaultNoteStatuses,
9-
defaultTaskTypes,
10-
defaultTitle,
11-
} from './root/defaultConfiguration';
122

13-
const App = () => (
14-
<CRM
15-
contactGender={defaultContactGender}
16-
companySectors={defaultCompanySectors}
17-
dealCategories={defaultDealCategories}
18-
dealStages={defaultDealStages}
19-
logo={defaultLogo}
20-
noteStatuses={defaultNoteStatuses}
21-
taskTypes={defaultTaskTypes}
22-
title={defaultTitle}
23-
/>
24-
);
3+
/**
4+
* Application entry point
5+
*
6+
* Customize Atomic CRM by passing props to the CRM component:
7+
* - contactGender
8+
* - companySectors
9+
* - darkTheme
10+
* - dealCategories
11+
* - dealPipelineStatuses
12+
* - dealStages
13+
* - lightTheme
14+
* - logo
15+
* - noteStatuses
16+
* - taskTypes
17+
* - title
18+
* ... as well as all the props accepted by react-admin's <Admin> component.
19+
*
20+
* @example
21+
* const App = () => (
22+
* <CRM
23+
* logo="./img/logo.png"
24+
* title="Acme CRM"
25+
* />
26+
* );
27+
*/
28+
const App = () => <CRM />;
2529

2630
export default App;

examples/crm/src/activity/ActivityLog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Alert, Divider, Skeleton, Stack } from '@mui/material';
22
import { useQuery } from '@tanstack/react-query';
33
import { Identifier, useDataProvider } from 'react-admin';
44

5-
import { CustomDataProvider } from '../dataProvider';
5+
import { CrmDataProvider } from '../providers/types';
66
import { ActivityLogContext } from './ActivityLogContext';
77
import { ActivityLogIterator } from './ActivityLogIterator';
88

@@ -17,7 +17,7 @@ export function ActivityLog({
1717
pageSize = 20,
1818
context = 'all',
1919
}: ActivityLogProps) {
20-
const dataProvider = useDataProvider<CustomDataProvider>();
20+
const dataProvider = useDataProvider<CrmDataProvider>();
2121
const { data, isPending, error } = useQuery({
2222
queryKey: ['activityLog', companyId],
2323
queryFn: () => dataProvider.getActivityLog(companyId),

examples/crm/src/companies/CompanyAside.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const CompanyAside = ({ link = 'edit' }: CompanyAsideProps) => {
4646
};
4747

4848
const CompanyInfo = ({ record }: { record: Company }) => {
49-
if (!record.website && !record.linkedIn && !record.phone_number) {
49+
if (!record.website && !record.linkedin_url && !record.phone_number) {
5050
return null;
5151
}
5252

@@ -102,7 +102,7 @@ const CompanyInfo = ({ record }: { record: Company }) => {
102102
};
103103

104104
const ContextInfo = ({ record }: { record: Company }) => {
105-
if (!record.revenue && !record.identifier) {
105+
if (!record.revenue && !record.id) {
106106
return null;
107107
}
108108

examples/crm/src/companies/CompanyAvatar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const CompanyAvatar = (props: {
2020
'& img': { objectFit: 'contain' },
2121
width,
2222
height,
23+
fontSize: height !== 40 ? '0.6rem' : undefined,
2324
}}
2425
>
2526
{record.name.charAt(0)}

examples/crm/src/companies/CompanyCard.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ export const CompanyCard = (props: { record?: Company }) => {
6666
{record.nb_contacts}
6767
</Typography>
6868
<Typography variant="caption" color="textSecondary">
69-
{record.nb_contacts > 1
70-
? 'contacts'
69+
{record.nb_contacts
70+
? record.nb_contacts > 1
71+
? 'contacts'
72+
: 'contact'
7173
: 'contact'}
7274
</Typography>
7375
</div>
@@ -79,7 +81,11 @@ export const CompanyCard = (props: { record?: Company }) => {
7981
{record.nb_deals}
8082
</Typography>
8183
<Typography variant="caption" color="textSecondary">
82-
{record.nb_deals > 1 ? 'deals' : 'deal'}
84+
{record.nb_deals
85+
? record.nb_deals > 1
86+
? 'deals'
87+
: 'deal'
88+
: 'deal'}
8389
</Typography>
8490
</div>
8591
</Box>

examples/crm/src/companies/CompanyInputs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const CompanyAccountManagerInput = () => {
163163
source="sales_id"
164164
reference="sales"
165165
filter={{
166-
disabled_neq: true,
166+
'disabled@neq': true,
167167
}}
168168
>
169169
<SelectInput

examples/crm/src/companies/CompanyList.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import {
32
TopToolbar,
43
ExportButton,
@@ -13,35 +12,25 @@ import {
1312

1413
import { ImageList } from './GridList';
1514
import { CompanyListFilter } from './CompanyListFilter';
16-
import { LinearProgress, Stack } from '@mui/material';
15+
import { Stack } from '@mui/material';
1716
import { CompanyEmpty } from './CompanyEmpty';
18-
import { hasOtherFiltersThanDefault } from '../misc/hasOtherFiltersThanDefault';
1917

2018
export const CompanyList = () => {
2119
const { identity } = useGetIdentity();
2220
if (!identity) return null;
2321
return (
24-
<ListBase
25-
perPage={25}
26-
filterDefaultValues={{ sales_id: identity?.id }}
27-
sort={{ field: 'name', order: 'ASC' }}
28-
>
22+
<ListBase perPage={25} sort={{ field: 'name', order: 'ASC' }}>
2923
<CompanyListLayout />
3024
</ListBase>
3125
);
3226
};
3327

3428
const CompanyListLayout = () => {
3529
const { data, isPending, filterValues } = useListContext();
36-
const { identity } = useGetIdentity();
37-
const hasOtherFiltersThanDefaultBoolean = hasOtherFiltersThanDefault(
38-
filterValues,
39-
'sales_id',
40-
identity?.id
41-
);
42-
if (isPending) return <LinearProgress />;
43-
if (!data?.length && !hasOtherFiltersThanDefaultBoolean)
44-
return <CompanyEmpty />;
30+
const hasFilters = filterValues && Object.keys(filterValues).length > 0;
31+
32+
if (isPending) return null;
33+
if (!data?.length && !hasFilters) return <CompanyEmpty />;
4534

4635
return (
4736
<Stack direction="row" component="div">

examples/crm/src/companies/CompanyListFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const CompanyListFilter = () => {
5252
<FilterListItem
5353
label="Me"
5454
value={{
55-
sales_id: identity && identity.id,
55+
sales_id: identity?.id,
5656
}}
5757
/>
5858
</FilterList>

examples/crm/src/companies/CompanyShow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const CompanyShowContent = () => {
8080
path="contacts"
8181
>
8282
<ReferenceManyField
83-
reference="contacts"
83+
reference="contacts_summary"
8484
target="company_id"
8585
sort={{ field: 'last_name', order: 'ASC' }}
8686
>
@@ -228,7 +228,7 @@ const DealsIterator = () => {
228228
currencyDisplay: 'narrowSymbol',
229229
minimumSignificantDigits: 3,
230230
})}
231-
, {deal.type}
231+
{deal.category ? `, ${deal.category}` : ''}
232232
</>
233233
}
234234
/>

0 commit comments

Comments
 (0)