Skip to content

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

fix import

Jean-Baptiste Kaisera222412f070b
diff --git a/doc/user/import-contacts.md b/doc/user/import-contacts.md
index 786e941e..13918d01 100644
--- a/doc/user/import-contacts.md
+++ b/doc/user/import-contacts.md
@@ -11,10 +11,9 @@ Atomic CRM displays an import contact buttons in the initial user onboarding pag
An example of the expected CSV file is available in the contact import modal:
```csv
-first_name,last_name,gender,title,company,email,phone_1_number,phone_1_type,phone_2_number,phone_2_type,background,first_seen,last_seen,has_newsletter,status,tags,linkedin_url
-John,Doe,male,Sales Executive,Acme,[email protected],659-980-2015,work,740.645.3807,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"influencer, developer",https://www.linkedin.com/in/johndoe
-Jane,Doe,female,Designer,Acme,[email protected],659-980-2020,work,740.647.3802,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"UI, design",https://www.linkedin.com/in/janedoe
-Camille,Brown,nonbinary,Accountant,Atomic Corp,[email protected];[email protected],659-910-3010,work,740.698.3752,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"payroll, accountant",
+first_name,last_name,gender,title,background,first_seen,last_seen,has_newsletter,status,tags,linkedin_url,company,email_work,email_home,email_other,phone_work,phone_home,phone_other
+John,Doe,male,Sales Executive,,2024-07-01T00:00:00+00:00,2024-07-01T11:54:49.95+00:00,false,in-contract,"influencer, developer",https://www.linkedin.com/in/johndoe,Acme,[email protected],[email protected],[email protected],659-980-2015,740.645.3807,(446) 758-2122
+Jane,Doe,female,Designer,,2024-07-01T00:00:00+00:00,2024-07-01T11:54:49.95+00:00,false,in-contract,"UI, design",https://www.linkedin.com/in/janedoe,Acme,,,[email protected],659-980-2020,740.647.3802,
```
When importing contacts, companies and tags will be automatically matched if they exist on the system, or imported ortherwise.
diff --git a/src/contacts/contacts_export.csv b/src/contacts/contacts_export.csv
index 40757051..06eb1699 100644
--- a/src/contacts/contacts_export.csv
+++ b/src/contacts/contacts_export.csv
@@ -1,4 +1,3 @@
-first_name,last_name,gender,title,company,email,phone_1_number,phone_1_type,phone_2_number,phone_2_type,background,first_seen,last_seen,has_newsletter,status,tags,linkedin_url
-John,Doe,male,Sales Executive,Acme,[email protected],659-980-2015,work,740.645.3807,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"influencer, developer",https://www.linkedin.com/in/johndoe
-Jane,Doe,female,Designer,Acme,[email protected],659-980-2020,work,740.647.3802,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"UI, design",https://www.linkedin.com/in/janedoe
-Camille,Brown,nonbinary,Accountant,Atomic Corp,[email protected];[email protected],659-910-3010,work,740.698.3752,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"payroll, accountant",
\ No newline at end of file
+first_name,last_name,gender,title,background,first_seen,last_seen,has_newsletter,status,tags,linkedin_url,company,email_work,email_home,email_other,phone_work,phone_home,phone_other
+John,Doe,male,Sales Executive,,2024-07-01T00:00:00+00:00,2024-07-01T11:54:49.95+00:00,false,in-contract,"influencer, developer",https://www.linkedin.com/in/johndoe,Acme,[email protected],[email protected],[email protected],659-980-2015,740.645.3807,(446) 758-2122
+Jane,Doe,female,Designer,,2024-07-01T00:00:00+00:00,2024-07-01T11:54:49.95+00:00,false,in-contract,"UI, design",https://www.linkedin.com/in/janedoe,Acme,,,[email protected],659-980-2020,740.647.3802,
\ No newline at end of file
diff --git a/src/contacts/useContactImport.tsx b/src/contacts/useContactImport.tsx
index 6ebfa2d3..13640e42 100644
--- a/src/contacts/useContactImport.tsx
+++ b/src/contacts/useContactImport.tsx
@@ -9,11 +9,12 @@ export type ContactImportSchema = {
gender: string;
title: string;
company: string;
- email: string;
- phone_1_number: string;
- phone_1_type: string;
- phone_2_number: string;
- phone_2_type: string;
+ email_work: string;
+ email_home: string;
+ email_other: string;
+ phone_work: string;
+ phone_home: string;
+ phone_other: string;
background: string;
avatar: string;
first_seen: string;
@@ -89,11 +90,12 @@ export function useContactImport() {
last_name,
gender,
title,
- email,
- phone_1_number,
- phone_1_type,
- phone_2_number,
- phone_2_type,
+ email_work,
+ email_home,
+ email_other,
+ phone_work,
+ phone_home,
+ phone_other,
background,
first_seen,
last_seen,
@@ -103,7 +105,16 @@ export function useContactImport() {
tags: tagNames,
linkedin_url,
}) => {
- const emailArray = email.split(';');
+ const email_jsonb = [
+ { email: email_work, type: 'Work' },
+ { email: email_home, type: 'Home' },
+ { email: email_other, type: 'Other' },
+ ].filter(({ email }) => email);
+ const phone_jsonb = [
+ { number: phone_work, type: 'Work' },
+ { number: phone_home, type: 'Home' },
+ { number: phone_other, type: 'Other' },
+ ].filter(({ number }) => number);
const company = companyName?.trim()
? companies.get(companyName.trim())
: undefined;
@@ -117,11 +128,8 @@ export function useContactImport() {
last_name,
gender,
title,
- email: emailArray,
- phone_1_number,
- phone_1_type,
- phone_2_number,
- phone_2_type,
+ email_jsonb,
+ phone_jsonb,
background,
first_seen: first_seen
? new Date(first_seen).toISOString()