/**
 * The credentials vault, as the server sends it.
 *
 * There is deliberately no password field on a row: a page payload never
 * carries one. `has_password` is what the card needs to decide between a masked
 * value and "not recorded yet", and the value itself only arrives from the
 * reveal endpoint.
 */

import type { Option, Paginated } from './crm';

export type VaultEntryRow = {
    id: number;
    title: string;
    url: string | null;
    /** The address without `www.`, for the chip under the title. */
    host: string | null;
    username: string | null;
    org_code: string | null;
    has_password: boolean;
    notes: string | null;
    is_active: boolean;
    /** How many times a person has opened the password. */
    reveal_count: number;
    last_revealed_at: string | null;
    last_revealed_by: string | null;
    updated_at: string | null;
    created_at: string | null;
};

export type VaultFilters = {
    search: string | null;
    status: string;
    password: string;
};

export type VaultIndexProps = {
    entries: Paginated<VaultEntryRow>;
    filters: VaultFilters;
    filterOptions: {
        statuses: Option[];
        passwords: Option[];
    };
    counts: {
        total: number;
        active: number;
        retired: number;
        missingPassword: number;
    };
    can: {
        manage: boolean;
        reveal: boolean;
    };
};
