@using RobotNet.Script.Shares.Dashboard
<div class="d-flex w-100 h-100 flex-row">
    <DailyComponentData Title="Completed" Data="@DataParam.Completed.ToString()" Unit="mission" Color="var(--dashboard-text-green-color)" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Error" Data="@DataParam.Error.ToString()" Unit="mission" Color="var(--dashboard-text-orange-color)" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Total" Data="@DataParam.Total.ToString()" Unit="mission" Color="var(--dashboard-text-green-color)" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Completed Rate" Data="@DataParam.CompletedRate.ToString()" Unit="@("\u200B")" Color="var(--dashboard-text-green-color)" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Takt Time Min" Data="@Math.Round(DataParam.TaktTimeMin, 2).ToString()" Unit="minute" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Takt Time Average" Data="@Math.Round(DataParam.TaktTimeAverage, 2).ToString()" Unit="minute" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Takt Time Max" Data="@Math.Round(DataParam.TaktTimeMax, 2).ToString()" Unit="minute" Width="@width" />
    <DailyComponentData Style="margin-left: 20px" Title="Robot" Data="@DataParam.RobotOnline.ToString()" Unit="online" Width="@width" />
</div>

@code {
    private string width = "12.25%";

    private DailyMissionDto DataParam = new();
    public void UpdateData(DailyMissionDto data)
    {
        DataParam.Completed = data.Completed;
        DataParam.Error = data.Error;
        DataParam.Total = data.Total;
        DataParam.CompletedRate = data.CompletedRate;
        DataParam.TaktTimeMin = data.TaktTimeMin;
        DataParam.TaktTimeAverage = data.TaktTimeAverage;
        DataParam.TaktTimeMax = data.TaktTimeMax;
        DataParam.RobotOnline = data.RobotOnline;
        StateHasChanged();
    }
}
