11import { parse } from "@conform-to/zod" ;
2+ import { InformationCircleIcon } from "@heroicons/react/20/solid" ;
23import { Form , useNavigation , useSubmit } from "@remix-run/react" ;
34import { ActionFunctionArgs , json } from "@remix-run/server-runtime" ;
45import { Waitpoint } from "@trigger.dev/database" ;
56import { useCallback , useRef } from "react" ;
67import { z } from "zod" ;
8+ import { CodeBlock } from "~/components/code/CodeBlock" ;
9+ import { InlineCode } from "~/components/code/InlineCode" ;
710import { JSONEditor } from "~/components/code/JSONEditor" ;
811import { Button } from "~/components/primitives/Buttons" ;
12+ import { Callout } from "~/components/primitives/Callout" ;
913import { Fieldset } from "~/components/primitives/Fieldset" ;
10- import { Header2 } from "~/components/primitives/Headers" ;
14+ import { Header3 } from "~/components/primitives/Headers" ;
1115import { InputGroup } from "~/components/primitives/InputGroup" ;
1216import { Label } from "~/components/primitives/Label" ;
17+ import { Paragraph } from "~/components/primitives/Paragraph" ;
1318import { prisma } from "~/db.server" ;
1419import { useOrganization } from "~/hooks/useOrganizations" ;
1520import { useProject } from "~/hooks/useProject" ;
@@ -90,7 +95,7 @@ export function CompleteWaitpointForm({ waitpoint }: { waitpoint: FormWaitpoint
9095 const isLoading = navigation . state !== "idle" ;
9196 const organization = useOrganization ( ) ;
9297 const project = useProject ( ) ;
93- const currentJson = useRef < string > ( "" ) ;
98+ const currentJson = useRef < string > ( "{\n\n} " ) ;
9499 const formAction = `/resources/orgs/${ organization . slug } /projects/${ project . slug } /waitpoints/${ waitpoint . friendlyId } /complete` ;
95100
96101 const submitForm = useCallback (
@@ -114,52 +119,62 @@ export function CompleteWaitpointForm({ waitpoint }: { waitpoint: FormWaitpoint
114119 ) ;
115120
116121 return (
117- < Form
118- action = { formAction }
119- method = "post"
120- onSubmit = { ( e ) => submitForm ( e ) }
121- className = "grid h-full max-h-full grid-rows-[2.5rem_1fr_3.25rem] overflow-hidden bg-background-bright"
122- >
123- < div className = "mx-3 flex items-center justify-between gap-2 border-b border-grid-dimmed" >
124- < Header2 className = { cn ( "whitespace-nowrap" ) } > Complete waitpoint </ Header2 >
125- </ div >
126- < div className = "overflow-y-scroll scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600" >
127- < div className = "p-3 " >
122+ < div className = "space-y-3" >
123+ < Form
124+ action = { formAction }
125+ method = "post"
126+ onSubmit = { ( e ) => submitForm ( e ) }
127+ className = "grid h-full max-h-full grid-rows-[2.5rem_1fr_2.5rem] overflow-hidden rounded-md border border-grid-bright"
128+ >
129+ < div className = "mx-3 flex items-center" >
130+ < Header3 className = { cn ( "whitespace-nowrap" ) } > Manually complete this waitpoint </ Header3 >
131+ </ div >
132+ < div className = "overflow-y-auto border-t border-grid-dimmed bg-charcoal-900 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600 " >
128133 < input type = "hidden" name = "type" value = { waitpoint . type } />
129- < Fieldset >
130- < InputGroup >
131- < Label > Payload</ Label >
132- < JSONEditor
133- autoFocus
134- defaultValue = { currentJson . current }
135- readOnly = { false }
136- basicSetup
137- onChange = { ( v ) => {
138- currentJson . current = v ;
139- } }
140- showClearButton = { false }
141- showCopyButton = { false }
142- height = "100%"
143- min-height = "100%"
144- max-height = "100%"
145- />
146- </ InputGroup >
147- </ Fieldset >
134+ < div className = "max-h-[70vh] min-h-40 overflow-y-auto bg-charcoal-900 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600" >
135+ < JSONEditor
136+ autoFocus
137+ defaultValue = { currentJson . current }
138+ readOnly = { false }
139+ basicSetup
140+ onChange = { ( v ) => {
141+ currentJson . current = v ;
142+ } }
143+ showClearButton = { false }
144+ showCopyButton = { false }
145+ height = "100%"
146+ min-height = "100%"
147+ max-height = "100%"
148+ />
149+ </ div >
148150 </ div >
149- </ div >
150- < div className = "flex items-center justify-end gap-2 border-t border-grid-dimmed px-2" >
151- < div className = "flex items-center gap-4" >
152- < Button
153- variant = "primary/medium"
154- type = "submit"
155- disabled = { isLoading }
156- shortcut = { { key : "enter" , modifiers : [ "mod" ] } }
157- LeadingIcon = { isLoading ? "spinner" : undefined }
158- >
159- { isLoading ? "Completing…" : "Complete" }
160- </ Button >
151+ < div className = "bg-charcoal-900 px-2" >
152+ < div className = "mb-2 flex items-center justify-end gap-2 border-t border-grid-dimmed pt-2" >
153+ < Button
154+ variant = "secondary/small"
155+ type = "submit"
156+ disabled = { isLoading }
157+ LeadingIcon = { isLoading ? "spinner" : undefined }
158+ >
159+ { isLoading ? "Completing…" : "Complete waitpoint" }
160+ </ Button >
161+ </ div >
162+ </ div >
163+ </ Form >
164+ < div className = "rounded-md border border-charcoal-700 bg-charcoal-800" >
165+ < div className = "flex items-center gap-2 px-2 pt-2" >
166+ < InformationCircleIcon className = "h-5 w-5 shrink-0 text-text-dimmed" />
167+ < Paragraph variant = "small" > To complete this waitpoint in your code use:</ Paragraph >
161168 </ div >
169+ < CodeBlock
170+ code = { `
171+ await wait.completeToken<YourType>(tokenId,
172+ output
173+ );` }
174+ className = "mt-1 max-w-full border-0 pl-1"
175+ showLineNumbers = { false }
176+ />
162177 </ div >
163- </ Form >
178+ </ div >
164179 ) ;
165180}
0 commit comments