@@ -7,12 +7,6 @@ import {
77 ApplyCouponDialog ,
88 type ApplyCouponTarget ,
99} from "~/components/admin/ApplyCouponDialog" ;
10- import {
11- Accordion ,
12- AccordionContent ,
13- AccordionItem ,
14- AccordionTrigger ,
15- } from "~/components/primitives/Accordion" ;
1610import { Button } from "~/components/primitives/Buttons" ;
1711import { CopyableText } from "~/components/primitives/CopyableText" ;
1812import { Header1 , Header2 } from "~/components/primitives/Headers" ;
@@ -29,10 +23,8 @@ import {
2923 TableRow ,
3024} from "~/components/primitives/Table" ;
3125import { SimpleTooltip } from "~/components/primitives/Tooltip" ;
32- import { logger } from "~/services/logger.server" ;
3326import {
3427 applyCouponDeal ,
35- getCouponDiagnostics ,
3628 listCouponDeals ,
3729 refreshCouponDeals ,
3830 resolveCouponCustomer ,
@@ -58,17 +50,10 @@ type CouponMatch = {
5850 primaryUserEmail : string | null ;
5951} ;
6052
61- type CouponDiagnostic = {
62- id : string ;
63- name : string | null ;
64- metadata : Record < string , string > ;
65- } ;
66-
6753type LoaderData = {
6854 email : string | null ;
6955 deals : CouponDeal [ ] ;
7056 matches : CouponMatch [ ] | null ;
71- diagnostics : CouponDiagnostic [ ] ;
7257 appliedDealKey : string | null ;
7358} ;
7459
@@ -83,10 +68,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
8368 const email = emailParam && emailParam . trim ( ) . length > 0 ? emailParam . trim ( ) : null ;
8469 const appliedDealKey = url . searchParams . get ( "applied" ) ;
8570
86- const [ dealsResult , diagnostics ] = await Promise . all ( [
87- listCouponDeals ( ) ,
88- safeDiagnostics ( ) ,
89- ] ) ;
71+ const dealsResult = await listCouponDeals ( ) ;
9072
9173 let matches : CouponMatch [ ] | null = null ;
9274 if ( email ) {
@@ -98,27 +80,11 @@ export async function loader({ request }: LoaderFunctionArgs) {
9880 email,
9981 deals : dealsResult . deals as CouponDeal [ ] ,
10082 matches,
101- diagnostics,
10283 appliedDealKey,
10384 } ;
10485 return typedjson ( data ) ;
10586}
10687
107- // Diagnostics is a nice-to-have panel; if billing has a transient issue with
108- // it, the rest of the page should still work. The other calls remain hard
109- // failures because the page is useless without them.
110- async function safeDiagnostics ( ) : Promise < CouponDiagnostic [ ] > {
111- try {
112- const result = await getCouponDiagnostics ( ) ;
113- return result . unregisteredCoupons as CouponDiagnostic [ ] ;
114- } catch ( error ) {
115- logger . warn ( "Coupon diagnostics fetch failed; rendering page without panel" , {
116- error : error instanceof Error ? error . message : String ( error ) ,
117- } ) ;
118- return [ ] ;
119- }
120- }
121-
12288const ApplySchema = z . object ( {
12389 intent : z . literal ( "apply" ) ,
12490 orgId : z . string ( ) . min ( 1 ) ,
@@ -217,7 +183,7 @@ function groupDealsByCategory(deals: CouponDeal[]): Array<[string, CouponDeal[]]
217183}
218184
219185export default function CouponsPage ( ) {
220- const { email, deals, matches, diagnostics , appliedDealKey } =
186+ const { email, deals, matches, appliedDealKey } =
221187 useTypedLoaderData < typeof loader > ( ) ;
222188 const actionData = useTypedActionData < typeof action > ( ) ;
223189
@@ -302,40 +268,6 @@ export default function CouponsPage() {
302268 </ Button >
303269 </ Form >
304270
305- { diagnostics . length > 0 && (
306- < Accordion type = "single" collapsible >
307- < AccordionItem value = "diagnostics" >
308- < AccordionTrigger >
309- { diagnostics . length } Stripe coupon{ diagnostics . length === 1 ? "" : "s" } aren't
310- tagged as deals
311- </ AccordionTrigger >
312- < AccordionContent >
313- < Paragraph variant = "small" className = "text-text-dimmed pb-2" >
314- These coupons are valid in Stripe but missing the{ " " }
315- < code className = "rounded bg-charcoal-700 px-1" > trigger_deal_key</ code > { " " }
316- metadata field, so they don't appear in the apply controls
317- below. Common causes: typo in the metadata field name, or the
318- coupon was never tagged.
319- </ Paragraph >
320- < ul className = "flex flex-col gap-1 text-sm" >
321- { diagnostics . map ( ( c ) => (
322- < li key = { c . id } className = "font-mono text-text-dimmed" >
323- { c . id }
324- { c . name ? ` — ${ c . name } ` : "" }
325- { Object . keys ( c . metadata ) . length > 0 ? (
326- < span className = "text-text-dimmed/70" >
327- { " " }
328- · { JSON . stringify ( c . metadata ) }
329- </ span >
330- ) : null }
331- </ li >
332- ) ) }
333- </ ul >
334- </ AccordionContent >
335- </ AccordionItem >
336- </ Accordion >
337- ) }
338-
339271 { matches === null ? (
340272 < Paragraph variant = "small" className = "text-text-dimmed" >
341273 Enter a Stripe customer email above to find matching Trigger.dev orgs.
0 commit comments