Fix frontend Docker build and session ID typing
This commit is contained in:
@@ -11,7 +11,7 @@ RUN npm install
|
|||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN mkdir -p public && npm run build
|
||||||
|
|
||||||
# Production
|
# Production
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default function PortfolioPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session?.user) {
|
if (session?.user?.id) {
|
||||||
fetchPortfolio(session.user.id);
|
fetchPortfolio(session.user.id);
|
||||||
}
|
}
|
||||||
}, [session, isPending, router]);
|
}, [session, isPending, router]);
|
||||||
@@ -48,13 +48,15 @@ export default function PortfolioPage() {
|
|||||||
|
|
||||||
const handleAddHolding = async (e: React.FormEvent) => {
|
const handleAddHolding = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const userId = session?.user?.id;
|
||||||
|
if (!userId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/portfolio`, {
|
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/portfolio`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
user_id: session?.user?.id,
|
user_id: userId,
|
||||||
ticker: newHolding.ticker.toUpperCase(),
|
ticker: newHolding.ticker.toUpperCase(),
|
||||||
shares: parseFloat(newHolding.shares),
|
shares: parseFloat(newHolding.shares),
|
||||||
avg_cost: parseFloat(newHolding.avg_cost)
|
avg_cost: parseFloat(newHolding.avg_cost)
|
||||||
@@ -63,7 +65,7 @@ export default function PortfolioPage() {
|
|||||||
|
|
||||||
setShowAddModal(false);
|
setShowAddModal(false);
|
||||||
setNewHolding({ ticker: '', shares: '', avg_cost: '' });
|
setNewHolding({ ticker: '', shares: '', avg_cost: '' });
|
||||||
fetchPortfolio(session?.user?.id);
|
fetchPortfolio(userId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error adding holding:', error);
|
console.error('Error adding holding:', error);
|
||||||
}
|
}
|
||||||
@@ -71,13 +73,15 @@ export default function PortfolioPage() {
|
|||||||
|
|
||||||
const handleDeleteHolding = async (id: number) => {
|
const handleDeleteHolding = async (id: number) => {
|
||||||
if (!confirm('Are you sure you want to delete this holding?')) return;
|
if (!confirm('Are you sure you want to delete this holding?')) return;
|
||||||
|
const userId = session?.user?.id;
|
||||||
|
if (!userId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/portfolio/${id}`, {
|
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/portfolio/${id}`, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
|
|
||||||
fetchPortfolio(session?.user?.id);
|
fetchPortfolio(userId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting holding:', error);
|
console.error('Error deleting holding:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default function WatchlistPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session?.user) {
|
if (session?.user?.id) {
|
||||||
fetchWatchlist(session.user.id);
|
fetchWatchlist(session.user.id);
|
||||||
}
|
}
|
||||||
}, [session, isPending, router]);
|
}, [session, isPending, router]);
|
||||||
@@ -38,13 +38,15 @@ export default function WatchlistPage() {
|
|||||||
|
|
||||||
const handleAddStock = async (e: React.FormEvent) => {
|
const handleAddStock = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const userId = session?.user?.id;
|
||||||
|
if (!userId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/watchlist`, {
|
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/watchlist`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
user_id: session?.user?.id,
|
user_id: userId,
|
||||||
ticker: newStock.ticker.toUpperCase(),
|
ticker: newStock.ticker.toUpperCase(),
|
||||||
company_name: newStock.company_name,
|
company_name: newStock.company_name,
|
||||||
sector: newStock.sector
|
sector: newStock.sector
|
||||||
@@ -53,7 +55,7 @@ export default function WatchlistPage() {
|
|||||||
|
|
||||||
setShowAddModal(false);
|
setShowAddModal(false);
|
||||||
setNewStock({ ticker: '', company_name: '', sector: '' });
|
setNewStock({ ticker: '', company_name: '', sector: '' });
|
||||||
fetchWatchlist(session?.user?.id);
|
fetchWatchlist(userId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error adding stock:', error);
|
console.error('Error adding stock:', error);
|
||||||
}
|
}
|
||||||
@@ -61,13 +63,15 @@ export default function WatchlistPage() {
|
|||||||
|
|
||||||
const handleDeleteStock = async (id: number) => {
|
const handleDeleteStock = async (id: number) => {
|
||||||
if (!confirm('Are you sure you want to remove this stock from watchlist?')) return;
|
if (!confirm('Are you sure you want to remove this stock from watchlist?')) return;
|
||||||
|
const userId = session?.user?.id;
|
||||||
|
if (!userId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/watchlist/${id}`, {
|
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/watchlist/${id}`, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
|
|
||||||
fetchWatchlist(session?.user?.id);
|
fetchWatchlist(userId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting stock:', error);
|
console.error('Error deleting stock:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user