import { Injectable } from '@nestjs/common';
import { TripPreferenceOverridesRepository } from './trip-preference-overrides.repository';
import type { PreferenceSubject, TripPreferenceOverride } from './trip.types';

@Injectable()
export class TripPreferenceOverridesService {
  constructor(private readonly repository: TripPreferenceOverridesRepository) {}

  listOverrides(tripId: string): Promise<TripPreferenceOverride[]> {
    return this.repository.listByTrip(tripId);
  }

  upsertOverride(
    tripId: string,
    subject: PreferenceSubject,
    overrides: Record<string, unknown>,
  ): Promise<TripPreferenceOverride> {
    return this.repository.upsert(tripId, subject, overrides);
  }

  removeOverride(tripId: string, overrideId: string): Promise<void> {
    return this.repository.remove(tripId, overrideId);
  }
}
