Skip to content

Commit db00131

Browse files
Fix: Test Cases
1 parent 463f308 commit db00131

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

app/Users/Controllers/UserAccountController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function updateProfile(Request $request, ImageRepo $imageRepo)
6767

6868
$this->userRepo->update($user, $validated, userCan('users-manage'));
6969

70-
SocialAccount::where('user_id', $user->id)->update(['custom_avatar' => array_key_exists('custom-avatar', $validated) ? $validated['custom-avatar'] : 1]);
70+
SocialAccount::where('user_id', $user->id)->update(['custom_avatar' => array_key_exists('custom-avatar', $validated) ? $validated['custom-avatar'] : 0]);
7171

7272
if (array_key_exists('custom-avatar', $validated)) {
7373
dispatch(new UpdateSocialUserAvatarJob($user->id));

resources/js/components/custom-avatar-checkbox.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class CustomAvatarCheckbox extends Component {
3636
.parentNode.classList.toggle('hidden', this.checkbox.checked);
3737
this.container.querySelector('.custom-file-input').disabled = this.checkbox.checked;
3838
this.container.querySelector('[refs="image-picker@reset-input"]').disabled = this.checkbox.checked;
39-
this.checkbox.value = this.checkbox.checked ? 0 : 1;
39+
this.checkbox.value = this.checkbox.checked ? 1 : 0;
4040
}
4141

4242
}

resources/views/users/account/profile.blade.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,19 @@
4545

4646
<div component="custom-avatar-checkbox">
4747
<label class="toggle-switch">
48-
<input type="checkbox" name="custom-avatar" value="{{user()->socialAccounts()->get()->first()->custom_avatar}}" @if(user()->socialAccounts()->first()->custom_avatar === 0 ? true : false) checked="checked" @endif>
48+
<?php
49+
if(user()->socialAccounts()->get()->count() > 0)
50+
{
51+
$userCustomAvatar = user()->socialAccounts()->get()->first()->custom_avatar;
52+
}
53+
else
54+
{
55+
$userCustomAvatar = 0;
56+
}
57+
?>
58+
<input type="checkbox" name="custom-avatar" value="{{$userCustomAvatar}}" @if($userCustomAvatar) checked="checked" @endif>
4959
<span tabindex="0" role="checkbox"
50-
aria-checked="{{ user()->socialAccounts()->get()->first()->custom_avatar === 0 ? 'true' : 'false' }}"
60+
aria-checked="{{ $userCustomAvatar ? 'true' : 'false' }}"
5161
class="custom-checkbox text-primary">@icon('check')</span>
5262
<span class="label">Use Social Account Avatar</span>
5363
</label>

0 commit comments

Comments
 (0)