import {
  ServiceItemTypes,
  type Task,
  type TaskEvent,
} from 'src/pages/dashboard/serviceManagement/types';

export const getTaskID = (task: Task | TaskEvent | null | undefined) => {
  if (!task) {
    return null;
  }
  if (
    !task.type ||
    task?.type === ServiceItemTypes.INCIDENT ||
    task?.type === ServiceItemTypes.APPROVAL
  ) {
    return `#SR${task.taskNumber}`;
  }
  if (task?.type === ServiceItemTypes.SUBTASK) {
    return `#TSK${task.taskNumber}`;
  }
  return null;
};

export const isApprovalTask = (task: Task | undefined) =>
  task?.type === ServiceItemTypes.APPROVAL;
