# cPanel Deployment Guide for Uni Flow Grants Website

## Building for Production

### Step 1: Create Production Build

Run the following commands in the `/app/frontend` directory:

```bash
cd /app/frontend
yarn build
```

This will create a `build` folder with optimized production files.

### Step 2: Files to Upload to cPanel

After running `yarn build`, upload the contents of the `/app/frontend/build` folder to your cPanel hosting:

**Upload these files/folders:**
- `index.html` (main entry point)
- `static/` folder (contains CSS, JS, and media files)
- `manifest.json`
- `robots.txt`
- `favicon.ico`
- Any other files in the build folder

### Step 3: cPanel Upload Instructions

1. **Login to cPanel**
   - Go to your hosting provider's cPanel login page
   - Enter your credentials

2. **Navigate to File Manager**
   - Find and click "File Manager" in cPanel
   - Navigate to `public_html` (or your domain's root folder)

3. **Upload Files**
   - Click "Upload" button
   - Select all files from `/app/frontend/build` folder
   - Upload them to your `public_html` directory
   
   **OR**
   
   - Compress the build folder as a `.zip` file
   - Upload the zip file to cPanel
   - Extract it in the File Manager

4. **Configure .htaccess for React Router**

Create a `.htaccess` file in your `public_html` directory with the following content:

```apache
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]
</IfModule>
```

This ensures that React Router works correctly on page refreshes.

## Important Notes

### Hidden Pages (No Navigation Links)

The following pages work but are not linked in the navigation:
- `/signup` - Signup page (accessible only via direct URL)
- `/verification` - Verification form page (Cognito form #26)

Users can access these pages by typing the URL directly:
- `https://yourdomain.com/signup`
- `https://yourdomain.com/verification`

### Environment Variables

Since this is a frontend-only build, there are no backend environment variables needed. The Cognito Forms are embedded using their public script tags.

### Troubleshooting

**Issue: Blank page or 404 errors on refresh**
- Solution: Make sure the `.htaccess` file is properly configured (see Step 4 above)

**Issue: Cognito Forms not loading**
- Solution: Check browser console for errors. The forms require an active internet connection and the Cognito Forms service to be available.

**Issue: Styles not loading**
- Solution: Ensure the `static` folder is uploaded correctly with all CSS files

## File Structure After Upload

```
public_html/
├── index.html
├── .htaccess
├── manifest.json
├── robots.txt
├── favicon.ico
└── static/
    ├── css/
    ├── js/
    └── media/
```

## Testing After Deployment

1. Visit your domain: `https://yourdomain.com`
2. Test all navigation links
3. Test authentication (Login/Signup)
4. Test forms on Check Eligibility and Contact Support pages
5. Test hidden pages:
   - `https://yourdomain.com/signup`
   - `https://yourdomain.com/verification`

## Contact

If you encounter any issues during deployment, check the browser console (F12) for error messages.
