A full-featured CRM built with React, shadcn/ui, and Supabase.
fix fakerest data provider
ThieryMichel0c9f720fc9fc
diff --git a/src/components/atomic-crm/providers/fakerest/dataProvider.ts b/src/components/atomic-crm/providers/fakerest/dataProvider.tsindex e4e4b988..5a950535 100644--- a/src/components/atomic-crm/providers/fakerest/dataProvider.ts+++ b/src/components/atomic-crm/providers/fakerest/dataProvider.ts@@ -438,6 +438,7 @@ export const dataProvider = withLifecycleCallbacks(id: contact_id,data: {nb_tasks: (contact.nb_tasks ?? 0) + 1,+ nb_pending_tasks: (contact.nb_pending_tasks ?? 0) + 1,},previousData: contact,});@@ -455,7 +456,7 @@ export const dataProvider = withLifecycleCallbacks(return params;},afterUpdate: async (result, dataProvider) => {- // update the contact: if the task is done, decrement the nb tasks, otherwise increment it+ // update the contact: if the task state has changed, decrement the nb of pending tasks if done else increment itconst { contact_id } = result.data;const { data: contact } = await dataProvider.getOne("contacts", {id: contact_id,@@ -464,10 +465,10 @@ export const dataProvider = withLifecycleCallbacks(await dataProvider.update("contacts", {id: contact_id,data: {- nb_tasks:+ nb_pending_tasks:taskUpdateType === TASK_MARKED_AS_DONE- ? (contact.nb_tasks ?? 0) - 1- : (contact.nb_tasks ?? 0) + 1,+ ? (contact.nb_pending_tasks ?? 0) - 1+ : (contact.nb_pending_tasks ?? 0) + 1,},previousData: contact,});@@ -484,6 +485,7 @@ export const dataProvider = withLifecycleCallbacks(id: contact_id,data: {nb_tasks: (contact.nb_tasks ?? 0) - 1,+ nb_pending_tasks: (contact.nb_pending_tasks ?? 0) - 1,},previousData: contact,});