# Vendor CRUD for Superadmin - Design Spec

## Overview

Add full CRUD operations (Create, Read, Update, Delete) for vendors in the superadmin dashboard.

## Current State

- **Create**: Admin can create vendors via dialog
- **Read**: List all vendors with status
- **Approve/Reject**: Handle pending vendors

## Required Changes

### Backend

**File:** `src/server/routers/vendor.router.ts`

1. **Update Mutation** - Update vendor details
   - Input: id, name, email, phone, vatPan, address
   - Validates uniqueness of email/vatPan (excluding current vendor)
   - Logs audit trail

2. **Delete Mutation** - Remove vendor (soft delete)
   - Input: id
   - Sets status to DEACTIVATED
   - Logs audit trail

### Frontend

**File:** `src/app/(dashboard)/vendors/page.tsx`

1. **Edit Vendor Dialog**
   - Opens on table row click
   - Pre-filled form with vendor data
   - Fields: name, email, phone, vatPan, address
   - Submit calls `vendor.update` mutation

2. **Delete Action**
   - Delete button in table row
   - Confirmation dialog with vendor name
   - Submit calls `vendor.delete` mutation

## Data Model

**VendorStatus enum** (needs update):

- PENDING
- APPROVED
- REJECTED
- DEACTIVATED (new)

## UI/UX

- Click row → Edit dialog
- Delete button with trash icon
- Confirmation dialog before delete
- Toast notifications on success/error

## Testing

- Test create, read, update, delete operations
- Verify audit logs are created
- Verify permissions (admin only)
