fix: AuthContext hoisting error and add presale launchpad UI

Frontend improvements for production readiness:
- Fixed AuthContext function hoisting issue (checkAdminStatus before use)
- Added complete Presale Launchpad UI (PresaleList, CreatePresale, PresaleDetail)
- Integrated with pallet-presale blockchain functionality
- Updated App.tsx routing for launchpad pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 18:32:08 +03:00
parent 3524f5c5c6
commit 9de2d853aa
5 changed files with 1360 additions and 31 deletions
+31 -31
View File
@@ -103,38 +103,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
clearInterval(timeoutChecker);
};
}, [user, updateLastActivity, checkSessionTimeout]);
useEffect(() => {
// Check active sessions and sets the user
supabase.auth.getSession().then(({ data: { session } }) => {
setUser(session?.user ?? null);
checkAdminStatus(); // Check admin status regardless of Supabase session
setLoading(false);
}).catch(() => {
// If Supabase is not available, still check wallet-based admin
checkAdminStatus();
setLoading(false);
});
// Listen for changes on auth state
const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session) => {
setUser(session?.user ?? null);
checkAdminStatus(); // Check admin status on auth change
setLoading(false);
});
// Listen for wallet changes (from PolkadotContext)
const handleWalletChange = () => {
checkAdminStatus();
};
window.addEventListener('walletChanged', handleWalletChange);
return () => {
subscription.unsubscribe();
window.removeEventListener('walletChanged', handleWalletChange);
};
}, [checkAdminStatus]);
const checkAdminStatus = useCallback(async () => {
// Admin wallet whitelist (blockchain-based auth)
@@ -182,6 +151,37 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
}
}, []);
useEffect(() => {
// Check active sessions and sets the user
supabase.auth.getSession().then(({ data: { session } }) => {
setUser(session?.user ?? null);
checkAdminStatus(); // Check admin status regardless of Supabase session
setLoading(false);
}).catch(() => {
// If Supabase is not available, still check wallet-based admin
checkAdminStatus();
setLoading(false);
});
// Listen for changes on auth state
const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session) => {
setUser(session?.user ?? null);
checkAdminStatus(); // Check admin status on auth change
setLoading(false);
});
// Listen for wallet changes (from PolkadotContext)
const handleWalletChange = () => {
checkAdminStatus();
};
window.addEventListener('walletChanged', handleWalletChange);
return () => {
subscription.unsubscribe();
window.removeEventListener('walletChanged', handleWalletChange);
};
}, [checkAdminStatus]);
const signIn = async (email: string, password: string) => {
try {
const { data, error } = await supabase.auth.signInWithPassword({