# Events - Leads Module

This document describes the **Events - Leads** module, which is a sub-module of the Events module. It provides a lead retrieval solution for exhibitors at an event.

## Overview

The Leads module allows exhibitors to capture, manage, and export leads from event attendees. It is designed to be used on a variety of devices, including desktops, tablets, and smartphones.

## Data Models

The Leads module is based on two main data models:

- **`EventExhibit`**: Represents an exhibitor at an event. It contains information about the exhibitor, such as their name, description, and booth number. It also includes configuration options for the lead retrieval service, such as custom questions and the number of licenses.
- **`EventExhibitTracking`**: Represents a lead captured by an exhibitor. It links an exhibitor (`event_exhibit_id`) with an attendee's badge (`event_badge_id`) and includes fields for notes and responses to custom questions.

## Features

- **Authentication:** The module supports two types of authentication for exhibitor staff:
    - **Shared Passcode:** A shared passcode can be used by all staff members of an exhibitor.
    - **License-based:** Individual licenses can be assigned to staff members, each with their own email and passcode.
- **Lead Capture:** Leads can be captured by:
    - **Scanning QR Codes:** The module includes a QR code scanner that can be used to scan the QR code on an attendee's badge.
    - **Manual Entry:** The attendee's badge ID can be entered manually.
- **Lead Management:** The module provides a comprehensive interface for managing leads, including:
    - Viewing a list of all captured leads.
    - Viewing the details of a single lead.
    - Adding notes to a lead.
    - Answering custom questions for a lead.
- **Lead Export:** Leads can be exported to a CSV or Excel file for further processing.
- **License Management:** Exhibitors can manage their licenses, including adding, editing, and removing licenses.
- **Client-Side Caching:** The module uses Dexie.js for client-side caching in IndexedDB, which improves performance and enables offline access.

## UI Components

The Leads module is composed of the following UI components:

- **`exhibit/[slug]/+page.svelte`:** The main entry point for an exhibitor. It provides a tabbed interface for accessing the different features of the module.
- **`exhibit/[slug]/leads_add_scan.svelte`:** A component for adding a new lead by scanning a badge or entering the badge ID manually.
- **`exhibit/[slug]/leads_list.svelte`:** A component for viewing and managing the list of captured leads.
- **`exhibit/[slug]/leads_manage.svelte`:** A component for managing the exhibitor's settings and exporting leads.
- **`exhibit/[slug]/leads_view_lead.svelte`:** A component for viewing the details of a single lead.

## How it Works

1.  The exhibitor navigates to the `events_leads/exhibit/[slug]` page, where `[slug]` is their exhibitor ID.
2.  They authenticate using either the shared staff passcode or their individual license.
3.  They can then use the different tabs to capture new leads, manage their existing leads, and configure their settings.
4.  All data is fetched from the API and cached in IndexedDB for offline access and faster loading times.
