import { DataSource } from 'typeorm';
import { JoinRequestEntity } from '../../../entities';
import { UpdateJoinRequestStatusCommand } from '../../types';

export async function handleUpdateJoinRequestStatus(command: UpdateJoinRequestStatusCommand, dataSource: DataSource): Promise<void> {
  const repo = dataSource.getRepository(JoinRequestEntity);
  const { requestId, status } = command.payload;

  await repo.update(requestId, { status });
}
