# CV & Cover Letter Feature - Quick Reference

## 🎯 Feature Status: ✅ COMPLETE

Everything needed for nurses to upload CVs and cover letters, and employers to view them, is fully implemented.

---

## 👩‍⚕️ For Nurses

### Upload Your CV
```
Dashboard → My Profile → Documents section
├── Select Document Type (CV, License, NCLEX, IELTS, OET, Passport, Other)
├── Click "Upload" and choose file (PDF, DOC, DOCX, JPG, PNG - max 5MB)
├── See your document in the "Your Documents" list
└── Status shows as "Uploaded" or "Verified"
```

### Apply for a Job
```
Browse Jobs → Click Job Details
├── Find "Select your CV/Resume" dropdown (REQUIRED)
├── Choose the CV you uploaded
├── Optionally write a Cover Letter
├── Click "Apply now"
└── See confirmation message
```

### Manage Your Documents
```
Dashboard → My Profile → Documents section
├── See all uploaded documents with status
├── Click "Delete" to remove any document
└── Upload new documents anytime
```

---

## 👔 For Employers

### View Applications
```
Dashboard → Applications
├── See list of applicants
├── Preview first 160 characters of cover letter
└── Click applicant name to see full details
```

### View Full Application
```
Click Applicant Name
├── See CV Document section:
│   ├── Document type (📄)
│   ├── Original filename
│   ├── Upload date
│   └── [View Document] button ← Click to open/download CV
├── See Cover Letter section:
│   └── Full cover letter text
├── Manage Application:
│   ├── Change Status dropdown
│   └── Add internal Notes
└── View Internal Notes:
    ├── All team notes with timestamps
    ├── Who added each note
    └── Delete buttons for management
```

---

## 🗂️ File Locations (For Developers)

### Key View Files
- `resources/views/nurse/profile/show.blade.php` - Document upload
- `resources/views/jobs/show.blade.php` - CV selection in job application
- `resources/views/employer/applications/show.blade.php` - View CV & cover letter
- `resources/views/employer/jobs/applicants.blade.php` - Application list

### Key Models
- `app/Models/JobApplication.php` - Has `cvDocument()` relationship
- `app/Models/NurseDocument.php` - Stores document metadata

### Key Controller
- `app/Http/Controllers/Nurse/ApplicationController.php@store()` - Saves cv_document_id

### Database
- Table: `job_applications` - Has `cv_document_id` column
- Table: `nurse_documents` - Stores file metadata
- Files: Stored in `storage/documents/`

---

## 🔑 Key Database Fields

### job_applications
```
cv_document_id    → Foreign key to nurse_documents.id
cover_letter      → Full cover letter text
status            → 'applied', 'shortlisted', 'interview', 'offer', 'hired', 'rejected'
```

### nurse_documents
```
type              → 'CV', 'License', 'NCLEX', 'IELTS', 'OET', 'Passport', 'Other'
original_filename → Filename shown to user
file_path         → Path in storage/documents/
status            → 'uploaded', 'pending_review', 'verified', 'rejected'
```

---

## ✅ What's Included

| Feature | Status | Location |
|---------|--------|----------|
| CV Upload | ✅ Done | Nurse Profile → Documents |
| CV Selection in Application | ✅ Done | Job Detail Page |
| CV Storage | ✅ Done | storage/documents/ |
| CV Display to Employer | ✅ Done | Application Detail Page |
| CV Download Link | ✅ Done | [View Document] button |
| Cover Letter Capture | ✅ Done | Job Application Form |
| Cover Letter Display | ✅ Done | Application Detail Page |
| Application Notes | ✅ Done | Application Detail Page |
| Status Management | ✅ Done | Application Detail Page |
| Validation | ✅ Done | Backend controller |
| Error Handling | ✅ Done | Graceful fallbacks |
| Professional UI | ✅ Done | All views styled |

---

## 🔄 User Flow Diagram

```
NURSE SIDE:
Upload → Browse → Select CV → Write Letter → Apply → Confirmation
  ↓                                                        ↓
storage/           jobs.show.blade.php                success message
documents/         application form                   shown to nurse

EMPLOYER SIDE:
View List → Click Application → See CV → Read Letter → Manage Status
     ↓                              ↓
applicants.blade.php      applications/show.blade.php
                          with download link & notes
```

---

## 🚨 Error Handling

### When CV is Missing
**Nurse Side**: Warning shown → "No CV on file. Upload your CV/Resume to your profile first."
**Employer Side**: Warning shown → "⚠️ No CV/document submitted with this application"

### When Nurse Tries to Apply Without CV
**Behavior**: Form disabled, message shown → "Upload a new CV/document if needed"

### When File is Deleted After Application
**Behavior**: Gracefully handled → Shows "No CV/document submitted" instead of error

---

## 📱 Supported File Types

```
✅ PDF     (best for documents)
✅ DOC     (Word)
✅ DOCX    (Word)
✅ JPG     (images)
✅ PNG     (images)

❌ Unsupported: .txt, .exe, .zip, etc.

Max File Size: 5MB per document
```

---

## 🎨 UI Components

### Nurse Side
- Document Type Dropdown (CV, License, NCLEX, etc.)
- File Upload Input with validation
- Document List with Status Badges
- Delete Buttons
- Link to Upload Page from Application Form

### Employer Side
- CV Section with Icon (📄)
- "View Document" Download Link (opens in new tab)
- Cover Letter Display with Whitespace Preserved
- Status Dropdown
- Notes Management (Add/View/Delete)
- Internal Notes List with Timestamps

---

## 🔍 How to Test

### As Nurse:
1. Create/Login to nurse account
2. Go to Dashboard → My Profile
3. Upload a PDF CV
4. Go to Browse Jobs
5. Click any job
6. Select your CV from dropdown
7. Write optional cover letter
8. Click "Apply now"
9. See success confirmation

### As Employer:
1. Create/Login to employer account
2. Go to Dashboard → Applications
3. Click any applicant
4. See CV section with "View Document" button
5. Click button → CV opens in new tab (can download)
6. See full cover letter text below
7. Add status and internal notes

---

## 🛠️ Troubleshooting

### "No CV/document submitted" appears for new applications
**Cause**: cv_document_id not being saved from form
**Solution**: Check that form has `name="cv_document_id"` and controller saves it

### CV file not opening when clicking "View Document"
**Cause**: Storage symlink missing or file not accessible
**Solution**: Run `php artisan storage:link` in terminal

### Dropdown shows no documents for nurse
**Cause**: Nurse hasn't uploaded documents yet
**Solution**: Upload document in Profile → Documents first

### File upload fails
**Cause**: File size > 5MB or wrong file type
**Solution**: Use PDF, DOC, DOCX, JPG, PNG and keep file under 5MB

---

## 📚 Related Documentation

- `CV_COVER_LETTER_VERIFICATION.md` - Full feature verification report
- `CV_FEATURE_IMPLEMENTATION_GUIDE.md` - Detailed architecture & diagrams
- `CV_FEATURE_SUMMARY.md` - Executive summary

---

## 🎉 That's It!

The feature is complete and ready to use. Nurses can upload and select CVs, employers can view them. Simple as that!

**Questions?** Check the verification report or implementation guide above.

**Status**: ✅ Production Ready
**Last Updated**: 2024-12-05
