import {
  CheckSmsKeyRequestReturnType,
  CreateTempUserDataType,
  TempUserType
} from '../api/temp-user';
import { CreateUserDataType, UserType } from '../api/user';
import { UseRegisterMutationDataType } from '../hooks/react-query/use-auth';
import { CodeType, CreateIntroducerDataType, IntroducerType } from '../api/introducer';
import { SettleRequestType } from '../api/settle-request';

// shared
export const mockedMobile = '09123456789';
export const mockedRestrictedMobile = '09121111111';

// auth
export const mockedAccessToken = 'access-token';
export const mockedRefreshToken = 'refresh-token';

// tempUser
export const mockedSmsKey = '123456';
export const mockedWrongSmsKey = '234567';
export const mockedAuthKey = 'mockedAuthKey';

export const mockedTempUserData: CreateTempUserDataType = { mobile: mockedMobile };
export const mockedTempUser: TempUserType = mockedTempUserData;

export const mockedCheckSmsKeyReturnData: CheckSmsKeyRequestReturnType = {
  ...mockedTempUserData,
  authKey: mockedAuthKey
};

// user
const userId = 6;
export const mockedFirstName = 'تست';
export const mockedLastName = 'تستیان';
export const mockedGender = 'M';
export const mockedName = `${mockedFirstName} ${mockedLastName}`;
export const mockedPassword = 'Pass123456789!';

export const mockedCreateUserData: CreateUserDataType = {
  firstName: mockedFirstName,
  lastName: mockedLastName,
  gender: mockedGender,
  mobile: mockedMobile,
  password: mockedPassword,
  authKey: mockedAuthKey
};

export const mockedUser: UserType = {
  id: userId,
  name: mockedName,
  mobile: mockedMobile,
  isSuperUser: false
};

// introducer
const introducerId = 8;
export const mockedIBan = '820540102680020817909002';
export const mockedWrongIBan = '123456789012345678901234';
const share = 10;
const discount = 10;
const validDays = 180;
const sharePrice = 3500000;
const paidPrice = 500000;
const studentCount = 0;

export const mockedCreateIntroducerData: CreateIntroducerDataType = { iban: '' };
export const mockedCode: CodeType = {
  id: introducerId,
  text: '123456',
  share,
  discount,
  validDays,
  sharePrice,
  studentCount
};
export const mockedIntroducer: IntroducerType = {
  id: introducerId,
  sharePrice,
  paidPrice,
  studentCount,
  iban: '',
  user: mockedUser,
  code: mockedCode
};

// transactions
export const mockedSettleRequest: SettleRequestType = {
  id: 101,
  status: false,
  iban: mockedIBan,
  transaction: null,
  created: 'Mon May 09 2022 01:07:52 GMT+0430'
};

export const mockedSettleRequests: SettleRequestType[] = [...Array(3)].map((_, index) => {
  const date = new Date();
  date.setMonth(date.getMonth() - index);

  return {
    id: index + 1,
    status: index % 2 === 0,
    iban: mockedIBan,
    transaction: {
      id: index + 1,
      amount: (index + 1) * 100000,
      date: date.toDateString(),
      paidFor: `پرداخت سهم معرف ماه ${index}`
    },
    created: date.toString()
  };
});

// login
export const mockedLoginData = { mobile: mockedMobile, password: mockedPassword };
export const mockedLoginReturnData = { access: mockedAccessToken, refresh: mockedRefreshToken };
export const mockedRefreshReturnData = { access: mockedAccessToken };

// register
export const mockedRegisterUserData: UseRegisterMutationDataType = {
  ...mockedCreateUserData,
  ...mockedCreateIntroducerData
};
