Skip to content

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

Remove i18n translation helpers for settings-defined data

Anibal Svarcas5b78e00e97f9
diff --git a/src/components/atomic-crm/companies/CompanyAside.tsx b/src/components/atomic-crm/companies/CompanyAside.tsx
index d5f7a6b3..cb646414 100644
--- a/src/components/atomic-crm/companies/CompanyAside.tsx
+++ b/src/components/atomic-crm/companies/CompanyAside.tsx
@@ -13,7 +13,6 @@ import { AsideSection } from "../misc/AsideSection";
import { useConfigurationContext } from "../root/ConfigurationContext";
import { SaleName } from "../sales/SaleName";
import type { Company } from "../types";
-import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
import { getTranslatedCompanySizeLabel } from "./getTranslatedCompanySizeLabel";
import { sizes } from "./sizes";
@@ -121,9 +120,7 @@ export const ContextInfo = ({ record }: { record: Company }) => {
}
const sector = companySectors.find((s) => s.value === record.sector);
- const sectorLabel = sector
- ? getTranslatedCompanySectorLabel(sector, translate)
- : undefined;
+ const sectorLabel = sector?.label;
const translatedSizes = sizes.map((size) => ({
...size,
name: getTranslatedCompanySizeLabel(size, translate),
diff --git a/src/components/atomic-crm/companies/CompanyCard.tsx b/src/components/atomic-crm/companies/CompanyCard.tsx
index 55c28eaf..1e08d6d9 100644
--- a/src/components/atomic-crm/companies/CompanyCard.tsx
+++ b/src/components/atomic-crm/companies/CompanyCard.tsx
@@ -1,31 +1,22 @@
import { DollarSign } from "lucide-react";
import { Link } from "react-router";
-import {
- useCreatePath,
- useListContext,
- useRecordContext,
- useTranslate,
-} from "ra-core";
+import { useCreatePath, useListContext, useRecordContext } from "ra-core";
import { ReferenceManyField } from "@/components/admin/reference-many-field";
import { Card } from "@/components/ui/card";
import { Avatar as ContactAvatar } from "../contacts/Avatar";
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Company } from "../types";
-import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
import { CompanyAvatar } from "./CompanyAvatar";
export const CompanyCard = (props: { record?: Company }) => {
const createPath = useCreatePath();
const record = useRecordContext<Company>(props);
const { companySectors } = useConfigurationContext();
- const translate = useTranslate();
if (!record) return null;
const sector = companySectors.find((s) => s.value === record.sector);
- const sectorLabel = sector
- ? getTranslatedCompanySectorLabel(sector, translate)
- : undefined;
+ const sectorLabel = sector?.label;
return (
<Link
diff --git a/src/components/atomic-crm/companies/CompanyInputs.tsx b/src/components/atomic-crm/companies/CompanyInputs.tsx
index 5c4e4867..e96f77db 100644
--- a/src/components/atomic-crm/companies/CompanyInputs.tsx
+++ b/src/components/atomic-crm/companies/CompanyInputs.tsx
@@ -11,7 +11,6 @@ import ImageEditorField from "../misc/ImageEditorField";
import { isLinkedinUrl } from "../misc/isLinkedInUrl";
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Company, Sale } from "../types";
-import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
import { getTranslatedCompanySizeLabel } from "./getTranslatedCompanySizeLabel";
import { sizes } from "./sizes";
@@ -105,10 +104,6 @@ const CompanyContactInputs = () => {
const CompanyContextInputs = () => {
const translate = useTranslate();
const { companySectors } = useConfigurationContext();
- const translatedCompanySectors = companySectors.map((sector) => ({
- ...sector,
- label: getTranslatedCompanySectorLabel(sector, translate),
- }));
const translatedSizes = sizes.map((size) => ({
...size,
name: getTranslatedCompanySizeLabel(size, translate),
@@ -121,7 +116,7 @@ const CompanyContextInputs = () => {
<SelectInput
source="sector"
label="crm.companies.fields.sector"
- choices={translatedCompanySectors}
+ choices={companySectors}
optionText="label"
optionValue="value"
helperText={false}
diff --git a/src/components/atomic-crm/companies/CompanyListFilter.tsx b/src/components/atomic-crm/companies/CompanyListFilter.tsx
index f7102768..3351bd20 100644
--- a/src/components/atomic-crm/companies/CompanyListFilter.tsx
+++ b/src/components/atomic-crm/companies/CompanyListFilter.tsx
@@ -5,7 +5,6 @@ import { SearchInput } from "@/components/admin/search-input";
import { FilterCategory } from "../filters/FilterCategory";
import { useConfigurationContext } from "../root/ConfigurationContext";
-import { getTranslatedCompanySectorLabel } from "./getTranslatedCompanySectorLabel";
import { getTranslatedCompanySizeLabel } from "./getTranslatedCompanySizeLabel";
import { sizes } from "./sizes";
@@ -17,10 +16,6 @@ export const CompanyListFilter = () => {
...size,
name: getTranslatedCompanySizeLabel(size, translate),
}));
- const translatedSectors = companySectors.map((sector) => ({
- ...sector,
- label: getTranslatedCompanySectorLabel(sector, translate),
- }));
return (
<div className="w-52 min-w-52 flex flex-col gap-8">
<FilterLiveForm>
@@ -45,7 +40,7 @@ export const CompanyListFilter = () => {
icon={<Truck className="h-4 w-4" />}
label={translate("crm.companies.filters.sector", { _: "Sector" })}
>
- {translatedSectors.map((sector) => (
+ {companySectors.map((sector) => (
<ToggleFilterButton
className="w-full justify-between"
label={sector.label}
diff --git a/src/components/atomic-crm/companies/getTranslatedCompanySectorLabel.ts b/src/components/atomic-crm/companies/getTranslatedCompanySectorLabel.ts
deleted file mode 100644
index 33650f49..00000000
--- a/src/components/atomic-crm/companies/getTranslatedCompanySectorLabel.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
-
-const defaultCompanySectorLabels: Record<string, string> = {
- "communication-services": "Communication Services",
- "consumer-discretionary": "Consumer Discretionary",
- "consumer-staples": "Consumer Staples",
- energy: "Energy",
- financials: "Financials",
- "health-care": "Health Care",
- industrials: "Industrials",
- "information-technology": "Information Technology",
- materials: "Materials",
- "real-estate": "Real Estate",
- utilities: "Utilities",
-};
-
-const getCompanySectorTranslationKey = (sectorValue: string) =>
- `crm.companies.sectors.${sectorValue.replaceAll("-", "_")}`;
-
-export const getTranslatedCompanySectorLabel = (
- sector: { value: string; label: string },
- translate: TranslateFn,
-) => {
- const defaultLabel = defaultCompanySectorLabels[sector.value];
- if (!defaultLabel || sector.label !== defaultLabel) {
- return sector.label;
- }
-
- return translate(getCompanySectorTranslationKey(sector.value), {
- _: sector.label,
- });
-};
diff --git a/src/components/atomic-crm/contacts/ContactListFilter.tsx b/src/components/atomic-crm/contacts/ContactListFilter.tsx
index 4438d5df..a954d3f4 100644
--- a/src/components/atomic-crm/contacts/ContactListFilter.tsx
+++ b/src/components/atomic-crm/contacts/ContactListFilter.tsx
@@ -15,7 +15,6 @@ import { useConfigurationContext } from "../root/ConfigurationContext";
import { ResponsiveFilters } from "../misc/ResponsiveFilters";
import { useIsMobile } from "@/hooks/use-mobile";
import { ActiveFilterButton } from "../misc/ActiveFilterButton";
-import { getTranslatedNoteStatusLabel } from "../notes/getTranslatedNoteStatusLabel";
export const ContactListFilter = () => {
const { noteStatuses } = useConfigurationContext();
@@ -109,8 +108,7 @@ export const ContactListFilter = () => {
className="w-auto md:w-full justify-between h-10 md:h-8"
label={
<span>
- {getTranslatedNoteStatusLabel(status, translate)}{" "}
- <Status status={status.value} />
+ {status.label} <Status status={status.value} />
</span>
}
value={{ status: status.value }}
@@ -248,8 +246,7 @@ export const ContactListFilterSummary = () => {
className="w-auto justify-between h-8"
label={
<span>
- {getTranslatedNoteStatusLabel(status, translate)}{" "}
- <Status status={status.value} />
+ {status.label} <Status status={status.value} />
</span>
}
value={{ status: status.value }}
diff --git a/src/components/atomic-crm/deals/DealInputs.tsx b/src/components/atomic-crm/deals/DealInputs.tsx
index b3244eb4..964eeac2 100644
--- a/src/components/atomic-crm/deals/DealInputs.tsx
+++ b/src/components/atomic-crm/deals/DealInputs.tsx
@@ -12,7 +12,6 @@ import { useIsMobile } from "@/hooks/use-mobile";
import { contactOptionText } from "../misc/ContactOption";
import { useConfigurationContext } from "../root/ConfigurationContext";
import { AutocompleteCompanyInput } from "../companies/AutocompleteCompanyInput.tsx";
-import { getTranslatedDealStageLabel } from "./getTranslatedDealStageLabel";
export const DealInputs = () => {
const isMobile = useIsMobile();
@@ -66,12 +65,8 @@ const DealLinkedToInputs = () => {
};
const DealMiscInputs = () => {
- const translate = useTranslate();
const { dealStages, dealCategories } = useConfigurationContext();
- const translatedDealStages = dealStages.map((stage) => ({
- ...stage,
- label: getTranslatedDealStageLabel(stage, translate),
- }));
+ const translate = useTranslate();
return (
<div className="flex flex-col gap-4 flex-1">
<h3 className="text-base font-medium">
@@ -100,7 +95,7 @@ const DealMiscInputs = () => {
/>
<SelectInput
source="stage"
- choices={translatedDealStages}
+ choices={dealStages}
optionText="label"
optionValue="value"
defaultValue="opportunity"
diff --git a/src/components/atomic-crm/deals/deal.ts b/src/components/atomic-crm/deals/deal.ts
index b3989df0..5f08c1a4 100644
--- a/src/components/atomic-crm/deals/deal.ts
+++ b/src/components/atomic-crm/deals/deal.ts
@@ -1,21 +1,16 @@
import type { DealStage } from "../types";
-import { getTranslatedDealStageLabel } from "./getTranslatedDealStageLabel";
type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
export const findDealLabel = (
dealStages: DealStage[],
dealValue: string,
- translate?: TranslateFn,
+ _translate?: TranslateFn,
) => {
const dealStage = dealStages.find((stage) => stage.value === dealValue);
if (!dealStage) {
return undefined;
}
- if (!translate) {
- return dealStage.label;
- }
-
- return getTranslatedDealStageLabel(dealStage, translate);
+ return dealStage.label;
};
diff --git a/src/components/atomic-crm/deals/getTranslatedDealStageLabel.ts b/src/components/atomic-crm/deals/getTranslatedDealStageLabel.ts
deleted file mode 100644
index a6f10d3c..00000000
--- a/src/components/atomic-crm/deals/getTranslatedDealStageLabel.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { DealStage } from "../types";
-
-type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
-
-const defaultDealStageLabels: Record<string, string> = {
- opportunity: "Opportunity",
- "proposal-sent": "Proposal Sent",
- "in-negociation": "In Negotiation",
- won: "Won",
- lost: "Lost",
- delayed: "Delayed",
-};
-
-const getDealStageTranslationKey = (stageValue: string) =>
- `crm.deals.stages.${stageValue.replaceAll("-", "_")}`;
-
-export const getTranslatedDealStageLabel = (
- stage: Pick<DealStage, "value" | "label">,
- translate: TranslateFn,
-) => {
- const defaultLabel = defaultDealStageLabels[stage.value];
- if (!defaultLabel || stage.label !== defaultLabel) {
- return stage.label;
- }
-
- return translate(getDealStageTranslationKey(stage.value), {
- _: stage.label,
- });
-};
diff --git a/src/components/atomic-crm/misc/Status.tsx b/src/components/atomic-crm/misc/Status.tsx
index e9d7258c..75f129e7 100644
--- a/src/components/atomic-crm/misc/Status.tsx
+++ b/src/components/atomic-crm/misc/Status.tsx
@@ -1,7 +1,5 @@
-import { useTranslate } from "ra-core";
import { cn } from "@/lib/utils";
-import { getTranslatedNoteStatusLabel } from "../notes/getTranslatedNoteStatusLabel";
import { useConfigurationContext } from "../root/ConfigurationContext";
export const Status = ({
@@ -12,7 +10,6 @@ export const Status = ({
className?: string;
}) => {
const { noteStatuses } = useConfigurationContext();
- const translate = useTranslate();
if (!status || !noteStatuses) return null;
const statusObject = noteStatuses.find((s: any) => s.value === status);
@@ -24,7 +21,7 @@ export const Status = ({
style={{ backgroundColor: statusObject.color }}
/>
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 text-xs text-white bg-gray-800 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10">
- {getTranslatedNoteStatusLabel(statusObject, translate)}
+ {statusObject.label}
</div>
</div>
);
diff --git a/src/components/atomic-crm/notes/NoteInputs.tsx b/src/components/atomic-crm/notes/NoteInputs.tsx
index c7902c8e..0a19a3de 100644
--- a/src/components/atomic-crm/notes/NoteInputs.tsx
+++ b/src/components/atomic-crm/notes/NoteInputs.tsx
@@ -16,7 +16,6 @@ import { foreignKeyMapping } from "./foreignKeyMapping";
import { AutocompleteInput, ReferenceInput } from "@/components/admin";
import { contactOptionText } from "../misc/ContactOption";
import { useIsMobile } from "@/hooks/use-mobile";
-import { getTranslatedNoteStatusLabel } from "./getTranslatedNoteStatusLabel";
export const NoteInputs = ({
showStatus,
@@ -107,7 +106,7 @@ export const NoteInputs = ({
source="status"
choices={noteStatuses.map((status) => ({
id: status.value,
- name: getTranslatedNoteStatusLabel(status, translate),
+ name: status.label,
value: status.value,
}))}
optionText={optionRenderer}
diff --git a/src/components/atomic-crm/notes/StatusSelector.tsx b/src/components/atomic-crm/notes/StatusSelector.tsx
index 16148a35..ddeee2fd 100644
--- a/src/components/atomic-crm/notes/StatusSelector.tsx
+++ b/src/components/atomic-crm/notes/StatusSelector.tsx
@@ -1,4 +1,3 @@
-import { useTranslate } from "ra-core";
import {
Select,
SelectContent,
@@ -9,11 +8,9 @@ import {
import { Status } from "../misc/Status";
import { useConfigurationContext } from "../root/ConfigurationContext";
-import { getTranslatedNoteStatusLabel } from "./getTranslatedNoteStatusLabel";
export const StatusSelector = ({ status, setStatus }: any) => {
const { noteStatuses } = useConfigurationContext();
- const translate = useTranslate();
const currentStatus = noteStatuses.find((s) => s.value === status);
@@ -23,8 +20,7 @@ export const StatusSelector = ({ status, setStatus }: any) => {
<SelectValue>
{currentStatus && (
<div className="flex items-center gap-2">
- {getTranslatedNoteStatusLabel(currentStatus, translate)}{" "}
- <Status status={currentStatus.value} />
+ {currentStatus.label} <Status status={currentStatus.value} />
</div>
)}
</SelectValue>
@@ -33,8 +29,7 @@ export const StatusSelector = ({ status, setStatus }: any) => {
{noteStatuses.map((statusOption) => (
<SelectItem key={statusOption.value} value={statusOption.value}>
<div className="flex items-center gap-2">
- {getTranslatedNoteStatusLabel(statusOption, translate)}{" "}
- <Status status={statusOption.value} />
+ {statusOption.label} <Status status={statusOption.value} />
</div>
</SelectItem>
))}
diff --git a/src/components/atomic-crm/notes/getTranslatedNoteStatusLabel.ts b/src/components/atomic-crm/notes/getTranslatedNoteStatusLabel.ts
deleted file mode 100644
index e82cee27..00000000
--- a/src/components/atomic-crm/notes/getTranslatedNoteStatusLabel.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import type { NoteStatus } from "../types";
-
-type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
-
-const defaultNoteStatusLabels: Record<string, string> = {
- cold: "Cold",
- warm: "Warm",
- hot: "Hot",
- "in-contract": "In Contract",
-};
-
-const getStatusTranslationKey = (statusValue: string) =>
- `crm.notes.statuses.${statusValue.replaceAll("-", "_")}`;
-
-export const getTranslatedNoteStatusLabel = (
- status: Pick<NoteStatus, "value" | "label">,
- translate: TranslateFn,
-) => {
- const defaultLabel = defaultNoteStatusLabels[status.value];
- if (!defaultLabel || status.label !== defaultLabel) {
- return status.label;
- }
-
- return translate(getStatusTranslationKey(status.value), {
- _: status.label,
- });
-};
diff --git a/src/components/atomic-crm/root/englishCrmMessages.ts b/src/components/atomic-crm/root/englishCrmMessages.ts
index d3b1555e..faf3c7d1 100644
--- a/src/components/atomic-crm/root/englishCrmMessages.ts
+++ b/src/components/atomic-crm/root/englishCrmMessages.ts
@@ -108,19 +108,6 @@ export const englishCrmMessages = {
sector: "Sector",
size: "Size",
},
- sectors: {
- communication_services: "Communication Services",
- consumer_discretionary: "Consumer Discretionary",
- consumer_staples: "Consumer Staples",
- energy: "Energy",
- financials: "Financials",
- health_care: "Health Care",
- industrials: "Industrials",
- information_technology: "Information Technology",
- materials: "Materials",
- real_estate: "Real Estate",
- utilities: "Utilities",
- },
sizes: {
one_employee: "1 employee",
two_to_nine_employees: "2-9 employees",
@@ -307,14 +294,6 @@ export const englishCrmMessages = {
filters: {
company: "Company",
},
- stages: {
- opportunity: "Opportunity",
- proposal_sent: "Proposal Sent",
- in_negociation: "In Negotiation",
- won: "Won",
- lost: "Lost",
- delayed: "Delayed",
- },
},
header: {
import_data: "Import data",
@@ -391,12 +370,6 @@ export const englishCrmMessages = {
reference_deal: "Deal",
show_options: "Show options",
},
- statuses: {
- cold: "Cold",
- warm: "Warm",
- hot: "Hot",
- in_contract: "In Contract",
- },
},
sales: {
create: {
@@ -498,17 +471,6 @@ export const englishCrmMessages = {
updated: "Task updated",
name: "Task |||| Tasks",
forcedCaseName: "Task",
- types: {
- none: "None",
- email: "Email",
- demo: "Demo",
- lunch: "Lunch",
- meeting: "Meeting",
- follow_up: "Follow-up",
- thank_you: "Thank you",
- ship: "Ship",
- call: "Call",
- },
},
theme: {
dark: "Dark theme",
diff --git a/src/components/atomic-crm/root/frenchCrmMessages.ts b/src/components/atomic-crm/root/frenchCrmMessages.ts
index d60c4f70..984dbe5e 100644
--- a/src/components/atomic-crm/root/frenchCrmMessages.ts
+++ b/src/components/atomic-crm/root/frenchCrmMessages.ts
@@ -108,19 +108,6 @@ export const frenchCrmMessages = {
sector: "Secteur",
size: "Taille",
},
- sectors: {
- communication_services: "Services de communication",
- consumer_discretionary: "Consommation discrétionnaire",
- consumer_staples: "Biens de consommation de base",
- energy: "Énergie",
- financials: "Finance",
- health_care: "Santé",
- industrials: "Industrie",
- information_technology: "Technologies de l'information",
- materials: "Matériaux",
- real_estate: "Immobilier",
- utilities: "Services publics",
- },
sizes: {
one_employee: "1 employé",
two_to_nine_employees: "2-9 employés",
@@ -311,14 +298,6 @@ export const frenchCrmMessages = {
filters: {
company: "Entreprise",
},
- stages: {
- opportunity: "Opportunité",
- proposal_sent: "Proposition envoyée",
- in_negociation: "En négociation",
- won: "Gagnée",
- lost: "Perdue",
- delayed: "Reportée",
- },
},
header: {
import_data: "Importer des données",
@@ -395,12 +374,6 @@ export const frenchCrmMessages = {
reference_deal: "Affaire",
show_options: "Afficher les options",
},
- statuses: {
- cold: "Froid",
- warm: "Tiède",
- hot: "Chaud",
- in_contract: "Sous contrat",
- },
},
sales: {
create: {
@@ -503,17 +476,6 @@ export const frenchCrmMessages = {
updated: "Tâche mise à jour",
name: "Tâche |||| Tâches",
forcedCaseName: "Tâche",
- types: {
- none: "Aucun",
- email: "E-mail",
- demo: "Démo",
- lunch: "Déjeuner",
- meeting: "Réunion",
- follow_up: "Relance",
- thank_you: "Remerciement",
- ship: "Expédition",
- call: "Appel",
- },
},
theme: {
dark: "Thème sombre",
diff --git a/src/components/atomic-crm/settings/SettingsPage.tsx b/src/components/atomic-crm/settings/SettingsPage.tsx
index fe784d96..a4cc528e 100644
--- a/src/components/atomic-crm/settings/SettingsPage.tsx
+++ b/src/components/atomic-crm/settings/SettingsPage.tsx
@@ -25,7 +25,6 @@ import {
} from "../root/ConfigurationContext";
import { defaultConfiguration } from "../root/defaultConfiguration";
import { validateItemsInUse } from "./validateItemsInUse";
-import { getTranslatedDealStageLabel } from "../deals/getTranslatedDealStageLabel";
const SECTIONS = [
{
@@ -350,8 +349,7 @@ const SettingsFormFields = () => {
}
}}
>
- {getTranslatedDealStageLabel(stage, translate) ||
- stage.value}
+ {stage.label || stage.value}
</Button>
);
},
diff --git a/src/components/atomic-crm/tasks/Task.tsx b/src/components/atomic-crm/tasks/Task.tsx
index 9248442b..b7a9410e 100644
--- a/src/components/atomic-crm/tasks/Task.tsx
+++ b/src/components/atomic-crm/tasks/Task.tsx
@@ -20,7 +20,6 @@ import {
import { useConfigurationContext } from "../root/ConfigurationContext";
import type { Contact, Task as TData } from "../types";
-import { getTranslatedTaskTypeLabel } from "./getTranslatedTaskTypeLabel";
import { TaskEdit } from "./TaskEdit";
import { TaskEditSheet } from "./TaskEditSheet";
import { useIsMobile } from "@/hooks/use-mobile";
@@ -114,7 +113,7 @@ export const Task = ({
(taskType) => taskType.value === task.type,
);
return matchedTaskType
- ? getTranslatedTaskTypeLabel(matchedTaskType, translate)
+ ? matchedTaskType.label
: task.type;
})()}
</span>
diff --git a/src/components/atomic-crm/tasks/TaskFormContent.tsx b/src/components/atomic-crm/tasks/TaskFormContent.tsx
index 06d6d1fd..54e75652 100644
--- a/src/components/atomic-crm/tasks/TaskFormContent.tsx
+++ b/src/components/atomic-crm/tasks/TaskFormContent.tsx
@@ -7,7 +7,6 @@ import { DateTimeInput } from "@/components/admin";
import { contactOptionText } from "../misc/ContactOption";
import { useConfigurationContext } from "../root/ConfigurationContext";
-import { getTranslatedTaskTypeLabel } from "./getTranslatedTaskTypeLabel";
export const TaskFormContent = ({
selectContact,
@@ -16,10 +15,6 @@ export const TaskFormContent = ({
}) => {
const { taskTypes } = useConfigurationContext();
const translate = useTranslate();
- const translatedTaskTypes = taskTypes.map((taskType) => ({
- ...taskType,
- label: getTranslatedTaskTypeLabel(taskType, translate),
- }));
return (
<div className="flex flex-col gap-4">
<TextInput
@@ -54,7 +49,7 @@ export const TaskFormContent = ({
source="type"
label="crm.tasks.fields.type"
validate={required()}
- choices={translatedTaskTypes}
+ choices={taskTypes}
optionText="label"
optionValue="value"
defaultValue="none"
diff --git a/src/components/atomic-crm/tasks/getTranslatedTaskTypeLabel.ts b/src/components/atomic-crm/tasks/getTranslatedTaskTypeLabel.ts
deleted file mode 100644
index f9638396..00000000
--- a/src/components/atomic-crm/tasks/getTranslatedTaskTypeLabel.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-type TranslateFn = (key: string, options?: { [key: string]: any }) => string;
-
-const defaultTaskTypeLabels: Record<string, string> = {
- none: "None",
- email: "Email",
- demo: "Demo",
- lunch: "Lunch",
- meeting: "Meeting",
- "follow-up": "Follow-up",
- "thank-you": "Thank you",
- ship: "Ship",
- call: "Call",
-};
-
-const getTaskTypeTranslationKey = (taskTypeValue: string) =>
- `crm.tasks.types.${taskTypeValue.replaceAll("-", "_")}`;
-
-export const getTranslatedTaskTypeLabel = (
- taskType: { value: string; label: string },
- translate: TranslateFn,
-) => {
- const defaultLabel = defaultTaskTypeLabels[taskType.value];
- if (!defaultLabel || taskType.label !== defaultLabel) {
- return taskType.label;
- }
-
- return translate(getTaskTypeTranslationKey(taskType.value), {
- _: taskType.label,
- });
-};