import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';

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

  async get() {
    return this.prisma.profile.findFirst();
  }

  async upsert(data: {
    description?: string;
    vision?: string;
    mission?: string;
    motto?: string;
    values?: string;
    accreditation?: string;
    history?: string;
  }) {
    const existing = await this.prisma.profile.findFirst();
    if (existing) {
      return this.prisma.profile.update({ where: { id: existing.id }, data });
    }
    return this.prisma.profile.create({ data: data as any });
  }
}
