Skip to content

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

Fix Company labels

fzaninotto9a431c6605f6
diff --git a/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx b/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx
index 57ef0873..b258633c 100644
--- a/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx
+++ b/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx
@@ -1,4 +1,4 @@
-import { useCreate, useGetIdentity, useNotify, useTranslate } from "ra-core";
+import { useCreate, useGetIdentity, useNotify } from "ra-core";
import { AutocompleteInput } from "@/components/admin/autocomplete-input";
import type { InputProps } from "ra-core";
import { useIsMobile } from "@/hooks/use-mobile";
@@ -10,7 +10,6 @@ export const AutocompleteCompanyInput = ({
const [create] = useCreate();
const { identity } = useGetIdentity();
const notify = useNotify();
- const translate = useTranslate();
const handleCreateCompany = async (name?: string) => {
if (!name) return;
try {
@@ -43,15 +42,8 @@ export const AutocompleteCompanyInput = ({
optionText="name"
helperText={false}
onCreate={handleCreateCompany}
- createItemLabel={translate(
- "resources.companies.autocomplete.create_item",
- {
- _: "Create %{item}",
- },
- )}
- createLabel={translate("resources.companies.autocomplete.create_label", {
- _: "Start typing to create a new company",
- })}
+ createItemLabel="resources.companies.autocomplete.create_item"
+ createLabel="resources.companies.autocomplete.create_label"
validate={validate}
modal={isMobile}
/>
diff --git a/src/components/atomic-crm/companies/CompanyAside.tsx b/src/components/atomic-crm/companies/CompanyAside.tsx
index 18621d7e..7897c234 100644
--- a/src/components/atomic-crm/companies/CompanyAside.tsx
+++ b/src/components/atomic-crm/companies/CompanyAside.tsx
@@ -70,7 +70,7 @@ export const CompanyInfo = ({ record }: { record: Company }) => {
return (
<AsideSection
- title={translate("resources.companies.aside.company_info", {
+ title={translate("resources.companies.field_categories.contact", {
_: "Company info",
})}
>
@@ -127,7 +127,9 @@ export const ContextInfo = ({ record }: { record: Company }) => {
return (
<AsideSection
- title={translate("resources.companies.aside.context", { _: "Context" })}
+ title={translate("resources.companies.field_categories.context", {
+ _: "Context",
+ })}
>
{sectorLabel && (
<span>
@@ -172,7 +174,7 @@ export const AddressInfo = ({ record }: { record: Company }) => {
return (
<AsideSection
- title={translate("resources.companies.aside.main_address", {
+ title={translate("resources.companies.field_categories.address", {
_: "Main address",
})}
noGap
@@ -208,7 +210,7 @@ export const AdditionalInfo = ({ record }: { record: Company }) => {
return (
<AsideSection
- title={translate("resources.companies.aside.additional_info", {
+ title={translate("resources.companies.field_categories.additional_info", {
_: "Additional info",
})}
>
diff --git a/src/components/atomic-crm/companies/CompanyInputs.tsx b/src/components/atomic-crm/companies/CompanyInputs.tsx
index b351fc94..152a1e4c 100644
--- a/src/components/atomic-crm/companies/CompanyInputs.tsx
+++ b/src/components/atomic-crm/companies/CompanyInputs.tsx
@@ -79,7 +79,9 @@ const CompanyContactInputs = () => {
return (
<div className="flex flex-col gap-4">
<h6 className="text-lg font-semibold">
- {translate("resources.companies.inputs.contact", { _: "Contact" })}
+ {translate("resources.companies.field_categories.contact", {
+ _: "Company info",
+ })}
</h6>
<TextInput source="website" helperText={false} validate={isUrl} />
<TextInput
@@ -102,7 +104,9 @@ const CompanyContextInputs = () => {
return (
<div className="flex flex-col gap-4">
<h6 className="text-lg font-semibold">
- {translate("resources.companies.inputs.context", { _: "Context" })}
+ {translate("resources.companies.field_categories.context", {
+ _: "Context",
+ })}
</h6>
<SelectInput
source="sector"
@@ -123,7 +127,9 @@ const CompanyAddressInputs = () => {
return (
<div className="flex flex-col gap-4">
<h6 className="text-lg font-semibold">
- {translate("resources.companies.inputs.address", { _: "Address" })}
+ {translate("resources.companies.field_categories.address", {
+ _: "Address",
+ })}
</h6>
<TextInput source="address" helperText={false} />
<TextInput source="city" helperText={false} />
@@ -139,7 +145,7 @@ const CompanyAdditionalInformationInputs = () => {
return (
<div className="flex flex-col gap-4">
<h6 className="text-lg font-semibold">
- {translate("resources.companies.inputs.additional_information", {
+ {translate("resources.companies.field_categories.additional_info", {
_: "Additional information",
})}
</h6>
diff --git a/src/components/atomic-crm/companies/CompanyListFilter.tsx b/src/components/atomic-crm/companies/CompanyListFilter.tsx
index b95e2a15..901ff32c 100644
--- a/src/components/atomic-crm/companies/CompanyListFilter.tsx
+++ b/src/components/atomic-crm/companies/CompanyListFilter.tsx
@@ -24,7 +24,7 @@ export const CompanyListFilter = () => {
<FilterCategory
icon={<Building className="h-4 w-4" />}
- label={translate("resources.companies.filters.size", { _: "Size" })}
+ label="resources.companies.fields.size"
>
{translatedSizes.map((size) => (
<ToggleFilterButton
@@ -38,7 +38,7 @@ export const CompanyListFilter = () => {
<FilterCategory
icon={<Truck className="h-4 w-4" />}
- label={translate("resources.companies.filters.sector", { _: "Sector" })}
+ label="resources.companies.fields.sector"
>
{companySectors.map((sector) => (
<ToggleFilterButton
@@ -52,9 +52,7 @@ export const CompanyListFilter = () => {
<FilterCategory
icon={<Users className="h-4 w-4" />}
- label={translate("crm.common.account_manager", {
- _: "Account manager",
- })}
+ label="resources.companies.fields.sales_id"
>
<ToggleFilterButton
className="w-full justify-between"
diff --git a/src/components/atomic-crm/companies/CompanyShow.tsx b/src/components/atomic-crm/companies/CompanyShow.tsx
index ea217e70..d6a2fd19 100644
--- a/src/components/atomic-crm/companies/CompanyShow.tsx
+++ b/src/components/atomic-crm/companies/CompanyShow.tsx
@@ -124,29 +124,21 @@ const CompanyShowContent = () => {
{translate("crm.common.activity", { _: "Activity" })}
</TabsTrigger>
<TabsTrigger value="contacts">
- {record.nb_contacts
- ? record.nb_contacts === 1
- ? translate("resources.companies.contacts.one", {
- _: "1 Contact",
- })
- : translate("resources.companies.contacts.many", {
- smart_count: record.nb_contacts,
- _: `${record.nb_contacts} Contacts`,
- })
- : translate("resources.companies.contacts.none", {
+ {record.nb_contacts === 0
+ ? translate("resources.companies.no_contacts", {
_: "No Contacts",
+ })
+ : translate("resources.companies.nb_contacts", {
+ smart_count: record.nb_contacts,
+ _: `${record.nb_contacts} Contacts`,
})}
</TabsTrigger>
{record.nb_deals ? (
<TabsTrigger value="deals">
- {record.nb_deals === 1
- ? translate("resources.companies.deals.one", {
- _: "1 deal",
- })
- : translate("resources.companies.deals.many", {
- smart_count: record.nb_deals,
- _: `${record.nb_deals} deals`,
- })}
+ {translate("resources.companies.nb_deals", {
+ smart_count: record.nb_deals,
+ _: `${record.nb_deals} deals`,
+ })}
</TabsTrigger>
) : null}
</TabsList>
diff --git a/src/components/atomic-crm/contacts/ContactListFilter.tsx b/src/components/atomic-crm/contacts/ContactListFilter.tsx
index f8418ab3..d3fe13f9 100644
--- a/src/components/atomic-crm/contacts/ContactListFilter.tsx
+++ b/src/components/atomic-crm/contacts/ContactListFilter.tsx
@@ -162,9 +162,7 @@ export const ContactListFilter = () => {
<FilterCategory
icon={<Users />}
- label={translate("crm.common.account_manager", {
- _: "Account manager",
- })}
+ label="resources.contacts.fields.sales_id"
>
<ToggleFilterButton
className="w-full justify-between h-10 md:h-8"
diff --git a/src/components/atomic-crm/root/englishCrmMessages.ts b/src/components/atomic-crm/root/englishCrmMessages.ts
index 36b30bff..4da26ae2 100644
--- a/src/components/atomic-crm/root/englishCrmMessages.ts
+++ b/src/components/atomic-crm/root/englishCrmMessages.ts
@@ -27,10 +27,10 @@ export const englishCrmMessages = {
description: "It seems your company list is empty.",
title: "No companies found",
},
- inputs: {
- additional_information: "Additional information",
- address: "Address",
+ field_categories: {
contact: "Contact",
+ additional_info: "Additional information",
+ address: "Address",
context: "Context",
},
action: {
@@ -39,26 +39,9 @@ export const englishCrmMessages = {
new: "New Company",
show: "Show company",
},
- contacts: {
- many: "%{smart_count} Contacts",
- none: "No Contacts",
- one: "1 Contact",
- },
- deals: {
- many: "%{smart_count} deals",
- one: "1 deal",
- },
- aside: {
- additional_info: "Additional info",
- company_info: "Company info",
- context: "Context",
- main_address: "Main address",
- },
- filters: {
- only_mine: "Only companies I manage",
- sector: "Sector",
- size: "Size",
- },
+ no_contacts: "No contact",
+ nb_contacts: "%{smart_count} contact |||| %{smart_count} contacts",
+ nb_deals: "%{smart_count} deal |||| %{smart_count} deals",
sizes: {
one_employee: "1 employee",
two_to_nine_employees: "2-9 employees",
@@ -387,7 +370,6 @@ export const englishCrmMessages = {
retry: "Retry",
show_less: "Show less",
with: "with",
- account_manager: "Account manager",
at: "at",
copied: "Copied!",
copy: "Copy",
diff --git a/src/components/atomic-crm/root/frenchCrmMessages.ts b/src/components/atomic-crm/root/frenchCrmMessages.ts
index bc9e37c8..8b3244b4 100644
--- a/src/components/atomic-crm/root/frenchCrmMessages.ts
+++ b/src/components/atomic-crm/root/frenchCrmMessages.ts
@@ -29,10 +29,10 @@ export const frenchCrmMessages = {
description: "Il semble que la liste de vos entreprises soit vide.",
title: "Aucune entreprise trouvée",
},
- inputs: {
- additional_information: "Informations Complémentaires",
- address: "Adresse",
+ field_categories: {
contact: "Contact",
+ additional_info: "Informations supplémentaires",
+ address: "Adresse",
context: "Contexte",
},
action: {
@@ -41,26 +41,9 @@ export const frenchCrmMessages = {
new: "Nouvelle entreprise",
show: "Afficher l'entreprise",
},
- contacts: {
- many: "%{smart_count} contacts",
- none: "Aucun contact",
- one: "1 contact",
- },
- deals: {
- many: "%{smart_count} affaires",
- one: "1 affaire",
- },
- aside: {
- additional_info: "Informations supplémentaires",
- company_info: "Informations de l'entreprise",
- context: "Contexte",
- main_address: "Adresse principale",
- },
- filters: {
- only_mine: "Seulement les entreprises que je gère",
- sector: "Secteur",
- size: "Taille",
- },
+ no_contacts: "Aucun contact",
+ nb_contacts: "%{smart_count} contact |||| %{smart_count} contacts",
+ nb_deals: "%{smart_count} affaire |||| %{smart_count} affaires",
sizes: {
one_employee: "1 employé",
two_to_nine_employees: "2-9 employés",
@@ -393,7 +376,6 @@ export const frenchCrmMessages = {
show_less: "Afficher moins",
task_count: "tâche |||| tâches",
with: "avec",
- account_manager: "Responsable de compte",
at: "chez",
copied: "Copié !",
copy: "Copier",
diff --git a/src/components/atomic-crm/root/i18nProvider.test.ts b/src/components/atomic-crm/root/i18nProvider.test.ts
index c27ec901..72873fa2 100644
--- a/src/components/atomic-crm/root/i18nProvider.test.ts
+++ b/src/components/atomic-crm/root/i18nProvider.test.ts
@@ -43,12 +43,6 @@ describe("i18nProvider", () => {
expect(i18nProvider.translate("resources.deals.empty.title")).toBe(
"Aucune affaire trouvée",
);
- expect(
- i18nProvider.translate("resources.companies.filters.only_mine"),
- ).toBe("Seulement les entreprises que je gère");
- expect(i18nProvider.translate("resources.companies.contacts.none")).toBe(
- "Aucun contact",
- );
});
it("uses browser french locale when available", () => {