@@ -57,33 +57,34 @@ export default function ClientPage({
5757 maxWaitingTimeMs : 15000 ,
5858 } )
5959
60- const claimMutation = useMutation ( {
61- mutationFn : async ( ) => {
62- if ( ! invitationToken ) {
63- throw new Error ( 'No invitation token' )
64- }
65-
66- const response = await fetch (
67- `${ CONFIG . BASE_URL } /v1/customer-seats/claim` ,
68- {
69- method : 'POST' ,
70- headers : {
71- 'Content-Type' : 'application/json' ,
60+ const { mutateAsync : claimMutateAsync , error : claimMutationError } =
61+ useMutation ( {
62+ mutationFn : async ( ) => {
63+ if ( ! invitationToken ) {
64+ throw new Error ( 'No invitation token' )
65+ }
66+
67+ const response = await fetch (
68+ `${ CONFIG . BASE_URL } /v1/customer-seats/claim` ,
69+ {
70+ method : 'POST' ,
71+ headers : {
72+ 'Content-Type' : 'application/json' ,
73+ } ,
74+ body : JSON . stringify ( {
75+ invitation_token : invitationToken ,
76+ } ) ,
7277 } ,
73- body : JSON . stringify ( {
74- invitation_token : invitationToken ,
75- } ) ,
76- } ,
77- )
78+ )
7879
79- if ( ! response . ok ) {
80- const error = await response . json ( )
81- throw new Error ( error . detail || 'Failed to claim seat' )
82- }
80+ if ( ! response . ok ) {
81+ const error = await response . json ( )
82+ throw new Error ( error . detail || 'Failed to claim seat' )
83+ }
8384
84- return await response . json ( )
85- } ,
86- } )
85+ return await response . json ( )
86+ } ,
87+ } )
8788
8889 // Establish SSE connection early to prevent race conditions
8990 const sseReadyRef = useRef ( false )
@@ -123,7 +124,7 @@ export default function ClientPage({
123124 sseReadyRef . current = true
124125 }
125126
126- const result = await claimMutation . mutateAsync ( )
127+ const result = await claimMutateAsync ( )
127128
128129 await fulfillmentPromiseRef . current
129130
@@ -138,7 +139,7 @@ export default function ClientPage({
138139 error instanceof Error ? error . message : 'Failed to claim seat'
139140 setClaimError ( errorMessage )
140141 }
141- } , [ claimInfo ?. product_id , claimMutation , organization . slug , router ] )
142+ } , [ claimInfo ?. product_id , claimMutateAsync , organization . slug , router ] )
142143
143144 if ( ! invitationToken ) {
144145 return (
@@ -242,9 +243,9 @@ export default function ClientPage({
242243 { claimingState !== 'idle' ? 'Claiming...' : 'Claim seat' }
243244 </ Button >
244245
245- { ( claimError || claimMutation . error ) && (
246+ { ( claimError || claimMutationError ) && (
246247 < div className = "rounded-lg bg-red-50 p-4 text-sm text-red-600 dark:bg-red-900/20 dark:text-red-400" >
247- { claimError || claimMutation . error ?. message }
248+ { claimError || claimMutationError ?. message }
248249 </ div >
249250 ) }
250251 </ div >
0 commit comments