Skip to content

Commit

Permalink
Show team flag on user search result
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Jan 17, 2025
1 parent d9f4860 commit 5c7fa43
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
12 changes: 6 additions & 6 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Models\NewsPost;
use App\Models\UserDonation;
use App\Transformers\MenuImageTransformer;
use App\Transformers\UserCompactTransformer;
use Auth;
use Jenssegers\Agent\Agent;
use Request;
Expand Down Expand Up @@ -142,12 +143,11 @@ public function quickSearch()
$result[$mode]['total'] = $search->count();
}

$result['user']['users'] = json_collection($searches['user']->data(), 'UserCompact', [
'country',
'cover',
'groups',
'support_level',
]);
$result['user']['users'] = json_collection(
$searches['user']->data(),
new UserCompactTransformer(),
[...UserCompactTransformer::CARD_INCLUDES, 'support_level'],
);
$result['beatmapset']['beatmapsets'] = json_collection($searches['beatmapset']->data(), 'Beatmapset', ['beatmaps']);
}

Expand Down
7 changes: 7 additions & 0 deletions resources/js/quick-search/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

import FlagCountry from 'components/flag-country';
import FlagTeam from 'components/flag-team';
import FriendButton from 'components/friend-button';
import SupporterIcon from 'components/supporter-icon';
import UserGroupBadges from 'components/user-group-badges';
Expand All @@ -26,6 +27,12 @@ export default function User({ user, modifiers = [] }: { modifiers?: string[]; u
<FlagCountry country={user.country} />
</div>

{user.team !== null &&
<div className='user-search-card__col user-search-card__col--flag'>
<FlagTeam team={user.team} />
</div>
}

<a className='user-search-card__col user-search-card__col--username' href={url}>
{user.username}
</a>
Expand Down
13 changes: 10 additions & 3 deletions resources/views/home/_search_result_user.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
See the LICENCE file in the repository root for full licence text.
--}}
@php
use App\Transformers\UserCompactTransformer;
@endphp
<div class="js-react--user-cards"
data-modifiers="{{ json_encode(['search']) }}"
data-users="{{ json_encode(json_collection($search->data(), 'UserCompact', ['cover', 'country', 'groups'])) }}">
</div>
data-modifiers="{{ json_encode(['search']) }}"
data-users="{{ json_encode(json_collection(
$search->data(),
new UserCompactTransformer(),
UserCompactTransformer::CARD_INCLUDES,
)) }}"
></div>

0 comments on commit 5c7fa43

Please sign in to comment.