import ClientData from "@business-logic/data/ClientData";
import TestCase from "@business-logic/types/TestCase";
import { DamageType, EndorsementType, PartQuestionType, 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: 'North Miami Beach',
    state: 'FL',
    postalCode: '33179',
    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 = `~AutomatedScenario0010a${faker.string.uuid().substring(0,6)}`;
const policySoap = MockPolicyData.getPolicySoapByScenario('0010a', customerDetails, policyNumber);

const advancedScenario0010Data: Partial<ITestData> = {
    clientTag: '',
    isDuplicateClaim: false,
    isPolicyFound: true,
    isNoComp: false,
    hasStateLawPopup: false,
    endorsements: [
        {
            endorsementType: EndorsementType.Educator,
            isOnPolicy: true,
            isClickYes: false
        }
    ],
    vehiclePartQuestions: [
        // {
        //     partQuestionType: PartQuestionType.WindshieldColor,
        //     isOnPage: true,
        //     optionToSelect: 'Green Tint'
        // },
        // {
        //     partQuestionType: PartQuestionType.PassengerRearColor,
        //     isOnPage: true,
        //     optionToSelect: 'Green Tint'
        // },
    ],
    isSafelite: true,
    servicePackage: faker.helpers.enumValue(ServicePackage),
    customerDetails: customerDetails,
    claimDetails: {
        policyNumber: policyNumber,
        policyDeductible: 1000,
        damageDate: '2023-09-01',
        damageCause: faker.helpers.enumValue(DamageType)
    },
    policySoap: policySoap,
    vehicleDetails: {
        year: '2019',
        make: 'Toyota',
        model: 'C-HR',
        style: ''
    },
    vehicleDamage: [
        VehicleDamage.WindshieldCrack,
        VehicleDamage.RearWindow
    ],
    appointmentDetails: {
        serviceLocation: ServiceLocation.DropOff,
        serviceAddress: customerAddress,
        appointmentDate: nextWeekday
    },
    paymentDetails: {
        paymentType: PaymentType.PayAtService
    }

}

// TODO: Add validation for deductible/covered amount

const advancedClients = ClientData.getAdvancedClients();
const advancedScenario0010TestCases: TestCase[] = [];
for (const client of advancedClients) {
    const data = {...advancedScenario0010Data};
    data.clientTag = client.clientTag;
    const tc = new TestCase({
        name: `0010a Advanced Repair No Deductible FL Rear Client: "${client.accountName}"`,
        tags: [`@${client.clientTag}`, `@${client.accountName}`, '@Advanced'],
        testData: data
    }, undefined, '0010a');
    advancedScenario0010TestCases.push(tc);
}

export default advancedScenario0010TestCases;