-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use new composer action hook in debugger
- Loading branch information
1 parent
9f105d7
commit 5b2945e
Showing
9 changed files
with
320 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/debugger/app/components/composer-action-debugger.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { | ||
ComposerActionResponse, | ||
ComposerActionState, | ||
} from "frames.js/types"; | ||
import { CastComposer, CastComposerRef } from "./cast-composer"; | ||
import { useRef, useState } from "react"; | ||
import { ComposerFormActionDialog } from "./composer-form-action-dialog"; | ||
import { useFarcasterIdentity } from "../hooks/useFarcasterIdentity"; | ||
|
||
type ComposerActionDebuggerProps = { | ||
url: string; | ||
actionMetadata: Partial<ComposerActionResponse>; | ||
onToggleToCastActionDebugger: () => void; | ||
}; | ||
|
||
export function ComposerActionDebugger({ | ||
actionMetadata, | ||
url, | ||
onToggleToCastActionDebugger, | ||
}: ComposerActionDebuggerProps) { | ||
const castComposerRef = useRef<CastComposerRef>(null); | ||
const signer = useFarcasterIdentity(); | ||
const [actionState, setActionState] = useState<ComposerActionState | null>( | ||
null | ||
); | ||
|
||
return ( | ||
<> | ||
<CastComposer | ||
composerAction={actionMetadata} | ||
onComposerActionClick={setActionState} | ||
ref={castComposerRef} | ||
/> | ||
{!!actionState && ( | ||
<ComposerFormActionDialog | ||
actionState={actionState} | ||
signer={signer} | ||
url={url} | ||
onClose={() => { | ||
setActionState(null); | ||
}} | ||
onSubmit={(newActionState) => { | ||
castComposerRef.current?.updateState(newActionState); | ||
setActionState(null); | ||
}} | ||
onToggleToCastActionDebugger={onToggleToCastActionDebugger} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
Oops, something went wrong.