import { CardContainerProps as HuCardContainerProps } from '@material-hu/components/design-system/CardContainer/types';
import { ListItemProps as HuListItemProps } from '@material-hu/components/design-system/List/components/ListItem/types';

// Generic type to extract values from const objects
export type ValueOf<T> = T[keyof T];

export type Journey = {
  id: number;
  processTemplateId: number;
  processName: string;
  assignee: {
    id: number;
    fullName: string;
    avatar: { url: string; alt: string };
  };
  progressStatus: JourneyProgressStatusType;
  totalSteps: number;
  totalTasks: number;
  expiredTasks: number;
  completedTasks: number;
};

export type JourneysParams = {
  search?: string;
  progressStatus?: JourneyProgressStatusType;
};

export type JourneyStepsSections = {
  availableSteps: JourneyStep[];
  notAvailableSteps: JourneyStep[];
};

export type JourneyStepsData = {
  processName: string;
  processStatus: JourneyProcessStatusType;
  steps: JourneyStep[];
};

export type JourneyStep = {
  id: number;
  processName: string;
  title: string;
  availableFrom: string;
  totalTasks: number;
  expiredTasks: number;
  completedTasks: number;
  status: JourneyStepStatusType;
};

export type GroupedSteps = {
  status: JourneyStepStatusType | null;
  data: JourneyStep[];
};

export type JourneyListItemProps = {
  id: number;
  cardBadge?: HuCardContainerProps['badge'];
  listItem?: HuListItemProps;
  listItemWrapper?: HuCardContainerProps;
};

export const JourneyStepStatus = {
  NOT_AVAILABLE: 'NOT_AVAILABLE',
  AVAILABLE: 'AVAILABLE',
  IN_PROGRESS: 'IN_PROGRESS',
  COMPLETED: 'COMPLETED',
} as const;

export const JourneyProgressStatus = {
  NOT_STARTED: 'NOT_STARTED',
  IN_PROGRESS: 'IN_PROGRESS',
  PAUSED: 'PAUSED',
  DONE: 'DONE',
} as const;

export const JourneyProcessStatus = {
  ACTIVE: 'ACTIVE',
  DRAFT: 'DRAFT',
  PAUSED: 'PAUSED',
} as const;

export const JourneysTabs = {
  MY_ONBOARDINGS: 'my_onboardings',
  MY_TEAM: 'my_team',
} as const;

export type JourneysTabsType = ValueOf<typeof JourneysTabs>;
export type JourneyProgressStatusType = ValueOf<typeof JourneyProgressStatus>;
export type JourneyStepStatusType = ValueOf<typeof JourneyStepStatus>;
export type JourneyProcessStatusType = ValueOf<typeof JourneyProcessStatus>;

/// My Team Journeys ///

export type JourneySummary = {
  id: number;
  processTemplateId: number;
  assignee: {
    id: number;
    internalId: string;
    firstName: string;
    lastName: string;
    hiringDate?: string;
    avatarUrl?: string;
  };
  progressStatus: JourneyProgressStatusType;
  processId: number;
  processName: string;
  stepsCurrentId: number;
  stepsCurrentTitle?: string;
  stepsTotal: number;
  actionsCurrentId: number;
  actionsCurrentTitle?: string;
  tasksTotal: number;
  tasksCompleted: number;
  tasksExpired: number;
  availableFromDate: string;
  startedAt?: string;
  completedAt?: string;
};

export type GetMyTeamJourneyParams = JourneysParams & {
  offset?: number;
  limit?: number;
};
