Skip to content

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

Fix deals with incorrect stage should not break deal list

fzaninottoae63b82af741
diff --git a/src/components/atomic-crm/deals/stages.ts b/src/components/atomic-crm/deals/stages.ts
index 3fc858b2..944353e6 100644
--- a/src/components/atomic-crm/deals/stages.ts
+++ b/src/components/atomic-crm/deals/stages.ts
@@ -10,7 +10,11 @@ export const getDealsByStage = (
if (!dealStages) return {};
const dealsByStage: Record<Deal["stage"], Deal[]> = unorderedDeals.reduce(
(acc, deal) => {
- acc[deal.stage].push(deal);
+ // if deal has a stage that does not exist in configuration, assign it to the first stage
+ const stage = dealStages.find((s) => s.value === deal.stage)
+ ? deal.stage
+ : dealStages[0].value;
+ acc[stage].push(deal);
return acc;
},
dealStages.reduce(