@@ -12,17 +12,18 @@ import {
1212 completeRegistration ,
1313 generateRegistrationToken ,
1414 buildPortalUrl ,
15+ getSfcForNotification ,
16+ getSfcForPortalInvite ,
1517} from '@/lib/sponsor-crm/registration'
1618import type { RegistrationSubmission } from '@/lib/sponsor-crm/registration'
1719import {
1820 logRegistrationComplete ,
1921 logEmailSent ,
2022 logContractStatusChange ,
2123} from '@/lib/sponsor-crm/activity'
22- import { clientReadUncached , clientWrite } from '@/lib/sanity/client'
24+ import { clientWrite } from '@/lib/sanity/client'
2325import { getConferenceForCurrentDomain } from '@/lib/conference/sanity'
2426import { notifySponsorRegistrationComplete } from '@/lib/slack/notify'
25- import type { Conference } from '@/lib/conference/types'
2627
2728export const registrationRouter = router ( {
2829 validate : publicProcedure
@@ -73,26 +74,7 @@ export const registrationRouter = router({
7374
7475 // Send Slack notification to sales channel
7576 try {
76- const sfcData = await clientReadUncached . fetch < {
77- sponsorName : string
78- tierTitle : string | null
79- contractValue : number | null
80- contractCurrency : string | null
81- conference : Conference | null
82- } > (
83- `*[_type == "sponsorForConference" && _id == $id][0]{
84- "sponsorName": sponsor->name,
85- "tierTitle": tier->title,
86- contractValue,
87- contractCurrency,
88- "conference": conference->{
89- _id, title, city, country, startDate, endDate,
90- organizer, salesNotificationChannel, domains,
91- socialLinks
92- }
93- }` ,
94- { id : sponsorForConferenceId } ,
95- )
77+ const sfcData = await getSfcForNotification ( sponsorForConferenceId )
9678
9779 if ( sfcData ?. conference ) {
9880 await notifySponsorRegistrationComplete (
@@ -120,7 +102,7 @@ export const registrationRouter = router({
120102
121103 if ( error || ! token ) {
122104 throw new TRPCError ( {
123- code : 'INTERNAL_SERVER_ERROR ' ,
105+ code : 'PRECONDITION_FAILED ' ,
124106 message : error ?. message || 'Failed to generate registration token' ,
125107 } )
126108 }
@@ -148,52 +130,7 @@ export const registrationRouter = router({
148130 )
149131 . mutation ( async ( { input, ctx } ) => {
150132 // Fetch full sponsor + conference data for the email
151- const sfc = await clientReadUncached . fetch < {
152- _id : string
153- status : string | null
154- registrationToken : string | null
155- registrationComplete : boolean
156- contractStatus : string | null
157- sponsor : { name : string } | null
158- contactPersons : Array < {
159- name : string
160- email : string
161- isPrimary ?: boolean
162- } > | null
163- tier : { title : string } | null
164- contractValue : number | null
165- contractCurrency : string | null
166- conference : {
167- title : string
168- city : string | null
169- startDate : string | null
170- organizer : string | null
171- sponsorEmail : string | null
172- socialLinks : string [ ] | null
173- } | null
174- } > (
175- `*[_type == "sponsorForConference" && _id == $id][0]{
176- _id,
177- status,
178- registrationToken,
179- registrationComplete,
180- contractStatus,
181- sponsor->{ name },
182- contactPersons[]{ name, email, isPrimary },
183- tier->{ title },
184- contractValue,
185- contractCurrency,
186- conference->{
187- title,
188- city,
189- startDate,
190- organizer,
191- sponsorEmail,
192- socialLinks
193- }
194- }` ,
195- { id : input . sponsorForConferenceId } ,
196- )
133+ const sfc = await getSfcForPortalInvite ( input . sponsorForConferenceId )
197134
198135 if ( ! sfc ) {
199136 throw new TRPCError ( {
0 commit comments