@using Shared.DTOs
@page "/GridTest"
<h3>GridTest</h3>
<main>

    <div class="signin-banner-area signin-banner-main-wrap d-flex align-items-center">
        <div class="signin-banner-left-box signin-banner-bg p-relative">
            <div class="signin-banner-bottom-shape">
                <img src="img/login/login-shape-1.png" alt="">
            </div>
            <div class="signin-banner-left-wrap">
               
            </div>
        </div>
        <div class="signin-banner-from d-flex justify-content-center align-items-center">
            <div class="signin-banner-from-wrap">
                <Grid TItem="Employee1" class="table table-hover table-bordered table-striped" DataProvider="EmployeesDataProvider" AllowFiltering="true" Responsive="true">
                    <GridColumn TItem="Employee1" HeaderText="Id" PropertyName="Id">
                        @context.Id
                    </GridColumn>
                    <GridColumn TItem="Employee1" HeaderText="Employee Name" PropertyName="Name" StringComparison="StringComparison.Ordinal">
                        @context.Name
                    </GridColumn>
                    <GridColumn TItem="Employee1" HeaderText="Designation" PropertyName="Designation">
                        @context.Designation
                    </GridColumn>
                    <GridColumn TItem="Employee1" HeaderText="DOJ" PropertyName="DOJ">
                        @context.DOJ
                    </GridColumn>
                    <GridColumn TItem="Employee1" HeaderText="Active" PropertyName="IsActive">
                        @context.IsActive
                    </GridColumn>
                </Grid>
            </div>
        </div>
    </div>

   

</main>
@code {
    private IEnumerable<Employee1>? employees;

    private async Task<GridDataProviderResult<Employee1>> EmployeesDataProvider(GridDataProviderRequest<Employee1> request)
    {
        if (employees is null) // pull employees only one time for client-side filtering, sorting, and paging
            employees = GetEmployees(); // call a service or an API to pull the employees

        return await Task.FromResult(request.ApplyTo(employees));
    }

    private IEnumerable<Employee1> GetEmployees()
    {
        return new List<Employee1>
        {
            new Employee1 { Id = 107, Name = "Alice", Designation = "AI Engineer", DOJ = new DateOnly(1998, 11, 17), IsActive = true },
            new Employee1 { Id = 103, Name = "Bob", Designation = "Senior DevOps Engineer", DOJ = new DateOnly(1985, 1, 5), IsActive = true },
            new Employee1 { Id = 106, Name = "John", Designation = "Data Engineer", DOJ = new DateOnly(1995, 4, 17), IsActive = true },
            new Employee1 { Id = 104, Name = "Pop", Designation = "Associate Architect", DOJ = new DateOnly(1985, 6, 8), IsActive = false },
            new Employee1 { Id = 105, Name = "Ronald", Designation = "Senior Data Engineer", DOJ = new DateOnly(1991, 8, 23), IsActive = true },
            new Employee1 { Id = 102, Name = "Line", Designation = "Architect", DOJ = new DateOnly(1977, 1, 12), IsActive = true },
            new Employee1 { Id = 101, Name = "Daniel", Designation = "Architect", DOJ = new DateOnly(1977, 1, 12), IsActive = true },
            new Employee1 { Id = 108, Name = "Zayne", Designation = "Data Analyst", DOJ = new DateOnly(1991, 1, 1), IsActive = true },
            new Employee1 { Id = 109, Name = "Isha", Designation = "App Maker", DOJ = new DateOnly(1996, 7, 1), IsActive = true },
        };
    }
}
