aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/actor_profile_follow_button.php
blob: e2b314dc8e4ae260187361ede82a675efe3a32e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
use Digitigrade\Model\FollowRelation;
use Digitigrade\Model\FollowRelationStatus;

$relation = FollowRelation::findByActors($user->actor, $actor);
$state = match ($relation?->status) {
    null => $actor->requestToFollow ? 'request' : 'normal',
    FollowRelationStatus::PENDING => 'pending',
    FollowRelationStatus::ACTIVE => 'active'
};
?>
<button class="<?= $state == 'active' ? 'secondary' : 'primary' ?>"
    hx-post="/fragment/actor/<?= $actor->id ?>/followButton" hx-swap="outerHTML" <?= $state == 'pending' ? 'disabled' : '' ?> hx-disabled-elt="this">
    <?= __(match ($state) {
        'active' => 'user.profile.unfollow.action',
        'pending' => 'user.profile.follow.pending',
        'request' => 'user.profile.requestToFollow.action',
        'normal' => 'user.profile.follow.action'
    }) ?>
</button>