@@ -7,7 +7,10 @@ import { getReferralOrThrow } from "@/lib/api/referrals/get-referral-or-throw";
77import { markReferralClosedWon } from "@/lib/api/referrals/mark-referral-closed-won" ;
88import { markReferralQualified } from "@/lib/api/referrals/mark-referral-qualified" ;
99import { notifyReferralStatusUpdate } from "@/lib/api/referrals/notify-referral-status-update" ;
10- import { REFERRAL_STATUS_TRANSITIONS } from "@/lib/referrals/constants" ;
10+ import {
11+ REFERRAL_STATUS_TO_ACTIVITY_ACTION ,
12+ REFERRAL_STATUS_TRANSITIONS ,
13+ } from "@/lib/referrals/constants" ;
1114import { ReferralWithCustomer } from "@/lib/types" ;
1215import { updateReferralStatusSchema } from "@/lib/zod/schemas/referrals" ;
1316import { prisma } from "@dub/prisma" ;
@@ -16,16 +19,6 @@ import { waitUntil } from "@vercel/functions";
1619import { authActionClient } from "../safe-action" ;
1720import { throwIfNoPermission } from "../throw-if-no-permission" ;
1821
19- const REFERRAL_EVENT_TYPES = {
20- [ ReferralStatus . pending ] : "referral.created" ,
21- [ ReferralStatus . qualified ] : "referral.qualified" ,
22- [ ReferralStatus . meeting ] : "referral.meeting" ,
23- [ ReferralStatus . negotiation ] : "referral.negotiation" ,
24- [ ReferralStatus . unqualified ] : "referral.unqualified" ,
25- [ ReferralStatus . closedWon ] : "referral.closedWon" ,
26- [ ReferralStatus . closedLost ] : "referral.closedLost" ,
27- } as const ;
28-
2922export const updateReferralStatusAction = authActionClient
3023 . inputSchema ( updateReferralStatusSchema )
3124 . action ( async ( { parsedInput, ctx } ) => {
@@ -92,7 +85,7 @@ export const updateReferralStatusAction = authActionClient
9285 resourceType : "referral" ,
9386 resourceId : referral . id ,
9487 userId : user . id ,
95- action : REFERRAL_EVENT_TYPES [ status ] ,
88+ action : REFERRAL_STATUS_TO_ACTIVITY_ACTION [ status ] ,
9689 description : notes ,
9790 changeSet : {
9891 status : {
0 commit comments