Skip to content

Commit

Permalink
fix fe lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 6, 2024
1 parent 1951a8f commit 929ba89
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
- name: Type check frontend
run: cd frontend && pnpm tsc --noEmit -p tsconfig.app.json

- name: Build
run: pnpm build
- name: Build frontend and backend
run: pnpm build:all

- name: Check formatting
run: pnpm prettier --check "src/**/!(*d).ts"
Expand Down
48 changes: 31 additions & 17 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { getDefaultConfig, RainbowKitProvider, darkTheme } from '@rainbow-me/rainbowkit';
import { mainnet, optimism, optimismGoerli, sepolia, goerli } from 'viem/chains';
import {
getDefaultConfig,
RainbowKitProvider,
darkTheme,
} from '@rainbow-me/rainbowkit';
import {
mainnet,
optimism,
optimismGoerli,
sepolia,
goerli,
} from 'viem/chains';
import { WagmiProvider, http } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import '@rainbow-me/rainbowkit/styles.css';
Expand All @@ -11,7 +21,7 @@ import { BalanceDisplay } from './components/BalanceDisplay';
import { CreateAllocation } from './components/CreateAllocation';
import HealthCheck from './components/HealthCheck';
import { DepositForm } from './components/DepositForm';
import { NotificationProvider } from './context/NotificationContext';
import { NotificationProvider } from './context/NotificationProvider';

// Configure supported chains
const projectId = 'YOUR_PROJECT_ID'; // Get from WalletConnect Cloud
Expand All @@ -22,9 +32,7 @@ const config = getDefaultConfig({
appName: 'Smallocator',
projectId,
chains,
transports: Object.fromEntries(
chains.map((chain) => [chain.id, http()])
),
transports: Object.fromEntries(chains.map((chain) => [chain.id, http()])),
ssr: true,
});

Expand All @@ -37,15 +45,19 @@ const customTheme = darkTheme({

function App() {
const [sessionToken, setSessionToken] = useState<string | null>(null);

const queryClient = useMemo(() => new QueryClient({
defaultOptions: {
queries: {
staleTime: Infinity,
refetchOnWindowFocus: false,
},
},
}), []);

const queryClient = useMemo(
() =>
new QueryClient({
defaultOptions: {
queries: {
staleTime: Infinity,
refetchOnWindowFocus: false,
},
},
}),
[]
);

return (
<WagmiProvider config={config}>
Expand Down Expand Up @@ -82,7 +94,7 @@ function App() {
</svg>
</a>
<WalletConnect hasSession={!!sessionToken} />
<SessionManager
<SessionManager
sessionToken={sessionToken}
onSessionUpdate={setSessionToken}
/>
Expand All @@ -109,7 +121,9 @@ function App() {
)}

{/* Create Allocation Form */}
{sessionToken && <CreateAllocation sessionToken={sessionToken} />}
{sessionToken && (
<CreateAllocation sessionToken={sessionToken} />
)}
</div>
</div>
</main>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CreateAllocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function CreateAllocation({ sessionToken }: CreateAllocationProps) {
if (amountBigInt > availableBigInt) {
newErrors.amount = 'Amount exceeds available balance';
}
} catch (_err) {
} catch {
newErrors.amount = 'Invalid amount';
}
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/DepositForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function DepositForm() {
if (numAmount <= 0) {
return { type: 'error', message: 'Amount must be greater than zero' };
}
} catch (_e) {
} catch {
return { type: 'error', message: 'Invalid amount format' };
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export function DepositForm() {
return { type: 'warning', message: 'Insufficient Allowance' };
}
return null;
} catch (_e) {
} catch {
return { type: 'error', message: 'Invalid amount format' };
}
}
Expand All @@ -91,7 +91,7 @@ export function DepositForm() {
return { type: 'error', message: 'Insufficient ETH Balance' };
}
return null;
} catch (_e) {
} catch {
return { type: 'error', message: 'Invalid amount format' };
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import { createContext, ReactNode } from 'react';

interface NotificationContextType {
showNotification: (notification: {
type: 'success' | 'error' | 'warning' | 'info';
title: string;
message: string;
}) => void;
}

export const NotificationContext = createContext<
NotificationContextType | undefined
>(undefined);
import { ReactNode } from 'react';
import { NotificationContext } from './notification-context';

export function NotificationProvider({ children }: { children: ReactNode }) {
const showNotification = (notification: {
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/context/notification-context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createContext } from 'react';

interface NotificationContextType {
showNotification: (notification: {
type: 'success' | 'error' | 'warning' | 'info';
title: string;
message: string;
}) => void;
}

export const NotificationContext = createContext<
NotificationContextType | undefined
>(undefined);
2 changes: 1 addition & 1 deletion frontend/src/hooks/useNotification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { NotificationContext } from '../context/NotificationContext';
import { NotificationContext } from '../context/notification-context';

export function useNotification() {
const context = useContext(NotificationContext);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useSessionPoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function useSessionPoller(
if (expiryTime < Date.now()) {
throw new Error('Session expired');
}
} catch (_error) {
} catch {
// On any error, clear the session
localStorage.removeItem(`session-${address}`);
onSessionUpdate(null);
Expand Down

0 comments on commit 929ba89

Please sign in to comment.