import { type Page, Locator } from '@playwright/test';
import { LookupPage } from './LookupPage';
import { AddressForm } from './forms/AddressForm';
import { VehicleSelectionForm } from './forms/VehicleSelectionForm';
import { ICustomerDetails, IVehicleDetails } from '@business-logic/types/CustomerDetails';

export class VehicleLookupAddressPage extends LookupPage {
    readonly addressForm: AddressForm;
    readonly vehicleSelectionForm: VehicleSelectionForm;
    
    url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-zip';

    constructor(page: Page) {
        super(page);
        this.addressForm = new AddressForm(page);
        this.vehicleSelectionForm = new VehicleSelectionForm(page);
        
        // Override the unserviceableZipAlertMessage for address-specific message
        this.unserviceableZipAlertMessage = this.page.locator('div.alert-danger.widget-name-AlertVinNotFoundWidget', 
            { hasText: "Your address didn't return a VIN match." });
    }

    async lookupVehicleByAddress(customerDetails: ICustomerDetails, vehicleDetails: IVehicleDetails) {
        await this.addressForm.populateAddress(customerDetails);
        //await this.nextPage();
        //await this.vehicleSelectionForm.selectVehicle(vehicleDetails);
    }
}