import { User } from "@/api/resources/User";
import { getZodiacSignByDate } from "../zodiac-sign";
import { ApiContextValue } from "@/api";
import { IPaymentInfo } from "@/api/resources/SinglePayment";

export const createSinglePayment = async (
  user: User,
  paymentInfo: IPaymentInfo,
  token: string,
  email: string,
  name: string | null,
  birthday: string | null,
  returnUrl: string,
  api: ApiContextValue,
  gender?: string
) => {
  return await api.createSinglePayment({
    token,
    data: {
      user: {
        id: `${user?.id}`,
        email,
        name: name || "",
        sign: user?.profile?.sign?.sign || getZodiacSignByDate(birthday || ""),
        age: user?.profile?.age?.years || 1,
        gender: gender || "",
      },
      partner: {
        sign: "partner_cancer",
        age: 26,
      },
      paymentInfo,
      return_url: returnUrl,
    },
  });
};
