import { type GetAccount$result } from '$houdini';

// Types
export type ScopeType = NonNullable<
	GetAccount$result['account']
>['addresses'][number]['scopes'][number];
export type AreaType = ScopeType['areas'][number];
export type TaskType = AreaType['tasks'][number];

// Frequency options for tasks - values must be lowercase to match backend enum
export const FREQUENCY_OPTIONS = [
	{ value: 'daily', label: 'Daily' },
	{ value: 'weekly', label: 'Weekly' },
	{ value: 'monthly', label: 'Monthly' },
	{ value: 'quarterly', label: 'Quarterly' },
	{ value: 'triannual', label: '3x/year' },
	{ value: 'annual', label: 'Annual' },
	{ value: 'as_needed', label: 'As Needed' }
] as const;

export function getFrequencyLabel(frequency: string): string {
	const lower = frequency?.toLowerCase();
	const option = FREQUENCY_OPTIONS.find((o) => o.value === lower);
	return option?.label ?? frequency;
}

export function getFrequencyShortLabel(frequency: string): string {
	const labels: Record<string, string> = {
		daily: 'Daily',
		weekly: 'Weekly',
		monthly: 'Monthly',
		quarterly: 'Qtrly',
		triannual: '3x/yr',
		annual: 'Annual',
		as_needed: 'PRN'
	};
	const lower = frequency?.toLowerCase();
	return labels[lower] || frequency;
}
