import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import type { TripMemberRole } from '../../../../libs/trips/src';

export const CurrentTripRole = createParamDecorator(
  (_data: unknown, ctx: ExecutionContext): TripMemberRole => {
    const request = ctx
      .switchToHttp()
      .getRequest<{ tripMembership: { role: TripMemberRole } }>();
    return request.tripMembership.role;
  },
);
