Skip to content

Commit e0eb015

Browse files
committed
Backport changes from atomic-crm
1 parent 3ed2898 commit e0eb015

File tree

16 files changed

+133
-79
lines changed

16 files changed

+133
-79
lines changed

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/companies/CompanyListFilter.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,7 @@ export const CompanyListFilter = () => {
2424
return (
2525
<Box width="13em" minWidth="13em" order={-1} mr={2} mt={5}>
2626
<FilterLiveSearch hiddenLabel />
27-
<FilterList
28-
label="Account manager"
29-
icon={<SupervisorAccountIcon />}
30-
>
31-
<FilterListItem
32-
label="Me"
33-
value={{
34-
sales_id: identity?.id,
35-
}}
36-
/>
37-
</FilterList>
27+
3828
<FilterList label="Size" icon={<BusinessIcon />}>
3929
{sizes.map(size => (
4030
<FilterListItem
@@ -54,6 +44,18 @@ export const CompanyListFilter = () => {
5444
/>
5545
))}
5646
</FilterList>
47+
48+
<FilterList
49+
label="Account manager"
50+
icon={<SupervisorAccountIcon />}
51+
>
52+
<FilterListItem
53+
label="Me"
54+
value={{
55+
sales_id: identity?.id,
56+
}}
57+
/>
58+
</FilterList>
5759
</Box>
5860
);
5961
};

examples/crm/src/contacts/ContactListContent.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
/* eslint-disable import/no-anonymous-default-export */
2-
import * as React from 'react';
3-
import {
4-
RecordContextProvider,
5-
ReferenceField,
6-
SimpleListLoading,
7-
TextField,
8-
useListContext,
9-
} from 'react-admin';
2+
import type { Theme } from '@mui/material';
103
import {
4+
Checkbox,
115
List,
126
ListItem,
137
ListItemAvatar,
148
ListItemIcon,
159
ListItemSecondaryAction,
1610
ListItemText,
17-
Checkbox,
1811
Typography,
1912
useMediaQuery,
2013
} from '@mui/material';
21-
import type { Theme } from '@mui/material';
22-
import { Link } from 'react-router-dom';
2314
import { formatRelative } from 'date-fns';
15+
import {
16+
RecordContextProvider,
17+
ReferenceField,
18+
SimpleListLoading,
19+
TextField,
20+
useListContext,
21+
} from 'react-admin';
22+
import { Link } from 'react-router-dom';
2423

25-
import { Avatar } from './Avatar';
2624
import { Status } from '../misc/Status';
27-
import { TagsList } from './TagsList';
2825
import { Contact } from '../types';
26+
import { Avatar } from './Avatar';
27+
import { TagsList } from './TagsList';
2928

3029
export const ContactListContent = () => {
3130
const {

examples/crm/src/contacts/ContactListFilter.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ export const ContactListFilter = () => {
3434
}}
3535
placeholder="Search name, company, etc."
3636
/>
37-
<FilterList
38-
label="Account manager"
39-
icon={<SupervisorAccountIcon />}
40-
>
41-
<FilterListItem label="Me" value={{ sales_id: identity?.id }} />
42-
</FilterList>
4337
<FilterList label="Last activity" icon={<AccessTimeIcon />}>
4438
<FilterListItem
4539
label="Today"
@@ -113,6 +107,12 @@ export const ContactListFilter = () => {
113107
/>
114108
))}
115109
</FilterList>
110+
<FilterList
111+
label="Account manager"
112+
icon={<SupervisorAccountIcon />}
113+
>
114+
<FilterListItem label="Me" value={{ sales_id: identity?.id }} />
115+
</FilterList>
116116
</Box>
117117
);
118118
};

examples/crm/src/dashboard/HotContacts.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ export const HotContacts = () => {
7777
)}
7878
leftAvatar={contact => <Avatar record={contact} />}
7979
dense
80+
empty={
81+
<Box p={2}>
82+
<Typography variant="body2" gutterBottom>
83+
Contacts with a "hot" status will appear here.
84+
</Typography>
85+
<Typography variant="body2">
86+
Change the status of a contact by adding a note
87+
to that contact and clicking on "show options".
88+
</Typography>
89+
</Box>
90+
}
8091
/>
8192
</Card>
8293
</Stack>

examples/crm/src/dashboard/TasksListEmpty.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@ export const TasksListEmpty = () => {
1717

1818
if (total) return null;
1919

20-
return <Typography variant="body2">No results found</Typography>;
20+
return (
21+
<Typography variant="body2">
22+
Tasks added to your contacts will appear here.
23+
</Typography>
24+
);
2125
};

examples/crm/src/dashboard/Welcome.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ export const Welcome = () => (
4747
<Button
4848
variant="contained"
4949
fullWidth
50-
href="https://github.com/marmelab/react-admin/tree/master/examples/crm"
51-
startIcon={<CodeIcon />}
50+
href="https://marmelab.com/react-admin"
51+
startIcon={<HomeIcon />}
5252
>
53-
Source
53+
React-admin site
5454
</Button>
5555
<Button
5656
variant="contained"
5757
fullWidth
58-
href="https://marmelab.com/react-admin"
59-
startIcon={<HomeIcon />}
58+
href="https://github.com/marmelab/react-admin/tree/master/examples/crm"
59+
startIcon={<CodeIcon />}
6060
>
61-
React-admin site
61+
Source of this demo
6262
</Button>
6363
</CardActions>
6464
</Card>

examples/crm/src/deals/DealEdit.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ export const DealEdit = ({ open, id }: { open: boolean; id?: string }) => {
3030
};
3131

3232
return (
33-
<Dialog open={open} onClose={handleClose} fullWidth maxWidth="md">
33+
<Dialog
34+
open={open}
35+
onClose={handleClose}
36+
fullWidth
37+
maxWidth="md"
38+
sx={{
39+
'& .MuiDialog-container': {
40+
alignItems: 'flex-start',
41+
},
42+
}}
43+
>
3444
{!!id ? (
3545
<EditBase
3646
id={id}
@@ -94,7 +104,11 @@ function EditHeader() {
94104
</Stack>
95105

96106
<Stack direction="row" spacing={1} sx={{ pr: 3 }}>
97-
<Button component={Link} to={`/deals/${deal.id}/show`}>
107+
<Button
108+
component={Link}
109+
to={`/deals/${deal.id}/show`}
110+
size="small"
111+
>
98112
Back to deal
99113
</Button>
100114
</Stack>

examples/crm/src/deals/DealShow.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ export const DealShow = ({ open, id }: { open: boolean; id?: string }) => {
4242
};
4343

4444
return (
45-
<Dialog open={open} onClose={handleClose} fullWidth maxWidth="md">
45+
<Dialog
46+
open={open}
47+
onClose={handleClose}
48+
fullWidth
49+
maxWidth="md"
50+
sx={{
51+
'& .MuiDialog-container': {
52+
alignItems: 'flex-start',
53+
},
54+
}}
55+
>
4656
<DialogContent sx={{ padding: 0 }}>
4757
{!!id ? (
4858
<ShowBase id={id}>
@@ -65,14 +75,18 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
6575
<DialogCloseButton
6676
onClose={handleClose}
6777
top={record.archived_at ? CLOSE_TOP_WITH_ARCHIVED : 16}
68-
right={20}
78+
right={10}
6979
color={record.archived_at ? 'white' : undefined}
7080
/>
7181
<Stack gap={1}>
7282
{record.archived_at ? <ArchivedTitle /> : null}
7383
<Box display="flex" p={2}>
74-
<Box ml={2} flex="1">
75-
<Stack direction="row" justifyContent="space-between">
84+
<Box flex="1">
85+
<Stack
86+
direction="row"
87+
justifyContent="space-between"
88+
mb={4}
89+
>
7690
<Stack direction="row" alignItems="center" gap={2}>
7791
<ReferenceField
7892
source="company_id"
@@ -88,7 +102,7 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
88102
<Stack
89103
gap={1}
90104
direction="row"
91-
pr={record.archived_at ? 0 : 4}
105+
pr={record.archived_at ? 0 : 6}
92106
>
93107
{record.archived_at ? (
94108
<>
@@ -104,7 +118,7 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
104118
</Stack>
105119
</Stack>
106120

107-
<Box display="flex" mb={2} mt={2}>
121+
<Box display="flex" m={2}>
108122
<Box display="flex" mr={5} flexDirection="column">
109123
<Typography
110124
color="textSecondary"
@@ -192,7 +206,7 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
192206
</Box>
193207

194208
{!!record.contact_ids?.length && (
195-
<Box mb={2}>
209+
<Box m={2}>
196210
<Box
197211
display="flex"
198212
mr={5}
@@ -216,7 +230,7 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
216230
)}
217231

218232
{record.description && (
219-
<Box mt={2} mb={2} sx={{ whiteSpace: 'pre-line' }}>
233+
<Box m={2} sx={{ whiteSpace: 'pre-line' }}>
220234
<Typography
221235
color="textSecondary"
222236
variant="caption"
@@ -229,9 +243,8 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
229243
</Box>
230244
)}
231245

232-
<Divider />
233-
234-
<Box mt={2}>
246+
<Box m={2}>
247+
<Divider />
235248
<ReferenceManyField
236249
target="deal_id"
237250
reference="dealNotes"

examples/crm/src/Header.tsx renamed to examples/crm/src/layout/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
useUserMenu,
2020
} from 'react-admin';
2121
import { Link, matchPath, useLocation } from 'react-router-dom';
22-
import { useConfigurationContext } from './root/ConfigurationContext';
22+
import { useConfigurationContext } from '../root/ConfigurationContext';
2323

2424
const Header = () => {
2525
const { logo, title } = useConfigurationContext();

0 commit comments

Comments
 (0)