import { Page } from "@playwright/test";
import { DashboardPage } from "../dashboard.page";
import { emptySent, haveSentHeadingColumn } from "./sent.snapshot";

export class SentPage extends DashboardPage {
    constructor(page: Page) {
        super(page);
    }

    async open(): Promise<void> {
        await this.page.goto("requests/sent");
    }

    get sentLoc() {
        return {
            table: {
                dataInRowSpan: (data: string) => this.genLoc(`//span[contains(.,'${data}')]`),
                dataInRow: (data: string) => this.genLoc(`//a[contains(text(),'${data}')] | //span[contains(text(),'${data}')]`),
                dataInRowManyText: (data: string) => this.genLoc(`//a[contains(.,'${data}')] | //span[contains(.,'${data}')]`),
            },

            filter: {
                inputByID: (id: string) => this.genLoc(`//input[@id='${id}']`),
                dropdownOption: (email: string) => this.genLoc(`//div[text()='${email}']/parent::div[@class='box-text box-text-business']`),
                noOption: this.genLoc("//div[@class='no-options']")
            }
        }
    }

    get sentSnapshot() {
        return {
            emptySent: emptySent,
            haveSentHeadingColumn: haveSentHeadingColumn
        }
    }
}