Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Fix(deals): Company name was not displayed in deal show modal

Jonathan ARNAULTd400a1f68a45
diff --git a/src/companies/CompanyAside.tsx b/src/companies/CompanyAside.tsx
index 4a8e4721..cb628d5e 100644
--- a/src/companies/CompanyAside.tsx
+++ b/src/companies/CompanyAside.tsx
@@ -102,7 +102,7 @@ const CompanyInfo = ({ record }: { record: Company }) => {
};
const ContextInfo = ({ record }: { record: Company }) => {
- if (!record.revenue && !record.identifier) {
+ if (!record.revenue && !record.id) {
return null;
}
diff --git a/src/companies/CompanyShow.tsx b/src/companies/CompanyShow.tsx
index 29e0ea18..5580455f 100644
--- a/src/companies/CompanyShow.tsx
+++ b/src/companies/CompanyShow.tsx
@@ -228,7 +228,7 @@ const DealsIterator = () => {
currencyDisplay: 'narrowSymbol',
minimumSignificantDigits: 3,
})}
- , {deal.type}
+ {deal.category ? `, ${deal.category}` : ''}
</>
}
/>
diff --git a/src/deals/ContactList.tsx b/src/deals/ContactList.tsx
index c26e9834..513b2f2e 100644
--- a/src/deals/ContactList.tsx
+++ b/src/deals/ContactList.tsx
@@ -1,6 +1,5 @@
-import * as React from 'react';
-import { useListContext } from 'react-admin';
import { Link, Stack, Typography } from '@mui/material';
+import { useListContext } from 'react-admin';
import { Link as RouterLink } from 'react-router-dom';
import { Avatar } from '../contacts/Avatar';
diff --git a/src/deals/DealCard.tsx b/src/deals/DealCard.tsx
index 124421a8..065668dd 100644
--- a/src/deals/DealCard.tsx
+++ b/src/deals/DealCard.tsx
@@ -1,9 +1,8 @@
-import * as React from 'react';
-import { ReferenceField, useRedirect } from 'react-admin';
-import { Box, Card, Typography } from '@mui/material';
import { Draggable } from '@hello-pangea/dnd';
-import { Deal } from '../types';
+import { Box, Card, Typography } from '@mui/material';
+import { ReferenceField, useRedirect } from 'react-admin';
import { CompanyAvatar } from '../companies/CompanyAvatar';
+import { Deal } from '../types';
export const DealCard = ({ deal, index }: { deal: Deal; index: number }) => {
if (!deal) return null;
@@ -73,7 +72,7 @@ export const DealCardContent = ({
currencyDisplay: 'narrowSymbol',
minimumSignificantDigits: 3,
})}
- , {deal.category}
+ {deal.category ? `, ${deal.category}` : ''}
</Typography>
</Box>
</Box>
diff --git a/src/deals/DealShow.tsx b/src/deals/DealShow.tsx
index 230cfe97..2d10fadd 100644
--- a/src/deals/DealShow.tsx
+++ b/src/deals/DealShow.tsx
@@ -207,7 +207,7 @@ const DealShowContent = ({ handleClose }: { handleClose: () => void }) => {
</Typography>
<ReferenceArrayField
source="contact_ids"
- reference="contacts"
+ reference="contacts_summary"
>
<ContactList />
</ReferenceArrayField>
diff --git a/src/notes/Note.tsx b/src/notes/Note.tsx
index 3330b344..e7ada349 100644
--- a/src/notes/Note.tsx
+++ b/src/notes/Note.tsx
@@ -1,3 +1,5 @@
+import TrashIcon from '@mui/icons-material/Delete';
+import EditIcon from '@mui/icons-material/Edit';
import ContentSave from '@mui/icons-material/Save';
import {
Box,
@@ -17,18 +19,16 @@ import {
useUpdate,
WithRecord,
} from 'react-admin';
-import TrashIcon from '@mui/icons-material/Delete';
-import EditIcon from '@mui/icons-material/Edit';
import { FieldValues, SubmitHandler } from 'react-hook-form';
+import { CompanyAvatar } from '../companies/CompanyAvatar';
import { Avatar } from '../contacts/Avatar';
+import { RelativeDate } from '../misc/RelativeDate';
import { Status } from '../misc/Status';
+import { SaleName } from '../sales/SaleName';
import { ContactNote, DealNote } from '../types';
import { NoteAttachments } from './NoteAttachments';
import { NoteInputs } from './NoteInputs';
-import { SaleName } from '../sales/SaleName';
-import { RelativeDate } from '../misc/RelativeDate';
-import { CompanyAvatar } from '../companies/CompanyAvatar';
export const Note = ({
showStatus,
@@ -112,7 +112,10 @@ export const Note = ({
render={record => <SaleName sale={record} />}
/>
</ReferenceField>{' '}
- added a note {showStatus && <Status status={note.status} />}
+ added a note{' '}
+ {showStatus && note.status && (
+ <Status status={note.status} />
+ )}
<Box
component="span"
sx={{
diff --git a/src/types.ts b/src/types.ts
index 4429a720..8aca43e5 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,3 +1,4 @@
+import { SvgIconComponent } from '@mui/icons-material';
import { Identifier, RaRecord } from 'react-admin';
import {
COMPANY_CREATED,
@@ -6,7 +7,6 @@ import {
DEAL_CREATED,
DEAL_NOTE_CREATED,
} from './consts';
-import { SvgIconComponent } from '@mui/icons-material';
export type SignUpData = {
email: string;
@@ -29,7 +29,7 @@ export type UpdatePasswordData = {
newPassword: string;
};
-export interface Sale extends RaRecord {
+export type Sale = {
first_name: string;
last_name: string;
administrator: boolean;
@@ -40,9 +40,9 @@ export interface Sale extends RaRecord {
// This is a copy of the user's email, to make it easier to handle by react admin
// DO NOT UPDATE this field directly, it should be updated by the backend
email: string;
-}
+} & Pick<RaRecord, 'id'>;
-export interface Company extends RaRecord {
+export type Company = {
name: string;
logo: RAFile;
sector: string;
@@ -63,9 +63,9 @@ export interface Company extends RaRecord {
context_links?: string[];
nb_contacts?: number;
nb_deals?: number;
-}
+} & Pick<RaRecord, 'id'>;
-export interface Contact extends RaRecord {
+export type Contact = {
first_name: string;
last_name: string;
title: string;
@@ -85,18 +85,21 @@ export interface Contact extends RaRecord {
phone_1_number: string;
phone_2_type: 'Work' | 'Home' | 'Other';
phone_2_number: string;
-}
-export interface ContactNote extends RaRecord {
+ nb_tasks?: number;
+ company_name?: string;
+} & Pick<RaRecord, 'id'>;
+
+export type ContactNote = {
contact_id: Identifier;
text: string;
date: string;
sales_id: Identifier;
status: string;
attachments?: AttachmentNote[];
-}
+} & Pick<RaRecord, 'id'>;
-export interface Deal extends RaRecord {
+export type Deal = {
name: string;
company_id: Identifier;
contact_ids: Identifier[];
@@ -110,29 +113,32 @@ export interface Deal extends RaRecord {
expected_closing_date: string;
sales_id: Identifier;
index: number;
-}
+} & Pick<RaRecord, 'id'>;
-export interface DealNote extends RaRecord {
+export type DealNote = {
deal_id: Identifier;
text: string;
date: string;
sales_id: Identifier;
attachments?: AttachmentNote[];
-}
-export interface Tag extends RaRecord {
+ // This is defined for compatibility with `ContactNote`
+ status?: undefined;
+} & Pick<RaRecord, 'id'>;
+
+export type Tag = {
name: string;
color: string;
-}
+} & Pick<RaRecord, 'id'>;
-export interface Task extends RaRecord {
+export type Task = {
contact_id: Identifier;
type: string;
text: string;
due_date: string;
done_date?: string | null;
sales_id?: Identifier;
-}
+} & Pick<RaRecord, 'id'>;
export type ActivityCompanyCreated = {
type: typeof COMPANY_CREATED;