import recordAxiosInstance from "@/shared/services/recordAxiosInstance";
import { withHeaders } from "./withHeaders";
import { AssignmentHistoryDto } from "@/record-management/components/userIncoming/remarkCreationCard";

export interface ChildIncomingInstanceDto {
  id: string;
  status?: string;
  createdAt?: string;

  assignedTo?: {
    id?: string;
    name?: {
      am?: string;
      en?: string;
    };
  };
}

export const getChildIncomingInstances = async (
  incomingInstanceId: string,
): Promise<AssignmentHistoryDto[]> => {
  try {
    const { data } = await recordAxiosInstance.get(
      `/incoming-instances/child-instances/${incomingInstanceId}`,
      {
        headers: withHeaders(),
      },
    );

    return data;
  } catch (error) {
    throw error;
  }
};
export const getMainChildIncomingInstances = async (
  recordId: string,
): Promise<AssignmentHistoryDto[]> => {
  try {
    const { data } = await recordAxiosInstance.get(
      `/incoming-instances/record-root/${recordId}`,
      {
        headers: withHeaders(),
      },
    );

    return data;
  } catch (error) {
    throw error;
  }
};
