<div>
    <h4>WIP Review</h4>

    <div class="card mb-3">
    <div class="card-body">
        <strong>Total Units:</strong>
        {{ $this->entries->sum('units') }}

        <br>

        <strong>Total Hours:</strong>
        {{ number_format($this->entries->sum('hours'), 2) }}

        <br>

        <strong>Total Value:</strong>
        £{{ number_format(
            $this->entries->sum(fn ($entry) => $entry->units * ($entry->user?->wip_unit_rate ?? 0)),
            2
        ) }}
    </div>
</div>

    <table class="table table-sm table-bordered">
        <thead>
            <tr>
                <th>Date</th>
                <th>Units</th>
                <th>Hours</th>
                <th>Recorded By</th>
                <th>Action Type</th>
                <th>Value</th>
                <th>Description</th>
            </tr>
        </thead>
        <tbody>
            @forelse($this->entries as $entry)
            <tr>
                <td>{{ optional($entry->started_at)->format('d/m/Y H:i') }}</td>
                <td>{{ $entry->units }}</td>
                <td>{{ $entry->hours }}</td>
                <td>{{ (($entry->user?->name_first . ' ' . $entry->user?->name_last) ?? 'Unknown') }}</td>
                <td>{{ ucfirst($entry->activity_type) }}</td>
                <td>£{{ number_format($entry->value, 2) }}</td>
            <td>{{ $entry->description }}</td>
             </tr>
            @empty
                <tr>
                    <td colspan="6" class="text-center text-muted">
                        No WIP entries recorded.
                    </td>
                </tr>
            @endforelse
        </tbody>
    </table>
</div>