Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
dschlabach committed Nov 22, 2024
1 parent a822b05 commit 825d071
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 0 additions & 3 deletions playground/nextjs-app-router/components/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import TransactionDemo from './demo/Transaction';
import TransactionDefaultDemo from './demo/TransactionDefault';
import WalletDemo from './demo/Wallet';
import WalletDefaultDemo from './demo/WalletDefault';
import { usePathname } from 'next/navigation';

const activeComponentMapping: Record<OnchainKitComponent, React.FC> = {
[OnchainKitComponent.Fund]: FundDemo,
Expand All @@ -39,8 +38,6 @@ const activeComponentMapping: Record<OnchainKitComponent, React.FC> = {
};

function Demo() {
const pathname = usePathname();
console.log('pathname:', pathname);
const { activeComponent } = useContext(AppContext);
const [isDarkMode, setIsDarkMode] = useState(true);
const [sideBarVisible, setSideBarVisible] = useState(true);
Expand Down
5 changes: 2 additions & 3 deletions playground/nextjs-app-router/lib/url-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,20 @@ const URL_PARAM_MAPPING: Partial<Record<OnchainKitComponent, string[]>> = {

export function getShareableUrl(activeComponent?: OnchainKitComponent) {
if (!activeComponent) {
return window.location.origin;
return `${window.location.origin}${window.location.pathname}`;
}

const relevantParams = getComponentQueryParams(activeComponent);
const params = new URLSearchParams();

for (const param of [...relevantParams, ...commonOptions]) {
const value = localStorage.getItem(getStorageKey(param));
// Only include the param if it's not the default value
if (value && value !== defaultState[param as keyof typeof defaultState]) {
params.set(param, value);
}
}

return `${window.location.origin}?${params.toString()}`;
return `${window.location.origin}${window.location.pathname}?${params.toString()}`;
}

export function getComponentQueryParams(component: OnchainKitComponent) {
Expand Down

0 comments on commit 825d071

Please sign in to comment.