# Events - Badges Module

This document describes the **Events - Badges** module, which is a sub-module of the Events module. It provides functionality for finding, reviewing, and printing badges for event attendees.

## Overview

The Badges module is designed to streamline the badge printing process at events. It allows event staff to quickly find an attendee's badge, review the information, and print it on demand.

## Data Models

The Badges module is based on two main data models:

- **`EventBadge`**: Represents a badge for an event attendee. It contains all the information that will be printed on the badge, such as the attendee's name, professional title, affiliations, and badge type. It also includes override fields that allow for last-minute corrections.
- **`EventBadgeTemplate`**: Represents a template for a badge. It defines the layout, style, and content of the badge, including logos, headers, footers, and ticket information.

## Features

- **Search:** The module provides a powerful search functionality that allows users to find badges by name, email, or affiliations.
- **QR Code Scanning:** It includes a QR code scanner that can be used to find a badge by scanning the QR code on an attendee's registration confirmation.
- **Badge Review:** Before printing, the module displays a preview of the badge, allowing the event staff to review the information and make any necessary corrections.
- **Printing:** The module provides a simple interface for printing badges.
- **Client-Side Caching:** The module uses Dexie.js for client-side caching in IndexedDB, which improves performance and enables offline access.

## UI Components

The Badges module is composed of the following UI components:

- **`+page.svelte` (in `src/routes/events_badges`):** The main entry point for the Badges module. It provides a restricted access page with some general information.
- **`review/+page.svelte`:** The main UI for finding and reviewing badges. It includes the search bar, QR code scanner, and the list of search results.
- **`/event/badge/view_badge` (route not in this directory):** A page that displays a preview of the badge and provides the printing functionality.

## How it Works

1.  The event staff navigates to the `events_badges/review` page.
2.  They can either search for an attendee by name, email, or affiliations, or they can use the QR code scanner to find the attendee's badge.
3.  The module displays a list of badges that match the search criteria.
4.  The staff clicks on a badge to view the details.
5.  The user is redirected to the `/event/badge/view_badge` page, which displays a preview of the badge.
6.  The staff can then print the badge.
