realtimex-crm 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DealList-ChYrdZWx.js → DealList-SBRy_lx8.js} +2 -2
- package/dist/assets/{DealList-ChYrdZWx.js.map → DealList-SBRy_lx8.js.map} +1 -1
- package/dist/assets/{index-CQbmGVM-.js → index-Br4zr5YA.js} +2 -2
- package/dist/assets/{index-CQbmGVM-.js.map → index-Br4zr5YA.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/supabase/functions/api-v1-activities/index.ts +47 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "realtimex-crm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "RealTimeX CRM - A full-featured CRM built with React, shadcn-admin-kit, and Supabase. Fork of Atomic CRM with RealTimeX App SDK integration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -73,65 +73,55 @@ async function createActivity(apiKey: any, req: Request) {
|
|
|
73
73
|
const body = await req.json();
|
|
74
74
|
const { type, ...activityData } = body;
|
|
75
75
|
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.from("contactNotes")
|
|
80
|
-
.insert({
|
|
81
|
-
...activityData,
|
|
82
|
-
sales_id: apiKey.sales_id,
|
|
83
|
-
})
|
|
84
|
-
.select()
|
|
85
|
-
.single();
|
|
76
|
+
// Map activity type to table and validate
|
|
77
|
+
let tableName: string;
|
|
78
|
+
let responseType: string;
|
|
86
79
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.from("dealNotes")
|
|
116
|
-
.insert({
|
|
117
|
-
...activityData,
|
|
118
|
-
sales_id: apiKey.sales_id,
|
|
119
|
-
})
|
|
120
|
-
.select()
|
|
121
|
-
.single();
|
|
80
|
+
switch (type) {
|
|
81
|
+
case "note":
|
|
82
|
+
case "contact_note":
|
|
83
|
+
tableName = "contactNotes";
|
|
84
|
+
responseType = "contact_note";
|
|
85
|
+
break;
|
|
86
|
+
case "company_note":
|
|
87
|
+
tableName = "companyNotes";
|
|
88
|
+
responseType = "company_note";
|
|
89
|
+
break;
|
|
90
|
+
case "deal_note":
|
|
91
|
+
tableName = "dealNotes";
|
|
92
|
+
responseType = "deal_note";
|
|
93
|
+
break;
|
|
94
|
+
case "task_note":
|
|
95
|
+
tableName = "taskNotes";
|
|
96
|
+
responseType = "task_note";
|
|
97
|
+
break;
|
|
98
|
+
case "task":
|
|
99
|
+
tableName = "tasks";
|
|
100
|
+
responseType = "task";
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
return createErrorResponse(
|
|
104
|
+
400,
|
|
105
|
+
"Invalid activity type. Must be 'contact_note', 'company_note', 'deal_note', 'task_note', or 'task'"
|
|
106
|
+
);
|
|
107
|
+
}
|
|
122
108
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
// Insert activity
|
|
110
|
+
const { data, error } = await supabaseAdmin
|
|
111
|
+
.from(tableName)
|
|
112
|
+
.insert({
|
|
113
|
+
...activityData,
|
|
114
|
+
sales_id: apiKey.sales_id,
|
|
115
|
+
})
|
|
116
|
+
.select()
|
|
117
|
+
.single();
|
|
126
118
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
headers: { "Content-Type": "application/json", ...corsHeaders },
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
return createErrorResponse(
|
|
133
|
-
400,
|
|
134
|
-
"Invalid activity type. Must be 'note', 'contact_note', 'task', or 'deal_note'"
|
|
135
|
-
);
|
|
119
|
+
if (error) {
|
|
120
|
+
return createErrorResponse(400, error.message);
|
|
136
121
|
}
|
|
122
|
+
|
|
123
|
+
return new Response(JSON.stringify({ data, type: responseType }), {
|
|
124
|
+
status: 201,
|
|
125
|
+
headers: { "Content-Type": "application/json", ...corsHeaders },
|
|
126
|
+
});
|
|
137
127
|
}
|