// Domain types for the Colectivo app.
// These are hand-written and represent business concepts.
// database.ts is generated — never edit it manually.

export type AvatarType = 'initials' | 'emoji' | 'upload';
export type MemberRole = 'admin' | 'member' | 'guest';
export type ListStatus = 'active' | 'completed' | 'archived';
// NoteColor is defined in database.ts (matches the Postgres enum) and re-exported via index.ts
import type { NoteColor } from './database.js';
export type { NoteColor };
export type Language = 'en' | 'es';

export interface User {
	id: string;
	email: string;
	display_name: string;
	language: Language;
	avatar_type: AvatarType;
	avatar_emoji: string | null;
	avatar_url: string | null;
	created_at: string;
}

export interface Collective {
	id: string;
	name: string;
	emoji: string;
	created_by: string;
	created_at: string;
}

export interface CollectiveMember {
	collective_id: string;
	user_id: string;
	role: MemberRole;
	joined_at: string;
}

export interface CollectiveInvitation {
	id: string;
	collective_id: string;
	invited_by: string;
	email: string;
	token: string;
	role: MemberRole;
	expires_at: string;
	accepted_at: string | null;
	created_at: string;
}

export interface ShoppingList {
	id: string;
	collective_id: string;
	name: string;
	status: ListStatus;
	created_by: string;
	created_at: string;
	completed_at: string | null;
	deleted_at: string | null;
}

export interface ShoppingItem {
	id: string;
	list_id: string;
	name: string;
	quantity: number | null;
	is_checked: boolean;
	checked_by: string | null;
	checked_at: string | null;
	sort_order: number;
	created_by: string;
	created_at: string;
}

export interface ItemFrequency {
	collective_id: string;
	name: string; // normalized: lower(trim())
	use_count: number;
	last_used_at: string;
}

export interface TaskList {
	id: string;
	collective_id: string;
	name: string;
	created_by: string;
	created_at: string;
}

export interface Task {
	id: string;
	list_id: string;
	title: string;
	is_completed: boolean;
	completed_by: string | null;
	completed_at: string | null;
	sort_order: number;
	created_by: string;
	created_at: string;
}

export interface Note {
	id: string;
	collective_id: string;
	title: string | null;
	content: string;
	color: NoteColor | null;
	is_pinned: boolean;
	is_archived: boolean;
	deleted_at: string | null;
	created_by: string;
	created_at: string;
	updated_by: string;
	updated_at: string;
}
