# Frontend Deployment Check & Fix

## Issue
Seeing "DBIS Core Banking System - Frontend application deployment pending" on refresh.

## Root Cause
This message appears when:
1. The frontend hasn't been built (`dist/` folder doesn't exist or is empty)
2. Nginx is pointing to the wrong directory
3. The build failed during deployment

## Solution

### Step 1: Check if Frontend is Built

If you're on the deployment container (VMID 10130):

```bash
# Check if dist folder exists
ls -la /opt/dbis-core/frontend/dist/

# Check if it has content
ls -la /opt/dbis-core/frontend/dist/ | head -20
```

### Step 2: Build the Frontend

If the `dist/` folder is missing or empty, build the frontend:

```bash
cd /opt/dbis-core/frontend

# Install dependencies (if needed)
npm install

# Build the application
npm run build
```

### Step 3: Verify Nginx Configuration

Check that nginx is pointing to the correct directory:

```bash
# Check nginx config
cat /etc/nginx/sites-available/dbis-frontend | grep root

# Should show:
# root /opt/dbis-core/frontend/dist;
```

### Step 4: Restart Nginx

After building, restart nginx:

```bash
systemctl restart nginx
systemctl status nginx
```

### Step 5: Verify Build Output

Check that index.html exists in dist:

```bash
ls -la /opt/dbis-core/frontend/dist/index.html
cat /opt/dbis-core/frontend/dist/index.html | head -10
```

## Quick Fix Script

Run this on the frontend container (VMID 10130):

```bash
#!/bin/bash
cd /opt/dbis-core/frontend

# Check if node_modules exists
if [ ! -d "node_modules" ]; then
    echo "Installing dependencies..."
    npm install
fi

# Build the application
echo "Building frontend..."
npm run build

# Verify build
if [ -f "dist/index.html" ]; then
    echo "✅ Build successful!"
    echo "Restarting nginx..."
    systemctl restart nginx
    echo "✅ Frontend should now be accessible"
else
    echo "❌ Build failed - check errors above"
    exit 1
fi
```

## From Proxmox Host

If you need to run this from the Proxmox host:

```bash
# SSH into the container
pct exec 10130 -- bash

# Then run the build commands above
```

Or run directly:

```bash
pct exec 10130 -- bash -c "cd /opt/dbis-core/frontend && npm run build && systemctl restart nginx"
```

## Troubleshooting

### Build Errors

If `npm run build` fails:
1. Check Node.js version: `node --version` (should be 18+)
2. Check for TypeScript errors
3. Check for missing dependencies
4. Review build output for specific errors

### Nginx Errors

If nginx fails to start:
1. Test config: `nginx -t`
2. Check logs: `journalctl -u nginx -n 50`
3. Verify directory permissions

### Still Seeing Placeholder

If you still see the placeholder message:
1. Clear browser cache
2. Check browser console for errors
3. Verify you're accessing the correct IP/URL
4. Check nginx access logs: `tail -f /var/log/nginx/access.log`
