Skip to content

Commit

Permalink
Merge pull request #94 from WillTheDeveloper/new-profile-ui
Browse files Browse the repository at this point in the history
New profile UI
  • Loading branch information
WillTheDeveloper authored Jul 22, 2022
2 parents 90528a2 + 0c4cf07 commit 5bbcb82
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 153 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The full public roadmap is available to everyone. The link to it can be found he
| Q/Year | Status |
|--------|--------|
| Q1 2022 | ✔️ Completed |
| Q2 2022 |Delayed |
| Q2 2022 |Completed |
| Q3 2022 | ✔️ In Progress |
| Q4 2022 | ❔ Planning |

Expand Down
24 changes: 22 additions & 2 deletions app/Http/Controllers/Community.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function profile($id)
{
return view('communityuser', [
'user' => User::query()->where('users.id', $id)->findOrFail($id),
'posts' => Post::query()->where('posts.user_id', $id)->orderByDesc('created_at')->paginate(5),
'comments' => Comment::query()->where('comments.user_id', $id)->orderByDesc('created_at')->limit(5)->get('*'),
'posts' => Post::query()->where('posts.user_id', $id)->orderByDesc('created_at')->limit(5)->get(),
'comments' => Comment::query()->where('comments.user_id', $id)->orderByDesc('created_at')->limit(5)->get(),
]);
}

Expand Down Expand Up @@ -185,4 +185,24 @@ public function deleteComment($id)

return back();
}

public function updatePrivacy(Request $request, $id)
{
$bio = $request->input('bio');
$privacy = $request->input('privacy');
$contact = $request->input('contact');

// dd([$bio, $privacy, $contact]);

User::query()->findOrFail($id)
->update(
[
'bio' => $bio,
'private' => $privacy,
'contact' => $contact,
]
);

return redirect(route('community.profile', $id));
}
}
4 changes: 3 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function Webhook()
'is_tutor' => 'boolean',
'is_admin' => 'boolean',
'is_moderator' => 'boolean',
'is_banned' => 'boolean'
'is_banned' => 'boolean',
'private' => 'boolean',
'contact' => 'boolean'
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('private')->default(0);
$table->boolean('contact')->default(0);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};
232 changes: 201 additions & 31 deletions resources/views/communityuser.blade.php

Large diffs are not rendered by default.

152 changes: 34 additions & 118 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,140 +192,56 @@ class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg bg-white
</div>




<!-- Page header -->
<div class="bg-white shadow">
<div class="px-4 sm:px-6 lg:max-w-6xl lg:mx-auto lg:px-8">
<div class="py-6 md:flex md:items-center md:justify-between lg:border-t lg:border-gray-200">
<div class="flex-1 min-w-0">
<!-- Profile -->
<div class="flex items-center">
<img class="hidden h-16 w-16 rounded-full sm:block" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.6&w=256&h=256&q=80" alt="">
<div>
<div class="flex items-center">
<img class="h-16 w-16 rounded-full sm:hidden" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.6&w=256&h=256&q=80" alt="">
<h1 class="ml-3 text-2xl font-bold leading-7 text-gray-900 sm:leading-9 sm:truncate">Hey, {{auth()->user()->name}}!</h1>
</div>
<dl class="mt-6 flex flex-col sm:ml-3 sm:mt-1 sm:flex-row sm:flex-wrap">
@if(auth()->user()->Institution()->exists())
<dt class="sr-only">Institution</dt>
<dd class="flex items-center text-sm text-gray-500 font-medium capitalize sm:mr-6">
<!-- Heroicon name: solid/office-building -->
<svg class="flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M4 4a2 2 0 012-2h8a2 2 0 012 2v12a1 1 0 110 2h-3a1 1 0 01-1-1v-2a1 1 0 00-1-1H9a1 1 0 00-1 1v2a1 1 0 01-1 1H4a1 1 0 110-2V4zm3 1h2v2H7V5zm2 4H7v2h2V9zm2-4h2v2h-2V5zm2 4h-2v2h2V9z" clip-rule="evenodd" />
</svg>
{{auth()->user()->Institution()->first()->institution}}
</dd>
@endif
@if(auth()->user()->hasVerifiedEmail())
<dt class="sr-only">Account status</dt>
<dd class="mt-3 flex items-center text-sm text-gray-500 font-medium sm:mr-6 sm:mt-0 capitalize">
<!-- Heroicon name: solid/check-circle -->
<svg class="flex-shrink-0 mr-1.5 h-5 w-5 text-green-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
</svg>
Verified account
</dd>
@endif
</dl>
</div>
</div>
</div>
{{--<div class="mt-6 flex space-x-3 md:mt-0 md:ml-4">
<button type="button" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500">Add money</button>
<button type="button" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500">Send money</button>
</div>--}}
</div>
</div>
</div>

<div class="mt-8">
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
<h2 class="text-lg leading-6 font-medium text-gray-900">Overview</h2>
<div class="mt-2 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3">
<!-- Card -->
{{-- <h2 class="text-lg leading-6 font-medium text-gray-900">Overview</h2>--}}

<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-5">
<div class="flex items-center">
<!-- This example requires Tailwind CSS v2.0+ -->
<div class="rounded-lg bg-white overflow-hidden shadow">
<h2 class="sr-only" id="profile-overview-title">Profile Overview</h2>
<div class="bg-white p-6">
<div class="sm:flex sm:items-center sm:justify-between">
<div class="sm:flex sm:space-x-5">
<div class="flex-shrink-0">
<!-- Heroicon name: outline/scale -->
<svg class="h-6 w-6 text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3" />
</svg>
<img class="mx-auto h-20 w-20 rounded-full" src="https://images.unsplash.com/photo-1550525811-e5869dd03032?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Attendance</dt>
<dd>
<div class="text-lg font-medium text-gray-900">(Coming Soon)</div>
</dd>
</dl>
<div class="mt-4 text-center sm:mt-0 sm:pt-1 sm:text-left">
<p class="text-sm font-medium text-gray-600">Welcome back,</p>
<p class="text-xl font-bold text-gray-900 sm:text-2xl">{{auth()->user()->name}}</p>
@switch(auth()->user()->hasVerifiedEmail())
@case(1)
<p class="text-sm font-medium text-green-600">Verified User</p>
@break(1)
@case(0)
<p class="text-sm font-medium text-red-600">Unverified. Please verify your email.</p>
@break(0)
@endswitch
</div>
</div>
</div>
<div class="bg-gray-50 px-5 py-3">
<div class="text-sm">
<a href="#" class="font-medium text-cyan-700 hover:text-cyan-900"> View details </a>
<div class="mt-5 flex justify-center sm:mt-0">
<a href="{{route('community.profile', auth()->id())}}" class="flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"> View profile </a>
</div>
</div>
</div>

<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<!-- Heroicon name: outline/scale -->
<svg class="h-6 w-6 text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3" />
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Assignments due</dt>
<dd>
<div class="text-lg font-medium text-gray-900">{{auth()->user()->Assignment()->count()}}</div>
</dd>
</dl>
</div>
</div>
</div>
<div class="bg-gray-50 px-5 py-3">
<div class="text-sm">
<a href="{{route('assignments')}}" class="font-medium text-cyan-700 hover:text-cyan-900"> View assignments </a>
</div>
<div class="border-t border-gray-200 bg-gray-50 grid grid-cols-1 divide-y divide-gray-200 sm:grid-cols-3 sm:divide-y-0 sm:divide-x">
<div class="px-6 py-5 text-sm font-medium text-center">
<span class="text-gray-900">{{auth()->user()->Assignment()->where('assignment_user.user_id', auth()->id())->where('assignment_user.submitted_on', null)->count()}}</span>
<span class="text-gray-600">Assignments due</span>
</div>
</div>

<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<!-- Heroicon name: outline/scale -->
<svg class="h-6 w-6 text-gray-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3" />
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Community contributions</dt>
<dd>
<div class="text-lg font-medium text-gray-900">{{auth()->user()->Post()->count() + auth()->user()->Comment()->count()}}</div>
</dd>
</dl>
</div>
</div>
<div class="px-6 py-5 text-sm font-medium text-center">
<span class="text-gray-900">{{auth()->user()->Post()->count()}}</span>
<span class="text-gray-600">Posts</span>
</div>
<div class="bg-gray-50 px-5 py-3">
<div class="text-sm">
<a href="{{route('community.profile', auth()->id())}}" class="font-medium text-cyan-700 hover:text-cyan-900"> View my contributions </a>
</div>

<div class="px-6 py-5 text-sm font-medium text-center">
<span class="text-gray-900">{{auth()->user()->Comment()->count()}}</span>
<span class="text-gray-600">Comments made</span>
</div>
</div>

<!-- More items... -->
</div>


</div>

<h2 class="max-w-6xl mx-auto mt-8 px-4 text-lg leading-6 font-medium text-gray-900 sm:px-6 lg:px-8">Recent activity</h2>
Expand Down
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@
Route::post('/institutions/{joincode}/deletenow', [Institution::class, 'deletedelete'])
->middleware(['auth', 'admin', 'verified'])
->name('institution.deletedelete');
Route::post('/community/user/{id}/privacy', [Community::class, 'updatePrivacy'])
->middleware(['auth', 'verified'])
->name('community.update-privacy');

//API GET ROUTES
Route::prefix('api')->group(function () {
Expand Down

0 comments on commit 5bbcb82

Please sign in to comment.