feature(guest access to explore page)
- guest users can access explore page - deal interactions are seen to customer and guest users - guest users redirected to login page for interactions
This commit is contained in:
parent
1442856fb4
commit
4fd98957cb
@ -67,10 +67,10 @@ protected function profileLink(): string
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
return match ($user->role) {
|
||||
return match ($user->role ?? null) {
|
||||
UserTypes::Broker->value => route('broker.profile.show', $user),
|
||||
UserTypes::User->value => route('customer.profile.show', $user),
|
||||
default => ''
|
||||
default => route('login.create')
|
||||
};
|
||||
}
|
||||
|
||||
@ -81,6 +81,9 @@ protected function categories(): Collection
|
||||
|
||||
protected function recentSearches(): Collection
|
||||
{
|
||||
if (!Auth::check()) {
|
||||
return collect();
|
||||
}
|
||||
return Auth::user()->recentSearches()->latest()->select(['id','query'])->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,9 +18,13 @@ export async function like(button) {
|
||||
showToast(response.data.message)
|
||||
|
||||
} catch (e) {
|
||||
if (e.response.status === 401){
|
||||
window.location.href = '/login/create';
|
||||
return;
|
||||
}
|
||||
showToast('Something went wrong!')
|
||||
// Revert the states
|
||||
toggleState(button, !isLiked, activeClasses);
|
||||
toggleState(button, isLiked, activeClasses);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
@ -38,6 +42,10 @@ export async function favorite(button) {
|
||||
showToast(response.data.message)
|
||||
|
||||
} catch (e) {
|
||||
if (e.response.status === 401){
|
||||
window.location.href = '/login/create';
|
||||
return;
|
||||
}
|
||||
showToast(e.response.data.message)
|
||||
toggleState(button, isFavorite, activeClasses);
|
||||
console.error(e);
|
||||
|
||||
@ -7,6 +7,10 @@ const reportForm = document.getElementById('report-form');
|
||||
|
||||
export function showReportModal(dealId, dealTitle) {
|
||||
// Clear the fields
|
||||
if (!reportForm || !reportModal) {
|
||||
window.location.href = '/login/create';
|
||||
return;
|
||||
}
|
||||
reportForm.reset();
|
||||
const oldErrors = reportForm.querySelectorAll('.text-red-500');
|
||||
oldErrors.forEach(error => error.remove());
|
||||
|
||||
@ -1,18 +1,31 @@
|
||||
@props(['deal' => '', 'broker' => ''])
|
||||
<x-ui.image-card class="deal-identifier deal-card shadow-lg cursor-pointer" :image="asset('storage/'.$deal->image)" data-deal-id="{{$deal->id}}">
|
||||
<x-ui.image-card class="deal-identifier deal-card shadow-lg cursor-pointer" :image="asset('storage/'.$deal->image)"
|
||||
data-deal-id="{{$deal->id}}">
|
||||
<div class="bg-white pt-8 p-4 h-full space-y-2 flex flex-col justify-between">
|
||||
<div class="flex justify-between">
|
||||
<x-ui.button-sm variant="neutral">
|
||||
{{$deal->category->name}}
|
||||
</x-ui.button-sm>
|
||||
<x-dashboard.user.action-toolbar :deal_title="$deal->title" :deal_id="$deal->id" :is-liked="$deal->is_liked" :is-favourite="$deal->is_favorite" />
|
||||
|
||||
{{-- Show this to guest or customer --}}
|
||||
@if(!auth()->check() || (auth()->check() && auth()->user()->isCustomer()))
|
||||
<x-dashboard.user.action-toolbar :deal_title="$deal->title" :deal_id="$deal->id"
|
||||
:is-liked="$deal->is_liked" :is-favourite="$deal->is_favorite"/>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<p class="font-bold text-lg ">{{$deal->title}}</p>
|
||||
|
||||
<p class="text-sm text-accent-600 wrap-break-word">{{$deal->description}}</p>
|
||||
|
||||
<x-dashboard.user.broker-contact :broker="$broker"/>
|
||||
@guest
|
||||
<a href="{{route('login.create')}}" class="flex space-x-2">
|
||||
<p class="font-bold hover:underline">Contact Broker</p>
|
||||
<x-heroicon-o-arrow-top-right-on-square class="w-4"/>
|
||||
</a>
|
||||
@endguest
|
||||
@auth
|
||||
<x-dashboard.user.broker-contact :broker="$broker"/>
|
||||
@endauth
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex space-x-3">
|
||||
@ -20,12 +33,14 @@
|
||||
<x-heroicon-o-heart class="w-4"/>
|
||||
</x-dashboard.user.stat-badge>
|
||||
|
||||
<x-dashboard.user.stat-badge id="{{'redirectBadge'.$deal->id}}" :count="$deal->total_redirection">
|
||||
<x-dashboard.user.stat-badge id="{{'redirectBadge'.$deal->id}}" :count="$deal->total_redirection">
|
||||
<x-heroicon-o-arrow-top-right-on-square class="w-4"/>
|
||||
</x-dashboard.user.stat-badge>
|
||||
</div>
|
||||
@if(filled($deal->link))
|
||||
<x-ui.button onclick="redirect('{{\Illuminate\Support\Facades\URL::signedRoute('redirect', $deal->id)}}', {{$deal->id}})" variant="neutral" class="flex space-x-2 items-center mt-2">
|
||||
<x-ui.button
|
||||
onclick="redirect('{{\Illuminate\Support\Facades\URL::signedRoute('redirect', $deal->id)}}', {{$deal->id}})"
|
||||
variant="neutral" class="flex space-x-2 items-center mt-2">
|
||||
<p>View Deal</p>
|
||||
<x-heroicon-o-arrow-top-right-on-square class="w-5 ml-1"/>
|
||||
</x-ui.button>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
@props(['profileLink' => ''])
|
||||
<div class="flex items-center">
|
||||
@auth
|
||||
<div class="relative group">
|
||||
<x-ui.button icon="user-circle" class="cursor-pointer" onclick="showMenu(this)"></x-ui.button>
|
||||
<ul class="menu opacity-0 z-10 scale-10 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-in-out w-48 absolute right-0 bg-white border border-gray-300 rounded-md shadow-xl py-2 text-accent-600">
|
||||
@ -12,7 +13,7 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@if(auth()->user()->role === \App\Enums\UserTypes::Broker->value)
|
||||
@if(auth()->check() && auth()->user()->role === \App\Enums\UserTypes::Broker->value)
|
||||
<li class="py-2 px-4 hover:bg-gray-100 hover:text-gray-900 hover:cursor-pointer hover:font-bold">
|
||||
<a href="{{route('broker.dashboard')}}" class="flex space-x-4">
|
||||
<div class="p-1 bg-gray-200 rounded-xl text-gray-900">
|
||||
@ -25,13 +26,22 @@
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<form method="post" action="{{route('logout')}}">
|
||||
@csrf
|
||||
@method('delete')
|
||||
<x-ui.button
|
||||
class="flex space-x-3 hover:bg-red-50 hover:border-red-100 hover:text-red-500 border border-white">
|
||||
<x-heroicon-o-arrow-right-start-on-rectangle class="w-4 stroke-2 mr-2"/>
|
||||
<p class="hidden sm:block">Logout</p>
|
||||
@endauth
|
||||
@guest
|
||||
<x-ui.button variant="neutral" link="{{route('login.create')}}">
|
||||
<p>Login </p>
|
||||
</x-ui.button>
|
||||
</form>
|
||||
@endguest
|
||||
|
||||
@auth
|
||||
<form method="post" action="{{route('logout')}}">
|
||||
@csrf
|
||||
@method('delete')
|
||||
<x-ui.button
|
||||
class="flex space-x-3 hover:bg-red-50 hover:border-red-100 hover:text-red-500 border border-white">
|
||||
<x-heroicon-o-arrow-right-start-on-rectangle class="w-4 stroke-2 mr-2"/>
|
||||
<p class="hidden sm:block">Logout</p>
|
||||
</x-ui.button>
|
||||
</form>
|
||||
@endauth
|
||||
</div>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
@props(['title' => ''])
|
||||
@php
|
||||
$pageTitle = config('app.name', 'Laravel');
|
||||
@ -11,6 +12,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
||||
<title>{{ $pageTitle }}</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{{asset('storage/'.'/images/favicon.ico')}}"/>
|
||||
<!-- Fonts -->
|
||||
|
||||
@ -20,14 +20,16 @@
|
||||
@endsession
|
||||
</div>
|
||||
|
||||
<x-explore.search :recent-searches="$recentSearches" :categories="$categories" />
|
||||
<x-explore.search :recent-searches="$recentSearches" :categories="$categories"/>
|
||||
|
||||
<!-- Sorting buttons -->
|
||||
<x-explore.toggle-buttons />
|
||||
<x-explore.toggle-buttons/>
|
||||
|
||||
<x-dashboard.user.listing :deals="$deals"/>
|
||||
<x-dashboard.user.report-modal/>
|
||||
<x-dashboard.user.deal-modal />
|
||||
@auth
|
||||
<x-dashboard.user.report-modal/>
|
||||
<x-dashboard.user.deal-modal/>
|
||||
@endauth
|
||||
</section>
|
||||
<x-ui.toast/>
|
||||
</x-layout>
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
require __DIR__.'/web/customer.php';
|
||||
|
||||
Route::get('/', HomeController::class)->name('home');
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/explore', ExplorePageController::class)->name('explore');
|
||||
|
||||
Route::get('/explore', ExplorePageController::class)->name('explore');
|
||||
Route::middleware('auth')->group(function () {
|
||||
|
||||
Route::view('/admin/dashboard', 'dashboards.admin.index')
|
||||
->middleware(HasRole::class.':'.UserTypes::Admin->value)
|
||||
|
||||
@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\InteractionType;
|
||||
use App\Enums\UserTypes;
|
||||
use App\Http\Controllers\Interaction\InteractionController;
|
||||
use App\Http\Middleware\HasRole;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
|
||||
Route::post('/like/{deal}', [InteractionController::class, 'togglesState'])
|
||||
->defaults('type', InteractionType::Like)
|
||||
->middleware('throttle:30,1')
|
||||
->middleware(['throttle:30,1', HasRole::class.':'.UserTypes::User->value])
|
||||
->name('like');
|
||||
|
||||
Route::post('/favorite/{deal}', [InteractionController::class, 'togglesState'])
|
||||
->defaults('type', InteractionType::Favorite)
|
||||
->middleware('throttle:30,1')
|
||||
->middleware(['throttle:30,1', HasRole::class.':'.UserTypes::User->value])
|
||||
->name('favorite');
|
||||
|
||||
Route::get('/redirect/{deal}', [InteractionController::class, 'redirect'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user