File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use client" ;
22
3+ import { useEffect , useState } from "react" ;
4+ import type { LogoState } from "@/iconlogo/domain/logo/logo.types" ;
5+ import { sanitizeLogoState } from "@/iconlogo/domain/logo/logo.validators" ;
36import TanStackQueryProvider from "@/iconlogo/integrations/tanstack-query/root-provider" ;
47import { AppShell } from "@/iconlogo/features/editor/AppShell" ;
58
69export default function IconLogoEditorClient ( ) {
10+ const [ sharedLogo , setSharedLogo ] = useState < LogoState | null > ( null ) ;
11+
12+ useEffect ( ( ) => {
13+ const raw = new URLSearchParams ( window . location . search ) . get ( "s" ) ;
14+ if ( ! raw ) return ;
15+ try {
16+ setSharedLogo ( sanitizeLogoState ( JSON . parse ( decodeURIComponent ( raw ) ) ) ) ;
17+ } catch {
18+ setSharedLogo ( null ) ;
19+ }
20+ } , [ ] ) ;
21+
722 return (
823 < TanStackQueryProvider >
924 < main className = "min-h-screen bg-black text-white overflow-hidden" >
10- < AppShell />
25+ < AppShell sharedLogo = { sharedLogo } />
1126 </ main >
1227 </ TanStackQueryProvider >
1328 ) ;
Original file line number Diff line number Diff line change 11import { useLogoStore } from "#/store/logo-store" ;
2- import { createShareFn } from "#/server/share.create" ;
32
43export async function createShareLink ( ) : Promise < string > {
54 const logo = useLogoStore . getState ( ) . present ;
6- const result = await createShareFn ( { data : { logoState : logo } } ) ;
7- return `${ window . location . origin } /editor?s=${ result . id } ` ;
5+ const payload = encodeURIComponent ( JSON . stringify ( logo ) ) ;
6+ return `${ window . location . origin } /iconlogo/ editor?s=${ payload } ` ;
87}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { Tooltip } from "@heroui/react";
44import type { LogoState } from "#/domain/logo/logo.types" ;
55import { loadLogoFromState } from "#/commands/logo/load-logo" ;
66import { CollectionsButton } from "#/features/collections/CollectionsButton" ;
7+ import { ShareButton } from "#/features/share/ShareButton" ;
78import { EditorPage } from "./EditorPage" ;
89import { FABs } from "./FABs" ;
910import { MobileTopBar } from "./MobileTopBar" ;
@@ -90,6 +91,9 @@ export function AppShell({
9091 </ Tooltip . Content >
9192 </ Tooltip >
9293 </ motion . div >
94+ < motion . div variants = { itemVariants } >
95+ < ShareButton />
96+ </ motion . div >
9397 < motion . div variants = { itemVariants } >
9498 < CollectionsButton />
9599 </ motion . div >
You can’t perform that action at this time.
0 commit comments