diff --git a/examples/crm/src/Header.tsx b/examples/crm/src/Header.tsx index 20eefb0b70d..f5405a2491d 100644 --- a/examples/crm/src/Header.tsx +++ b/examples/crm/src/Header.tsx @@ -100,7 +100,7 @@ const Header = () => { /> {permissions === 'admin' && ( { const { data, isPending } = useGetList('deals', { pagination: { perPage: 100, page: 1 }, sort: { - field: 'start_at', + field: 'created_at', order: 'ASC', }, }); @@ -27,7 +27,7 @@ export const DealsChart = () => { if (!data) return []; const dealsByMonth = data.reduce((acc, deal) => { const month = startOfMonth( - deal.start_at ?? new Date() + deal.created_at ?? new Date() ).toISOString(); if (!acc[month]) { acc[month] = []; diff --git a/examples/crm/src/dataGenerator/deals.ts b/examples/crm/src/dataGenerator/deals.ts index 2310cbee624..9beb1ceaa2e 100644 --- a/examples/crm/src/dataGenerator/deals.ts +++ b/examples/crm/src/dataGenerator/deals.ts @@ -1,13 +1,13 @@ -import { random, lorem } from 'faker/locale/en_US'; import { add } from 'date-fns'; +import { lorem, random } from 'faker/locale/en_US'; -import { Db } from './types'; -import { Deal } from '../types'; -import { randomDate } from './utils'; import { defaultDealCategories, defaultDealStages, } from '../root/defaultConfiguration'; +import { Deal } from '../types'; +import { Db } from './types'; +import { randomDate } from './utils'; export const generateDeals = (db: Db): Deal[] => { const deals = Array.from(Array(50).keys()).map(id => { @@ -22,10 +22,9 @@ export const generateDeals = (db: Db): Deal[] => { new Date(company.created_at) ).toISOString(); - const start_at = created_at; - const expecting_closing_date = randomDate( - new Date(start_at), - add(new Date(start_at), { months: 6 }) + const expected_closing_date = randomDate( + new Date(created_at), + add(new Date(created_at), { months: 6 }) ).toISOString(); return { @@ -37,10 +36,9 @@ export const generateDeals = (db: Db): Deal[] => { stage: random.arrayElement(defaultDealStages).value, description: lorem.paragraphs(random.number({ min: 1, max: 4 })), amount: random.number(1000) * 100, - created_at: created_at, + created_at, updated_at: randomDate(new Date(created_at)).toISOString(), - start_at, - expecting_closing_date, + expected_closing_date, sales_id: company.sales_id, index: 0, nb_notes: 0, diff --git a/examples/crm/src/deals/DealCreate.tsx b/examples/crm/src/deals/DealCreate.tsx index 79d782d95b4..c337c52865c 100644 --- a/examples/crm/src/deals/DealCreate.tsx +++ b/examples/crm/src/deals/DealCreate.tsx @@ -11,9 +11,9 @@ import { useListContext, useRedirect, } from 'react-admin'; +import { DialogCloseButton } from '../misc/DialogCloseButton'; import { Deal } from '../types'; import { DealInputs } from './DealInputs'; -import { DialogCloseButton } from '../misc/DialogCloseButton'; export const DealCreate = ({ open }: { open: boolean }) => { const redirect = useRedirect(); @@ -92,7 +92,6 @@ export const DealCreate = ({ open }: { open: boolean }) => { sales_id: identity?.id, contact_ids: [], index: 0, - start_at: new Date().toISOString(), }} > diff --git a/examples/crm/src/deals/DealInputs.tsx b/examples/crm/src/deals/DealInputs.tsx index 962c305ec45..06401b473e3 100644 --- a/examples/crm/src/deals/DealInputs.tsx +++ b/examples/crm/src/deals/DealInputs.tsx @@ -108,19 +108,11 @@ export const DealInputs = () => { /> - ); }; diff --git a/examples/crm/src/deals/DealShow.tsx b/examples/crm/src/deals/DealShow.tsx index b4bed23dffc..f5de4448926 100644 --- a/examples/crm/src/deals/DealShow.tsx +++ b/examples/crm/src/deals/DealShow.tsx @@ -112,30 +112,16 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => { - + - Starting date + Expected closing date - {format(record.start_at, 'PP')} - - - - - Expecting closing date - - - {format( - record.expecting_closing_date, - 'PP' - )} + {format(record.expected_closing_date, 'PP')} @@ -157,17 +143,23 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => { - - - Category - - - {record.category} - - + + Category + + + {record.category} + + + )} void }) => { - - + {!!record.contact_ids?.length && ( + + + + Contacts + + + + + + + )} + + {record.description && ( + - Contacts + Description + + + {record.description} - - - - - - - - Description - - - {record.description} - - + )} diff --git a/examples/crm/src/root/CRM.tsx b/examples/crm/src/root/CRM.tsx index eef1c56265b..2a6b91e6154 100644 --- a/examples/crm/src/root/CRM.tsx +++ b/examples/crm/src/root/CRM.tsx @@ -43,26 +43,6 @@ type CRMProps = { darkTheme?: RaThemeOptions; } & Partial; -// const defaultLightTheme = { -// ...defaultTheme, -// palette: { -// background: { -// default: '#fafafb', -// }, -// }, -// components: { -// RaFileInput: { -// styleOverrides: { -// root: { -// '& .RaFileInput-dropZone': { -// backgroundColor: 'MistyRose', -// }, -// }, -// }, -// }, -// }, -// }; - const defaultLightTheme = deepmerge(defaultTheme, { palette: { background: { diff --git a/examples/crm/src/sales/SalesCreate.tsx b/examples/crm/src/sales/SalesCreate.tsx index c892a7f9298..db77efc55f5 100644 --- a/examples/crm/src/sales/SalesCreate.tsx +++ b/examples/crm/src/sales/SalesCreate.tsx @@ -1,13 +1,22 @@ import { Create, PasswordInput, required, SimpleForm } from 'react-admin'; -import { SalesForm } from './SalesForm'; +import { SalesInputs } from './SalesInputs'; +import { Container, Typography } from '@mui/material'; export function SalesCreate() { return ( - - - - - - + + + + Create sale person + + + + + + ); } diff --git a/examples/crm/src/sales/SalesEdit.tsx b/examples/crm/src/sales/SalesEdit.tsx index 4996072b3f6..fb6facd299f 100644 --- a/examples/crm/src/sales/SalesEdit.tsx +++ b/examples/crm/src/sales/SalesEdit.tsx @@ -9,7 +9,8 @@ import { useRecordContext, } from 'react-admin'; import { Sale } from '../types'; -import { SalesForm } from './SalesForm'; +import { SalesInputs } from './SalesInputs'; +import { Container, Typography } from '@mui/material'; function EditToolbar() { const { identity } = useGetIdentity(); @@ -33,14 +34,28 @@ function EditToolbar() { export function SalesEdit() { return ( - <> + }> - - - + + + + - + ); } + +const SaleEditTitle = () => { + const record = useRecordContext(); + if (!record) return null; + return ( + + Edit {record?.first_name} {record?.last_name} + + ); +}; diff --git a/examples/crm/src/sales/SalesForm.tsx b/examples/crm/src/sales/SalesForm.tsx deleted file mode 100644 index 0a816cd2d0f..00000000000 --- a/examples/crm/src/sales/SalesForm.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { - BooleanInput, - required, - TextInput, - useGetIdentity, - useRecordContext, -} from 'react-admin'; -import { Sale } from '../types'; - -export function SalesForm() { - const { identity } = useGetIdentity(); - const record = useRecordContext(); - - return ( - <> - - - - - - - ); -} diff --git a/examples/crm/src/sales/SalesInputs.tsx b/examples/crm/src/sales/SalesInputs.tsx new file mode 100644 index 00000000000..f68a389c59b --- /dev/null +++ b/examples/crm/src/sales/SalesInputs.tsx @@ -0,0 +1,41 @@ +import { + BooleanInput, + required, + TextInput, + useGetIdentity, + useRecordContext, +} from 'react-admin'; +import { Sale } from '../types'; +import { ReactNode } from 'react'; +import { Stack } from '@mui/material'; + +export function SalesInputs({ children }: { children: ReactNode }) { + const { identity } = useGetIdentity(); + const record = useRecordContext(); + + return ( + + + + + {children} + + + ); +} diff --git a/examples/crm/src/sales/SalesList.tsx b/examples/crm/src/sales/SalesList.tsx index 03695e57d04..59589b80af2 100644 --- a/examples/crm/src/sales/SalesList.tsx +++ b/examples/crm/src/sales/SalesList.tsx @@ -15,7 +15,7 @@ function SalesListActions() { return ( - + ); } @@ -34,7 +34,7 @@ export function SalesList() { - + diff --git a/examples/crm/src/settings/SettingsPage.tsx b/examples/crm/src/settings/SettingsPage.tsx index bf28bf465f4..a78bcf42240 100644 --- a/examples/crm/src/settings/SettingsPage.tsx +++ b/examples/crm/src/settings/SettingsPage.tsx @@ -105,7 +105,7 @@ const SettingsForm = ({ {isEditMode ? 'Show' : 'Edit'} - + diff --git a/examples/crm/src/settings/UpdatePassword.tsx b/examples/crm/src/settings/UpdatePassword.tsx index 79006b1cf2b..12061bf2b99 100644 --- a/examples/crm/src/settings/UpdatePassword.tsx +++ b/examples/crm/src/settings/UpdatePassword.tsx @@ -8,8 +8,15 @@ import { TextField, Typography, } from '@mui/material'; -import { useGetIdentity, useGetOne, useNotify, useUpdate } from 'react-admin'; +import { + Toolbar, + useGetIdentity, + useGetOne, + useNotify, + useUpdate, +} from 'react-admin'; import { useForm } from 'react-hook-form'; +import { DialogCloseButton } from '../misc/DialogCloseButton'; const PASSWORD_POLICY = { regex: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/, // Example policy: Minimum 8 characters, at least one letter and one number @@ -75,17 +82,18 @@ export const UpdatePassword = ({ return ( + Change Password - - - Password for Jane Doe account is "demo" - -
- + + + + Password for Jane Doe account is "demo" + + - - + + + - - -
+ + +
); }; diff --git a/examples/crm/src/types.ts b/examples/crm/src/types.ts index 56ebbbd2ca4..f24e00fb06c 100644 --- a/examples/crm/src/types.ts +++ b/examples/crm/src/types.ts @@ -80,8 +80,7 @@ export interface Deal extends RaRecord { created_at: string; updated_at: string; archived_at?: string; - start_at: string; - expecting_closing_date: string; + expected_closing_date: string; sales_id: Identifier; index: number; nb_notes: number;