diff --git a/examples/crm/src/contacts/ContactAside.tsx b/examples/crm/src/contacts/ContactAside.tsx index 6e7af8d67f..f0ed014fad 100644 --- a/examples/crm/src/contacts/ContactAside.tsx +++ b/examples/crm/src/contacts/ContactAside.tsx @@ -66,33 +66,31 @@ export const ContactAside = ({ link = 'edit' }: { link?: 'edit' | 'show' }) => { /> )} - {record.phone_number1 && ( + {record.phone_number1.number && ( - {' '} - - Work - + {' '} + {record.phone_number1.type !== 'Other' && ( + + )} )} - {record.phone_number2 && ( + {record.phone_number2.number && ( - {' '} - - Home - + {' '} + {record.phone_number2.type !== 'Other' && ( + + )} )} diff --git a/examples/crm/src/contacts/ContactCreate.tsx b/examples/crm/src/contacts/ContactCreate.tsx index f3b0393d29..5e5497447e 100644 --- a/examples/crm/src/contacts/ContactCreate.tsx +++ b/examples/crm/src/contacts/ContactCreate.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { CreateBase, Form, Toolbar, useGetIdentity } from 'react-admin'; -import { Card, CardContent, Box, Avatar } from '@mui/material'; +import { Card, CardContent, Box } from '@mui/material'; import { ContactInputs } from './ContactInputs'; import { Contact } from '../types'; @@ -22,14 +22,7 @@ export const ContactCreate = () => {
- - - - - - - - + diff --git a/examples/crm/src/contacts/ContactEdit.tsx b/examples/crm/src/contacts/ContactEdit.tsx index fc9336a9e6..d906d325f5 100644 --- a/examples/crm/src/contacts/ContactEdit.tsx +++ b/examples/crm/src/contacts/ContactEdit.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { EditBase, Form, Toolbar, useEditContext } from 'react-admin'; import { Card, CardContent, Box } from '@mui/material'; -import { Avatar } from './Avatar'; import { ContactInputs } from './ContactInputs'; import { ContactAside } from './ContactAside'; import { Contact } from '../types'; @@ -22,14 +21,7 @@ const ContactEditContent = () => { - - - - - - - - + diff --git a/examples/crm/src/contacts/ContactInputs.tsx b/examples/crm/src/contacts/ContactInputs.tsx index fc90156ca7..ccd0d9d7e7 100644 --- a/examples/crm/src/contacts/ContactInputs.tsx +++ b/examples/crm/src/contacts/ContactInputs.tsx @@ -10,16 +10,25 @@ import { useCreate, useGetIdentity, useNotify, + RadioButtonGroupInput, } from 'react-admin'; -import { Divider, Box, Stack } from '@mui/material'; +import { + Divider, + Stack, + Typography, + useMediaQuery, + useTheme, +} from '@mui/material'; import { useConfigurationContext } from '../root/ConfigurationContext'; +import { Avatar } from './Avatar'; +import { Sale } from '../types'; const isLinkedinUrl = (url: string) => { if (!url) return; try { // Parse the URL to ensure it is valid const parsedUrl = new URL(url); - if (!parsedUrl.hostname.includes('linkedin.com')) { + if (!parsedUrl.hostname.startsWith('https://linkedin.com/')) { return 'URL must be from linkedin.com'; } } catch (e) { @@ -29,7 +38,64 @@ const isLinkedinUrl = (url: string) => { }; export const ContactInputs = () => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('md')); + + return ( + + + + + + + + + + + + + + + + + ); +}; + +const ContactIdentityInputs = () => { const { contactGender } = useConfigurationContext(); + return ( + + Identity + + + + + ); +}; + +const ContactPositionInputs = () => { const [create] = useCreate(); const { identity } = useGetIdentity(); const notify = useNotify(); @@ -55,87 +121,89 @@ export const ContactInputs = () => { } }; return ( - - - + Position + + + + + + ); +}; + +const ContactPersonalInformationInputs = () => { + return ( + + Personal info + + + choice.id} + choices={[{ id: 'Work' }, { id: 'Home' }, { id: 'Other' }]} + /> - - - - - - - - + - - - - - - - - choice.id} + choices={[{ id: 'Work' }, { id: 'Home' }, { id: 'Other' }]} /> - + + + ); +}; + +const ContactMiscInputs = () => { + return ( + + Misc + + + + - - - - - - - - - - - - + + ); }; + +const saleOptionRenderer = (choice: Sale) => + `${choice.first_name} ${choice.last_name}`; diff --git a/examples/crm/src/dataGenerator/contacts.ts b/examples/crm/src/dataGenerator/contacts.ts index 6a572d9925..a1fc07e38c 100644 --- a/examples/crm/src/dataGenerator/contacts.ts +++ b/examples/crm/src/dataGenerator/contacts.ts @@ -66,8 +66,14 @@ export const generateContacts = (db: Db): Contact[] => { company_id: company.id, company_name: company.name, email, - phone_number1: phone.phoneNumber(), - phone_number2: phone.phoneNumber(), + phone_number1: { + number: phone.phoneNumber(), + type: random.arrayElement(['Work', 'Home', 'Other']), + }, + phone_number2: { + number: phone.phoneNumber(), + type: random.arrayElement(['Work', 'Home', 'Other']), + }, background: lorem.sentence(), acquisition: random.arrayElement(['inbound', 'outbound']), avatar, diff --git a/examples/crm/src/types.ts b/examples/crm/src/types.ts index 0fc65b9f81..8d4374feae 100644 --- a/examples/crm/src/types.ts +++ b/examples/crm/src/types.ts @@ -56,6 +56,8 @@ export interface Contact extends RaRecord { nb_notes: number; status: string; background: string; + phone_number1: { number: string; type: 'Work' | 'Home' | 'Other' }; + phone_number2: { number: string; type: 'Work' | 'Home' | 'Other' }; } export interface ContactNote extends RaRecord {