import { segmentQueryBuilderUrl } from 'constants/dca/segments';
import { ContactType, MarketingPermission, Segment, SegmentMode } from '@komi-app/fans-sdk';
import { v4 } from 'uuid';

export interface SegmentUrlProps {
  mode: SegmentMode;
  segmentId?: string;
}

export const createSegmentUrl = (params: SegmentUrlProps) => {
  const searchParams = new URLSearchParams();

  Object.entries(params).forEach(([key, value]) => {
    if (value !== undefined) searchParams.append(key, value);
  });

  return `${segmentQueryBuilderUrl}?${searchParams}`;
};
export const createDefaultSegment = (talentProfileId: string): Segment => ({
  segmentId: v4(),
  talentProfileId,
  name: "",
  contactType: ContactType.Any,
  marketingPermission: MarketingPermission.EmailGranted,
  expressions: [],
});
