A full-featured CRM built with React, shadcn/ui, and Supabase.
Remove contact gender from config
fzaninotto4e16a0125988
diff --git a/doc/src/content/docs/developers/customizing.mdx b/doc/src/content/docs/developers/customizing.mdxindex fb4243d9..ed5f40d5 100644--- a/doc/src/content/docs/developers/customizing.mdx+++ b/doc/src/content/docs/developers/customizing.mdx@@ -26,10 +26,6 @@ import { CRM } from "@/components/atomic-crm/root/CRM";const App = () => (<CRM- contactGender={[- { value: 'male', label: 'He' },- { value: 'female', label: 'She' },- ]}companySectors={['Technology', 'Finance']}dealCategories={['Copywriting', 'Design']}dealPipelineStatuses={['won']}@@ -55,7 +51,6 @@ export default App;| Props | Description | Type ||-------------------------|-----------------------------------------------------------------------|-----------------|-| `contactGender` | The gender options for contacts used in the application. | ContactGender[] || `companySectors` | The list of company sectors used in the application. | string[] || `darkTheme` | The theme to use when the application is in dark mode. | RaThemeOptions || `dealCategories` | The categories of deals used in the application. | string[] |diff --git a/registry.json b/registry.jsonindex e651ec83..b26b0aa6 100644--- a/registry.json+++ b/registry.json@@ -155,10 +155,6 @@"path": "src/components/atomic-crm/root/useConfigurationLoader.ts","type": "registry:component"},- {- "path": "src/components/atomic-crm/root/iconRegistry.ts",- "type": "registry:component"- },{"path": "src/components/atomic-crm/root/i18nProvider.tsx","type": "registry:component"@@ -639,6 +635,10 @@"path": "src/components/atomic-crm/contacts/exportToVCard.ts","type": "registry:component"},+ {+ "path": "src/components/atomic-crm/contacts/contactGender.ts",+ "type": "registry:component"+ },{"path": "src/components/atomic-crm/contacts/TagsListEdit.tsx","type": "registry:component"diff --git a/src/App.tsx b/src/App.tsxindex e74f7a98..fca9ca06 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -4,7 +4,6 @@ import { CRM } from "@/components/atomic-crm/root/CRM";* Application entry point** Customize Atomic CRM by passing props to the CRM component:- * - contactGender* - companySectors* - darkTheme* - dealCategoriesdiff --git a/src/components/atomic-crm/contacts/ContactInputs.tsx b/src/components/atomic-crm/contacts/ContactInputs.tsxindex 7edb04ce..73be197f 100644--- a/src/components/atomic-crm/contacts/ContactInputs.tsx+++ b/src/components/atomic-crm/contacts/ContactInputs.tsx@@ -12,7 +12,7 @@ import { ArrayInput } from "@/components/admin/array-input";import { SimpleFormIterator } from "@/components/admin/simple-form-iterator";import { isLinkedinUrl } from "../misc/isLinkedInUrl";-import { useConfigurationContext } from "../root/ConfigurationContext";+import { contactGender } from "./contactGender";import type { Sale } from "../types";import { Avatar } from "./Avatar";import { AutocompleteCompanyInput } from "../companies/AutocompleteCompanyInput.tsx";@@ -43,7 +43,6 @@ export const ContactInputs = () => {};const ContactIdentityInputs = () => {- const { contactGender } = useConfigurationContext();return (<div className="flex flex-col gap-4"><h6 className="text-lg font-semibold">Identity</h6>diff --git a/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx b/src/components/atomic-crm/contacts/ContactPersonalInfo.tsxindex 3ce70d91..507c5148 100644--- a/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx+++ b/src/components/atomic-crm/contacts/ContactPersonalInfo.tsx@@ -5,12 +5,10 @@ import { TextField } from "@/components/admin/text-field";import { EmailField } from "@/components/admin/email-field";import { Mail, Phone, Linkedin } from "lucide-react";import type { ReactNode } from "react";-import { useConfigurationContext } from "../root/ConfigurationContext";-import { genderIconRegistry } from "../root/iconRegistry";+import { contactGender } from "./contactGender";import type { Contact } from "../types";export const ContactPersonalInfo = () => {- const { contactGender } = useConfigurationContext();const record = useRecordContext<Contact>();if (!record) return null;@@ -60,12 +58,12 @@ export const ContactPersonalInfo = () => {{contactGender.map((genderOption) => {if (record.gender === genderOption.value) {- const Icon =- genderIconRegistry[genderOption.icon] ?? genderIconRegistry.User;return (<PersonalInfoRowkey={genderOption.value}- icon={<Icon className="w-4 h-4 text-muted-foreground" />}+ icon={+ <genderOption.icon className="w-4 h-4 text-muted-foreground" />+ }primary={<div>{genderOption.label}</div>}/>);diff --git a/src/components/atomic-crm/contacts/contactGender.ts b/src/components/atomic-crm/contacts/contactGender.tsnew file mode 100644index 00000000..1e7f11ac--- /dev/null+++ b/src/components/atomic-crm/contacts/contactGender.ts@@ -0,0 +1,9 @@+import { Mars, NonBinary, Venus } from "lucide-react";++import type { ContactGender } from "../types";++export const contactGender: ContactGender[] = [+ { value: "male", label: "He/Him", icon: Mars },+ { value: "female", label: "She/Her", icon: Venus },+ { value: "nonbinary", label: "They/Them", icon: NonBinary },+];diff --git a/src/components/atomic-crm/providers/fakerest/dataGenerator/contacts.ts b/src/components/atomic-crm/providers/fakerest/dataGenerator/contacts.tsindex ea58d5ed..92f2f536 100644--- a/src/components/atomic-crm/providers/fakerest/dataGenerator/contacts.ts+++ b/src/components/atomic-crm/providers/fakerest/dataGenerator/contacts.ts@@ -7,10 +7,8 @@ import {random,} from "faker/locale/en_US";-import {- defaultContactGender,- defaultNoteStatuses,-} from "../../../root/defaultConfiguration";+import { defaultNoteStatuses } from "../../../root/defaultConfiguration";+import { contactGender } from "../../../contacts/contactGender";import type { Company, Contact } from "../../../types";import type { Db } from "./types";import { randomDate, weightedBoolean } from "./utils";@@ -33,7 +31,7 @@ export const generateContacts = (db: Db, size = 500): Required<Contact>[] => {return Array.from(Array(size).keys()).map((id) => {const has_avatar =weightedBoolean(25) && numberOfContacts < nbAvailblePictures;- const gender = random.arrayElement(defaultContactGender).value;+ const gender = random.arrayElement(contactGender).value;const first_name = name.firstName(gender as any);const last_name = name.lastName();const email_jsonb = [diff --git a/src/components/atomic-crm/root/CRM.tsx b/src/components/atomic-crm/root/CRM.tsxindex b6bf239a..fe34ed28 100644--- a/src/components/atomic-crm/root/CRM.tsx+++ b/src/components/atomic-crm/root/CRM.tsx@@ -39,7 +39,6 @@ import {import type { CrmDataProvider } from "../providers/types";import {defaultCompanySectors,- defaultContactGender,defaultDarkModeLogo,defaultDealCategories,defaultDealPipelineStatuses,@@ -74,7 +73,6 @@ export type CRMProps = {* default configurations and themes but allows for customization through props. The component* seeds the store with any custom prop values for backwards compatibility.*- * @param {Array<ContactGender>} contactGender - The gender options for contacts used in the application.* @param {string[]} companySectors - The list of company sectors used in the application.* @param {RaThemeOptions} darkTheme - The theme to use when the application is in dark mode.* @param {string[]} dealCategories - The categories of deals used in the application.@@ -108,7 +106,6 @@ export type CRMProps = {* export default App;*/export const CRM = ({- contactGender = defaultContactGender,companySectors = defaultCompanySectors,dealCategories = defaultDealCategories,dealPipelineStatuses = defaultDealPipelineStatuses,@@ -154,7 +151,6 @@ export const CRM = ({title,darkModeLogo,lightModeLogo,- contactGender,googleWorkplaceDomain,disableEmailPasswordAuthentication,} satisfies ConfigurationContextValue);diff --git a/src/components/atomic-crm/root/ConfigurationContext.tsx b/src/components/atomic-crm/root/ConfigurationContext.tsxindex a580e033..0c9a4513 100644--- a/src/components/atomic-crm/root/ConfigurationContext.tsx+++ b/src/components/atomic-crm/root/ConfigurationContext.tsx@@ -1,6 +1,6 @@import { useStore } from "ra-core";-import type { ContactGender, DealStage, NoteStatus } from "../types";+import type { DealStage, NoteStatus } from "../types";export const CONFIGURATION_STORE_KEY = "app.configuration";@@ -14,7 +14,6 @@ export interface ConfigurationContextValue {title: string;darkModeLogo: string;lightModeLogo: string;- contactGender: ContactGender[];googleWorkplaceDomain?: string;disableEmailPasswordAuthentication?: boolean;}diff --git a/src/components/atomic-crm/root/defaultConfiguration.ts b/src/components/atomic-crm/root/defaultConfiguration.tsindex 45bc9255..c79222e9 100644--- a/src/components/atomic-crm/root/defaultConfiguration.ts+++ b/src/components/atomic-crm/root/defaultConfiguration.ts@@ -55,8 +55,3 @@ export const defaultTaskTypes = ["Call",];-export const defaultContactGender = [- { value: "male", label: "He/Him", icon: "Mars" },- { value: "female", label: "She/Her", icon: "Venus" },- { value: "nonbinary", label: "They/Them", icon: "NonBinary" },-];diff --git a/src/components/atomic-crm/root/iconRegistry.ts b/src/components/atomic-crm/root/iconRegistry.tsdeleted file mode 100644index 0a708c06..00000000--- a/src/components/atomic-crm/root/iconRegistry.ts+++ /dev/null@@ -1,13 +0,0 @@-import type { ComponentType } from "react";-import { Mars, Venus, NonBinary, User, CircleOff } from "lucide-react";--export const genderIconRegistry: Record<- string,- ComponentType<{ className?: string }>-> = {- Mars,- Venus,- NonBinary,- User,- CircleOff,-};diff --git a/src/components/atomic-crm/settings/AppConfigPage.tsx b/src/components/atomic-crm/settings/AppConfigPage.tsxindex a6c90ea6..e4d0ce8f 100644--- a/src/components/atomic-crm/settings/AppConfigPage.tsx+++ b/src/components/atomic-crm/settings/AppConfigPage.tsx@@ -6,16 +6,14 @@ import { Button } from "@/components/ui/button";import { Card, CardContent } from "@/components/ui/card";import { Separator } from "@/components/ui/separator";import { ArrayInput } from "@/components/admin/array-input";-import { SelectInput } from "@/components/admin/select-input";import { SimpleFormIterator } from "@/components/admin/simple-form-iterator";import { TextInput } from "@/components/admin/text-input";import {useConfigurationContext,useConfigurationUpdater,+ type ConfigurationContextValue,} from "../root/ConfigurationContext";-import { genderIconRegistry } from "../root/iconRegistry";-import { type ConfigurationContextValue } from "../root/ConfigurationContext";const SECTIONS = [{ id: "branding", label: "Branding" },@@ -24,14 +22,8 @@ const SECTIONS = [{ id: "deal-categories", label: "Deal Categories" },{ id: "note-statuses", label: "Note Statuses" },{ id: "task-types", label: "Task Types" },- { id: "contact-gender", label: "Contact Gender" },];-const iconChoices = Object.keys(genderIconRegistry).map((name) => ({- id: name,- name,-}));-const splitLines = (text: string): string[] =>text.split("\n")@@ -49,7 +41,6 @@ const transformFormValues = (data: Record<string, any>) => ({dealStages: data.dealStages,dealPipelineStatuses: data.dealPipelineStatuses,noteStatuses: data.noteStatuses,- contactGender: data.contactGender,} satisfies ConfigurationContextValue,});@@ -95,7 +86,6 @@ const AppConfigForm = () => {dealStages: config.dealStages,dealPipelineStatuses: config.dealPipelineStatuses,noteStatuses: config.noteStatuses,- contactGender: config.contactGender,}),[config],);@@ -281,26 +271,6 @@ const AppConfigFormFields = () => {</CardContent></Card>- {/* Contact Gender */}- <Card id="contact-gender">- <CardContent className="space-y-4">- <h2 className="text-xl font-semibold text-muted-foreground">- Contact Gender Options- </h2>- <ArrayInput source="contactGender" label={false}>- <SimpleFormIterator inline disableReordering>- <TextInput source="value" label={false} placeholder="Value" />- <TextInput source="label" label={false} placeholder="Label" />- <SelectInput- source="icon"- label={false}- choices={iconChoices}- className="w-36"- />- </SimpleFormIterator>- </ArrayInput>- </CardContent>- </Card></div>{/* Sticky save button */}diff --git a/src/components/atomic-crm/types.ts b/src/components/atomic-crm/types.tsindex 42463ae2..1a90e747 100644--- a/src/components/atomic-crm/types.ts+++ b/src/components/atomic-crm/types.ts@@ -1,4 +1,5 @@import type { Identifier, RaRecord } from "ra-core";+import type { ComponentType } from "react";import type {COMPANY_CREATED,@@ -222,5 +223,5 @@ export interface NoteStatus {export interface ContactGender {value: string;label: string;- icon: string;+ icon: ComponentType<{ className?: string }>;}