# FINEART Artist Profile Pages - Implementation Guide

## What's New in v3.1

Three new artist profile pages:
1. **Legal Informations** - Company/professional details
2. **Profile Informations** - Standard WP profile (already exists via MVX)
3. **Artist Signature** - Signature upload and digitalization

## Installation

1. Upload the updated plugin files
2. The new pages will automatically appear in the Artist Profile menu
3. Flush permalinks: Settings → Permalinks → Save Changes

## New Database Fields

### Legal Information (User Meta)
```
fineart_company_name
fineart_company_street
fineart_company_city
fineart_company_postal_code
fineart_company_country
fineart_vat_number
fineart_legal_info_complete (yes/empty)
```

### Artist Signature (User Meta)
```
fineart_signature_file_id (Google Drive file ID)
fineart_signature_preview_id (WP attachment ID for preview)
fineart_signature_uploaded_date (datetime)
artist_signature (digitalized signature URL - set by admin)
```

## URLs

- Legal Informations: `/dashboard/legal-informations/`
- Profile Informations: `/dashboard/vendor-profile/` (MVX default)
- Artist Signature: `/dashboard/artist-signature/`

## Legal Informations Page

**Fields:**
- Full Name (read-only, from user account)
- Company Name (required)
- Street Address (required)
- City (required)
- Postal Code (required)
- Country (required, dropdown)
- VAT Number (optional)
- Confirmation checkbox (required)

**Features:**
- Auto-saves to user meta
- Marks profile as complete when saved
- Status badge shows completion state
- AJAX form submission

## Artist Signature Page

**Upload Section:**
- Drag & drop support
- Click to upload
- JPG only, max 3MB
- Preview before upload
- Uploads to Google Drive (or local fallback)
- Also saves to WP media library for preview

**Digitalized Section:**
- Shows empty state until admin digitizes
- Displays digitalized signature once admin uploads
- Read-only field (admin-controlled via `artist_signature` meta key)

**Admin Workflow:**
1. Artist uploads raw signature
2. File saved to Google Drive folder: `FINEART_Artist_Signatures`
3. Admin downloads, digitizes (removes background, etc)
4. Admin uploads digitalized version to user meta `artist_signature`
5. Digitalized signature appears on artist's page

## Profile Informations Page

This uses the existing MVX vendor profile page at `/dashboard/vendor-profile/`. No changes needed - it already handles:
- Username
- Email
- Password change
- Display name
- Billing/shipping addresses

## Google Drive Setup

For signature uploads to work with Google Drive:

1. Create service account in Google Cloud Console
2. Download credentials JSON
3. Place at: `/wp-content/themes/your-theme/google-credentials.json`
4. Install Google Client library:
   ```bash
   composer require google/apiclient
   ```

If Google Drive is not set up, signatures will save locally with a fallback ID.

## Admin Tasks

### View Artist's Legal Info
```php
$legal_info = FineArt_Artist_Utils::get_legal_info($user_id);
// Returns: company_name, company_street, company_city, etc.
```

### Check Profile Completion
```php
$completion = FineArt_Artist_Utils::get_profile_completion($user_id);
// Returns:
// - legal_complete (bool)
// - signature_complete (bool)
// - artwork_count (int)
// - ready_for_validation (bool)
```

### Upload Digitalized Signature (Admin)
1. Go to Users → Edit User
2. Scroll to custom fields or use a plugin like Advanced Custom Fields
3. Add/update meta key: `artist_signature`
4. Value: URL to digitalized signature image
5. Save

Or via code:
```php
update_user_meta($user_id, 'artist_signature', 'https://fineart.gallery/path/to/digitalized-sig.png');
```

### Access Uploaded Signatures
Signatures are stored in Google Drive folder: `FINEART_Artist_Signatures`
Filename format: `signature_user_{USER_ID}_{TIMESTAMP}.jpg`

## Frontend Usage

### Check if artist has completed legal info
```php
$is_complete = get_user_meta($user_id, 'fineart_legal_info_complete', true) === 'yes';
```

### Get signature info
```php
$sig_info = FineArt_Artist_Signature::get_signature_info($user_id);
// Returns:
// - uploaded (bool)
// - file_id (string)
// - preview_url (string)
// - digitalized_url (string)
// - has_digitalized (bool)
```

## Styling

All pages use inline CSS for simplicity and portability. The styling matches FINEART's brand:
- Primary color: #d53668
- Secondary color: #daae52
- Gradient buttons
- Clean, modern forms

## Testing Checklist

### Legal Informations
- [ ] Page loads at `/dashboard/legal-informations/`
- [ ] Full name is pre-filled and read-only
- [ ] All required fields validate
- [ ] Country dropdown works
- [ ] Form submits via AJAX
- [ ] Success message appears
- [ ] Status badge updates to "Completed"
- [ ] Data saves to user meta

### Artist Signature
- [ ] Page loads at `/dashboard/artist-signature/`
- [ ] Drag & drop works
- [ ] Click to upload works
- [ ] File type validation works (JPG only)
- [ ] File size validation works (3MB max)
- [ ] Preview shows before upload
- [ ] Upload button appears after file selection
- [ ] Form submits via AJAX
- [ ] Success message appears
- [ ] Uploaded signature displays
- [ ] Digitalized section shows "Awaiting" state
- [ ] When admin adds `artist_signature` meta, digitalized shows

### Profile Informations
- [ ] Page loads at `/dashboard/vendor-profile/`
- [ ] All MVX profile fields work
- [ ] Password change works
- [ ] Changes save properly

## Next Steps

After these pages are working:
1. Build the artwork uploader with Cloudinary integration
2. Add conditional dashboard content (alert banners for incomplete profiles)
3. Implement validation workflow (submit for review, approve/reject)
4. Add email notifications for each step

## Troubleshooting

### Page shows 404
- Flush permalinks: Settings → Permalinks → Save Changes
- Verify plugin is active

### Form doesn't submit
- Check browser console for JavaScript errors
- Verify AJAX URL is correct
- Check PHP error logs

### Google Drive upload fails
- Verify credentials file exists
- Check service account permissions
- Falls back to local storage if GDrive unavailable

### Signature doesn't display
- Check if file uploaded successfully
- Verify attachment ID saved to meta
- Check file permissions

## Support

For issues:
1. Enable WP_DEBUG in wp-config.php
2. Check `/wp-content/debug.log`
3. Check browser console for JS errors
4. Verify all plugin files uploaded correctly
