Fix frontend Docker build and session ID typing

This commit is contained in:
2026-02-20 22:02:48 -05:00
parent 7df3d54103
commit 6e299b1e1f
3 changed files with 17 additions and 9 deletions

View File

@@ -22,7 +22,7 @@ export default function PortfolioPage() {
return;
}
if (session?.user) {
if (session?.user?.id) {
fetchPortfolio(session.user.id);
}
}, [session, isPending, router]);
@@ -48,13 +48,15 @@ export default function PortfolioPage() {
const handleAddHolding = async (e: React.FormEvent) => {
e.preventDefault();
const userId = session?.user?.id;
if (!userId) return;
try {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/portfolio`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
user_id: session?.user?.id,
user_id: userId,
ticker: newHolding.ticker.toUpperCase(),
shares: parseFloat(newHolding.shares),
avg_cost: parseFloat(newHolding.avg_cost)
@@ -63,7 +65,7 @@ export default function PortfolioPage() {
setShowAddModal(false);
setNewHolding({ ticker: '', shares: '', avg_cost: '' });
fetchPortfolio(session?.user?.id);
fetchPortfolio(userId);
} catch (error) {
console.error('Error adding holding:', error);
}
@@ -71,13 +73,15 @@ export default function PortfolioPage() {
const handleDeleteHolding = async (id: number) => {
if (!confirm('Are you sure you want to delete this holding?')) return;
const userId = session?.user?.id;
if (!userId) return;
try {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/portfolio/${id}`, {
method: 'DELETE'
});
fetchPortfolio(session?.user?.id);
fetchPortfolio(userId);
} catch (error) {
console.error('Error deleting holding:', error);
}