I want to filter the data that appears in the ResumeCart screen by the user who suspended the transaction so that the user only shows his transactions.
I found a filter function and expected it would do the job and wrote the following code.
import * as ResumeCart from "PosApi/Extend/Views/ResumeCartView";
import { IExtensionCommandContext } from "PosApi/Extend/Views/AppBarCommands";
import { ObjectExtensions } from "PosApi/TypeExtensions";
import { GetLoggedOnEmployeeClientRequest, GetLoggedOnEmployeeClientResponse } from "PosApi/Consume/Employees";
export default class ResumeCartFilterByUser extends ResumeCart.ResumeCartExtensionCommandBase {
private _state: ResumeCart.IResumeCartExtensionCommandState;
private _isFiltered: boolean = false;
constructor(context: IExtensionCommandContext<ResumeCart.IResumeCartToExtensionCommandMessageTypeMap>) {
super(context);
this.id = "LogicFilterByUser";
this.label = "Filter By User";
this.extraClass = "iconLightningBolt";
}
protected init(state: ResumeCart.IResumeCartExtensionCommandState): void {
this._state = state;
this.isVisible = true;
this.canExecute = true;
}
protected async execute(): Promise<void> {
this._isFiltered=!this._isFiltered;
if (this._isFiltered) {
const employeeResponse =
await this.context.runtime.executeAsync(new GetLoggedOnEmployeeClientRequest<GetLoggedOnEmployeeClientResponse>());
if (!ObjectExtensions.isNullOrUndefined(employeeResponse) && !employeeResponse.canceled )
{
const employeeId = employeeResponse.data.result.StaffId;
this._state.suspendedCarts.filter(cart => cart.suspendedCart.Cart.StaffId === employeeId);
}
else
{
this._isFiltered = false;
}
}
}
}
But when the order is executed, there are no changes to the records displayed
I know that I may be using the function incorrectly, but I searched and did not find any example of filtering data, I hope you give me an example of filtering data or correct the code to work and filter the data
khaled basher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1