<?php

use Illuminate\Support\Collection;
use Livewire\Component;

new class extends Component {
    public Collection $crews;

    public function mount(): void
    {
        $this->crews = Auth::user()
            ->crews()
            ->withCount(['users', 'patches'])
            ->get();
    }
};
?>

<div class="flex flex-col gap-3 px-4 pt-6 pb-4">
    <div class="flex items-center justify-between">
        <h1 class="text-xl font-bold text-foreground">Your Groups</h1>
        <div class="flex gap-2">
            <button class="btn-outline w-full text-base bg-background">Join</button>
            <livewire:groups.create/>
        </div>
    </div>
    @foreach($crews as $crew)
        <livewire:group-card :crew="$crew" :key="$crew->id"/>
    @endforeach
</div>
