File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,11 +165,23 @@ export async function action({ request }: ActionFunctionArgs) {
165165 try {
166166 const result = await applyCouponDeal ( { orgId, dealKey } ) ;
167167 if ( ! result . success ) {
168+ // Cast to read `code` and `currentDealKey` from the wire body. The
169+ // platform's generic ErrorSchema currently strips these to `error`
170+ // only, so they arrive as undefined for now; the cast keeps the route
171+ // forward-compatible with a future schema loosening that preserves
172+ // them, at which point the precise UI messages will start rendering
173+ // automatically.
174+ const err = result as {
175+ success : false ;
176+ error : string ;
177+ code ?: string ;
178+ currentDealKey ?: string ;
179+ } ;
168180 return typedjson < ActionResponse > (
169181 {
170- error : result . error ?? "Failed to apply coupon deal." ,
171- code : result . code ,
172- currentDealKey : result . currentDealKey ?? null ,
182+ error : err . error ,
183+ code : err . code ,
184+ currentDealKey : err . currentDealKey ?? null ,
173185 } ,
174186 { status : 400 }
175187 ) ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import {
1717 type UsageResult ,
1818 type UsageSeriesParams ,
1919 type CurrentPlan ,
20- type ApplyCouponDealResponse ,
20+ type ApplyCouponDealResult ,
2121 type CouponDiagnosticsResponse ,
2222 type ListCouponDealsResponse ,
2323 type ResolveCouponCustomerResponse ,
@@ -844,7 +844,7 @@ export async function resolveCouponCustomer(
844844export async function applyCouponDeal ( input : {
845845 orgId : string ;
846846 dealKey : string ;
847- } ) : Promise < ApplyCouponDealResponse > {
847+ } ) : Promise < ApplyCouponDealResult > {
848848 if ( ! client ) throw new Error ( "Platform client not configured" ) ;
849849
850850 const [ error , result ] = await tryCatch ( client . applyCouponDeal ( input ) ) ;
You can’t perform that action at this time.
0 commit comments