import ClientData from "@business-logic/data/ClientData";
import TestCase from "@business-logic/types/TestCase";
import { DamageType, EndorsementType, PaymentType, ServiceLocation, ServicePackage, VehicleDamage } from "@business-logic/types/Enums";
import { ITestData } from "@business-logic/types/ITestData"
import { faker } from "@faker-js/faker";
import { getNextWeekday } from "@impl/utils/DateUtils";
import MockPolicyData from "@business-logic/data/MockPolicyData";
import { ICustomerDetails } from "@business-logic/types/CustomerDetails";
import { IAddress } from "@business-logic/types/IAddress";

const nextWeekday = getNextWeekday();
const customerAddress: IAddress = {
    street: faker.location.streetAddress(),
    city: 'Birmingham',
    state: 'AL',
    postalCode: '35118',
    country: 'United States'
}
const customerDetails: ICustomerDetails = {
    firstName: faker.person.firstName(),
    lastName: faker.person.lastName(),
    email: 'itqatest@safelite.com',
    phoneNumber: '614-531-0031',
    notes: 'Automated Test',
    address: customerAddress
}

const policyNumber = `~AutomatedScenario0011a${faker.string.uuid().substring(0, 6)}`;
const policySoap = MockPolicyData.getPolicySoapByScenario('0011a', customerDetails, policyNumber);

const advancedScenario0011Data: Partial<ITestData> = {
    clientTag: '',
    isDuplicateClaim: false,
    isPolicyFound: true,
    isNoComp: false,
    isItac: true,
    hasStateLawPopup: false,
    endorsements: [
        {
            endorsementType: EndorsementType.Educator,
            isOnPolicy: true,
            isClickYes: false
        }
    ],
    partQuestions: undefined,
    isSafelite: true,
    servicePackage: faker.helpers.enumValue(ServicePackage),
    customerDetails: customerDetails,
    claimDetails: {
        policyNumber: policyNumber,
        policyDeductible: 500,
        damageDate: '2023-03-01',
        damageCause: faker.helpers.enumValue(DamageType)
    },
    policySoap: policySoap,
    vehicleDetails: {
        year: '2006',
        make: 'Honda',
        model: 'Element',
        style: ''
    },
    otherVehiclesOnPolicy: [
        {
            year: '2006',
            make: 'Chevrolet',
            model: 'Silverado'
        },
        {
            year: '2017',
            make: 'Jeep',
            model: 'Wrangler'
        },
        {
            year: '2001',
            make: 'Toyota',
            model: 'Sienna'
        },
        {
            year: '2005',
            make: 'Jeep',
            model: 'Wrangler'
        },
        {
            year: '2022',
            make: 'wild',
            model: '178bhfkx'
        }
    ],
    vehicleDamage: [
        VehicleDamage.WindshieldCrack,
    ],
    appointmentDetails: {
        serviceLocation: ServiceLocation.InShop,
        shopAddress: undefined,
        appointmentDate: nextWeekday
    },
    paymentDetails: ClientData.getDefaultPaypalDetails()

}

// TODO: Add validation for deductible/covered amount
const advancedClients = ClientData.getAdvancedClients();
const advancedScenario0011TestCases: TestCase[] = [];
for (const client of advancedClients) {
    const data = { ...advancedScenario0011Data };
    data.clientTag = client.clientTag;
    const tc = new TestCase({
        name: `0011a Advanced ITAC No Adas Client: "${client.accountName}"`,
        tags: [`@${client.clientTag}`, `@${client.accountName}`, '@Advanced'],
        testData: data
    }, undefined, '0011a');
    advancedScenario0011TestCases.push(tc);
}

export default advancedScenario0011TestCases;