import routes from "@/routes";

export interface Payload {
  formData: FormData;
  gender?: "male" | "female";
}

export type Response = {
  fingers: IPalmistryFinger[];
  lines: IPalmistryLine[];
};

export interface IPalmistryFinger {
  name: string;
  point: IPalmistryPoint;
}

export interface IPalmistryLine {
  name: string;
  line: number;
  points: IPalmistryPoint[];
}

export interface IPalmistryPoint {
  x: number;
  y: number;
}

export const createRequest = ({ formData, gender }: Payload) => {
  const urlString = !!gender?.length ? `${routes.server.getPalmistryLines()}/${gender}` : routes.server.getPalmistryLines();
  const url = new URL(urlString);
  const body = formData;
  return new Request(url, {
    method: "POST",
    body,
  });
};
