@@ -6,11 +6,8 @@ import { useScrollTo } from "@/hooks/use-scroll-to";
66import { Sandpack } from "@codesandbox/sandpack-react" ;
77import { dracula as draculaTheme } from "@codesandbox/sandpack-themes" ;
88import { CheckIcon } from "@heroicons/react/16/solid" ;
9- import {
10- ArrowLongRightIcon ,
11- ChevronDownIcon ,
12- PlusIcon ,
13- } from "@heroicons/react/20/solid" ;
9+ import { ArrowLongRightIcon , ChevronDownIcon } from "@heroicons/react/20/solid" ;
10+ import { ArrowUpOnSquareIcon } from "@heroicons/react/24/outline" ;
1411import * as Select from "@radix-ui/react-select" ;
1512import * as Tooltip from "@radix-ui/react-tooltip" ;
1613import {
@@ -21,6 +18,7 @@ import {
2118import { AnimatePresence , motion } from "framer-motion" ;
2219import { FormEvent , useEffect , useState } from "react" ;
2320import LoadingDots from "../../components/loading-dots" ;
21+ import { shareApp } from "./actions" ;
2422
2523export default function Home ( ) {
2624 let [ status , setStatus ] = useState <
@@ -332,24 +330,30 @@ export default function Home() {
332330 < Tooltip . Root delayDuration = { 0 } >
333331 < Tooltip . Trigger asChild >
334332 < button
335- onClick = { ( ) => {
336- location . reload ( ) ;
333+ onClick = { async ( ) => {
334+ let userMessages = messages . filter (
335+ ( message ) => message . role === "user" ,
336+ ) ;
337+ let prompt =
338+ userMessages [ userMessages . length - 1 ] . content ;
337339
338- // TODO: Cancel stream and reset this state
339- // setMessages([]);
340- // setStatus("initial");
340+ await shareApp ( {
341+ generatedCode,
342+ prompt,
343+ model : modelUsedForInitialCode ,
344+ } ) ;
341345 } }
342346 className = "inline-flex size-[68px] items-center justify-center rounded-3xl bg-blue-500"
343347 >
344- < PlusIcon className = "size-10 text-white" />
348+ < ArrowUpOnSquareIcon className = "size-6 text-white" />
345349 </ button >
346350 </ Tooltip . Trigger >
347351 < Tooltip . Portal >
348352 < Tooltip . Content
349353 className = "select-none rounded bg-white px-4 py-2.5 text-sm leading-none shadow-md shadow-black/20"
350354 sideOffset = { 5 }
351355 >
352- Create a new app
356+ Share your app
353357 < Tooltip . Arrow className = "fill-white" />
354358 </ Tooltip . Content >
355359 </ Tooltip . Portal >
0 commit comments