first commit

This commit is contained in:
2026-06-10 10:46:22 +05:45
commit 473bdd627b
136 changed files with 19074 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
+7
View File
@@ -0,0 +1,7 @@
import './bootstrap';
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.start();
+4
View File
@@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
@@ -0,0 +1,27 @@
<x-guest-layout>
<div class="mb-4 text-sm text-gray-600">
{{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
</div>
<form method="POST" action="{{ route('password.confirm') }}">
@csrf
<!-- Password -->
<div>
<x-input-label for="password" :value="__('Password')" />
<x-text-input id="password" class="block mt-1 w-full"
type="password"
name="password"
required autocomplete="current-password" />
<x-input-error :messages="$errors->get('password')" class="mt-2" />
</div>
<div class="flex justify-end mt-4">
<x-primary-button>
{{ __('Confirm') }}
</x-primary-button>
</div>
</form>
</x-guest-layout>
@@ -0,0 +1,25 @@
<x-guest-layout>
<div class="mb-4 text-sm text-gray-600">
{{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }}
</div>
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
<form method="POST" action="{{ route('password.email') }}">
@csrf
<!-- Email Address -->
<div>
<x-input-label for="email" :value="__('Email')" />
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autofocus />
<x-input-error :messages="$errors->get('email')" class="mt-2" />
</div>
<div class="flex items-center justify-end mt-4">
<x-primary-button>
{{ __('Email Password Reset Link') }}
</x-primary-button>
</div>
</form>
</x-guest-layout>
+47
View File
@@ -0,0 +1,47 @@
<x-guest-layout>
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
<form method="POST" action="{{ route('login') }}">
@csrf
<!-- Email Address -->
<div>
<x-input-label for="email" :value="__('Email')" />
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autofocus autocomplete="username" />
<x-input-error :messages="$errors->get('email')" class="mt-2" />
</div>
<!-- Password -->
<div class="mt-4">
<x-input-label for="password" :value="__('Password')" />
<x-text-input id="password" class="block mt-1 w-full"
type="password"
name="password"
required autocomplete="current-password" />
<x-input-error :messages="$errors->get('password')" class="mt-2" />
</div>
<!-- Remember Me -->
<div class="block mt-4">
<label for="remember_me" class="inline-flex items-center">
<input id="remember_me" type="checkbox" class="rounded border-gray-300 text-indigo-600 shadow-sm focus:ring-indigo-500" name="remember">
<span class="ms-2 text-sm text-gray-600">{{ __('Remember me') }}</span>
</label>
</div>
<div class="flex items-center justify-end mt-4">
@if (Route::has('password.request'))
<a class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" href="{{ route('password.request') }}">
{{ __('Forgot your password?') }}
</a>
@endif
<x-primary-button class="ms-3">
{{ __('Log in') }}
</x-primary-button>
</div>
</form>
</x-guest-layout>
+52
View File
@@ -0,0 +1,52 @@
<x-guest-layout>
<form method="POST" action="{{ route('register') }}">
@csrf
<!-- Name -->
<div>
<x-input-label for="name" :value="__('Name')" />
<x-text-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required autofocus autocomplete="name" />
<x-input-error :messages="$errors->get('name')" class="mt-2" />
</div>
<!-- Email Address -->
<div class="mt-4">
<x-input-label for="email" :value="__('Email')" />
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autocomplete="username" />
<x-input-error :messages="$errors->get('email')" class="mt-2" />
</div>
<!-- Password -->
<div class="mt-4">
<x-input-label for="password" :value="__('Password')" />
<x-text-input id="password" class="block mt-1 w-full"
type="password"
name="password"
required autocomplete="new-password" />
<x-input-error :messages="$errors->get('password')" class="mt-2" />
</div>
<!-- Confirm Password -->
<div class="mt-4">
<x-input-label for="password_confirmation" :value="__('Confirm Password')" />
<x-text-input id="password_confirmation" class="block mt-1 w-full"
type="password"
name="password_confirmation" required autocomplete="new-password" />
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
</div>
<div class="flex items-center justify-end mt-4">
<a class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" href="{{ route('login') }}">
{{ __('Already registered?') }}
</a>
<x-primary-button class="ms-4">
{{ __('Register') }}
</x-primary-button>
</div>
</form>
</x-guest-layout>
@@ -0,0 +1,39 @@
<x-guest-layout>
<form method="POST" action="{{ route('password.store') }}">
@csrf
<!-- Password Reset Token -->
<input type="hidden" name="token" value="{{ $request->route('token') }}">
<!-- Email Address -->
<div>
<x-input-label for="email" :value="__('Email')" />
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus autocomplete="username" />
<x-input-error :messages="$errors->get('email')" class="mt-2" />
</div>
<!-- Password -->
<div class="mt-4">
<x-input-label for="password" :value="__('Password')" />
<x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
<x-input-error :messages="$errors->get('password')" class="mt-2" />
</div>
<!-- Confirm Password -->
<div class="mt-4">
<x-input-label for="password_confirmation" :value="__('Confirm Password')" />
<x-text-input id="password_confirmation" class="block mt-1 w-full"
type="password"
name="password_confirmation" required autocomplete="new-password" />
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
</div>
<div class="flex items-center justify-end mt-4">
<x-primary-button>
{{ __('Reset Password') }}
</x-primary-button>
</div>
</form>
</x-guest-layout>
@@ -0,0 +1,31 @@
<x-guest-layout>
<div class="mb-4 text-sm text-gray-600">
{{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }}
</div>
@if (session('status') == 'verification-link-sent')
<div class="mb-4 font-medium text-sm text-green-600">
{{ __('A new verification link has been sent to the email address you provided during registration.') }}
</div>
@endif
<div class="mt-4 flex items-center justify-between">
<form method="POST" action="{{ route('verification.send') }}">
@csrf
<div>
<x-primary-button>
{{ __('Resend Verification Email') }}
</x-primary-button>
</div>
</form>
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
{{ __('Log Out') }}
</button>
</form>
</div>
</x-guest-layout>
@@ -0,0 +1,3 @@
<svg viewBox="0 0 316 316" xmlns="http://www.w3.org/2000/svg" {{ $attributes }}>
<path d="M305.8 81.125C305.77 80.995 305.69 80.885 305.65 80.755C305.56 80.525 305.49 80.285 305.37 80.075C305.29 79.935 305.17 79.815 305.07 79.685C304.94 79.515 304.83 79.325 304.68 79.175C304.55 79.045 304.39 78.955 304.25 78.845C304.09 78.715 303.95 78.575 303.77 78.475L251.32 48.275C249.97 47.495 248.31 47.495 246.96 48.275L194.51 78.475C194.33 78.575 194.19 78.725 194.03 78.845C193.89 78.955 193.73 79.045 193.6 79.175C193.45 79.325 193.34 79.515 193.21 79.685C193.11 79.815 192.99 79.935 192.91 80.075C192.79 80.285 192.71 80.525 192.63 80.755C192.58 80.875 192.51 80.995 192.48 81.125C192.38 81.495 192.33 81.875 192.33 82.265V139.625L148.62 164.795V52.575C148.62 52.185 148.57 51.805 148.47 51.435C148.44 51.305 148.36 51.195 148.32 51.065C148.23 50.835 148.16 50.595 148.04 50.385C147.96 50.245 147.84 50.125 147.74 49.995C147.61 49.825 147.5 49.635 147.35 49.485C147.22 49.355 147.06 49.265 146.92 49.155C146.76 49.025 146.62 48.885 146.44 48.785L93.99 18.585C92.64 17.805 90.98 17.805 89.63 18.585L37.18 48.785C37 48.885 36.86 49.035 36.7 49.155C36.56 49.265 36.4 49.355 36.27 49.485C36.12 49.635 36.01 49.825 35.88 49.995C35.78 50.125 35.66 50.245 35.58 50.385C35.46 50.595 35.38 50.835 35.3 51.065C35.25 51.185 35.18 51.305 35.15 51.435C35.05 51.805 35 52.185 35 52.575V232.235C35 233.795 35.84 235.245 37.19 236.025L142.1 296.425C142.33 296.555 142.58 296.635 142.82 296.725C142.93 296.765 143.04 296.835 143.16 296.865C143.53 296.965 143.9 297.015 144.28 297.015C144.66 297.015 145.03 296.965 145.4 296.865C145.5 296.835 145.59 296.775 145.69 296.745C145.95 296.655 146.21 296.565 146.45 296.435L251.36 236.035C252.72 235.255 253.55 233.815 253.55 232.245V174.885L303.81 145.945C305.17 145.165 306 143.725 306 142.155V82.265C305.95 81.875 305.89 81.495 305.8 81.125ZM144.2 227.205L100.57 202.515L146.39 176.135L196.66 147.195L240.33 172.335L208.29 190.625L144.2 227.205ZM244.75 114.995V164.795L226.39 154.225L201.03 139.625V89.825L219.39 100.395L244.75 114.995ZM249.12 57.105L292.81 82.265L249.12 107.425L205.43 82.265L249.12 57.105ZM114.49 184.425L96.13 194.995V85.305L121.49 70.705L139.85 60.135V169.815L114.49 184.425ZM91.76 27.425L135.45 52.585L91.76 77.745L48.07 52.585L91.76 27.425ZM43.67 60.135L62.03 70.705L87.39 85.305V202.545V202.555V202.565C87.39 202.735 87.44 202.895 87.46 203.055C87.49 203.265 87.49 203.485 87.55 203.695V203.705C87.6 203.875 87.69 204.035 87.76 204.195C87.84 204.375 87.89 204.575 87.99 204.745C87.99 204.745 87.99 204.755 88 204.755C88.09 204.905 88.22 205.035 88.33 205.175C88.45 205.335 88.55 205.495 88.69 205.635L88.7 205.645C88.82 205.765 88.98 205.855 89.12 205.965C89.28 206.085 89.42 206.225 89.59 206.325C89.6 206.325 89.6 206.325 89.61 206.335C89.62 206.335 89.62 206.345 89.63 206.345L139.87 234.775V285.065L43.67 229.705V60.135ZM244.75 229.705L148.58 285.075V234.775L219.8 194.115L244.75 179.875V229.705ZM297.2 139.625L253.49 164.795V114.995L278.85 100.395L297.21 89.825V139.625H297.2Z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

@@ -0,0 +1,7 @@
@props(['status'])
@if ($status)
<div {{ $attributes->merge(['class' => 'font-medium text-sm text-green-600']) }}>
{{ $status }}
</div>
@endif
@@ -0,0 +1,3 @@
<button {{ $attributes->merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-red-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-red-500 active:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition ease-in-out duration-150']) }}>
{{ $slot }}
</button>
@@ -0,0 +1 @@
<a {{ $attributes->merge(['class' => 'block w-full px-4 py-2 text-start text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out']) }}>{{ $slot }}</a>
@@ -0,0 +1,35 @@
@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white'])
@php
$alignmentClasses = match ($align) {
'left' => 'ltr:origin-top-left rtl:origin-top-right start-0',
'top' => 'origin-top',
default => 'ltr:origin-top-right rtl:origin-top-left end-0',
};
$width = match ($width) {
'48' => 'w-48',
default => $width,
};
@endphp
<div class="relative" x-data="{ open: false }" @click.outside="open = false" @close.stop="open = false">
<div @click="open = ! open">
{{ $trigger }}
</div>
<div x-show="open"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition ease-in duration-75"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
class="absolute z-50 mt-2 {{ $width }} rounded-md shadow-lg {{ $alignmentClasses }}"
style="display: none;"
@click="open = false">
<div class="rounded-md ring-1 ring-black ring-opacity-5 {{ $contentClasses }}">
{{ $content }}
</div>
</div>
</div>
@@ -0,0 +1,9 @@
@props(['messages'])
@if ($messages)
<ul {{ $attributes->merge(['class' => 'text-sm text-red-600 space-y-1']) }}>
@foreach ((array) $messages as $message)
<li>{{ $message }}</li>
@endforeach
</ul>
@endif
@@ -0,0 +1,5 @@
@props(['value'])
<label {{ $attributes->merge(['class' => 'block font-medium text-sm text-gray-700']) }}>
{{ $value ?? $slot }}
</label>
@@ -0,0 +1,78 @@
@props([
'name',
'show' => false,
'maxWidth' => '2xl'
])
@php
$maxWidth = [
'sm' => 'sm:max-w-sm',
'md' => 'sm:max-w-md',
'lg' => 'sm:max-w-lg',
'xl' => 'sm:max-w-xl',
'2xl' => 'sm:max-w-2xl',
][$maxWidth];
@endphp
<div
x-data="{
show: @js($show),
focusables() {
// All focusable element types...
let selector = 'a, button, input:not([type=\'hidden\']), textarea, select, details, [tabindex]:not([tabindex=\'-1\'])'
return [...$el.querySelectorAll(selector)]
// All non-disabled elements...
.filter(el => ! el.hasAttribute('disabled'))
},
firstFocusable() { return this.focusables()[0] },
lastFocusable() { return this.focusables().slice(-1)[0] },
nextFocusable() { return this.focusables()[this.nextFocusableIndex()] || this.firstFocusable() },
prevFocusable() { return this.focusables()[this.prevFocusableIndex()] || this.lastFocusable() },
nextFocusableIndex() { return (this.focusables().indexOf(document.activeElement) + 1) % (this.focusables().length + 1) },
prevFocusableIndex() { return Math.max(0, this.focusables().indexOf(document.activeElement)) -1 },
}"
x-init="$watch('show', value => {
if (value) {
document.body.classList.add('overflow-y-hidden');
{{ $attributes->has('focusable') ? 'setTimeout(() => firstFocusable().focus(), 100)' : '' }}
} else {
document.body.classList.remove('overflow-y-hidden');
}
})"
x-on:open-modal.window="$event.detail == '{{ $name }}' ? show = true : null"
x-on:close-modal.window="$event.detail == '{{ $name }}' ? show = false : null"
x-on:close.stop="show = false"
x-on:keydown.escape.window="show = false"
x-on:keydown.tab.prevent="$event.shiftKey || nextFocusable().focus()"
x-on:keydown.shift.tab.prevent="prevFocusable().focus()"
x-show="show"
class="fixed inset-0 overflow-y-auto px-4 py-6 sm:px-0 z-50"
style="display: {{ $show ? 'block' : 'none' }};"
>
<div
x-show="show"
class="fixed inset-0 transform transition-all"
x-on:click="show = false"
x-transition:enter="ease-out duration-300"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="ease-in duration-200"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
>
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>
<div
x-show="show"
class="mb-6 bg-white rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full {{ $maxWidth }} sm:mx-auto"
x-transition:enter="ease-out duration-300"
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave="ease-in duration-200"
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
{{ $slot }}
</div>
</div>
@@ -0,0 +1,11 @@
@props(['active'])
@php
$classes = ($active ?? false)
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out';
@endphp
<a {{ $attributes->merge(['class' => $classes]) }}>
{{ $slot }}
</a>
@@ -0,0 +1,3 @@
<button {{ $attributes->merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 focus:bg-gray-700 active:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition ease-in-out duration-150']) }}>
{{ $slot }}
</button>
@@ -0,0 +1,11 @@
@props(['active'])
@php
$classes = ($active ?? false)
? 'block w-full ps-3 pe-4 py-2 border-l-4 border-indigo-400 text-start text-base font-medium text-indigo-700 bg-indigo-50 focus:outline-none focus:text-indigo-800 focus:bg-indigo-100 focus:border-indigo-700 transition duration-150 ease-in-out'
: 'block w-full ps-3 pe-4 py-2 border-l-4 border-transparent text-start text-base font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 hover:border-gray-300 focus:outline-none focus:text-gray-800 focus:bg-gray-50 focus:border-gray-300 transition duration-150 ease-in-out';
@endphp
<a {{ $attributes->merge(['class' => $classes]) }}>
{{ $slot }}
</a>
@@ -0,0 +1,3 @@
<button {{ $attributes->merge(['type' => 'button', 'class' => 'inline-flex items-center px-4 py-2 bg-white border border-gray-300 rounded-md font-semibold text-xs text-gray-700 uppercase tracking-widest shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-25 transition ease-in-out duration-150']) }}>
{{ $slot }}
</button>
@@ -0,0 +1,3 @@
@props(['disabled' => false])
<input @disabled($disabled) {{ $attributes->merge(['class' => 'border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm']) }}>
+17
View File
@@ -0,0 +1,17 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Dashboard') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900">
{{ __("You're logged in!") }}
</div>
</div>
</div>
</div>
</x-app-layout>
+778
View File
@@ -0,0 +1,778 @@
@extends('layouts.master')
@section('content')
<div class="max-w-7xl mx-auto px-6 py-8">
<!-- HEADER -->
<div class="flex items-center justify-between mb-7">
<div>
<h1 class="text-slate-900 text-xl font-bold tracking-tight">Student Registrations</h1>
<p class="text-slate-500 text-sm mt-0.5">Track registrations and goal scores for today's session.</p>
</div>
<div class="flex items-center gap-2.5">
<a href="{{ route('registrations.index') }}"
class="flex items-center gap-2 bg-white hover:bg-slate-50 border border-slate-200 text-slate-700 text-sm font-medium px-4 py-2 rounded-lg transition-colors shadow-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 6h18"></path>
<path d="M3 12h18"></path>
<path d="M3 18h18"></path>
</svg>
All Registrations
</a>
<a href="{{ route('leaderboard') }}"
class="flex items-center gap-2 bg-white hover:bg-slate-50 border border-slate-200 text-slate-700 text-sm font-medium px-4 py-2 rounded-lg transition-colors shadow-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/>
</svg>
Leaderboard
</a>
<button id="newRegistrationBtn"
class="flex items-center gap-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors shadow-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
</svg>
New Registration
</button>
</div>
</div>
<!-- STATS -->
<div class="grid grid-cols-3 gap-4 mb-7">
<div class="bg-white rounded-xl border border-slate-200 px-5 py-4 flex items-center gap-4 shadow-sm">
<div class="w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center shrink-0">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#64748b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/>
<path d="M23 21v-2a4 4 0 00-3-3.87"/><path d="M16 3.13a4 4 0 010 7.75"/>
</svg>
</div>
<div>
<p class="text-2xl font-bold text-slate-900 leading-none">{{ $total }}</p>
<p class="text-xs text-slate-500 mt-1 font-medium">Total Registrations</p>
</div>
</div>
<div class="bg-white rounded-xl border border-slate-200 px-5 py-4 flex items-center gap-4 shadow-sm">
<div class="w-9 h-9 rounded-lg bg-emerald-50 flex items-center justify-center shrink-0">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 000 20M12 2a14.5 14.5 0 010 20M2 12h20"/>
</svg>
</div>
<div>
<p class="text-2xl font-bold text-slate-900 leading-none">{{ $played }}</p>
<p class="text-xs text-emerald-600 mt-1 font-medium">Played Today</p>
</div>
</div>
<div class="bg-white rounded-xl border border-slate-200 px-5 py-4 flex items-center gap-4 shadow-sm">
<div class="w-9 h-9 rounded-lg bg-indigo-50 flex items-center justify-center shrink-0">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#6366f1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>
</svg>
</div>
<div>
<p class="text-2xl font-bold text-slate-900 leading-none">{{ $topScore }}</p>
<p class="text-xs text-indigo-600 mt-1 font-medium">Top Score</p>
</div>
</div>
</div>
<!-- TABLE -->
<div class="bg-white rounded-xl border border-slate-200 overflow-hidden shadow-sm">
<div class="px-5 py-3.5 border-b border-slate-100 flex items-center justify-between">
<div class="flex items-center gap-2 text-slate-700 font-semibold text-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/>
<line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>
</svg>
Today's Sessions
</div>
<span class="text-xs font-medium text-slate-400 bg-slate-100 px-2 py-0.5 rounded-full">{{ $total }} students</span>
</div>
<table class="w-full text-sm">
<thead>
<tr class="bg-slate-50 border-b border-slate-100">
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider w-16">ID</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Name</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Phone</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Email</th>
<th class="px-5 py-3 text-center text-xs font-semibold text-slate-500 uppercase tracking-wider">Today's Shots</th>
<th class="px-5 py-3 text-center text-xs font-semibold text-slate-500 uppercase tracking-wider">Total Score</th>
<th class="px-5 py-3 text-right text-xs font-semibold text-slate-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@foreach ($registrations as $reg)
<tr class="hover:bg-slate-50/70 transition-colors group"
data-session-id="{{ $reg['session_id'] ?? '' }}"
data-name="{{ $reg['name'] }}"
data-total-score="{{ $reg['total_score'] }}"
data-shots="{{ json_encode($reg['today_goals'] ?? []) }}"
data-shots-recorded="{{ is_array($reg['today_goals']) ? count($reg['today_goals']) : 0 }}"
data-reg-id="{{ $reg['id'] }}">
<td class="px-5 py-3.5">
<span class="text-xs font-mono text-slate-400">#{{ str_pad($reg['id'], 4, '0', STR_PAD_LEFT) }}</span>
</td>
<td class="px-5 py-3.5">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center shrink-0">
<span class="text-xs font-bold text-indigo-600">{{ strtoupper(substr($reg['name'], 0, 1)) }}</span>
</div>
<span class="font-medium text-slate-800">{{ $reg['name'] }}</span>
</div>
</td>
<td class="px-5 py-3.5 text-slate-500">{{ $reg['phone'] }}</td>
<td class="px-5 py-3.5 text-slate-500">{{ $reg['email'] }}</td>
<td class="px-5 py-3.5">
<div class="shots-cell flex items-center justify-center gap-1.5">
@if(is_null($reg['today_goals']))
<span class="text-xs text-slate-400 italic">Not played</span>
@else
@foreach($reg['today_goals'] as $i => $goal)
@if($goal)
<div class="w-7 h-7 rounded-full bg-emerald-100 border-2 border-emerald-400 flex items-center justify-center" title="Shot {{ $i+1 }}: Goal">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</div>
@else
<div class="w-7 h-7 rounded-full bg-slate-100 border-2 border-slate-300 flex items-center justify-center" title="Shot {{ $i+1 }}: Miss">
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</div>
@endif
@endforeach
@endif
</div>
</td>
<td class="px-5 py-3.5 text-center">
<div class="inline-flex items-center gap-1 font-bold text-slate-900">
<svg width="13" height="13" viewBox="0 0 24 24" fill="#6366f1" stroke="none"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>
<span class="text-base score-cell">{{ $reg['total_score'] }}</span>
</div>
</td>
<td class="px-5 py-3.5">
<div class="flex items-center justify-end gap-1">
@if(is_null($reg['today_goals']))
<button class="flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium text-indigo-600 bg-indigo-50 hover:bg-indigo-100 border border-indigo-200 transition-colors">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>
Record Score
</button>
@else
<span class="text-xs text-slate-400 italic px-1">Played </span>
@endif
<button class="p-1.5 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors opacity-0 group-hover:opacity-100">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"/></svg>
</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="px-5 py-3 border-t border-slate-100 flex items-center justify-between">
<p class="text-xs text-slate-400">Showing <span class="font-medium text-slate-600">{{ $total }}</span> students</p>
</div>
</div>
</div>
<!-- FLOATING FOOTBALL BTN -->
<style>
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-8px); }
}
#footballBtn { animation: float 2.8s ease-in-out infinite; }
#footballBtn:hover { animation: none; transform: translateY(-10px) rotate(12deg); }
#footballBtn:active { transform: scale(0.92); }
</style>
<button id="footballBtn" onclick="openScoreboard()" title="View Scoreboard"
class="fixed bottom-8 right-8 z-40 w-24 h-24 cursor-pointer bg-transparent border-none outline-none p-0">
<img src="{{ asset('assets/wcup.png') }}" alt="Scoreboard" class="w-full h-full object-contain drop-shadow-md">
</button>
<div class="fixed bottom-[7rem] right-8 z-40 pointer-events-none">
<span id="footballTooltip" class="bg-slate-900 text-white text-xs font-medium px-2.5 py-1 rounded-lg shadow opacity-0 transition-opacity duration-150 whitespace-nowrap">
Scoreboard
</span>
</div>
<iframe id="scoreboardFrame" src="" data-src="{{ route('scoreboard') }}"
allowfullscreen
style="display:none; position:fixed; inset:0; width:100vw; height:100vh; border:none; z-index:9999;"></iframe>
<!-- ============================================================ -->
<!-- REGISTRATION MODAL -->
<!-- ============================================================ -->
<div id="registrationModal" class="fixed inset-0 z-50 hidden items-center justify-center">
<!-- Backdrop -->
<div id="modalBackdrop" class="absolute inset-0 bg-slate-900/60 backdrop-blur-sm"></div>
<!-- Panel -->
<div class="relative bg-white rounded-2xl shadow-2xl w-full max-w-sm mx-4 overflow-hidden">
<!-- Top accent bar -->
<div class="h-1 bg-gradient-to-r from-indigo-500 via-purple-500 to-indigo-600"></div>
<div class="p-6">
<!-- Header -->
<div class="flex items-start justify-between mb-6">
<div>
<h3 class="text-slate-900 font-bold text-lg leading-tight">New Registration</h3>
<p id="modalSubtitle" class="text-slate-500 text-xs mt-0.5">Enter the student's phone number to begin.</p>
</div>
<button id="closeRegistrationModal"
class="ml-4 w-7 h-7 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-slate-500 transition-colors shrink-0">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
<!-- Step indicators -->
<div class="flex items-center gap-2 mb-6">
<div id="step1dot" class="flex items-center gap-1.5">
<div class="w-6 h-6 rounded-full bg-indigo-600 flex items-center justify-center text-white text-xs font-bold">1</div>
<span class="text-xs font-medium text-indigo-600">Phone</span>
</div>
<div class="flex-1 h-px bg-slate-200" id="step1line"></div>
<div id="step2dot" class="flex items-center gap-1.5 opacity-40">
<div class="w-6 h-6 rounded-full bg-slate-300 flex items-center justify-center text-slate-600 text-xs font-bold">2</div>
<span class="text-xs font-medium text-slate-400">Verify</span>
</div>
<div class="flex-1 h-px bg-slate-200" id="step2line"></div>
<div id="step3dot" class="flex items-center gap-1.5 opacity-40">
<div class="w-6 h-6 rounded-full bg-slate-300 flex items-center justify-center text-slate-600 text-xs font-bold">3</div>
<span class="text-xs font-medium text-slate-400">Details</span>
</div>
</div>
<!-- STEP 1: Phone -->
<div id="stepPhone">
<label class="block text-xs font-semibold text-slate-600 mb-1.5 uppercase tracking-wide">Phone Number</label>
<div class="flex items-center border border-slate-200 rounded-xl overflow-hidden focus-within:ring-2 focus-within:ring-indigo-500 focus-within:border-indigo-500 transition-all bg-slate-50">
<div class="px-3 py-2.5 border-r border-slate-200 bg-white">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 013.07 9.81 19.79 19.79 0 01.06 1.18 2 2 0 012.03 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.09 7.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 14.92z"/>
</svg>
</div>
<input type="tel" id="phone" placeholder="+977 98XXXXXXXX"
class="flex-1 px-3 py-2.5 bg-transparent text-sm text-slate-800 placeholder-slate-400 outline-none">
</div>
<button id="sendOtpBtn"
class="mt-4 w-full bg-indigo-600 hover:bg-indigo-700 active:bg-indigo-800 text-white text-sm font-semibold py-2.5 rounded-xl transition-colors flex items-center justify-center gap-2">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/>
</svg>
Send OTP
</button>
</div>
<!-- STEP 2: Verify OTP -->
<div id="stepOtp" class="hidden">
<div class="bg-indigo-50 border border-indigo-100 rounded-xl px-4 py-3 mb-4 flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center shrink-0">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#6366f1" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 013.07 9.81 19.79 19.79 0 01.06 1.18 2 2 0 012.03 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.09 7.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 14.92z"/>
</svg>
</div>
<div>
<p class="text-xs font-semibold text-indigo-700">OTP sent to <span id="phoneSentTo" class="font-bold"></span></p>
<p class="text-xs text-indigo-500 mt-0.5">Expires in 2 minutes</p>
</div>
</div>
<!-- Dev OTP preview -->
<div id="otpPreview" class="hidden bg-amber-50 border border-amber-200 rounded-xl px-4 py-2.5 mb-4 flex items-center gap-2">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="#d97706" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
<p class="text-xs font-semibold text-amber-700">Dev OTP: <span id="otpValue" class="font-mono tracking-widest"></span></p>
</div>
<label class="block text-xs font-semibold text-slate-600 mb-1.5 uppercase tracking-wide">Enter OTP</label>
<input type="text" id="otp" maxlength="6" placeholder="— — — — — —"
class="w-full border border-slate-200 rounded-xl px-4 py-2.5 text-center text-xl font-mono tracking-[.5em] text-slate-800 bg-slate-50
focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 focus:bg-white transition-all placeholder-slate-300">
<button id="verifyOtpBtn"
class="mt-4 w-full bg-emerald-600 hover:bg-emerald-700 active:bg-emerald-800 text-white text-sm font-semibold py-2.5 rounded-xl transition-colors flex items-center justify-center gap-2">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12"/>
</svg>
Verify OTP
</button>
<button id="backToPhone" class="mt-2.5 w-full text-xs text-slate-400 hover:text-slate-600 py-1.5 transition-colors">
Change phone number
</button>
</div>
<!-- STEP 3: Extra details (new user only) -->
<div id="stepDetails" class="hidden">
<div class="bg-emerald-50 border border-emerald-100 rounded-xl px-4 py-3 mb-4 flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-emerald-100 flex items-center justify-center shrink-0">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12"/>
</svg>
</div>
<div>
<p class="text-xs font-semibold text-emerald-700">Phone verified!</p>
<p class="text-xs text-emerald-600 mt-0.5">New student please fill in their details.</p>
</div>
</div>
<div class="space-y-3">
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1.5 uppercase tracking-wide">Full Name <span class="text-red-400">*</span></label>
<input type="text" id="regName" placeholder="Student's full name"
class="w-full border border-slate-200 rounded-xl px-3 py-2.5 text-sm text-slate-800 bg-slate-50
focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 focus:bg-white transition-all placeholder-slate-400">
</div>
<div>
<label class="block text-xs font-semibold text-slate-600 mb-1.5 uppercase tracking-wide">Email <span class="text-slate-400 font-normal normal-case">(optional)</span></label>
<input type="email" id="regEmail" placeholder="student@email.com"
class="w-full border border-slate-200 rounded-xl px-3 py-2.5 text-sm text-slate-800 bg-slate-50
focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 focus:bg-white transition-all placeholder-slate-400">
</div>
</div>
<button id="submitRegistrationBtn"
class="mt-5 w-full bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-semibold py-2.5 rounded-xl transition-colors flex items-center justify-center gap-2">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/>
</svg>
Register Student
</button>
</div>
<!-- Error message -->
<div id="modalError" class="hidden mt-3 bg-red-50 border border-red-200 rounded-xl px-4 py-3 flex items-center gap-2">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="#ef4444" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
<p id="modalErrorText" class="text-xs text-red-600 font-medium"></p>
</div>
</div>
</div>
</div>
<!-- ============================================================ -->
<!-- SHOT RECORDING SIDE PANEL -->
<!-- ============================================================ -->
<div id="shotPanel"
class="fixed top-0 right-0 h-full w-80 bg-white border-l border-slate-200 shadow-2xl z-40
transform translate-x-full transition-transform duration-300 ease-in-out
flex flex-col">
<!-- Panel Header -->
<div class="px-5 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
<div>
<p class="text-xs font-semibold text-slate-400 uppercase tracking-wider">Recording Shots For</p>
<p id="panelName" class="text-slate-900 font-bold text-base mt-0.5"></p>
</div>
<button id="closeShotPanel"
class="w-7 h-7 rounded-full bg-slate-200 hover:bg-slate-300 flex items-center justify-center text-slate-500 transition-colors">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
<!-- Shot Indicators -->
<div class="px-5 py-4 border-b border-slate-100">
<p class="text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3">Today's Shots</p>
<div class="flex items-center gap-3">
<div id="shotIndicator1" class="flex-1 h-10 rounded-lg border-2 border-slate-200 bg-slate-50 flex items-center justify-center text-xs font-bold text-slate-400">
Shot 1
</div>
<div id="shotIndicator2" class="flex-1 h-10 rounded-lg border-2 border-slate-200 bg-slate-50 flex items-center justify-center text-xs font-bold text-slate-400">
Shot 2
</div>
<div id="shotIndicator3" class="flex-1 h-10 rounded-lg border-2 border-slate-200 bg-slate-50 flex items-center justify-center text-xs font-bold text-slate-400">
Shot 3
</div>
</div>
</div>
<!-- Current Shot -->
<div class="flex-1 flex flex-col items-center justify-center px-5 gap-5">
<div id="shotReadyState">
<p class="text-center text-slate-400 text-xs font-semibold uppercase tracking-wider mb-1">Current Shot</p>
<p id="currentShotLabel" class="text-center text-slate-900 font-black text-4xl mb-6">Shot 1</p>
<div class="flex flex-col gap-3 w-full px-2">
<button id="goalBtn"
class="w-full py-8 flex flex-col items-center justify-center gap-3 rounded-2xl
bg-emerald-50 hover:bg-emerald-100 active:scale-95
border-2 border-emerald-300 hover:border-emerald-500
transition-all duration-150">
<span class="text-5xl"></span>
<span class="text-emerald-700 font-black text-base uppercase tracking-widest">Goal</span>
<span class="text-emerald-500 text-xs font-semibold">+1 pt</span>
</button>
<button id="missBtn"
class="w-full py-8 flex flex-col items-center justify-center gap-3 rounded-2xl
bg-red-50 hover:bg-red-100 active:scale-95
border-2 border-red-300 hover:border-red-500
transition-all duration-150">
<span class="text-5xl font-black text-red-500"></span>
<span class="text-red-700 font-black text-base uppercase tracking-widest">Miss</span>
<span class="text-red-400 text-xs font-semibold">0 pts</span>
</button>
</div>
</div>
<!-- Done state (all 3 recorded) -->
<div id="shotDoneState" class="hidden text-center">
<div class="w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12"/>
</svg>
</div>
<p class="text-slate-900 font-bold text-lg">All shots recorded!</p>
<p class="text-slate-500 text-sm mt-1">Session score: <span id="sessionScoreDisplay" class="font-bold text-indigo-600"></span> pts</p>
</div>
</div>
<!-- Total Score Footer -->
<div class="px-5 py-4 border-t border-slate-100 bg-slate-50">
<div class="flex items-center justify-between">
<p class="text-xs font-semibold text-slate-400 uppercase tracking-wider">Cumulative Total</p>
<div class="flex items-center gap-1">
<svg width="13" height="13" viewBox="0 0 24 24" fill="#6366f1" stroke="none">
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>
</svg>
<span id="panelTotalScore" class="text-slate-900 font-black text-xl">0</span>
<span class="text-slate-400 text-xs font-medium">pts</span>
</div>
</div>
</div>
</div>
<!-- Overlay behind panel -->
<div id="shotPanelOverlay"
class="fixed inset-0 bg-black/20 z-30 hidden"
id="shotPanelOverlay">
</div>
@endsection
@push('js')
<script>
// ── Row selection + Shot panel ───────────────────────────────
let selectedSessionId = null;
let currentShot = 1;
let shotResults = [];
let selectedRow = null;
function openShotPanel(row) {
// Deselect previous
if (selectedRow) selectedRow.classList.remove('ring-2', 'ring-inset', 'ring-indigo-400', 'bg-indigo-50/40');
selectedRow = row;
row.classList.add('ring-2', 'ring-inset', 'ring-indigo-400', 'bg-indigo-50/40');
selectedSessionId = row.dataset.sessionId;
currentShot = parseInt(row.dataset.shotsRecorded || 0) + 1;
shotResults = JSON.parse(row.dataset.shots || '[]');
document.getElementById('panelName').textContent = row.dataset.name;
document.getElementById('panelTotalScore').textContent = row.dataset.totalScore;
refreshPanel();
document.getElementById('shotPanel').classList.remove('translate-x-full');
document.getElementById('shotPanelOverlay').classList.remove('hidden');
}
function closeShotPanel() {
document.getElementById('shotPanel').classList.add('translate-x-full');
document.getElementById('shotPanelOverlay').classList.add('hidden');
if (selectedRow) selectedRow.classList.remove('ring-2', 'ring-inset', 'ring-indigo-400', 'bg-indigo-50/40');
selectedRow = null;
}
function refreshPanel() {
// Update indicators
for (let i = 1; i <= 3; i++) {
const el = document.getElementById('shotIndicator' + i);
el.className = 'flex-1 h-10 rounded-lg border-2 flex items-center justify-center text-xs font-bold transition-all';
if (i < currentShot) {
const goal = shotResults[i - 1];
if (goal) {
el.classList.add('border-emerald-400', 'bg-emerald-50', 'text-emerald-600');
el.innerHTML = '⚽ Goal';
} else {
el.classList.add('border-red-300', 'bg-red-50', 'text-red-500');
el.innerHTML = '✕ Miss';
}
} else if (i === currentShot) {
el.classList.add('border-indigo-400', 'bg-indigo-50', 'text-indigo-600', 'animate-pulse');
el.innerHTML = 'Shot ' + i;
} else {
el.classList.add('border-slate-200', 'bg-slate-50', 'text-slate-400');
el.innerHTML = 'Shot ' + i;
}
}
if (currentShot > 3) {
document.getElementById('shotReadyState').classList.add('hidden');
document.getElementById('shotDoneState').classList.remove('hidden');
const goals = shotResults.filter(Boolean).length;
document.getElementById('sessionScoreDisplay').textContent = goals;
} else {
document.getElementById('shotReadyState').classList.remove('hidden');
document.getElementById('shotDoneState').classList.add('hidden');
document.getElementById('currentShotLabel').textContent = 'Shot ' + currentShot;
}
}
function recordShot(result) {
if (!selectedSessionId || currentShot > 3) return;
const shotNumber = currentShot;
$.post("{{ route('registrations.record-shot') }}", {
_token: "{{ csrf_token() }}",
session_id: selectedSessionId,
shot_number: shotNumber,
result: result ? 1 : 0,
})
.done(res => {
shotResults.push(result);
currentShot++;
// Update the indicator + panel
refreshPanel();
// Update total score in footer + in the row
document.getElementById('panelTotalScore').textContent = res.total_score;
if (selectedRow) {
selectedRow.dataset.totalScore = res.total_score;
selectedRow.dataset.shots = JSON.stringify(shotResults);
selectedRow.dataset.shotsRecorded = shotResults.length;
// Live-update score cell
const scoreCell = selectedRow.querySelector('.score-cell');
if (scoreCell) scoreCell.textContent = res.total_score;
// Live-update shot dots
const shotsCell = selectedRow.querySelector('.shots-cell');
if (shotsCell) {
shotsCell.innerHTML = shotResults.map((g, i) =>
g ? `<div class="w-7 h-7 rounded-full bg-emerald-100 border-2 border-emerald-400 flex items-center justify-center" title="Shot ${i+1}: Goal">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</div>`
: `<div class="w-7 h-7 rounded-full bg-slate-100 border-2 border-slate-300 flex items-center justify-center" title="Shot ${i+1}: Miss">
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</div>`
).join('');
}
}
})
.fail(() => alert('Failed to record shot. Please try again.'));
}
document.getElementById('goalBtn').addEventListener('click', () => recordShot(true));
document.getElementById('missBtn').addEventListener('click', () => recordShot(false));
document.getElementById('closeShotPanel').addEventListener('click', closeShotPanel);
document.getElementById('shotPanelOverlay').addEventListener('click', closeShotPanel);
// Row click listeners
document.querySelectorAll('tr[data-session-id]').forEach(row => {
row.classList.add('cursor-pointer');
row.addEventListener('click', () => {
openShotPanel(row);
// Sync selected player to scoreboard
const regId = row.dataset.regId;
if (regId) {
$.post("{{ route('scoreboard.select') }}", {
_token: "{{ csrf_token() }}",
registration_id: regId,
});
}
});
});
// ── Scoreboard ──────────────────────────────────────────────
const footballBtn = document.getElementById('footballBtn');
const tooltip = document.getElementById('footballTooltip');
footballBtn.addEventListener('mouseenter', () => tooltip.style.opacity = 1);
footballBtn.addEventListener('mouseleave', () => tooltip.style.opacity = 0);
function openScoreboard() {
const frame = document.getElementById('scoreboardFrame');
if (!frame.src || frame.src === window.location.href) frame.src = frame.dataset.src;
const req = frame.requestFullscreen || frame.webkitRequestFullscreen || frame.mozRequestFullScreen || frame.msRequestFullscreen;
if (req) req.call(frame);
}
['fullscreenchange','webkitfullscreenchange','mozfullscreenchange','MSFullscreenChange'].forEach(e =>
document.addEventListener(e, () => {
const fs = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
document.getElementById('scoreboardFrame').style.display = fs ? 'block' : 'none';
})
);
// ── Modal state ──────────────────────────────────────────────
const modal = document.getElementById('registrationModal');
const stepPhone = document.getElementById('stepPhone');
const stepOtp = document.getElementById('stepOtp');
const stepDetails = document.getElementById('stepDetails');
function showModal() {
modal.classList.remove('hidden');
modal.classList.add('flex');
goToStep(1);
}
function hideModal() {
modal.classList.add('hidden');
modal.classList.remove('flex');
clearError();
document.getElementById('phone').value = '';
document.getElementById('otp').value = '';
document.getElementById('regName').value = '';
document.getElementById('regEmail').value = '';
}
function goToStep(step) {
stepPhone.classList.add('hidden');
stepOtp.classList.add('hidden');
stepDetails.classList.add('hidden');
clearError();
const subtitles = {
1: 'Enter the student\'s phone number to begin.',
2: 'Enter the 6-digit OTP sent to the student\'s phone.',
3: 'New student — fill in their details to complete registration.'
};
document.getElementById('modalSubtitle').textContent = subtitles[step];
// Step indicators
const s2 = document.getElementById('step2dot');
const s3 = document.getElementById('step3dot');
s2.classList.toggle('opacity-40', step < 2);
s3.classList.toggle('opacity-40', step < 3);
s2.querySelector('div').className = step >= 2
? 'w-6 h-6 rounded-full bg-indigo-600 flex items-center justify-center text-white text-xs font-bold'
: 'w-6 h-6 rounded-full bg-slate-300 flex items-center justify-center text-slate-600 text-xs font-bold';
s3.querySelector('div').className = step >= 3
? 'w-6 h-6 rounded-full bg-indigo-600 flex items-center justify-center text-white text-xs font-bold'
: 'w-6 h-6 rounded-full bg-slate-300 flex items-center justify-center text-slate-600 text-xs font-bold';
if (step === 1) stepPhone.classList.remove('hidden');
if (step === 2) stepOtp.classList.remove('hidden');
if (step === 3) stepDetails.classList.remove('hidden');
}
function showError(msg) {
document.getElementById('modalError').classList.remove('hidden');
document.getElementById('modalErrorText').textContent = msg;
}
function clearError() {
document.getElementById('modalError').classList.add('hidden');
}
// ── Open / Close ─────────────────────────────────────────────
document.getElementById('newRegistrationBtn').addEventListener('click', showModal);
document.getElementById('closeRegistrationModal').addEventListener('click', hideModal);
document.getElementById('modalBackdrop').addEventListener('click', hideModal);
document.getElementById('backToPhone').addEventListener('click', () => goToStep(1));
// ── Send OTP ─────────────────────────────────────────────────
document.getElementById('sendOtpBtn').addEventListener('click', function () {
const phone = document.getElementById('phone').value.trim();
if (!phone) { showError('Please enter a phone number.'); return; }
this.disabled = true;
this.textContent = 'Sending…';
$.post("{{ route('registrations.send-otp') }}", {
_token: "{{ csrf_token() }}",
phone: phone
})
.done(res => {
document.getElementById('phoneSentTo').textContent = phone;
if (res.otp) {
document.getElementById('otpPreview').classList.remove('hidden');
document.getElementById('otpValue').textContent = res.otp;
}
goToStep(2);
})
.fail(() => showError('Failed to send OTP. Please try again.'))
.always(() => {
this.disabled = false;
this.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg> Send OTP`;
});
});
// ── Verify OTP ───────────────────────────────────────────────
document.getElementById('verifyOtpBtn').addEventListener('click', function () {
const phone = document.getElementById('phone').value.trim();
const otp = document.getElementById('otp').value.trim();
if (!otp) { showError('Please enter the OTP.'); return; }
this.disabled = true;
this.textContent = 'Verifying…';
$.post("{{ route('registrations.verify-otp') }}", {
_token: "{{ csrf_token() }}",
phone: phone,
otp: otp
})
.done(res => {
if (res.status === 'session_created') {
hideModal();
location.reload();
} else if (res.status === 'needs_registration') {
goToStep(3);
}
})
.fail(xhr => {
const res = xhr.responseJSON;
if (res?.status === 'blocked') {
showError(res.message || 'This student has already played today.');
} else if (res?.status === 'invalid_otp') {
showError('Invalid OTP. Please try again.');
} else {
showError('Something went wrong. Please try again.');
}
})
.always(() => {
this.disabled = false;
this.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg> Verify OTP`;
});
});
// ── Submit new registration (step 3) ─────────────────────────
document.getElementById('submitRegistrationBtn').addEventListener('click', function () {
const name = document.getElementById('regName').value.trim();
const email = document.getElementById('regEmail').value.trim();
const phone = document.getElementById('phone').value.trim();
if (!name) { showError('Please enter the student\'s name.'); return; }
this.disabled = true;
this.textContent = 'Registering…';
$.post("{{ route('registrations.store') }}", {
_token: "{{ csrf_token() }}",
phone: phone,
name: name,
email: email
})
.done(res => {
if (res.status === 'session_created') {
hideModal();
location.reload();
}
})
.fail(() => showError('Registration failed. Please try again.'))
.always(() => {
this.disabled = false;
this.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/></svg> Register Student`;
});
});
</script>
@endpush
@@ -0,0 +1,349 @@
@extends('layouts.master')
@section('content')
<div class="max-w-7xl mx-auto px-6 py-8">
<!-- HEADER -->
<div class="flex items-center justify-between mb-7">
<div>
<h1 class="text-slate-900 text-xl font-bold tracking-tight">Student Registrations</h1>
<p class="text-slate-500 text-sm mt-0.5">View registrations and manage student comments.</p>
</div>
<div class="flex items-center gap-2.5">
<a href="{{ route('registrations.index') }}"
class="flex items-center gap-2 bg-white hover:bg-slate-50 border border-slate-200 text-slate-700 text-sm font-medium px-4 py-2 rounded-lg transition-colors shadow-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 6h18"/><path d="M3 12h18"/><path d="M3 18h18"/>
</svg>
All Registrations
</a>
<a href="{{ route('leaderboard') }}"
class="flex items-center gap-2 bg-white hover:bg-slate-50 border border-slate-200 text-slate-700 text-sm font-medium px-4 py-2 rounded-lg transition-colors shadow-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/>
</svg>
Leaderboard
</a>
</div>
</div>
<!-- STATS -->
<div class="grid grid-cols-3 gap-4 mb-7">
<div class="bg-white rounded-xl border border-slate-200 px-5 py-4 flex items-center gap-4 shadow-sm">
<div class="w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center shrink-0">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#64748b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/>
<path d="M23 21v-2a4 4 0 00-3-3.87"/><path d="M16 3.13a4 4 0 010 7.75"/>
</svg>
</div>
<div>
<p class="text-2xl font-bold text-slate-900 leading-none">{{ $total }}</p>
<p class="text-xs text-slate-500 mt-1 font-medium">Total Registrations</p>
</div>
</div>
<div class="bg-white rounded-xl border border-slate-200 px-5 py-4 flex items-center gap-4 shadow-sm">
<div class="w-9 h-9 rounded-lg bg-emerald-50 flex items-center justify-center shrink-0">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 000 20M12 2a14.5 14.5 0 010 20M2 12h20"/>
</svg>
</div>
<div>
<p class="text-2xl font-bold text-slate-900 leading-none">{{ $played }}</p>
<p class="text-xs text-emerald-600 mt-1 font-medium">Played Today</p>
</div>
</div>
<div class="bg-white rounded-xl border border-slate-200 px-5 py-4 flex items-center gap-4 shadow-sm">
<div class="w-9 h-9 rounded-lg bg-indigo-50 flex items-center justify-center shrink-0">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#6366f1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>
</svg>
</div>
<div>
<p class="text-2xl font-bold text-slate-900 leading-none">{{ $topScore }}</p>
<p class="text-xs text-indigo-600 mt-1 font-medium">Top Score</p>
</div>
</div>
</div>
<!-- TABLE -->
<div class="bg-white rounded-xl border border-slate-200 overflow-hidden shadow-sm">
<div class="px-5 py-3.5 border-b border-slate-100 flex items-center justify-between">
<div class="flex items-center gap-2 text-slate-700 font-semibold text-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/>
<line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>
</svg>
Today's Sessions
</div>
<span class="text-xs font-medium text-slate-400 bg-slate-100 px-2 py-0.5 rounded-full">{{ $registrations->count() }} students</span>
</div>
<table class="w-full text-sm">
<thead>
<tr class="bg-slate-50 border-b border-slate-100">
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider w-16">ID</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Name</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Phone</th>
<th class="px-5 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider">Email</th>
<th class="px-5 py-3 text-center text-xs font-semibold text-slate-500 uppercase tracking-wider">Today's Shots</th>
<th class="px-5 py-3 text-center text-xs font-semibold text-slate-500 uppercase tracking-wider">Total Score</th>
<th class="px-5 py-3 text-center text-xs font-semibold text-slate-500 uppercase tracking-wider">Comments</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@foreach ($registrations as $reg)
<tr class="hover:bg-slate-50/70 transition-colors group cursor-pointer"
data-reg-id="{{ $reg['id'] }}"
data-name="{{ $reg['name'] }}">
<td class="px-5 py-3.5">
<span class="text-xs font-mono text-slate-400">#{{ str_pad($reg['id'], 4, '0', STR_PAD_LEFT) }}</span>
</td>
<td class="px-5 py-3.5">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center shrink-0">
<span class="text-xs font-bold text-indigo-600">{{ strtoupper(substr($reg['name'], 0, 1)) }}</span>
</div>
<span class="font-medium text-slate-800">{{ $reg['name'] }}</span>
</div>
</td>
<td class="px-5 py-3.5 text-slate-500">{{ $reg['phone'] }}</td>
<td class="px-5 py-3.5 text-slate-500">{{ $reg['email'] }}</td>
<td class="px-5 py-3.5">
<div class="flex items-center justify-center gap-1.5">
@if(is_null($reg['today_goals']))
<span class="text-xs text-slate-400 italic">Not played</span>
@else
@foreach($reg['today_goals'] as $i => $goal)
@if($goal)
<div class="w-7 h-7 rounded-full bg-emerald-100 border-2 border-emerald-400 flex items-center justify-center" title="Shot {{ $i+1 }}: Goal">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</div>
@else
<div class="w-7 h-7 rounded-full bg-slate-100 border-2 border-slate-300 flex items-center justify-center" title="Shot {{ $i+1 }}: Miss">
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</div>
@endif
@endforeach
@endif
</div>
</td>
<td class="px-5 py-3.5 text-center">
<div class="inline-flex items-center gap-1 font-bold text-slate-900">
<svg width="13" height="13" viewBox="0 0 24 24" fill="#6366f1" stroke="none"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>
<span class="text-base">{{ $reg['total_score'] }}</span>
</div>
</td>
<td class="px-5 py-3.5 text-center">
<span class="inline-flex items-center gap-1 text-xs font-medium text-slate-500 bg-slate-100 px-2 py-1 rounded-full">
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/>
</svg>
{{ $reg['comment_count'] ?? 0 }}
</span>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="px-5 py-3 border-t border-slate-100">
<p class="text-xs text-slate-400">Showing <span class="font-medium text-slate-600">{{ $registrations->count() }}</span> students</p>
</div>
</div>
</div>
<!-- ============================================================ -->
<!-- COMMENT SIDE PANEL -->
<!-- ============================================================ -->
<div id="commentPanel"
class="fixed top-0 right-0 h-full w-96 bg-white border-l border-slate-200 shadow-2xl z-40
transform translate-x-full transition-transform duration-300 ease-in-out
flex flex-col">
<!-- Panel Header -->
<div class="px-5 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50 shrink-0">
<div>
<p class="text-xs font-semibold text-slate-400 uppercase tracking-wider">Comments for</p>
<p id="commentPanelName" class="text-slate-900 font-bold text-base mt-0.5"></p>
</div>
<button id="closeCommentPanel"
class="w-7 h-7 rounded-full bg-slate-200 hover:bg-slate-300 flex items-center justify-center text-slate-500 transition-colors">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
</svg>
</button>
</div>
<!-- Comment History -->
<div id="commentList" class="flex-1 overflow-y-auto px-5 py-4 space-y-3 min-h-0">
<!-- filled by JS -->
<div id="commentLoading" class="flex items-center justify-center h-full text-slate-400 text-sm">
<svg class="animate-spin mr-2" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 11-18 0 9 9 0 0118 0"/></svg>
Loading comments…
</div>
<div id="commentEmpty" class="hidden flex-col items-center justify-center h-full text-center py-12">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-3">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/>
</svg>
</div>
<p class="text-slate-500 text-sm font-medium">No comments yet</p>
<p class="text-slate-400 text-xs mt-1">Add the first comment below.</p>
</div>
</div>
<!-- New Comment Input -->
<div class="px-5 py-4 border-t border-slate-100 bg-slate-50 shrink-0">
<label class="block text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2">Add Comment</label>
<textarea id="newCommentText" rows="3"
placeholder="Write a comment about this student…"
class="w-full border border-slate-200 rounded-xl px-3 py-2.5 text-sm text-slate-800 bg-white
focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500
transition-all placeholder-slate-400 resize-none"></textarea>
<button id="submitCommentBtn"
class="mt-2.5 w-full bg-indigo-600 hover:bg-indigo-700 active:bg-indigo-800
text-white text-sm font-semibold py-2.5 rounded-xl transition-colors
flex items-center justify-center gap-2">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/>
</svg>
Post Comment
</button>
</div>
</div>
<!-- Overlay -->
<div id="commentPanelOverlay" class="fixed inset-0 bg-black/20 z-30 hidden"></div>
@endsection
@push('js')
<script>
let selectedRegId = null;
let selectedRegRow = null;
// ── Open panel ───────────────────────────────────────────────
function openCommentPanel(row) {
if (selectedRegRow) selectedRegRow.classList.remove('ring-2', 'ring-inset', 'ring-indigo-400', 'bg-indigo-50/40');
selectedRegRow = row;
row.classList.add('ring-2', 'ring-inset', 'ring-indigo-400', 'bg-indigo-50/40');
selectedRegId = row.dataset.regId;
document.getElementById('commentPanelName').textContent = row.dataset.name;
document.getElementById('newCommentText').value = '';
document.getElementById('commentPanel').classList.remove('translate-x-full');
document.getElementById('commentPanelOverlay').classList.remove('hidden');
loadComments();
}
function closeCommentPanel() {
document.getElementById('commentPanel').classList.add('translate-x-full');
document.getElementById('commentPanelOverlay').classList.add('hidden');
if (selectedRegRow) selectedRegRow.classList.remove('ring-2', 'ring-inset', 'ring-indigo-400', 'bg-indigo-50/40');
selectedRegRow = null;
selectedRegId = null;
}
// ── Load comments ─────────────────────────────────────────────
function loadComments() {
const list = document.getElementById('commentList');
const loading = document.getElementById('commentLoading');
const empty = document.getElementById('commentEmpty');
// Clear previous comments (keep loading/empty nodes)
list.querySelectorAll('.comment-item').forEach(el => el.remove());
loading.classList.remove('hidden');
empty.classList.add('hidden');
$.ajax({
url: '{{ route("comments.index") }}',
method: 'GET',
data: { registration_id: selectedRegId },
success: function (res) {
loading.classList.add('hidden');
if (!res.comments || res.comments.length === 0) {
empty.classList.remove('hidden');
empty.classList.add('flex');
return;
}
empty.classList.add('hidden');
res.comments.forEach(c => appendComment(c, false));
list.scrollTop = list.scrollHeight;
},
error: function () {
loading.classList.add('hidden');
loading.textContent = 'Failed to load comments.';
loading.classList.remove('hidden');
}
});
}
// ── Render a single comment bubble ───────────────────────────
function appendComment(c, scrollInto = true) {
const list = document.getElementById('commentList');
const el = document.createElement('div');
el.className = 'comment-item bg-slate-50 border border-slate-200 rounded-xl px-4 py-3';
el.innerHTML = `
<div class="flex items-center justify-between mb-1.5">
<span class="text-xs font-semibold text-indigo-600">${escHtml(c.author ?? 'Counselor')}</span>
<span class="text-xs text-slate-400">${escHtml(c.created_at_human ?? c.created_at ?? '')}</span>
</div>
<p class="text-sm text-slate-700 leading-relaxed">${escHtml(c.comment)}</p>`;
list.appendChild(el);
if (scrollInto) list.scrollTop = list.scrollHeight;
}
function escHtml(str) {
return String(str).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
}
// ── Submit comment ────────────────────────────────────────────
document.getElementById('submitCommentBtn').addEventListener('click', function () {
const text = document.getElementById('newCommentText').value.trim();
if (!text || !selectedRegId) return;
this.disabled = true;
this.textContent = 'Posting…';
const btn = this;
$.ajax({
url: '{{ route("comments.store") }}',
method: 'POST',
data: {
_token: '{{ csrf_token() }}',
registration_id: selectedRegId,
comment: text,
},
success: function (res) {
document.getElementById('newCommentText').value = '';
document.getElementById('commentEmpty').classList.add('hidden');
if (selectedRegRow) {
const badge = selectedRegRow.querySelector('.comment-count');
if (badge) badge.textContent = parseInt(badge.textContent || '0') + 1;
}
appendComment(res.comment);
},
error: function () {
alert('Failed to post comment. Please try again.');
},
complete: function () {
btn.disabled = false;
btn.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg> Post Comment`;
}
});
});
// ── Row clicks ───────────────────────────────────────────────
document.querySelectorAll('tr[data-reg-id]').forEach(row => {
row.addEventListener('click', () => openCommentPanel(row));
});
document.getElementById('closeCommentPanel').addEventListener('click', closeCommentPanel);
document.getElementById('commentPanelOverlay').addEventListener('click', closeCommentPanel);
</script>
@endpush
+24
View File
@@ -0,0 +1,24 @@
<footer class="border-t border-slate-200 bg-white mt-auto">
<div class="max-w-7xl mx-auto px-6 py-4 flex items-center justify-between">
<!-- Left: Brand + Copyright -->
<div class="flex items-center gap-2 text-slate-400 text-xs">
<div class="w-4 h-4 rounded bg-indigo-500 flex items-center justify-center shrink-0">
<svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 10v6M2 10l10-5 10 5-10 5z"/><path d="M6 12v5c0 1.657 2.686 3 6 3s6-1.343 6-3v-5"/>
</svg>
</div>
<span>&copy; {{ date('Y') }} Rosetta International Education. All rights reserved.</span>
</div>
<!-- Right: Links -->
<div class="flex items-center gap-4 text-xs text-slate-400">
<a href="#" class="hover:text-slate-600 transition-colors">Privacy Policy</a>
<span class="text-slate-200">|</span>
<a href="#" class="hover:text-slate-600 transition-colors">Terms of Use</a>
<span class="text-slate-200">|</span>
<a href="mailto:info@rosettaeducation.com" class="hover:text-slate-600 transition-colors">Contact</a>
</div>
</div>
</footer>
+30
View File
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
<!-- Scripts -->
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="font-sans text-gray-900 antialiased">
<div class="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 bg-gray-100">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 fill-current text-gray-500" />
</a>
</div>
<div class="w-full sm:max-w-md mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
{{ $slot }}
</div>
</div>
</body>
</html>
+63
View File
@@ -0,0 +1,63 @@
<!-- HEADER -->
<header class="bg-slate-900 border-b border-slate-800 sticky top-0 z-30">
<div class="max-w-7xl mx-auto px-6 h-14 flex items-center justify-between">
<!-- LEFT: Logo + Brand -->
<div class="flex items-center gap-3">
<div class="w-7 h-7 rounded-lg bg-indigo-500 flex items-center justify-center shrink-0">
<!-- Graduation cap icon -->
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 10v6M2 10l10-5 10 5-10 5z"/><path d="M6 12v5c0 1.657 2.686 3 6 3s6-1.343 6-3v-5"/>
</svg>
</div>
<div class="leading-tight">
<span class="font-bold text-white text-sm tracking-tight">Rosetta International Education</span>
</div>
<span class="text-slate-600 text-xs font-medium hidden sm:block">/ Admin</span>
</div>
<!-- RIGHT: Profile Dropdown -->
<div class="relative dropdown" tabindex="0">
<button class="flex items-center gap-2.5 px-3 py-1.5 rounded-lg hover:bg-slate-800 transition-colors focus:outline-none group">
<div class="w-7 h-7 rounded-full bg-indigo-500 flex items-center justify-center text-white text-xs font-bold">
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
</div>
<span class="text-slate-300 text-xs font-medium hidden sm:block">{{ auth()->user()->name }}</span>
<!-- Chevron -->
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="transition-transform group-focus:rotate-180">
<polyline points="6 9 12 15 18 9"/>
</svg>
</button>
<!-- Dropdown Menu -->
<div class="dropdown-menu hidden absolute right-0 mt-1.5 w-52 bg-white rounded-xl shadow-xl border border-slate-200 py-1.5 z-50">
<!-- User info -->
<div class="px-4 py-2.5 border-b border-slate-100 mb-1">
<p class="text-xs font-semibold text-slate-800">{{ auth()->user()->name }}</p>
<p class="text-xs text-slate-400 mt-0.5">{{ auth()->user()->email }}</p>
</div>
<a href="{{ route('profile.edit') }}"
class="flex items-center gap-2.5 px-4 py-2 text-sm text-slate-600 hover:bg-slate-50 hover:text-slate-900 transition-colors">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg>
Edit Profile
</a>
<div class="border-t border-slate-100 mt-1 pt-1">
<form method="POST" action="{{ route('logout') }}">
@csrf
<button class="w-full flex items-center gap-2.5 px-4 py-2 text-sm text-red-500 hover:bg-red-50 transition-colors">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/>
</svg>
Logout
</button>
</form>
</div>
</div>
</div>
</div>
</header>
+58
View File
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Admin Dashboard Rosetta International Education</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
}
.dropdown:focus-within .dropdown-menu {
display: block;
}
</style>
@stack('css')
</head>
<body class="bg-slate-50 min-h-screen flex flex-col">
@include('layouts.header')
<main class="flex-1">
@yield('content')
</main>
@include('layouts.footer')
<!-- Dropdown + Scoreboard JS -->
<!-- Replace your dropdown JS with jQuery version -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function () {
// Toggle dropdown
$('.dropdown > button').on('click', function (e) {
e.stopPropagation();
$(this).next('.dropdown-menu').toggleClass('hidden');
});
// Close all dropdowns when clicking outside
$(document).on('click', function () {
$('.dropdown-menu').addClass('hidden');
});
});
</script>
@stack('js')
</body>
</html>
@@ -0,0 +1,100 @@
<nav x-data="{ open: false }" class="bg-white border-b border-gray-100">
<!-- Primary Navigation Menu -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<!-- Logo -->
<div class="shrink-0 flex items-center">
<a href="{{ route('dashboard') }}">
<x-application-logo class="block h-9 w-auto fill-current text-gray-800" />
</a>
</div>
<!-- Navigation Links -->
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
<x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-nav-link>
</div>
</div>
<!-- Settings Dropdown -->
<div class="hidden sm:flex sm:items-center sm:ms-6">
<x-dropdown align="right" width="48">
<x-slot name="trigger">
<button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
<div>{{ Auth::user()->name }}</div>
<div class="ms-1">
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</div>
</button>
</x-slot>
<x-slot name="content">
<x-dropdown-link :href="route('profile.edit')">
{{ __('Profile') }}
</x-dropdown-link>
<!-- Authentication -->
<form method="POST" action="{{ route('logout') }}">
@csrf
<x-dropdown-link :href="route('logout')"
onclick="event.preventDefault();
this.closest('form').submit();">
{{ __('Log Out') }}
</x-dropdown-link>
</form>
</x-slot>
</x-dropdown>
</div>
<!-- Hamburger -->
<div class="-me-2 flex items-center sm:hidden">
<button @click="open = ! open" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
<path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
</div>
<!-- Responsive Navigation Menu -->
<div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden">
<div class="pt-2 pb-3 space-y-1">
<x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('Dashboard') }}
</x-responsive-nav-link>
</div>
<!-- Responsive Settings Options -->
<div class="pt-4 pb-1 border-t border-gray-200">
<div class="px-4">
<div class="font-medium text-base text-gray-800">{{ Auth::user()->name }}</div>
<div class="font-medium text-sm text-gray-500">{{ Auth::user()->email }}</div>
</div>
<div class="mt-3 space-y-1">
<x-responsive-nav-link :href="route('profile.edit')">
{{ __('Profile') }}
</x-responsive-nav-link>
<!-- Authentication -->
<form method="POST" action="{{ route('logout') }}">
@csrf
<x-responsive-nav-link :href="route('logout')"
onclick="event.preventDefault();
this.closest('form').submit();">
{{ __('Log Out') }}
</x-responsive-nav-link>
</form>
</div>
</div>
</div>
</nav>
+161
View File
@@ -0,0 +1,161 @@
@extends('layouts.master')
@section('content')
<div class="max-w-3xl mx-auto px-6 py-8">
<!-- Header -->
<div class="flex items-center justify-between mb-8">
<div>
<h1 class="text-slate-900 text-xl font-bold tracking-tight">Leaderboard</h1>
<p class="text-slate-500 text-sm mt-0.5">All-time cumulative scores &middot; {{ $total }} students</p>
</div>
<a href="{{ route('home') }}"
class="flex items-center gap-2 bg-white hover:bg-slate-50 border border-slate-200 text-slate-600 text-sm font-medium px-4 py-2 rounded-lg transition-colors shadow-sm">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/>
</svg>
Dashboard
</a>
</div>
<!-- ── TOP 3 PODIUM ── -->
@if($students->count() >= 3)
<div class="relative mb-8">
<!-- Background glow -->
<div class="absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-indigo-50 to-transparent rounded-2xl pointer-events-none"></div>
<div class="relative grid grid-cols-3 gap-3 items-end px-4 pt-6">
{{-- 2nd place --}}
<div class="flex flex-col items-center">
<div class="relative mb-3">
<div class="w-14 h-14 rounded-full bg-white border-4 border-slate-300 shadow-md flex items-center justify-center font-black text-slate-600 text-xl">
{{ strtoupper(substr($students[1]->name, 0, 1)) }}
</div>
<span class="absolute -bottom-1 -right-1 text-lg leading-none">🥈</span>
</div>
<p class="text-xs font-bold text-slate-700 text-center leading-tight mb-3 truncate w-full text-center">{{ explode(' ', $students[1]->name)[0] }}</p>
<div class="w-full bg-slate-200 border border-slate-300 rounded-t-2xl h-28 flex flex-col items-center justify-center gap-1 shadow-inner">
<span class="text-2xl font-black text-slate-700">{{ $students[1]->total_score }}</span>
<span class="text-xs text-slate-500 font-semibold uppercase tracking-wide">pts</span>
</div>
</div>
{{-- 1st place --}}
<div class="flex flex-col items-center -mt-4">
<!-- Crown -->
<div class="text-2xl mb-1">👑</div>
<div class="relative mb-3">
<div class="w-18 h-18 w-[4.5rem] h-[4.5rem] rounded-full bg-gradient-to-br from-yellow-300 to-amber-400 border-4 border-yellow-400 shadow-lg shadow-yellow-200 flex items-center justify-center font-black text-white text-2xl">
{{ strtoupper(substr($students[0]->name, 0, 1)) }}
</div>
<div class="absolute inset-0 rounded-full bg-yellow-400/20 animate-ping"></div>
</div>
<p class="text-xs font-bold text-slate-800 text-center leading-tight mb-3 truncate w-full text-center">{{ explode(' ', $students[0]->name)[0] }}</p>
<div class="w-full bg-gradient-to-b from-yellow-400 to-amber-500 rounded-t-2xl h-40 flex flex-col items-center justify-center gap-1 shadow-lg shadow-amber-200">
<span class="text-3xl font-black text-white drop-shadow">{{ $students[0]->total_score }}</span>
<span class="text-xs text-yellow-100 font-bold uppercase tracking-wide">pts</span>
</div>
</div>
{{-- 3rd place --}}
<div class="flex flex-col items-center">
<div class="relative mb-3">
<div class="w-14 h-14 rounded-full bg-white border-4 border-orange-300 shadow-md flex items-center justify-center font-black text-orange-500 text-xl">
{{ strtoupper(substr($students[2]->name, 0, 1)) }}
</div>
<span class="absolute -bottom-1 -right-1 text-lg leading-none">🥉</span>
</div>
<p class="text-xs font-bold text-slate-700 text-center leading-tight mb-3 truncate w-full text-center">{{ explode(' ', $students[2]->name)[0] }}</p>
<div class="w-full bg-gradient-to-b from-orange-200 to-orange-300 border border-orange-300 rounded-t-2xl h-20 flex flex-col items-center justify-center gap-1 shadow-inner">
<span class="text-2xl font-black text-orange-700">{{ $students[2]->total_score }}</span>
<span class="text-xs text-orange-500 font-semibold uppercase tracking-wide">pts</span>
</div>
</div>
</div>
</div>
@endif
<!-- ── FULL RANKINGS ── -->
<div class="bg-white rounded-2xl border border-slate-200 overflow-hidden shadow-sm">
<div class="px-5 py-3.5 border-b border-slate-100 flex items-center justify-between">
<div class="flex items-center gap-2 text-slate-700 font-semibold text-sm">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/>
</svg>
All Rankings
</div>
<span class="text-xs text-slate-400 bg-slate-100 px-2 py-0.5 rounded-full font-medium">{{ $total }} students</span>
</div>
<div class="divide-y divide-slate-100">
@foreach($students as $i => $s)
@php $rank = $i + 1; @endphp
<div class="px-5 py-3.5 flex items-center gap-4
{{ $rank === 1 ? 'bg-amber-50/60' : 'hover:bg-slate-50/60' }} transition-colors">
<!-- Rank badge -->
<div class="w-8 shrink-0 flex justify-center">
@if($rank === 1)
<span class="text-xl">🥇</span>
@elseif($rank === 2)
<span class="text-xl">🥈</span>
@elseif($rank === 3)
<span class="text-xl">🥉</span>
@else
<span class="w-6 h-6 rounded-full bg-slate-100 flex items-center justify-center text-xs font-bold text-slate-500">{{ $rank }}</span>
@endif
</div>
<!-- Avatar -->
<div class="w-9 h-9 rounded-full flex items-center justify-center shrink-0 font-bold text-sm
{{ $rank === 1 ? 'bg-amber-100 text-amber-600 ring-2 ring-amber-300' : 'bg-indigo-100 text-indigo-600' }}">
{{ strtoupper(substr($s->name, 0, 1)) }}
</div>
<!-- Name + meta -->
<div class="flex-1 min-w-0">
<p class="font-semibold text-slate-800 text-sm truncate {{ $rank === 1 ? 'text-amber-800' : '' }}">
{{ $s->name }}
</p>
<p class="text-xs text-slate-400 mt-0.5">
{{ $s->sessions_count }} session{{ $s->sessions_count !== 1 ? 's' : '' }}
&middot; {{ $s->phone }}
</p>
</div>
<!-- Progress bar -->
<div class="w-28 hidden sm:block">
<div class="h-1.5 bg-slate-100 rounded-full overflow-hidden">
<div class="h-full rounded-full transition-all duration-500
{{ $rank === 1 ? 'bg-gradient-to-r from-amber-400 to-yellow-500' : 'bg-gradient-to-r from-indigo-400 to-indigo-500' }}"
style="width: {{ $maxScore > 0 ? round(($s->total_score / $maxScore) * 100) : 0 }}%">
</div>
</div>
</div>
<!-- Score -->
<div class="flex items-baseline gap-1 shrink-0">
<svg width="12" height="12" viewBox="0 0 24 24" fill="{{ $rank === 1 ? '#f59e0b' : '#6366f1' }}" stroke="none">
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>
</svg>
<span class="font-black text-slate-900 text-base">{{ $s->total_score }}</span>
<span class="text-xs text-slate-400 font-medium">pts</span>
</div>
</div>
@endforeach
</div>
@if($students instanceof \Illuminate\Pagination\LengthAwarePaginator && $students->hasPages())
<div class="px-5 py-3 border-t border-slate-100">
{{ $students->links() }}
</div>
@endif
</div>
</div>
@endsection
+29
View File
@@ -0,0 +1,29 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Profile') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
<div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
<div class="max-w-xl">
@include('profile.partials.update-profile-information-form')
</div>
</div>
<div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
<div class="max-w-xl">
@include('profile.partials.update-password-form')
</div>
</div>
<div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
<div class="max-w-xl">
@include('profile.partials.delete-user-form')
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,55 @@
<section class="space-y-6">
<header>
<h2 class="text-lg font-medium text-gray-900">
{{ __('Delete Account') }}
</h2>
<p class="mt-1 text-sm text-gray-600">
{{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.') }}
</p>
</header>
<x-danger-button
x-data=""
x-on:click.prevent="$dispatch('open-modal', 'confirm-user-deletion')"
>{{ __('Delete Account') }}</x-danger-button>
<x-modal name="confirm-user-deletion" :show="$errors->userDeletion->isNotEmpty()" focusable>
<form method="post" action="{{ route('profile.destroy') }}" class="p-6">
@csrf
@method('delete')
<h2 class="text-lg font-medium text-gray-900">
{{ __('Are you sure you want to delete your account?') }}
</h2>
<p class="mt-1 text-sm text-gray-600">
{{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.') }}
</p>
<div class="mt-6">
<x-input-label for="password" value="{{ __('Password') }}" class="sr-only" />
<x-text-input
id="password"
name="password"
type="password"
class="mt-1 block w-3/4"
placeholder="{{ __('Password') }}"
/>
<x-input-error :messages="$errors->userDeletion->get('password')" class="mt-2" />
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button x-on:click="$dispatch('close')">
{{ __('Cancel') }}
</x-secondary-button>
<x-danger-button class="ms-3">
{{ __('Delete Account') }}
</x-danger-button>
</div>
</form>
</x-modal>
</section>
@@ -0,0 +1,48 @@
<section>
<header>
<h2 class="text-lg font-medium text-gray-900">
{{ __('Update Password') }}
</h2>
<p class="mt-1 text-sm text-gray-600">
{{ __('Ensure your account is using a long, random password to stay secure.') }}
</p>
</header>
<form method="post" action="{{ route('password.update') }}" class="mt-6 space-y-6">
@csrf
@method('put')
<div>
<x-input-label for="update_password_current_password" :value="__('Current Password')" />
<x-text-input id="update_password_current_password" name="current_password" type="password" class="mt-1 block w-full" autocomplete="current-password" />
<x-input-error :messages="$errors->updatePassword->get('current_password')" class="mt-2" />
</div>
<div>
<x-input-label for="update_password_password" :value="__('New Password')" />
<x-text-input id="update_password_password" name="password" type="password" class="mt-1 block w-full" autocomplete="new-password" />
<x-input-error :messages="$errors->updatePassword->get('password')" class="mt-2" />
</div>
<div>
<x-input-label for="update_password_password_confirmation" :value="__('Confirm Password')" />
<x-text-input id="update_password_password_confirmation" name="password_confirmation" type="password" class="mt-1 block w-full" autocomplete="new-password" />
<x-input-error :messages="$errors->updatePassword->get('password_confirmation')" class="mt-2" />
</div>
<div class="flex items-center gap-4">
<x-primary-button>{{ __('Save') }}</x-primary-button>
@if (session('status') === 'password-updated')
<p
x-data="{ show: true }"
x-show="show"
x-transition
x-init="setTimeout(() => show = false, 2000)"
class="text-sm text-gray-600"
>{{ __('Saved.') }}</p>
@endif
</div>
</form>
</section>
@@ -0,0 +1,64 @@
<section>
<header>
<h2 class="text-lg font-medium text-gray-900">
{{ __('Profile Information') }}
</h2>
<p class="mt-1 text-sm text-gray-600">
{{ __("Update your account's profile information and email address.") }}
</p>
</header>
<form id="send-verification" method="post" action="{{ route('verification.send') }}">
@csrf
</form>
<form method="post" action="{{ route('profile.update') }}" class="mt-6 space-y-6">
@csrf
@method('patch')
<div>
<x-input-label for="name" :value="__('Name')" />
<x-text-input id="name" name="name" type="text" class="mt-1 block w-full" :value="old('name', $user->name)" required autofocus autocomplete="name" />
<x-input-error class="mt-2" :messages="$errors->get('name')" />
</div>
<div>
<x-input-label for="email" :value="__('Email')" />
<x-text-input id="email" name="email" type="email" class="mt-1 block w-full" :value="old('email', $user->email)" required autocomplete="username" />
<x-input-error class="mt-2" :messages="$errors->get('email')" />
@if ($user instanceof \Illuminate\Contracts\Auth\MustVerifyEmail && ! $user->hasVerifiedEmail())
<div>
<p class="text-sm mt-2 text-gray-800">
{{ __('Your email address is unverified.') }}
<button form="send-verification" class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
{{ __('Click here to re-send the verification email.') }}
</button>
</p>
@if (session('status') === 'verification-link-sent')
<p class="mt-2 font-medium text-sm text-green-600">
{{ __('A new verification link has been sent to your email address.') }}
</p>
@endif
</div>
@endif
</div>
<div class="flex items-center gap-4">
<x-primary-button>{{ __('Save') }}</x-primary-button>
@if (session('status') === 'profile-updated')
<p
x-data="{ show: true }"
x-show="show"
x-transition
x-init="setTimeout(() => show = false, 2000)"
class="text-sm text-gray-600"
>{{ __('Saved.') }}</p>
@endif
</div>
</form>
</section>
+79
View File
@@ -0,0 +1,79 @@
@extends('layouts.master')
@section('content')
<div class="max-w-7xl mx-auto px-6 py-8">
<!-- HEADER -->
<div class="flex items-center justify-between mb-7">
<div>
<h1 class="text-slate-900 text-xl font-bold">All Registrations</h1>
<p class="text-slate-500 text-sm mt-0.5">Complete list of registered users</p>
</div>
</div>
<!-- TABLE -->
<div class="bg-white border rounded-xl overflow-hidden">
<table class="w-full text-sm">
<thead class="bg-slate-50 border-b">
<tr>
<th class="px-5 py-3 text-left">ID</th>
<th class="px-5 py-3 text-left">Name</th>
<th class="px-5 py-3 text-left">Phone</th>
<th class="px-5 py-3 text-left">Email</th>
<th class="px-5 py-3 text-center">Total Score</th>
<th class="px-5 py-3 text-center">Created</th>
</tr>
</thead>
<tbody>
@foreach ($registrations as $reg)
<tr class="border-b hover:bg-slate-50">
<td class="px-5 py-3">#{{ $reg->id }}</td>
<td class="px-5 py-3 font-medium">
{{ $reg->name ?? '-' }}
</td>
<td class="px-5 py-3">
{{ $reg->phone }}
</td>
<td class="px-5 py-3">
{{ $reg->email ?? '-' }}
</td>
<td class="px-5 py-3 text-center font-bold">
{{ $reg->total_score }}
</td>
<td class="px-5 py-3 text-center text-slate-500">
{{ $reg->created_at->format('Y-m-d') }}
</td>
</tr>
@endforeach
</tbody>
</table>
<!-- PAGINATION -->
<div class="px-5 py-3 border-t flex justify-between items-center">
<div class="text-xs text-slate-500">
Showing {{ $registrations->firstItem() }} - {{ $registrations->lastItem() }}
of {{ $registrations->total() }}
</div>
<div>
{{ $registrations->links() }}
</div>
</div>
</div>
</div>
@endsection
+289
View File
@@ -0,0 +1,289 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rosetta Education - Score & Win</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
--cyan:#02aeef; --blue:#0647c9; --green:#06c70d; --red:#ef150f;
}
html, body { width:100vw; height:100vh; overflow:hidden; font-family:Impact,Haettenschweiler,'Arial Narrow Bold',Arial,sans-serif; color:#fff; background:#020814; }
.screen {
position:relative; width:100vw; height:100vh;
display:flex; flex-direction:column;
padding:1.2vh 3.5vw 1vh; gap:0.8vh;
background:
linear-gradient(180deg,rgba(0,8,25,.3) 0%,rgba(0,15,35,.2) 46%,rgba(0,12,24,.5) 100%),
url('assets/stadium-bg.png') center center/cover no-repeat;
}
.screen::before {
content:""; position:absolute; inset:0;
background:radial-gradient(circle at 50% 34%,rgba(0,174,239,.12),transparent 30%),
linear-gradient(90deg,rgba(0,0,0,.45),transparent 20%,transparent 80%,rgba(0,0,0,.45));
pointer-events:none; z-index:0;
}
.topbar,.player-panel,.score-row,.bottom-row,.footer { position:relative; z-index:1; }
/* TOPBAR */
.topbar { display:grid; grid-template-columns:22vw 1fr 22vw; align-items:center; gap:1.5vw; flex-shrink:0; }
.logo-wrap img { width:20vw; max-width:360px; filter:drop-shadow(0 4px 8px rgba(0,0,0,.7)); }
.title-badge { justify-self:center; text-align:center; padding:.7vh 2vw .9vh; transform:skew(-10deg); background:linear-gradient(180deg,rgba(0,34,73,.85),rgba(0,9,25,.9)); border:1px solid rgba(0,174,239,.4); box-shadow:0 0 18px rgba(0,174,239,.25),inset 0 0 16px rgba(0,174,239,.1); }
.title-badge .title { transform:skew(10deg); font-size:clamp(28px,3.6vw,58px); line-height:.95; letter-spacing:2px; text-shadow:0 4px 0 rgba(0,0,0,.5),0 0 12px rgba(0,174,239,.5); }
.title-badge .title span { color:var(--cyan); }
.title-badge .sub { transform:skew(10deg); display:inline-block; margin-top:.3vh; padding:.2vh 1.5vw; font-size:clamp(11px,1.3vw,20px); letter-spacing:1px; background:linear-gradient(180deg,#147aff,#0643bd); border:1px solid #029bff; box-shadow:0 0 10px rgba(0,168,255,.5); }
.passion { justify-self:end; padding:.9vh 1.4vw; display:flex; align-items:center; gap:.7vw; border:1.5px solid var(--cyan); border-radius:11px; background:rgba(3,18,39,.8); box-shadow:0 0 16px rgba(0,174,239,.5),inset 0 0 16px rgba(0,174,239,.12); font-family:Arial,sans-serif; font-weight:900; text-transform:uppercase; font-size:clamp(10px,1.25vw,18px); line-height:1.3; text-shadow:0 2px 4px #000; }
.passion .cup { font-size:clamp(16px,2vw,30px); }
.passion span { color:var(--cyan); }
/* PLAYER PANEL */
.player-panel { width:50vw; margin:0 auto; flex-shrink:0; text-align:center; padding:.7vh 2vw 1vh; background:rgba(3,15,34,.82); border:1.5px solid rgba(0,174,239,.36); border-radius:24px 24px 12px 12px; clip-path:polygon(6% 0,94% 0,100% 50%,94% 100%,6% 100%,0 50%); box-shadow:0 0 22px rgba(0,174,239,.25),inset 0 0 20px rgba(0,174,239,.08); }
.player-panel .label { font-family:Arial,sans-serif; color:var(--cyan); font-size:clamp(10px,1.3vw,18px); font-weight:900; letter-spacing:1px; text-transform:uppercase; }
.player-panel .name { font-size:clamp(28px,3.8vw,60px); letter-spacing:.5vw; margin-top:.2vh; text-shadow:0 4px 8px rgba(0,0,0,.8),0 0 8px rgba(255,255,255,.2); transition:opacity .3s; }
/* SCORE ROW */
.score-row { display:grid; grid-template-columns:1.1fr 1fr 1fr 1fr; gap:1vw; width:88vw; margin:0 auto; flex-shrink:0; }
.card { border:1.5px solid var(--cyan); border-radius:11px; background:linear-gradient(180deg,rgba(2,23,52,.9),rgba(0,10,24,.85)); box-shadow:0 0 12px rgba(0,174,239,.55),inset 0 0 22px rgba(0,174,239,.1); padding:.7vh .8vw; text-align:center; overflow:hidden; position:relative; display:flex; flex-direction:column; align-items:center; justify-content:space-evenly; }
.card::before { content:""; position:absolute; inset:0; background:linear-gradient(135deg,rgba(255,255,255,.08),transparent 25%,transparent 70%,rgba(0,174,239,.07)); pointer-events:none; }
.card-title { position:relative; z-index:1; width:100%; padding:.35vh .4vw; border:1px solid #009dff; border-radius:5px; background:linear-gradient(180deg,#0c7cff,#063cae); font-family:Arial,sans-serif; font-weight:900; font-size:clamp(10px,1.25vw,18px); text-transform:uppercase; }
.total-number { position:relative; z-index:1; font-size:clamp(48px,6.5vw,110px); line-height:1; text-shadow:0 6px 0 rgba(0,0,0,.5); transition:all .4s; }
.points { position:relative; z-index:1; color:var(--cyan); font-family:Arial,sans-serif; font-weight:900; font-size:clamp(10px,1.3vw,18px); letter-spacing:1px; }
.stars { color:var(--cyan); padding:0 .4vw; }
.shot-icon { position:relative; z-index:1; font-size:clamp(28px,3.8vw,58px); transition:all .3s; }
.shot-icon.miss { color:var(--red); filter:drop-shadow(0 0 12px rgba(255,0,0,.7)); text-shadow:0 0 14px #ff4a43; }
.shot-icon.goal { filter:drop-shadow(0 0 15px rgba(0,255,70,.5)); }
.shot-icon.pending { opacity:.3; }
.result { position:relative; z-index:1; width:82%; padding:.35vh 0; border-radius:6px; font-family:Arial,sans-serif; font-size:clamp(12px,1.7vw,24px); font-weight:900; text-transform:uppercase; box-shadow:inset 0 0 10px rgba(255,255,255,.15); transition:all .3s; }
.goal-badge { background:linear-gradient(180deg,#0ddc12,#047706); border:1px solid #2aff38; }
.miss-badge { background:linear-gradient(180deg,#ff2b21,#8c0806); border:1px solid #ff4b43; }
.pending-badge { background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.15); color:rgba(255,255,255,.4); }
.shot-points { position:relative; z-index:1; font-family:Arial,sans-serif; color:var(--cyan); font-size:clamp(10px,1.2vw,16px); font-weight:900; }
/* BOTTOM ROW */
.bottom-row { display:grid; grid-template-columns:1.25fr .85fr; gap:2.5vw; width:88vw; margin:0 auto; flex:1; min-height:0; padding-bottom:.5vh; }
.leaderboard,.next-box { background:rgba(1,17,35,.85); border:1.5px solid var(--cyan); border-radius:12px; box-shadow:0 0 14px rgba(0,174,239,.5),inset 0 0 22px rgba(0,174,239,.07); overflow:hidden; display:flex; flex-direction:column; }
.section-title { flex-shrink:0; width:62%; margin:0 auto .6vh; padding:.5vh 1vw; text-align:center; transform:skew(-15deg); background:linear-gradient(180deg,#0b77f2,#043894); border:1px solid #009dff; box-shadow:0 0 13px rgba(0,168,255,.5); font-family:Arial,sans-serif; font-size:clamp(10px,1.25vw,17px); font-weight:900; text-transform:uppercase; }
.section-title span { display:block; transform:skew(15deg); }
.leaderboard { padding:.8vh 1.4vw; }
.ranks-wrap { flex:1; min-height:0; display:flex; flex-direction:column; justify-content:space-evenly; }
.rank { display:grid; grid-template-columns:3vw 1fr 13vw 3.8vw 2.5vw; align-items:center; gap:.6vw; padding:.3vh 0; border-bottom:1px solid rgba(0,174,239,.15); font-family:Arial,sans-serif; transition:all .3s; }
.rank:last-child { border-bottom:none; }
.rank.active-player { background:rgba(0,174,239,.1); border-radius:6px; padding-left:.4vw; }
.medal { font-size:clamp(12px,1.6vw,22px); text-align:center; }
.rank-num { width:1.9vw; height:1.9vw; border-radius:4px; display:grid; place-items:center; background:linear-gradient(180deg,#197cff,#06398e); border:1px solid #00aeef; font-size:clamp(9px,1.1vw,15px); font-weight:900; }
.rname { font-size:clamp(10px,1.2vw,17px); font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar { height:1.2vh; border-radius:99px; background:rgba(0,0,0,.5); overflow:hidden; }
.bar i { display:block; height:100%; background:linear-gradient(90deg,#0566e9,#0ab4ff,#0640c3); transition:width .5s ease; }
.rscore { color:var(--cyan); font-size:clamp(14px,1.9vw,26px); font-weight:900; text-align:right; }
.pts { font-size:clamp(8px,.9vw,13px); font-family:Arial,sans-serif; }
.next-box { text-align:center; cursor:default; justify-content:center; align-items:center; gap:1vh; padding:1.5vh 0; border:none; background:rgba(1,17,35,.85); border:1.5px solid var(--cyan); }
.next-ball { width:9.5vw; height:9.5vw; border-radius:50%; display:grid; place-items:center; font-size:clamp(32px,5.5vw,80px); background:radial-gradient(circle,rgba(0,174,239,.3),transparent 62%); box-shadow:0 0 24px rgba(0,174,239,.55); }
.waiting-text { font-family:Arial,sans-serif; font-size:clamp(11px,1.4vw,20px); font-weight:900; text-transform:uppercase; letter-spacing:.5px; color:var(--cyan); }
.footer { flex-shrink:0; width:50vw; margin:0 auto; padding:.65vh 2vw; display:flex; justify-content:center; gap:3vw; background:rgba(1,17,35,.82); border:1px solid rgba(0,174,239,.5); border-radius:12px 12px 0 0; font-family:Arial,sans-serif; font-size:clamp(9px,1vw,14px); font-weight:900; text-transform:uppercase; }
.footer span:first-child { color:var(--cyan); }
/* pulse on score update */
@keyframes scorePop { 0%{transform:scale(1)} 50%{transform:scale(1.2)} 100%{transform:scale(1)} }
.score-pop { animation:scorePop .35s ease; }
</style>
</head>
<body>
<main class="screen">
<header class="topbar">
<div class="logo-wrap"><img src="assets/rosetta-logo.png" alt="Rosetta Education International" /></div>
<div class="title-badge">
<div class="title">SC⚽RE <span>&amp; WIN</span></div>
<div class="sub">CHALLENGE 2025</div>
</div>
<div class="passion">
<div class="cup">🏆</div>
<div>Play with <span>Passion</span>,<br/>Win with <span>Pride!</span></div>
</div>
</header>
<section class="player-panel">
<div class="label"> &nbsp; Player Now Playing &nbsp; </div>
<div class="name" id="playerName">Waiting for player…</div>
</section>
<section class="score-row">
<div class="card total-card">
<div class="card-title">Total Score</div>
<div class="total-number" id="totalScore"></div>
<div class="points"><span class="stars"></span>POINTS<span class="stars"></span></div>
</div>
<div class="card shot-card" id="shotCard1">
<div class="card-title">Shot 1</div>
<div class="shot-icon pending" id="shotIcon1"></div>
<div class="result pending-badge" id="shotResult1"></div>
<div class="shot-points" id="shotPts1">0 PTS</div>
</div>
<div class="card shot-card" id="shotCard2">
<div class="card-title">Shot 2</div>
<div class="shot-icon pending" id="shotIcon2"></div>
<div class="result pending-badge" id="shotResult2"></div>
<div class="shot-points" id="shotPts2">0 PTS</div>
</div>
<div class="card shot-card" id="shotCard3">
<div class="card-title">Shot 3</div>
<div class="shot-icon pending" id="shotIcon3"></div>
<div class="result pending-badge" id="shotResult3"></div>
<div class="shot-points" id="shotPts3">0 PTS</div>
</div>
</section>
<section class="bottom-row">
<div class="leaderboard">
<div class="section-title"><span>Top 5 Leaderboard</span></div>
<div class="ranks-wrap" id="leaderboardRows">
<!-- filled by JS -->
</div>
</div>
<div class="next-box">
<div class="section-title"><span>Now Playing</span></div>
<div class="next-ball"></div>
<div class="waiting-text" id="waitingText">Select a player</div>
</div>
</section>
<footer class="footer">
<span> Event In Progress</span>
<span>|</span>
<span>👥 Cheer. Support. Inspire.</span>
</footer>
</main>
<script>
const POLL_URL = "{{ route('scoreboard.state') }}";
const MEDALS = ['🏆','🥈','🥉'];
let lastPlayerId = null;
let lastShots = [];
let lastTotal = null;
let lastLeaderStr = '';
function renderShot(index, result) {
// index 0-based
const n = index + 1;
const icon = document.getElementById('shotIcon' + n);
const res = document.getElementById('shotResult' + n);
const pts = document.getElementById('shotPts' + n);
if (result === true) {
icon.className = 'shot-icon goal';
icon.textContent = '⚽';
res.className = 'result goal-badge';
res.textContent = 'Goal';
pts.textContent = '+1 PT';
} else if (result === false) {
icon.className = 'shot-icon miss';
icon.textContent = '✕';
res.className = 'result miss-badge';
res.textContent = 'Miss';
pts.textContent = '0 PTS';
} else {
icon.className = 'shot-icon pending';
icon.textContent = '⚽';
res.className = 'result pending-badge';
res.textContent = '—';
pts.textContent = '0 PTS';
}
}
function resetShots() {
for (let i = 0; i < 3; i++) renderShot(i, null);
}
function popScore(el) {
el.classList.remove('score-pop');
void el.offsetWidth; // reflow
el.classList.add('score-pop');
}
function renderLeaderboard(rows, activeId) {
const wrap = document.getElementById('leaderboardRows');
const maxScore = rows[0]?.total_score || 1;
wrap.innerHTML = rows.map((r, i) => {
const medal = i < 3 ? `<div class="medal">${MEDALS[i]}</div>` : `<div class="rank-num">${r.rank}</div>`;
const pct = Math.round((r.total_score / maxScore) * 100);
const active = r.id === activeId ? 'active-player' : '';
return `
<div class="rank ${active}">
${medal}
<div class="rname">${r.name}</div>
<div class="bar"><i style="width:${pct}%"></i></div>
<div class="rscore">${r.total_score}</div>
<div class="pts">PTS</div>
</div>`;
}).join('');
}
function poll() {
fetch(POLL_URL)
.then(r => r.json())
.then(data => {
// ── Leaderboard ──────────────────────────────
const lbStr = JSON.stringify(data.leaderboard);
if (lbStr !== lastLeaderStr) {
renderLeaderboard(data.leaderboard, data.player?.id);
lastLeaderStr = lbStr;
}
// ── Player ───────────────────────────────────
if (!data.player) {
if (lastPlayerId !== null) {
document.getElementById('playerName').textContent = 'Waiting for player…';
document.getElementById('totalScore').textContent = '—';
document.getElementById('waitingText').textContent = 'Select a player';
resetShots();
lastPlayerId = null;
lastShots = [];
lastTotal = null;
}
return;
}
const p = data.player;
// New player selected
if (p.id !== lastPlayerId) {
document.getElementById('playerName').textContent = p.name.toUpperCase();
document.getElementById('waitingText').textContent = p.name;
resetShots();
lastPlayerId = p.id;
lastShots = [];
lastTotal = null;
renderLeaderboard(data.leaderboard, p.id);
}
// Update total score
if (p.total_score !== lastTotal) {
const el = document.getElementById('totalScore');
el.textContent = p.total_score;
if (lastTotal !== null) popScore(el);
lastTotal = p.total_score;
}
// Update shots one by one
p.shots.forEach((result, i) => {
if (lastShots[i] === undefined) {
renderShot(i, result);
}
});
lastShots = [...p.shots];
})
.catch(() => {}); // silently ignore network errors
}
// Poll every 3 seconds
poll();
setInterval(poll, 3000);
</script>
</body>
</html>
File diff suppressed because one or more lines are too long