11import { EnvelopeIcon , ExclamationCircleIcon , XMarkIcon } from "@heroicons/react/20/solid" ;
22import { CheckCircleIcon } from "@heroicons/react/24/solid" ;
3- import { Toaster , toast } from "sonner" ;
3+ import { useSearchParams } from "@remix-run/react" ;
4+ import { useEffect } from "react" ;
45import { useTypedLoaderData } from "remix-typedjson" ;
6+ import { Toaster , toast } from "sonner" ;
7+ import { type ToastMessageAction } from "~/models/message.server" ;
58import { type loader } from "~/root" ;
6- import { useEffect } from "react" ;
7- import { Paragraph } from "./Paragraph" ;
89import { cn } from "~/utils/cn" ;
9- import { type ToastMessageAction } from "~/models/message.server" ;
10- import { Header2 , Header3 } from "./Headers" ;
1110import { Button , LinkButton } from "./Buttons" ;
12- import { Feedback } from "../Feedback" ;
13- import assertNever from "assert-never" ;
14- import { assertExhaustive } from "@trigger.dev/core" ;
11+ import { Header2 } from "./Headers" ;
12+ import { Paragraph } from "./Paragraph" ;
1513
1614const defaultToastDuration = 5000 ;
1715const permanentToastDuration = 60 * 60 * 24 * 1000 ;
@@ -78,14 +76,14 @@ export function ToastUI({
7876 < ExclamationCircleIcon className = "mt-1 size-4 min-w-4 text-error" />
7977 ) }
8078 < div className = "flex flex-col" >
81- { title && < Header2 className = "pt-1 " > { title } </ Header2 > }
82- < Paragraph variant = "small/dimmed" className = "py-1 " >
79+ { title && < Header2 className = "pt-0 " > { title } </ Header2 > }
80+ < Paragraph variant = "small/dimmed" className = "pb-1 pt-0.5 " >
8381 { message }
8482 </ Paragraph >
85- < Action action = { action } toastId = { t } />
83+ < Action action = { action } toastId = { t } className = "my-2" />
8684 </ div >
8785 < button
88- className = "hover:bg-midnight-800 ms-auto rounded p-2 text-text-dimmed transition hover:text-text-bright"
86+ className = "hover:bg-midnight-800 -mr-1 -mt-1 ms-auto rounded p-2 text-text-dimmed transition hover:text-text-bright"
8987 onClick = { ( ) => toast . dismiss ( t ) }
9088 >
9189 < XMarkIcon className = "size-4" />
@@ -95,37 +93,48 @@ export function ToastUI({
9593 ) ;
9694}
9795
98- function Action ( { action, toastId } : { action ?: ToastMessageAction ; toastId : string } ) {
96+ function Action ( {
97+ action,
98+ toastId,
99+ className,
100+ } : {
101+ action ?: ToastMessageAction ;
102+ toastId : string ;
103+ className ?: string ;
104+ } ) {
105+ const [ _ , setSearchParams ] = useSearchParams ( ) ;
106+
99107 if ( ! action ) return null ;
100108
101109 switch ( action . action . type ) {
102110 case "link" : {
103111 return (
104- < LinkButton variant = { action . variant ?? "secondary/small" } to = { action . action . path } >
112+ < LinkButton
113+ className = { className }
114+ variant = { action . variant ?? "secondary/small" }
115+ to = { action . action . path }
116+ >
105117 { action . label }
106118 </ LinkButton >
107119 ) ;
108120 }
109121 case "help" : {
122+ const feedbackType = action . action . feedbackType ;
110123 return (
111- < Feedback
112- button = {
113- < Button
114- variant = { action . variant ?? "secondary/small" }
115- LeadingIcon = { EnvelopeIcon }
116- onClick = { ( e ) => {
117- e . preventDefault ( ) ;
118- toast . dismiss ( toastId ) ;
119- } }
120- >
121- { action . label }
122- </ Button >
123- }
124- />
124+ < Button
125+ className = { className }
126+ variant = { action . variant ?? "secondary/small" }
127+ LeadingIcon = { EnvelopeIcon }
128+ onClick = { ( ) => {
129+ setSearchParams ( {
130+ feedbackPanel : feedbackType ,
131+ } ) ;
132+ toast . dismiss ( toastId ) ;
133+ } }
134+ >
135+ { action . label }
136+ </ Button >
125137 ) ;
126138 }
127- default : {
128- return null ;
129- }
130139 }
131140}
0 commit comments