import { t } from "@lingui/macro";
import { html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { CoreApi, UserConsent } from "@goauthentik/api";
import { AKResponse } from "../../api/Client";
import { DEFAULT_CONFIG } from "../../api/Config";
import { PAGE_SIZE } from "../../constants";
import "../forms/DeleteBulkForm";
import { Table, TableColumn } from "../table/Table";
@customElement("ak-user-consent-list")
export class UserConsentList extends Table {
@property({ type: Number })
userId?: number;
apiEndpoint(page: number): Promise> {
return new CoreApi(DEFAULT_CONFIG).coreUserConsentList({
user: this.userId,
ordering: this.order,
page: page,
pageSize: PAGE_SIZE,
});
}
checkbox = true;
order = "-expires";
columns(): TableColumn[] {
return [
new TableColumn(t`Application`, "application"),
new TableColumn(t`Expires`, "expires"),
];
}
renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length < 1;
return html` {
return new CoreApi(DEFAULT_CONFIG).coreUserConsentUsedByList({
id: item.pk,
});
}}
.delete=${(item: UserConsent) => {
return new CoreApi(DEFAULT_CONFIG).coreUserConsentDestroy({
id: item.pk,
});
}}
>
`;
}
row(item: UserConsent): TemplateResult[] {
return [html`${item.application.name}`, html`${item.expires?.toLocaleString()}`];
}
}