A full-featured CRM built with React, shadcn/ui, and Supabase.
Final adjustments
fzaninotto1863086c1138
diff --git a/doc/src/content/docs/developers/customizing.mdx b/doc/src/content/docs/developers/customizing.mdxindex 6d0103f2..808026c2 100644--- a/doc/src/content/docs/developers/customizing.mdx+++ b/doc/src/content/docs/developers/customizing.mdx@@ -89,16 +89,16 @@ The `i18nProvider` defines:- the list of available locales (`availableLocales`)- how messages are resolved for each locale-Relative date rendering is handled by `src/components/atomic-crm/misc/RelativeDate.tsx`. If you add a new locale, also update that file to load the matching `date-fns` locale so relative dates keep working in the UI.-The language switcher appears in the Profile page when more than one locale is configured.### Adding a New Language-1. Add or create the message catalog for the new locale. Use the English messages catalog as a base.-2. Merge it with base messages (Shadcn Admin Kit comes with [35 languages integrations](https://marmelab.com/ra-core/translationlocales/))-2. Edit `src/components/atomic-crm/providers/commons/i18nProvider.ts` and add the locale to the provider.-5. Start the app, switch locale from the Profile page, and verify fallback behavior.+1. Import a translation package for the base messages (Shadcn Admin Kit comes with [35 languages integrations](https://marmelab.com/ra-core/translationlocales/))+2. Create a message catalog for the CRM messages. Use the English messages catalog as a base (`src/components/atomic-crm/providers/commons/englishCrmMessages.ts`).+3. Merge these two translation files using the `mergeTranslations` utility+4. Edit `src/components/atomic-crm/providers/commons/i18nProvider.ts` and add a new locale with the merged messages to the provider.+5. Import the new locale for date formatting in `src/components/atomic-crm/misc/RelativeDate.tsx`.+6. Start the app, switch locale from the Profile page, and verify that the new locale is working as expected.### Type-Checking Message Catalogsdiff --git a/registry.json b/registry.jsonindex 36877dbb..3ba08596 100644--- a/registry.json+++ b/registry.json@@ -137,10 +137,6 @@"path": "src/components/atomic-crm/simple-list/ListNoResults.tsx","type": "registry:component"},- {- "path": "src/components/atomic-crm/settings/validateItemsInUse.ts",- "type": "registry:component"- },{"path": "src/components/atomic-crm/settings/SettingsPage.tsx","type": "registry:component"diff --git a/src/components/admin/filter-form.tsx b/src/components/admin/filter-form.tsxindex d9899c33..0b04d95d 100644--- a/src/components/admin/filter-form.tsx+++ b/src/components/admin/filter-form.tsx@@ -373,6 +373,7 @@ export const FilterButton = (props: FilterButtonProps) => {><BookmarkMinus className="h-4 w-4 mr-2" />{translate("ra.saved_queries.remove_label_with_name", {+ _: 'Remove query "%{name}"',name: savedQuery.label,})}</DropdownMenuItem>@@ -403,7 +404,9 @@ export const FilterButton = (props: FilterButtonProps) => {{hasFilterValues && !hasSavedCurrentQuery && !disableSaveQuery && (<DropdownMenuItem onClick={showAddSavedQueryDialog}><BookmarkPlus className="h-4 w-4 mr-2" />- {translate("ra.saved_queries.new_label")}+ {translate("ra.saved_queries.new_label", {+ _: "Save current query...",+ })}</DropdownMenuItem>)}{hasFilterValues && (@@ -414,7 +417,9 @@ export const FilterButton = (props: FilterButtonProps) => {}}><X className="h-4 w-4 mr-2" />- {translate("ra.action.remove_all_filters")}+ {translate("ra.action.remove_all_filters", {+ _: "Remove all filters",+ })}</DropdownMenuItem>)}</DropdownMenuContent>diff --git a/src/components/atomic-crm/contacts/ContactListFilter.tsx b/src/components/atomic-crm/contacts/ContactListFilter.tsxindex 57f17720..eb459074 100644--- a/src/components/atomic-crm/contacts/ContactListFilter.tsx+++ b/src/components/atomic-crm/contacts/ContactListFilter.tsx@@ -105,7 +105,7 @@ export const ContactListFilter = () => {))}</FilterCategory>- <FilterCategory label="resources.tags.name" icon={<Tag />}>+ <FilterCategory label="resources.contacts.filters.tags" icon={<Tag />}>{data &&data.map((record) => (<ToggleFilterButton@@ -128,7 +128,10 @@ export const ContactListFilter = () => {))}</FilterCategory>- <FilterCategory icon={<CheckSquare />} label="resources.tasks.name">+ <FilterCategory+ icon={<CheckSquare />}+ label="resources.contacts.filters.tasks"+ ><ToggleFilterButtonclassName="w-full justify-between h-10 md:h-8"label="resources.tasks.filters.with_pending"diff --git a/src/components/atomic-crm/contacts/ContactShow.tsx b/src/components/atomic-crm/contacts/ContactShow.tsxindex 4d3c3d68..3422e910 100644--- a/src/components/atomic-crm/contacts/ContactShow.tsx+++ b/src/components/atomic-crm/contacts/ContactShow.tsx@@ -2,7 +2,6 @@ import { useState } from "react";import {RecordRepresentation,ShowBase,- useReferenceManyFieldController,useShowContext,useTranslate,} from "ra-core";@@ -135,7 +134,9 @@ const ContactShowContentMobile = () => {{translate("resources.notes.name", { smart_count: 2 })}</TabsTrigger><TabsTrigger value="tasks">- <PendingTasksTabLabel />+ {translate("crm.common.task_count", {+ smart_count: record.nb_tasks,+ })}</TabsTrigger><TabsTrigger value="details">{translate("crm.common.details")}@@ -221,20 +222,6 @@ const ContactShowContentMobile = () => {);};-const PendingTasksTabLabel = () => {- const translate = useTranslate();- const { total = 0 } = useReferenceManyFieldController<Contact>({- filter: { "done_date@is": null },- page: 1,- perPage: 1,- reference: "tasks",- source: "id",- target: "contact_id",- });-- return translate("crm.common.task_count", { smart_count: total });-};-const ContactShowContent = () => {const translate = useTranslate();const { record, isPending } = useShowContext<Contact>();diff --git a/src/components/atomic-crm/dashboard/Welcome.tsx b/src/components/atomic-crm/dashboard/Welcome.tsxindex 416e4e8d..ecadb143 100644--- a/src/components/atomic-crm/dashboard/Welcome.tsx+++ b/src/components/atomic-crm/dashboard/Welcome.tsx@@ -1,45 +1,41 @@-import { useTranslate } from "ra-core";import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";-export const Welcome = () => {- const translate = useTranslate();-- return (- <Card>- <CardHeader className="px-4">- <CardTitle>{translate("crm.dashboard.welcome.title")}</CardTitle>- </CardHeader>- <CardContent className="px-4">- <p className="text-sm mb-4">- <a- href="https://marmelab.com/atomic-crm"- className="underline hover:no-underline"- >- Atomic CRM- </a>{" "}- {translate("crm.dashboard.welcome.paragraph_1")}- </p>- <p className="text-sm mb-4">- {translate("crm.dashboard.welcome.paragraph_2")}- </p>- <p className="text-sm">- {translate("crm.dashboard.welcome.powered_by")}{" "}- <a- href="https://marmelab.com/shadcn-admin-kit"- className="underline hover:no-underline"- >- shadcn-admin-kit- </a>{" "}- {translate("crm.dashboard.welcome.paragraph_3")}{" "}- <a- href="https://github.com/marmelab/atomic-crm"- className="underline hover:no-underline"- >- marmelab/atomic-crm- </a>- .- </p>- </CardContent>- </Card>- );-};+export const Welcome = () => (+ <Card>+ <CardHeader className="px-4">+ <CardTitle>Your CRM Starter Kit</CardTitle>+ </CardHeader>+ <CardContent className="px-4">+ <p className="text-sm mb-4">+ <a+ href="https://marmelab.com/atomic-crm"+ className="underline hover:no-underline"+ >+ Atomic CRM+ </a>{" "}+ is a template designed to help you quickly build your own CRM.+ </p>+ <p className="text-sm mb-4">+ This demo runs on a mock API, so you can explore and modify the data. It+ resets on reload. The full version uses Supabase for the backend.+ </p>+ <p className="text-sm">+ Powered by{" "}+ <a+ href="https://marmelab.com/shadcn-admin-kit"+ className="underline hover:no-underline"+ >+ shadcn-admin-kit+ </a>+ , Atomic CRM is fully open-source. You can find the code at{" "}+ <a+ href="https://github.com/marmelab/atomic-crm"+ className="underline hover:no-underline"+ >+ marmelab/atomic-crm+ </a>+ .+ </p>+ </CardContent>+ </Card>+);diff --git a/src/components/atomic-crm/notes/NoteCreate.tsx b/src/components/atomic-crm/notes/NoteCreate.tsxindex 6317a90f..9a5e50c0 100644--- a/src/components/atomic-crm/notes/NoteCreate.tsx+++ b/src/components/atomic-crm/notes/NoteCreate.tsx@@ -100,9 +100,7 @@ const NoteCreateButton = ({<div className="flex justify-end"><SaveButtontype="button"- label={translate("resources.notes.action.add_this", {- _: "Add this note",- })}+ label={translate("resources.notes.action.add_this")}transform={(data) => ({...data,[foreignKeyMapping[reference]]: record.id,@@ -112,9 +110,7 @@ const NoteCreateButton = ({mutationOptions={{onSuccess: handleSuccess,}}- >- {translate("resources.notes.action.add_this")}- </SaveButton>+ /></div>);};diff --git a/src/components/atomic-crm/notes/NoteCreateSheet.tsx b/src/components/atomic-crm/notes/NoteCreateSheet.tsxindex 6e861feb..3e107b84 100644--- a/src/components/atomic-crm/notes/NoteCreateSheet.tsx+++ b/src/components/atomic-crm/notes/NoteCreateSheet.tsx@@ -1,9 +1,9 @@import {type Identifier,- RecordRepresentation,useDataProvider,useGetIdentity,useGetOne,+ useGetRecordRepresentation,useNotify,useRedirect,useTranslate,@@ -38,6 +38,7 @@ export const NoteCreateSheet = ({const notify = useNotify();const redirect = useRedirect();const translate = useTranslate();+ const getContactRepresentation = useGetRecordRepresentation("contacts");if (!identity) return null;@@ -68,14 +69,10 @@ export const NoteCreateSheet = ({title={<h1 className="text-xl font-semibold truncate pr-10">{!selectContact- ? translate("resources.notes.sheet.create_for")+ ? translate("resources.notes.sheet.create_for", {+ name: getContactRepresentation(contact!),+ }): translate("resources.notes.sheet.create")}- {!selectContact && (- <>- {" "}- <RecordRepresentation record={contact} resource="contacts" />- </>- )}</h1>}redirect={false}diff --git a/src/components/atomic-crm/notes/NoteEditSheet.tsx b/src/components/atomic-crm/notes/NoteEditSheet.tsxindex b87b7998..7fc2dc21 100644--- a/src/components/atomic-crm/notes/NoteEditSheet.tsx+++ b/src/components/atomic-crm/notes/NoteEditSheet.tsx@@ -1,8 +1,8 @@import { DeleteButton, ReferenceField } from "@/components/admin";import {type Identifier,- RecordRepresentation,useCreatePath,+ useGetRecordRepresentation,useTranslate,WithRecord,} from "ra-core";@@ -30,6 +30,7 @@ export const NoteEditSheet = ({id: record ? record[foreignKeyMapping["contacts"]] : undefined,});};+ const getContactRepresentation = useGetRecordRepresentation("contacts");return (<EditSheet@@ -41,17 +42,11 @@ export const NoteEditSheet = ({reference="contacts"render={({ referenceRecord }) => (<h1 className="text-xl font-semibold truncate pr-10">- {referenceRecord ? (- <>- {translate("resources.notes.sheet.edit_for")}{" "}- <RecordRepresentation- record={referenceRecord}- resource="contacts"- />- </>- ) : (- translate("resources.notes.sheet.edit")- )}+ {referenceRecord+ ? translate("resources.notes.sheet.edit_for", {+ name: getContactRepresentation(referenceRecord),+ })+ : translate("resources.notes.sheet.edit")}</h1>)}/>diff --git a/src/components/atomic-crm/providers/commons/englishCrmMessages.ts b/src/components/atomic-crm/providers/commons/englishCrmMessages.tsindex 678eaf88..5a893597 100644--- a/src/components/atomic-crm/providers/commons/englishCrmMessages.ts+++ b/src/components/atomic-crm/providers/commons/englishCrmMessages.ts@@ -162,6 +162,8 @@ export const englishCrmMessages = {search: "Search name, company...",this_week: "This week",today: "Today",+ tags: "Tags",+ tasks: "Tasks",},hot: {empty_change_status:@@ -234,9 +236,9 @@ export const englishCrmMessages = {},sheet: {create: "Create note",- create_for: "Create note for",+ create_for: "Create note for %{name}",edit: "Edit note",- edit_for: "Edit note for",+ edit_for: "Edit note for %{name}",},deleted: "Note deleted",empty: "No notes yet",@@ -305,11 +307,11 @@ export const englishCrmMessages = {deleted: "Task deleted successfully",dialog: {create: "Create task",- create_for: "Create task for",+ create_for: "Create task for %{name}",},sheet: {edit: "Edit task",- edit_for: "Edit task for",+ edit_for: "Edit task for %{name}",},empty: "No tasks yet",empty_list_hint: "Tasks added to your contacts will appear here.",@@ -395,16 +397,6 @@ export const englishCrmMessages = {latest_activity_error: "Error loading latest activity",latest_notes: "My Latest Notes",latest_notes_added_ago: "added %{timeAgo}",- welcome: {- paragraph_1:- "is a template designed to help you quickly build your own CRM.",- paragraph_2:- "This demo runs on a mock API, so you can explore and modify the data. It resets on reload. The full version uses Supabase for the backend.",- paragraph_3:- "Atomic CRM is fully open-source. You can find the code at",- powered_by: "Powered by",- title: "Your CRM Starter Kit",- },stepper: {install: "Install Atomic CRM",progress: "%{step}/3 done",diff --git a/src/components/atomic-crm/providers/commons/frenchCrmMessages.ts b/src/components/atomic-crm/providers/commons/frenchCrmMessages.tsindex ad6e4636..155847a6 100644--- a/src/components/atomic-crm/providers/commons/frenchCrmMessages.ts+++ b/src/components/atomic-crm/providers/commons/frenchCrmMessages.ts@@ -166,6 +166,8 @@ export const frenchCrmMessages = {search: "Rechercher nom, entreprise...",this_week: "Cette semaine",today: "Aujourd'hui",+ tags: "Étiquettes",+ tasks: "Tâches",},hot: {empty_change_status:@@ -238,9 +240,9 @@ export const frenchCrmMessages = {},sheet: {create: "Créer une note",- create_for: "Créer une note pour",+ create_for: "Créer une note pour %{name}",edit: "Modifier la note",- edit_for: "Modifier la note pour",+ edit_for: "Modifier la note pour %{name}",},deleted: "Note supprimée",empty: "Aucune note pour l'instant",@@ -310,11 +312,11 @@ export const frenchCrmMessages = {deleted: "Tâche supprimée avec succès",dialog: {create: "Créer une tâche",- create_for: "Créer une tâche pour",+ create_for: "Créer une tâche pour %{name}",},sheet: {edit: "Modifier la tâche",- edit_for: "Modifier la tâche pour",+ edit_for: "Modifier la tâche pour %{name}",},empty: "Aucune tâche pour l'instant",empty_list_hint: "Les tâches ajoutées à vos contacts apparaîtront ici.",@@ -401,16 +403,6 @@ export const frenchCrmMessages = {"Erreur lors du chargement de la dernière activité",latest_notes: "Mes dernières notes",latest_notes_added_ago: "ajouté %{timeAgo}",- welcome: {- paragraph_1:- "est un template conçu pour vous aider à créer rapidement votre propre CRM.",- paragraph_2:- "Cette démo fonctionne avec une API mockée, afin que vous puissiez explorer et modifier les données. Elle se réinitialise au rechargement. La version complète utilise Supabase comme backend.",- paragraph_3:- "Atomic CRM est entièrement open source. Vous pouvez retrouver le code sur",- powered_by: "Propulsé par",- title: "Votre kit de démarrage CRM",- },stepper: {install: "Installer Atomic CRM",progress: "%{step}/3 terminé",diff --git a/src/components/atomic-crm/sales/SalesEdit.tsx b/src/components/atomic-crm/sales/SalesEdit.tsxindex 8befa7a5..db9a7d3e 100644--- a/src/components/atomic-crm/sales/SalesEdit.tsx+++ b/src/components/atomic-crm/sales/SalesEdit.tsx@@ -94,7 +94,6 @@ const SaleEditTitle = () => {<h2 className="text-lg font-semibold mb-4">{translate("resources.sales.edit.title", {name: `${record.first_name} ${record.last_name}`,- _: `Edit ${record.first_name} ${record.last_name}`,})}</h2>);diff --git a/src/components/atomic-crm/sales/SalesList.tsx b/src/components/atomic-crm/sales/SalesList.tsxindex 2648e137..7cfce18b 100644--- a/src/components/atomic-crm/sales/SalesList.tsx+++ b/src/components/atomic-crm/sales/SalesList.tsx@@ -8,14 +8,12 @@ import { Badge } from "@/components/ui/badge";import { TopToolbar } from "../layout/TopToolbar";-const SalesListActions = () => {- return (- <TopToolbar>- <ExportButton />- <CreateButton label="resources.sales.action.new" />- </TopToolbar>- );-};+const SalesListActions = () => (+ <TopToolbar>+ <ExportButton />+ <CreateButton label="resources.sales.action.new" />+ </TopToolbar>+);const filters = [<SearchInput source="q" alwaysOn />];@@ -46,24 +44,16 @@ const OptionsField = (_props: { label?: string | boolean }) => {};export function SalesList() {- const translate = useTranslate();return (<List- title={translate("resources.sales.name", { smart_count: 2 })}filters={filters}actions={<SalesListActions />}sort={{ field: "first_name", order: "ASC" }}><DataTable>- <DataTable.Col- source="first_name"- label="resources.sales.fields.first_name"- />- <DataTable.Col- source="last_name"- label="resources.sales.fields.last_name"- />- <DataTable.Col source="email" label="resources.sales.fields.email" />+ <DataTable.Col source="first_name" />+ <DataTable.Col source="last_name" />+ <DataTable.Col source="email" /><DataTable.Col label={false}><OptionsField /></DataTable.Col>diff --git a/src/components/atomic-crm/settings/SettingsPage.test.ts b/src/components/atomic-crm/settings/SettingsPage.test.tsindex 53e1e2cb..712a3f42 100644--- a/src/components/atomic-crm/settings/SettingsPage.test.ts+++ b/src/components/atomic-crm/settings/SettingsPage.test.ts@@ -1,6 +1,6 @@import { describe, it, expect } from "vitest";import type { RaRecord } from "ra-core";-import { validateItemsInUse } from "./validateItemsInUse";+import { validateItemsInUse } from "./SettingsPage";describe("validateItemsInUse", () => {const deals: RaRecord[] = [diff --git a/src/components/atomic-crm/settings/SettingsPage.tsx b/src/components/atomic-crm/settings/SettingsPage.tsxindex 1cb5fd9e..aedba409 100644--- a/src/components/atomic-crm/settings/SettingsPage.tsx+++ b/src/components/atomic-crm/settings/SettingsPage.tsx@@ -1,4 +1,6 @@+/* eslint-disable react-refresh/only-export-components */import { RotateCcw, Save } from "lucide-react";+import type { RaRecord } from "ra-core";import {EditBase,Form,@@ -24,7 +26,6 @@ import {type ConfigurationContextValue,} from "../root/ConfigurationContext";import { defaultConfiguration } from "../root/defaultConfiguration";-import { validateItemsInUse } from "./validateItemsInUse";const SECTIONS = [{@@ -46,6 +47,61 @@ const SECTIONS = [const ensureValues = (items: { value?: string; label: string }[] | undefined) =>items?.map((item) => ({ ...item, value: item.value || toSlug(item.label) }));+type ValidateItemsInUseMessages = {+ duplicate?: (displayName: string, duplicates: string[]) => string;+ inUse?: (displayName: string, inUse: string[]) => string;+ validating?: string;+};++/**+ * Validate that no items were removed if they are still referenced by existing deals.+ * Also rejects duplicate slug values.+ * Returns undefined if valid, or an error message string.+ */+export const validateItemsInUse = (+ items: { value: string; label: string }[] | undefined,+ deals: RaRecord[] | undefined,+ fieldName: string,+ displayName: string,+ messages?: ValidateItemsInUseMessages,+) => {+ if (!items) return undefined;+ // Check for duplicate slugs+ const slugs = items.map((i) => i.value || toSlug(i.label));+ const seen = new Set<string>();+ const duplicates = new Set<string>();+ for (const slug of slugs) {+ if (seen.has(slug)) duplicates.add(slug);+ seen.add(slug);+ }+ if (duplicates.size > 0) {+ const duplicatesList = [...duplicates];+ return (+ messages?.duplicate?.(displayName, duplicatesList) ??+ `Duplicate ${displayName}: ${duplicatesList.join(", ")}`+ );+ }+ // Check that no in-use value was removed (skip if deals haven't loaded)+ if (!deals) return messages?.validating ?? "Validating…";+ const values = new Set(slugs);+ const inUse = [+ ...new Set(+ deals+ .filter(+ (deal) => deal[fieldName] && !values.has(deal[fieldName] as string),+ )+ .map((deal) => deal[fieldName] as string),+ ),+ ];+ if (inUse.length > 0) {+ return (+ messages?.inUse?.(displayName, inUse) ??+ `Cannot remove ${displayName} that are still used by deals: ${inUse.join(", ")}`+ );+ }+ return undefined;+};+const transformFormValues = (data: Record<string, any>) => ({config: {title: data.title,diff --git a/src/components/atomic-crm/settings/validateItemsInUse.ts b/src/components/atomic-crm/settings/validateItemsInUse.tsdeleted file mode 100644index 3594fdc0..00000000--- a/src/components/atomic-crm/settings/validateItemsInUse.ts+++ /dev/null@@ -1,57 +0,0 @@-import type { RaRecord } from "ra-core";-import { toSlug } from "@/lib/toSlug";--type ValidateItemsInUseMessages = {- duplicate?: (displayName: string, duplicates: string[]) => string;- inUse?: (displayName: string, inUse: string[]) => string;- validating?: string;-};--/**- * Validate that no items were removed if they are still referenced by existing deals.- * Also rejects duplicate slug values.- * Returns undefined if valid, or an error message string.- */-export const validateItemsInUse = (- items: { value: string; label: string }[] | undefined,- deals: RaRecord[] | undefined,- fieldName: string,- displayName: string,- messages?: ValidateItemsInUseMessages,-) => {- if (!items) return undefined;- // Check for duplicate slugs- const slugs = items.map((i) => i.value || toSlug(i.label));- const seen = new Set<string>();- const duplicates = new Set<string>();- for (const slug of slugs) {- if (seen.has(slug)) duplicates.add(slug);- seen.add(slug);- }- if (duplicates.size > 0) {- const duplicatesList = [...duplicates];- return (- messages?.duplicate?.(displayName, duplicatesList) ??- `Duplicate ${displayName}: ${duplicatesList.join(", ")}`- );- }- // Check that no in-use value was removed (skip if deals haven't loaded)- if (!deals) return messages?.validating ?? "Validating…";- const values = new Set(slugs);- const inUse = [- ...new Set(- deals- .filter(- (deal) => deal[fieldName] && !values.has(deal[fieldName] as string),- )- .map((deal) => deal[fieldName] as string),- ),- ];- if (inUse.length > 0) {- return (- messages?.inUse?.(displayName, inUse) ??- `Cannot remove ${displayName} that are still used by deals: ${inUse.join(", ")}`- );- }- return undefined;-};diff --git a/src/components/atomic-crm/tasks/AddTask.tsx b/src/components/atomic-crm/tasks/AddTask.tsxindex 6f895e85..9f6decef 100644--- a/src/components/atomic-crm/tasks/AddTask.tsx+++ b/src/components/atomic-crm/tasks/AddTask.tsx@@ -2,9 +2,9 @@ import { Plus } from "lucide-react";import {CreateBase,Form,- RecordRepresentation,useDataProvider,useGetIdentity,+ useGetRecordRepresentation,useNotify,useRecordContext,useTranslate,@@ -46,6 +46,7 @@ export const AddTask = ({const handleOpen = () => {setOpen(true);};+ const getContactRepresentation = useGetRecordRepresentation("contacts");const handleSuccess = async (data: any) => {setOpen(false);@@ -60,9 +61,7 @@ export const AddTask = ({previousData: contact.data,});- notify("resources.tasks.added", {- messageArgs: { _: "Task added" },- });+ notify("resources.tasks.added");};if (!identity) return null;@@ -117,17 +116,10 @@ export const AddTask = ({<DialogHeader><DialogTitle>{!selectContact- ? translate("resources.tasks.dialog.create_for")+ ? translate("resources.tasks.dialog.create_for", {+ name: getContactRepresentation(contact!),+ }): translate("resources.tasks.dialog.create")}- {!selectContact && (- <>- {" "}- <RecordRepresentation- record={contact}- resource="contacts"- />- </>- )}</DialogTitle></DialogHeader><TaskFormContent selectContact={selectContact} />diff --git a/src/components/atomic-crm/tasks/Task.tsx b/src/components/atomic-crm/tasks/Task.tsxindex f44bfa62..a4e856c5 100644--- a/src/components/atomic-crm/tasks/Task.tsx+++ b/src/components/atomic-crm/tasks/Task.tsx@@ -2,6 +2,7 @@ import { useQueryClient } from "@tanstack/react-query";import { MoreVertical } from "lucide-react";import {useDeleteWithUndoController,+ useGetRecordRepresentation,useNotify,useTranslate,useUpdate,@@ -36,6 +37,7 @@ export const Task = ({const notify = useNotify();const translate = useTranslate();const queryClient = useQueryClient();+ const getContactRepresentation = useGetRecordRepresentation("contacts");const [openEdit, setOpenEdit] = useState(false);@@ -132,12 +134,11 @@ export const Task = ({className="inline text-sm text-muted-foreground"render={({ referenceRecord }) => {if (!referenceRecord) return null;- const name = `${referenceRecord.first_name} ${referenceRecord.last_name}`;return (<>{" "}{translate("resources.tasks.regarding_contact", {- name,+ name: getContactRepresentation(referenceRecord),})}</>);diff --git a/src/components/atomic-crm/tasks/TaskCreateSheet.tsx b/src/components/atomic-crm/tasks/TaskCreateSheet.tsxindex ab3d07d9..f5546ede 100644--- a/src/components/atomic-crm/tasks/TaskCreateSheet.tsx+++ b/src/components/atomic-crm/tasks/TaskCreateSheet.tsx@@ -1,9 +1,9 @@import {type Identifier,- RecordRepresentation,useDataProvider,useGetIdentity,useGetOne,+ useGetRecordRepresentation,useNotify,useTranslate,useUpdate,@@ -25,6 +25,7 @@ export const TaskCreateSheet = ({}: TaskCreateSheetProps) => {const { identity } = useGetIdentity();const translate = useTranslate();+ const getContactRepresentation = useGetRecordRepresentation("contacts");const selectContact = contact_id == null;const { data: contact } = useGetOne(@@ -50,9 +51,7 @@ export const TaskCreateSheet = ({data: { last_seen: new Date().toISOString() },previousData: contact,});- notify("resources.tasks.added", {- messageArgs: { _: "Task added" },- });+ notify("resources.tasks.added");// No redirect, only close the sheetonOpenChange(false);};@@ -63,14 +62,10 @@ export const TaskCreateSheet = ({title={<h1 className="text-xl font-semibold truncate pr-10">{!selectContact- ? translate("resources.tasks.dialog.create_for")+ ? translate("resources.tasks.dialog.create_for", {+ name: getContactRepresentation(contact!),+ }): translate("resources.tasks.dialog.create")}- {!selectContact && (- <>- {" "}- <RecordRepresentation record={contact} resource="contacts" />- </>- )}</h1>}redirect={false}diff --git a/src/components/atomic-crm/tasks/TaskEdit.tsx b/src/components/atomic-crm/tasks/TaskEdit.tsxindex ff4ce1b5..105546a8 100644--- a/src/components/atomic-crm/tasks/TaskEdit.tsx+++ b/src/components/atomic-crm/tasks/TaskEdit.tsx@@ -41,9 +41,6 @@ export const TaskEdit = ({notify("resources.tasks.updated", {type: "info",undoable: true,- messageArgs: {- _: "Task updated",- },});},}}@@ -65,9 +62,6 @@ export const TaskEdit = ({notify("resources.tasks.deleted", {type: "info",undoable: true,- messageArgs: {- _: "Task deleted",- },});},}}diff --git a/src/components/atomic-crm/tasks/TaskEditSheet.tsx b/src/components/atomic-crm/tasks/TaskEditSheet.tsxindex 7ce9b836..af16031a 100644--- a/src/components/atomic-crm/tasks/TaskEditSheet.tsx+++ b/src/components/atomic-crm/tasks/TaskEditSheet.tsx@@ -1,5 +1,6 @@import { DeleteButton, ReferenceField } from "@/components/admin";-import { type Identifier, RecordRepresentation, useTranslate } from "ra-core";+import type { Identifier } from "ra-core";+import { useGetRecordRepresentation, useTranslate } from "ra-core";import { EditSheet } from "../misc/EditSheet";import { TaskFormContent } from "./TaskFormContent";@@ -15,6 +16,7 @@ export const TaskEditSheet = ({taskId,}: TaskEditSheetProps) => {const translate = useTranslate();+ const getContactRepresentation = useGetRecordRepresentation("contacts");return (<EditSheetresource="tasks"@@ -25,17 +27,11 @@ export const TaskEditSheet = ({reference="contacts"render={({ referenceRecord }) => (<h1 className="text-xl font-semibold truncate pr-10">- {referenceRecord ? (- <>- {translate("resources.tasks.sheet.edit_for")}{" "}- <RecordRepresentation- record={referenceRecord}- resource="contacts"- />- </>- ) : (- translate("resources.tasks.sheet.edit")- )}+ {referenceRecord+ ? translate("resources.tasks.sheet.edit_for", {+ name: getContactRepresentation(referenceRecord),+ })+ : translate("resources.tasks.sheet.edit")}</h1>)}/>diff --git a/src/components/atomic-crm/tasks/TaskFormContent.tsx b/src/components/atomic-crm/tasks/TaskFormContent.tsxindex 32df2df1..ca821ae2 100644--- a/src/components/atomic-crm/tasks/TaskFormContent.tsx+++ b/src/components/atomic-crm/tasks/TaskFormContent.tsx@@ -27,6 +27,7 @@ export const TaskFormContent = ({{selectContact && (<ReferenceInput source="contact_id" reference="contacts_summary"><AutocompleteInput+ label="resources.tasks.fields.contact_id"optionText={contactOptionText}helperText={false}validate={required()}diff --git a/src/components/atomic-crm/tasks/TasksListContent.tsx b/src/components/atomic-crm/tasks/TasksListContent.tsxindex a427c837..418be46b 100644--- a/src/components/atomic-crm/tasks/TasksListContent.tsx+++ b/src/components/atomic-crm/tasks/TasksListContent.tsx@@ -8,9 +8,7 @@ export const TasksListContent = () => {<TasksListByDueDateemptyPlaceholder={<p className="text-sm">- {translate("resources.tasks.empty_list_hint", {- _: "Tasks added to your contacts will appear here.",- })}+ {translate("resources.tasks.empty_list_hint")}</p>}/>