Skip to content

Commit be64f83

Browse files
authored
Merge pull request #416 from Gbemi-programmer/fix/consolidate-layout-imports
Fix/consolidate layout imports
2 parents 99b9065 + b3b8635 commit be64f83

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

app/(merchant)/layout.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
import { useCallback, useState, useEffect } from "react";
44
import { useRouter } from "next/navigation";
55
import { AlertTriangle } from "lucide-react";
6-
import { MerchantSidebar } from "@/components/layout";
6+
import { MerchantSidebar, MobileNavDrawer, Topbar, Footer, MobileBottomNav } from "@/components/layout";
77
import { merchantNavItems } from "@/lib/navigation/merchantNav";
88
import { PageTransition, ErrorBoundary } from "@/components/shared";
9-
import { MobileNavDrawer } from "@/components/layout";
10-
import { Topbar } from "@/components/layout";
11-
import Footer from "@/components/layout";
12-
import { MobileBottomNav } from "@/components/layout";
139
import { OnboardingWizard } from "@/components/onboarding/OnboardingWizard";
1410
import { useWalletStore } from "@/lib/store/walletStore";
1511
import { useAuthStore } from "@/lib/store/authStore";
@@ -55,9 +51,13 @@ export default function MerchantLayout({
5551
}, [logout, router, dismissWarning]);
5652

5753
useEffect(() => {
58-
router.prefetch("/transactions");
59-
router.prefetch("/payments");
60-
}, [router]);
54+
try {
55+
router.prefetch("/transactions");
56+
router.prefetch("/payments");
57+
} catch {
58+
// Prefetch may throw during SSR or in edge environments
59+
}
60+
}, []);
6161

6262
return (
6363
<div className="flex h-screen overflow-hidden bg-background">

components/shared/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export * from './CurrencyDisplay';
55
export * from './ErrorDisplay';
66
export * from './StatusBadge';
77
export * from './CopyAddress';
8-
export * from './EmptyState';
8+
export * from './EmptyState';
9+
export * from './PageHeader';

lib/api/hooks.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import { useMemo } from 'react';
34
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
45
import { apiClient } from './axios';
56
import type { MerchantProfile, MerchantBankAccount } from '../types';
@@ -192,10 +193,13 @@ export function useRates(): UseRatesResult {
192193
});
193194

194195
const rates: ApiRate[] = query.data?.rates ?? [];
195-
const primaryRate =
196-
query.data?.usdcNgn ??
197-
rates.find((r) => r.from === 'USDC' && r.to === 'NGN')?.rate ??
198-
null;
196+
const primaryRate = useMemo(
197+
() =>
198+
query.data?.usdcNgn ??
199+
rates.find((r) => r.from === 'USDC' && r.to === 'NGN')?.rate ??
200+
null,
201+
[query.data, rates],
202+
);
199203

200204
return {
201205
data: rates,

0 commit comments

Comments
 (0)