import { Injectable } from '@nestjs/common';
import { PrismaService } from '@core/database/prisma/prisma.service';
import { GeoRegion } from '@prisma/client';

@Injectable()
export class GeoRegionService {
  constructor(private prisma: PrismaService) {}

  list(): Promise<GeoRegion[]> {
    return this.prisma.geoRegion.findMany({
      where: { enabled: true },
      orderBy: { code: 'asc' },
    });
  }

  findByCode(code: string): Promise<GeoRegion | null> {
    return this.prisma.geoRegion.findUnique({ where: { code } });
  }
}
