// CBDC Monetary Committee Service
// SCB Monetary Committees

import prisma from '@/shared/database/prisma';
import { v4 as uuidv4 } from 'uuid';


export class CbdcMonetaryCommitteeService {
  /**
   * Create monetary committee
   */
  async createCommittee(
    sovereignBankId: string,
    committeeName: string,
    memberCount?: number,
    votingMechanism: string = 'simple_majority'
  ) {
    return await prisma.cbdc_monetary_committees.create({
      data: {
        id: uuidv4(),
        committeeId: `COMMITTEE-${uuidv4()}`,
        sovereignBankId,
        committeeName,
        memberCount,
        votingMechanism,
        status: 'active',
        createdAt: new Date(),
        updatedAt: new Date(),
      },
    });
  }

  /**
   * Get committee by ID
   */
  async getCommittee(committeeId: string) {
    return await prisma.cbdc_monetary_committees.findUnique({
      where: { committeeId },
    });
  }

  /**
   * Get committees for bank
   */
  async getCommitteesForBank(sovereignBankId: string) {
    return await prisma.cbdc_monetary_committees.findMany({
      where: {
        sovereignBankId,
        status: 'active',
      },
    });
  }
}

export const cbdcMonetaryCommitteeService = new CbdcMonetaryCommitteeService();

