feature/profile-page #71
@@ -1,40 +1,149 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="profile-page">
|
<div class="profile-container">
|
||||||
<h1>My Profile</h1>
|
|
||||||
|
|
||||||
<!-- Loading State -->
|
<!-- Loading State -->
|
||||||
<div v-if="loading" class="loading">
|
<div v-if="loading" class="state-card loading-card">
|
||||||
|
<div class="spinner"></div>
|
||||||
<p>Loading your profile...</p>
|
<p>Loading your profile...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Error State -->
|
<!-- Error State -->
|
||||||
<div v-else-if="error" class="error">
|
<div v-else-if="error" class="state-card error-card">
|
||||||
<p>Error: {{ error }}</p>
|
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
<button @click="retry">Retry</button>
|
<circle cx="12" cy="12" r="10" stroke-width="2"/>
|
||||||
|
<line x1="12" y1="8" x2="12" y2="12" stroke-width="2"/>
|
||||||
|
<line x1="12" y1="16" x2="12.01" y2="16" stroke-width="2"/>
|
||||||
|
</svg>
|
||||||
|
<h3>Oops! Something went wrong</h3>
|
||||||
|
<p>{{ error }}</p>
|
||||||
|
<button @click="retry" class="retry-btn">
|
||||||
|
<svg class="btn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path d="M1 4v6h6M23 20v-6h-6" stroke-width="2"/>
|
||||||
|
<path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15" stroke-width="2"/>
|
||||||
|
</svg>
|
||||||
|
Try Again
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- User Data from Auth Store (preferred) -->
|
<!-- User Profile -->
|
||||||
<div v-else-if="authStore.currentUser" class="user-info">
|
<div v-else-if="authStore.currentUser" class="profile-card">
|
||||||
<div class="info-item">
|
<div class="profile-header">
|
||||||
<strong>Name:</strong> {{ authStore.currentUser.name }}
|
<div class="avatar-container">
|
||||||
|
<img
|
||||||
|
v-if="authStore.currentUser.photo_avatar_filename"
|
||||||
|
:src="`/storage/avatars/${authStore.currentUser.photo_avatar_filename}`"
|
||||||
|
:alt="authStore.currentUser.name"
|
||||||
|
class="avatar"
|
||||||
|
/>
|
||||||
|
<div v-else class="avatar-placeholder">
|
||||||
|
{{ authStore.currentUser.name.charAt(0).toUpperCase() }}
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item">
|
|
||||||
<strong>Email:</strong> {{ authStore.currentUser.email }}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item">
|
<div class="profile-info">
|
||||||
<strong>Nickname:</strong> {{ authStore.currentUser.nickname }}
|
<h1 class="profile-name">{{ authStore.currentUser.name }}</h1>
|
||||||
|
<p class="profile-nickname">@{{ authStore.currentUser.nickname }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="coins-badge">
|
||||||
|
<svg class="coin-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<circle cx="12" cy="12" r="10" stroke-width="1.5"/>
|
||||||
|
<text x="12" y="16" text-anchor="middle" fill="currentColor" font-size="12" font-weight="bold">$</text>
|
||||||
|
</svg>
|
||||||
|
<span>{{ authStore.currentUser.coins_balance }} coins</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="profile-body">
|
||||||
|
<div class="info-grid">
|
||||||
|
<div class="info-card">
|
||||||
|
<div class="info-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" stroke-width="1.5"/>
|
||||||
|
<polyline points="22,6 12,13 2,6" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="info-content">
|
||||||
|
<label>Email</label>
|
||||||
|
<p>{{ authStore.currentUser.email }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-card">
|
||||||
|
<div class="info-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" stroke-width="1.5"/>
|
||||||
|
<circle cx="12" cy="7" r="4" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="info-content">
|
||||||
|
<label>Account Type</label>
|
||||||
|
<p>{{ authStore.currentUser.type === 'P' ? 'Player' : 'Other' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-card">
|
||||||
|
<div class="info-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<rect x="3" y="4" width="18" height="18" rx="2" ry="2" stroke-width="1.5"/>
|
||||||
|
<line x1="16" y1="2" x2="16" y2="6" stroke-width="1.5"/>
|
||||||
|
<line x1="8" y1="2" x2="8" y2="6" stroke-width="1.5"/>
|
||||||
|
<line x1="3" y1="10" x2="21" y2="10" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="info-content">
|
||||||
|
<label>Member Since</label>
|
||||||
|
<p>{{ formatDate(authStore.currentUser.created_at) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-card">
|
||||||
|
<div class="info-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<circle cx="12" cy="12" r="10" stroke-width="1.5"/>
|
||||||
|
<path d="M9 12l2 2 4-4" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="info-content">
|
||||||
|
<label>Status</label>
|
||||||
|
<p>
|
||||||
|
<span :class="['status-badge', authStore.currentUser.blocked ? 'blocked' : 'active']">
|
||||||
|
{{ authStore.currentUser.blocked ? 'Blocked' : 'Active' }}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-card" v-if="authStore.currentUser.email_verified_at">
|
||||||
|
<div class="info-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" stroke-width="1.5"/>
|
||||||
|
<polyline points="22 4 12 14.01 9 11.01" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="info-content">
|
||||||
|
<label>Email Verified</label>
|
||||||
|
<p>{{ formatDate(authStore.currentUser.email_verified_at) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-card">
|
||||||
|
<div class="info-icon">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<polyline points="23 4 23 10 17 10" stroke-width="1.5"/>
|
||||||
|
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="info-content">
|
||||||
|
<label>Last Updated</label>
|
||||||
|
<p>{{ formatDate(authStore.currentUser.updated_at) }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item">
|
|
||||||
<strong>Coins Balance:</strong> {{ authStore.currentUser.coins_balance }}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item">
|
|
||||||
<strong>Joined:</strong> {{ formatDate(authStore.currentUser.created_at) }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- No Data State -->
|
<!-- No Data State -->
|
||||||
<div v-else class="no-data">
|
<div v-else class="state-card redirect-card">
|
||||||
<p> No user data or not logged in. Please log in to view your profile. </p>
|
<div class="spinner"></div>
|
||||||
|
<p>Redirecting to login...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -53,7 +162,12 @@ const loading = ref(false)
|
|||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
|
|
||||||
const formatDate = (dateString) => {
|
const formatDate = (dateString) => {
|
||||||
return new Date(dateString).toLocaleString()
|
const date = new Date(dateString)
|
||||||
|
return date.toLocaleDateString('en-US', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchProfile = async () => {
|
const fetchProfile = async () => {
|
||||||
@@ -94,71 +208,272 @@ onMounted(async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.profile-page {
|
.profile-container {
|
||||||
max-width: 600px;
|
min-height: 100vh;
|
||||||
margin: 2rem auto;
|
background: #fafafa;
|
||||||
|
padding: 2rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* State Cards */
|
||||||
|
.state-card {
|
||||||
|
background: white;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
padding: 3rem;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
max-width: 400px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-card, .redirect-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border: 3px solid #f0f0f0;
|
||||||
|
border-top: 3px solid #000;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card .icon {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
margin: 0 auto 1rem;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card h3 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-card p {
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
background: #000;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: background 0.2s;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-btn:hover {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-icon {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Profile Card */
|
||||||
|
.profile-card {
|
||||||
|
background: white;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
max-width: 900px;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-header {
|
||||||
|
background: #000;
|
||||||
|
padding: 3rem 2rem 2rem;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
color: white;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-container {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar, .avatar-placeholder {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
margin: 0 auto;
|
||||||
|
border: 3px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-placeholder {
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-name {
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0 0 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-nickname {
|
||||||
|
font-size: 1rem;
|
||||||
|
opacity: 0.8;
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coins-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
background: white;
|
||||||
|
color: #000;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 1rem;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.coin-icon {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Profile Body */
|
||||||
|
.profile-body {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
.info-grid {
|
||||||
margin-bottom: 2rem;
|
display: grid;
|
||||||
color: #333;
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||||
font-size: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-info {
|
|
||||||
background: #f5f5f5;
|
|
||||||
padding: 1.5rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
padding: 0.75rem 0;
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
display: flex;
|
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-item:last-child {
|
.info-card {
|
||||||
border-bottom: none;
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.25rem;
|
||||||
|
background: white;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
transition: box-shadow 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-item strong {
|
.info-card:hover {
|
||||||
min-width: 140px;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||||
color: #555;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading, .error, .no-data {
|
.info-icon {
|
||||||
text-align: center;
|
width: 40px;
|
||||||
padding: 2rem;
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.info-icon svg {
|
||||||
color: #d32f2f;
|
width: 20px;
|
||||||
background: #ffebee;
|
height: 20px;
|
||||||
padding: 1.5rem;
|
stroke-width: 1.5;
|
||||||
border-radius: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-data {
|
.info-content {
|
||||||
background: #fff3e0;
|
flex: 1;
|
||||||
padding: 1.5rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
.info-content label {
|
||||||
margin-top: 1rem;
|
display: block;
|
||||||
padding: 0.75rem 1.5rem;
|
font-size: 0.75rem;
|
||||||
background: #1976d2;
|
font-weight: 600;
|
||||||
color: white;
|
color: #999;
|
||||||
border: none;
|
margin-bottom: 0.25rem;
|
||||||
border-radius: 4px;
|
text-transform: uppercase;
|
||||||
cursor: pointer;
|
letter-spacing: 0.5px;
|
||||||
font-size: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
.info-content p {
|
||||||
background: #1565c0;
|
font-size: 0.95rem;
|
||||||
|
color: #000;
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
border: 1px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.active {
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
border-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.blocked {
|
||||||
|
background: #000;
|
||||||
|
color: #fff;
|
||||||
|
border-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.profile-container {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-header {
|
||||||
|
padding: 2rem 1rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-name {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar, .avatar-placeholder {
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user