admin_szolgáltatók_

This commit is contained in:
Roo
2026-07-01 02:27:38 +00:00
parent 189cbfd7ca
commit 6e627d0ebe
491 changed files with 20965 additions and 9703 deletions

View File

@@ -18,7 +18,7 @@
<!-- Error State -->
<div v-else-if="error" class="bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8">
<p class="text-rose-400">{{ t('gamification.point_rules.load_error') }}</p>
<p class="text-rose-400">{{ t('gamification.point_rules.error') }}</p>
<button @click="fetchRules" class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline">{{ t('gamification.point_rules.retry') }}</button>
</div>
@@ -29,7 +29,7 @@
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
{{ t('gamification.point_rules.create_btn') }}
{{ t('gamification.point_rules.create') }}
</button>
</div>
@@ -38,31 +38,117 @@
<table class="w-full">
<thead>
<tr class="border-b border-slate-700">
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.col_id') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.col_action_key') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.col_points') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.col_description') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.col_status') }}</th>
<th class="text-right px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.col_actions') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.id') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.action_key') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.points') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.description') }}</th>
<th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.status') }}</th>
<th class="text-right px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider">{{ t('gamification.point_rules.actions') }}</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-700/50">
<tr v-for="rule in rules" :key="rule.id" class="hover:bg-slate-700/30 transition">
<td class="px-6 py-4 text-sm text-slate-400">{{ rule.id }}</td>
<!-- Action Key (inline editable) -->
<td class="px-6 py-4">
<code class="text-sm font-mono text-amber-300 bg-amber-500/10 px-2 py-0.5 rounded">{{ rule.action_key }}</code>
<template v-if="isEditing(rule.id, 'action_key')">
<input
ref="inlineInputRef"
v-model="editValue"
type="text"
maxlength="100"
class="w-full px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50"
@keyup.enter="saveEdit(rule, 'action_key')"
@keyup.escape="cancelEdit()"
@blur="saveEdit(rule, 'action_key')"
@click.stop
/>
</template>
<template v-else>
<code
class="text-sm font-mono text-amber-300 bg-amber-500/10 px-2 py-0.5 rounded cursor-pointer hover:bg-amber-500/20 transition"
@click="startEdit(rule, 'action_key')"
>{{ rule.action_key }}</code>
</template>
</td>
<!-- Points (inline editable) -->
<td class="px-6 py-4">
<span class="text-sm font-semibold" :class="rule.points >= 0 ? 'text-emerald-400' : 'text-rose-400'">
{{ rule.points >= 0 ? '+' : '' }}{{ rule.points }}
</span>
<template v-if="isEditing(rule.id, 'points')">
<input
ref="inlineInputRef"
v-model.number="editValue"
type="number"
min="-10000"
max="10000"
class="w-24 px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50"
@keyup.enter="saveEdit(rule, 'points')"
@keyup.escape="cancelEdit()"
@blur="saveEdit(rule, 'points')"
@click.stop
/>
</template>
<template v-else>
<span
class="text-sm font-semibold cursor-pointer hover:opacity-80 transition"
:class="rule.points >= 0 ? 'text-emerald-400' : 'text-rose-400'"
@click="startEdit(rule, 'points')"
>
{{ rule.points >= 0 ? '+' : '' }}{{ rule.points }}
</span>
</template>
</td>
<td class="px-6 py-4 text-sm text-slate-300 max-w-xs truncate">{{ rule.description || '—' }}</td>
<!-- Description (inline editable) -->
<td class="px-6 py-4">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium" :class="rule.is_active ? 'bg-emerald-500/10 text-emerald-400' : 'bg-slate-500/10 text-slate-400'">
{{ rule.is_active ? t('gamification.point_rules.active') : t('gamification.point_rules.inactive') }}
</span>
<template v-if="isEditing(rule.id, 'description')">
<input
ref="inlineInputRef"
v-model="editValue"
type="text"
class="w-full px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50"
@keyup.enter="saveEdit(rule, 'description')"
@keyup.escape="cancelEdit()"
@blur="saveEdit(rule, 'description')"
@click.stop
/>
</template>
<template v-else>
<span
class="text-sm text-slate-300 max-w-xs truncate block cursor-pointer hover:text-white transition"
@click="startEdit(rule, 'description')"
>{{ rule.description || '—' }}</span>
</template>
</td>
<!-- Status (inline toggle) -->
<td class="px-6 py-4">
<template v-if="isEditing(rule.id, 'is_active')">
<div class="flex items-center gap-2" @click.stop>
<button
@click="editValue = true; saveEdit(rule, 'is_active')"
class="px-2 py-1 text-xs font-medium rounded transition"
:class="editValue ? 'bg-emerald-500/20 text-emerald-400 ring-1 ring-emerald-500/50' : 'bg-slate-700 text-slate-400 hover:bg-slate-600'"
>{{ t('gamification.point_rules.active') }}</button>
<button
@click="editValue = false; saveEdit(rule, 'is_active')"
class="px-2 py-1 text-xs font-medium rounded transition"
:class="!editValue ? 'bg-rose-500/20 text-rose-400 ring-1 ring-rose-500/50' : 'bg-slate-700 text-slate-400 hover:bg-slate-600'"
>{{ t('gamification.point_rules.inactive') }}</button>
</div>
</template>
<template v-else>
<span
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:ring-2 hover:ring-amber-500/50 transition"
:class="rule.is_active ? 'bg-emerald-500/10 text-emerald-400' : 'bg-slate-500/10 text-slate-400'"
@click="startEdit(rule, 'is_active')"
>
{{ rule.is_active ? t('gamification.point_rules.active') : t('gamification.point_rules.inactive') }}
</span>
</template>
</td>
<td class="px-6 py-4 text-right">
<div class="flex items-center justify-end gap-2">
<button @click="openEditModal(rule)" class="p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition" :title="t('gamification.point_rules.edit')">
@@ -80,7 +166,7 @@
</tr>
<tr v-if="rules.length === 0">
<td colspan="6" class="px-6 py-12 text-center text-sm text-slate-500">
{{ t('gamification.point_rules.empty') }}
{{ t('gamification.point_rules.no_items') }}
</td>
</tr>
</tbody>
@@ -140,7 +226,7 @@
id="is_active"
class="w-4 h-4 rounded bg-slate-700 border-slate-600 text-amber-500 focus:ring-amber-500/50"
/>
<label for="is_active" class="text-sm text-slate-300">{{ t('gamification.point_rules.active_label') }}</label>
<label for="is_active" class="text-sm text-slate-300">{{ t('gamification.point_rules.is_active') }}</label>
</div>
<!-- Error Message -->
@@ -165,9 +251,9 @@
<!-- Delete Confirmation Modal -->
<div v-if="showDeleteModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" @click.self="showDeleteModal = false">
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-md mx-4 shadow-2xl">
<h2 class="text-lg font-semibold text-white mb-2">{{ t('gamification.point_rules.delete_confirm_title') }}</h2>
<h2 class="text-lg font-semibold text-white mb-2">{{ t('gamification.point_rules.delete_title') }}</h2>
<p class="text-sm text-slate-400 mb-6">
{{ t('gamification.point_rules.delete_confirm_body', { action_key: deletingRule?.action_key }) }}
{{ t('gamification.point_rules.delete_confirm', { name: deletingRule?.action_key }) }}
</p>
<div class="flex justify-end gap-3">
<button @click="showDeleteModal = false" class="px-4 py-2 text-sm text-slate-400 hover:text-white transition">{{ t('gamification.point_rules.cancel') }}</button>
@@ -189,6 +275,8 @@
</template>
<script setup lang="ts">
import { nextTick, ref, reactive, onMounted } from 'vue'
definePageMeta({
middleware: 'auth',
})
@@ -203,6 +291,11 @@ interface PointRule {
is_active: boolean
}
interface EditingCell {
id: number
field: string
}
const loading = ref(true)
const error = ref(false)
const rules = ref<PointRule[]>([])
@@ -214,6 +307,12 @@ const saving = ref(false)
const formError = ref('')
const toast = ref('')
// Inline editing state
const editingCell = ref<EditingCell | null>(null)
const editValue = ref<string | number | boolean>('')
const inlineInputRef = ref<HTMLInputElement | null>(null)
const inlineSaving = ref(false)
const form = reactive({
action_key: '',
points: 0,
@@ -313,7 +412,7 @@ async function saveRule() {
await fetchRules()
} catch (e: any) {
if (e?.response?.status === 409) {
formError.value = t('gamification.point_rules.duplicate_error')
formError.value = t('gamification.point_rules.duplicate_key')
} else {
formError.value = t('gamification.point_rules.save_error')
}
@@ -342,6 +441,92 @@ async function deleteRule() {
}
}
// --- Inline Editing Methods ---
function isEditing(ruleId: number, field: string): boolean {
return editingCell.value?.id === ruleId && editingCell.value?.field === field
}
async function startEdit(rule: PointRule, field: string) {
if (inlineSaving.value) return
editingCell.value = { id: rule.id, field }
// Set the initial edit value based on field type
if (field === 'is_active') {
editValue.value = rule.is_active
} else if (field === 'points') {
editValue.value = rule.points
} else if (field === 'description') {
editValue.value = rule.description || ''
} else {
editValue.value = rule.action_key
}
// Focus the input after DOM update
await nextTick()
if (inlineInputRef.value) {
inlineInputRef.value.focus()
}
}
function cancelEdit() {
editingCell.value = null
editValue.value = ''
}
async function saveEdit(rule: PointRule, field: string) {
if (!editingCell.value || inlineSaving.value) return
// Build the partial payload
const payload: Record<string, any> = {}
let newValue = editValue.value
// Type coercion
if (field === 'points') {
newValue = Number(newValue)
if (isNaN(newValue as number)) return
} else if (field === 'is_active') {
newValue = Boolean(newValue)
} else if (field === 'description') {
newValue = (newValue as string) || null
} else {
newValue = String(newValue).trim()
if (!newValue) return // don't save empty action_key
}
// Check if value actually changed
const oldValue = (rule as any)[field]
if (newValue === oldValue) {
cancelEdit()
return
}
payload[field] = newValue
inlineSaving.value = true
try {
await $fetch(`/api/v1/admin/gamification/point-rules/${rule.id}`, {
method: 'PUT',
headers: getHeaders(),
body: payload,
})
// Update local state optimistically
;(rule as any)[field] = newValue
showToast(t('gamification.point_rules.updated'))
cancelEdit()
} catch (e: any) {
console.error('Failed to save inline edit:', e)
if (e?.response?.status === 409) {
formError.value = t('gamification.point_rules.duplicate_key')
// Show error briefly
setTimeout(() => { formError.value = '' }, 3000)
}
cancelEdit()
} finally {
inlineSaving.value = false
}
}
onMounted(() => {
fetchRules()
})

View File

@@ -14,7 +14,7 @@
<input
v-model="searchQuery"
type="text"
:placeholder="$t('garages.search_placeholder')"
:placeholder="$t('common.search_placeholder')"
class="w-full pl-10 pr-4 py-2.5 bg-slate-800 border border-slate-700 rounded-lg text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 transition"
/>
</div>
@@ -25,7 +25,7 @@
>
<option value="all">{{ $t('garages.all_types') }}</option>
<option value="individual">{{ $t('garages.type_individual') }}</option>
<option value="corporate">{{ $t('garages.type_corporate') }}</option>
<option value="corporate">{{ $t('common.type_corporate') }}</option>
</select>
<select
v-model="selectedPackage"
@@ -50,7 +50,7 @@
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
</svg>
<p class="text-slate-400 text-sm">{{ $t('garages.loading') }}</p>
<p class="text-slate-400 text-sm">{{ $t('common.loading') }}</p>
</div>
</div>
@@ -61,7 +61,7 @@
</svg>
<p class="text-red-400 text-sm mb-2">{{ error }}</p>
<button @click="fetchGarages" class="px-4 py-2 text-sm bg-indigo-600/20 text-indigo-300 hover:bg-indigo-600/30 rounded-lg transition">
{{ $t('garages.retry') }}
{{ $t('common.retry') }}
</button>
</div>
@@ -123,10 +123,10 @@
<tr class="border-b border-slate-700 bg-slate-800/80">
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">ID</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('garages.company_name') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('garages.status') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('common.status') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('garages.current_package') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('garages.expiration_date') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('garages.actions') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('common.actions') }}</th>
</tr>
</thead>
<tbody>
@@ -214,7 +214,7 @@
? 'bg-red-500/10 text-red-300 hover:bg-red-500/20'
: 'bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20'"
>
{{ garage.is_active ? $t('garages.deactivate') : $t('garages.activate') }}
{{ garage.is_active ? $t('common.deactivate') : $t('common.activate') }}
</button>
</div>
</td>
@@ -231,7 +231,7 @@
<svg class="w-12 h-12 text-slate-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
</svg>
<p class="text-slate-400 text-sm">{{ $t('garages.no_results') }}</p>
<p class="text-slate-400 text-sm">{{ $t('common.no_results') }}</p>
</div>
</div>
</template>
@@ -267,7 +267,7 @@
{{ selectedGarage?.subscription_tier_name || $t('garages.free_fallback') }}
</p>
<p v-if="selectedGarage?.subscription_expires_at" class="text-xs text-slate-400 mt-1">
{{ $t('garages.expires') }}: {{ formatDate(selectedGarage.subscription_expires_at) }}
{{ $t('common.expires') }}: {{ formatDate(selectedGarage.subscription_expires_at) }}
</p>
</div>
@@ -318,7 +318,7 @@
@click="closeSubscriptionModal"
class="px-4 py-2 text-sm font-medium text-slate-300 hover:text-white transition"
>
{{ $t('garages.cancel') }}
{{ $t('common.cancel') }}
</button>
<button
@click="saveSubscription"
@@ -333,9 +333,9 @@
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
</svg>
{{ $t('garages.saving') }}
{{ $t('common.saving') }}
</span>
<span v-else>{{ $t('garages.save') }}</span>
<span v-else>{{ $t('common.save') }}</span>
</button>
</div>
</div>

View File

@@ -24,7 +24,7 @@
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
</svg>
<span class="text-slate-400 text-sm">{{ $t('packages.loading') }}</span>
<span class="text-slate-400 text-sm">{{ $t('common.loading') }}</span>
</div>
</div>
@@ -35,7 +35,7 @@
@click="fetchPackages"
class="px-4 py-2 bg-red-700 hover:bg-red-600 text-white rounded-lg transition text-sm"
>
{{ $t('packages.retry') }}
{{ $t('common.retry') }}
</button>
</div>
@@ -50,7 +50,7 @@
@click="openCreateModal"
class="px-5 py-2.5 bg-emerald-600 hover:bg-emerald-500 text-white font-medium rounded-lg transition text-sm"
>
{{ $t('packages.create_first') }}
{{ $t('common.create_first') }}
</button>
</div>
@@ -181,7 +181,7 @@
@click="openEditModal(pkg)"
class="flex-1 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white font-medium rounded-lg transition text-sm"
>
{{ $t('packages.edit') }}
{{ $t('common.edit') }}
</button>
<button
@click="duplicatePackage(pkg)"
@@ -195,7 +195,7 @@
<button
@click="confirmDelete(pkg)"
class="px-3 py-2.5 bg-red-700 hover:bg-red-600 text-red-200 rounded-lg transition"
:title="$t('packages.delete')"
:title="$t('common.delete')"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
@@ -216,7 +216,7 @@
<!-- Modal Header -->
<div class="flex items-center justify-between px-6 py-4 border-b border-slate-700">
<h3 class="text-lg font-semibold text-white">
{{ isCreating ? $t('packages.create_title') : ($t('packages.edit_title') + ': ' + getDisplayName(editingPackage!)) }}
{{ isCreating ? $t('common.create_title') : ($t('common.edit_title') + ': ' + getDisplayName(editingPackage!)) }}
</h3>
<button
@click="showModal = false"
@@ -717,7 +717,7 @@
@click="showModal = false"
class="px-4 py-2 text-sm text-slate-400 hover:text-white transition"
>
{{ $t('packages.cancel') }}
{{ $t('common.cancel') }}
</button>
<button
@click="savePackage"
@@ -728,7 +728,7 @@
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
</svg>
{{ isCreating ? $t('packages.create') : $t('packages.save') }}
{{ isCreating ? $t('common.create') : $t('common.save') }}
</button>
</div>
</div>
@@ -742,7 +742,7 @@
@click.self="showDeleteConfirm = false"
>
<div class="bg-slate-800 border border-slate-700 rounded-xl w-full max-w-md mx-4 p-6 shadow-2xl">
<h3 class="text-lg font-semibold text-white mb-2">{{ $t('packages.delete_title') }}</h3>
<h3 class="text-lg font-semibold text-white mb-2">{{ $t('common.delete_title') }}</h3>
<p class="text-slate-400 text-sm mb-6">
{{ $t('packages.delete_confirm', { name: getDisplayName(deletingPackage) }) }}
</p>
@@ -751,14 +751,14 @@
@click="showDeleteConfirm = false"
class="px-4 py-2 text-sm text-slate-400 hover:text-white transition"
>
{{ $t('packages.cancel') }}
{{ $t('common.cancel') }}
</button>
<button
@click="deletePackage"
:disabled="saving"
class="px-6 py-2 bg-red-600 hover:bg-red-500 disabled:bg-slate-600 disabled:cursor-not-allowed text-white font-medium rounded-lg transition text-sm"
>
{{ $t('packages.delete_btn') }}
{{ $t('common.delete_btn') }}
</button>
</div>
</div>

View File

@@ -12,7 +12,7 @@
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
</svg>
<span class="ml-3 text-slate-400">{{ $t('permissions.loading') }}</span>
<span class="ml-3 text-slate-400">{{ $t('common.loading') }}</span>
</div>
<!-- Error State -->
@@ -27,7 +27,7 @@
</div>
</div>
<button @click="fetchAll" class="mt-4 px-4 py-2 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition">
{{ $t('permissions.retry') }}
{{ $t('common.retry') }}
</button>
</div>
@@ -91,10 +91,10 @@
<!-- Quick toggle all -->
<div class="mt-2 flex gap-2">
<button @click="selectAllRoles" class="text-xs text-indigo-400 hover:text-indigo-300 transition">
{{ $t('permissions.select_all') }}
{{ $t('common.select_all') }}
</button>
<button @click="deselectAllRoles" class="text-xs text-slate-500 hover:text-slate-400 transition">
{{ $t('permissions.deselect_all') }}
{{ $t('common.deselect_all') }}
</button>
</div>
</div>
@@ -112,7 +112,7 @@
</button>
<button @click="discardChanges"
class="px-4 py-2.5 bg-slate-700 hover:bg-slate-600 text-slate-300 font-medium rounded-lg transition">
{{ $t('permissions.discard') }}
{{ $t('common.discard') }}
</button>
<span class="text-sm text-slate-400 ml-auto">
{{ $t('permissions.modified_count', { count: modifiedRoles.size }) }}
@@ -132,7 +132,7 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
<span class="text-xs font-semibold uppercase tracking-wider text-slate-400">
{{ $t('permissions.permission') }}
{{ $t('common.permission') }}
</span>
</div>
</th>
@@ -249,7 +249,7 @@
</button>
<button @click="discardChanges"
class="px-4 py-2.5 bg-slate-700 hover:bg-slate-600 text-slate-300 font-medium rounded-lg transition">
{{ $t('permissions.discard') }}
{{ $t('common.discard') }}
</button>
<span class="text-sm text-slate-400">
{{ $t('permissions.modified_count', { count: modifiedRoles.size }) }}

View File

@@ -1,566 +0,0 @@
<template>
<div>
<!-- Back Button & Header -->
<div class="mb-8">
<button
@click="goBack"
class="inline-flex items-center gap-1.5 text-sm text-slate-400 hover:text-white transition mb-4"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
Vissza a szolgáltatókhoz
</button>
<h1 class="text-2xl font-bold text-white">Szolgáltató részletek</h1>
<p class="text-slate-400 mt-1">Szolgáltató #{{ $route.params.id }}</p>
</div>
<!-- Loading State -->
<div v-if="loading" class="flex items-center justify-center py-20">
<div class="text-slate-400 flex items-center gap-3">
<svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
<span>Szolgáltató betöltése...</span>
</div>
</div>
<!-- Error State -->
<div v-else-if="error" class="bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8">
<p class="text-rose-400">Hiba történt a szolgáltató betöltése közben.</p>
<button @click="fetchProvider" class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline">Újrapróbálkozás</button>
</div>
<!-- Not Found -->
<div v-else-if="!provider" class="bg-slate-800 rounded-xl border border-slate-700 p-6">
<p class="text-slate-400 text-center py-12">A szolgáltató nem található.</p>
</div>
<template v-else>
<!-- Status Banner -->
<div
class="rounded-xl border p-4 mb-6 flex items-center gap-3"
:class="statusBannerClass"
>
<span class="flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center" :class="statusIconClass">
<svg v-if="provider.status === 'approved'" class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
<svg v-else-if="provider.status === 'pending'" class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<svg v-else class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
<div>
<p class="text-sm font-medium" :class="statusTextClass">{{ statusLabel(provider.status) }}</p>
<p class="text-xs mt-0.5" :class="statusSubtextClass">{{ statusDescription(provider.status) }}</p>
</div>
</div>
<!-- Main Content Grid -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Left Column: Basic Info -->
<div class="lg:col-span-2 space-y-6">
<!-- Basic Information -->
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
<h2 class="text-lg font-semibold text-white mb-4">Alapadatok</h2>
<dl class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Név</dt>
<dd class="text-sm text-white mt-1 font-medium">{{ provider.name }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Kategória</dt>
<dd class="text-sm text-white mt-1">{{ provider.category || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Forrás</dt>
<dd class="mt-1">
<code class="text-sm font-mono text-amber-300 bg-amber-500/10 px-2 py-0.5 rounded">{{ provider.source }}</code>
</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Validációs pontszám</dt>
<dd class="mt-1">
<div class="flex items-center gap-2">
<div class="w-24 h-2 bg-slate-700 rounded-full overflow-hidden">
<div
class="h-full rounded-full transition-all"
:class="provider.validation_score >= 50 ? 'bg-emerald-500' : provider.validation_score >= 20 ? 'bg-amber-500' : 'bg-slate-500'"
:style="{ width: Math.min(provider.validation_score, 100) + '%' }"
/>
</div>
<span class="text-sm text-white font-medium">{{ provider.validation_score }}</span>
</div>
</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Létrehozva</dt>
<dd class="text-sm text-white mt-1">{{ formatDate(provider.created_at) }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Beküldő user ID</dt>
<dd class="text-sm text-white mt-1">{{ provider.added_by_user_id || '—' }}</dd>
</div>
</dl>
</div>
<!-- Address Information -->
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
<h2 class="text-lg font-semibold text-white mb-4">Cím adatok</h2>
<dl class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="md:col-span-2">
<dt class="text-xs text-slate-500 uppercase tracking-wider">Teljes cím</dt>
<dd class="text-sm text-white mt-1">{{ provider.address || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Város</dt>
<dd class="text-sm text-white mt-1">{{ provider.city || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Irányítószám</dt>
<dd class="text-sm text-white mt-1">{{ provider.address_zip || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Utca</dt>
<dd class="text-sm text-white mt-1">{{ provider.address_street_name || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Házszám</dt>
<dd class="text-sm text-white mt-1">{{ provider.address_house_number || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Plus Code</dt>
<dd class="text-sm text-white mt-1">{{ provider.plus_code || '—' }}</dd>
</div>
</dl>
</div>
<!-- Contact Information -->
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
<h2 class="text-lg font-semibold text-white mb-4">Elérhetőség</h2>
<dl class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Telefon</dt>
<dd class="text-sm text-white mt-1">{{ provider.contact_phone || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Email</dt>
<dd class="text-sm text-white mt-1">{{ provider.contact_email || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-slate-500 uppercase tracking-wider">Weboldal</dt>
<dd class="text-sm text-white mt-1">
<a v-if="provider.website" :href="provider.website" target="_blank" class="text-indigo-400 hover:text-indigo-300 underline">
{{ provider.website }}
</a>
<span v-else></span>
</dd>
</div>
</dl>
</div>
</div>
<!-- Right Column: Actions -->
<div class="space-y-4">
<!-- Moderation Actions -->
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6">
<h2 class="text-lg font-semibold text-white mb-4">Moderációs műveletek</h2>
<!-- Pending Actions -->
<div v-if="provider.status === 'pending'" class="space-y-3">
<button
@click="approveProvider"
:disabled="actionLoading"
class="w-full px-4 py-3 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 text-white rounded-lg text-sm font-medium transition flex items-center justify-center gap-2"
>
<svg v-if="actionLoading" class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
<svg v-else class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
Jóváhagyás
</button>
<button
@click="openRejectModal"
:disabled="actionLoading"
class="w-full px-4 py-3 bg-rose-600/20 hover:bg-rose-600/40 disabled:opacity-50 text-rose-400 rounded-lg text-sm font-medium transition flex items-center justify-center gap-2"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
Elutasítás
</button>
</div>
<!-- Approved Actions -->
<div v-else-if="provider.status === 'approved'" class="space-y-3">
<button
@click="openFlagModal"
:disabled="actionLoading"
class="w-full px-4 py-3 bg-purple-600/20 hover:bg-purple-600/40 disabled:opacity-50 text-purple-400 rounded-lg text-sm font-medium transition flex items-center justify-center gap-2"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 21v-4m0 0V5a2 2 0 012-2h6.5l1 1H21l-3 6 3 6h-8.5l-1-1H5a2 2 0 00-2 2zm9-13.5V9" />
</svg>
Megjelölés (Flag)
</button>
<button
@click="deleteProvider"
:disabled="actionLoading"
class="w-full px-4 py-3 bg-rose-600/20 hover:bg-rose-600/40 disabled:opacity-50 text-rose-400 rounded-lg text-sm font-medium transition flex items-center justify-center gap-2"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
Törlés (Soft Delete)
</button>
</div>
<!-- Rejected / Flagged Info -->
<div v-else class="text-sm text-slate-400 text-center py-4">
<p>A szolgáltató {{ provider.status === 'rejected' ? 'elutasításra' : 'megjelölésre' }} került.</p>
<button
@click="deleteProvider"
:disabled="actionLoading"
class="mt-3 w-full px-4 py-3 bg-rose-600/20 hover:bg-rose-600/40 disabled:opacity-50 text-rose-400 rounded-lg text-sm font-medium transition flex items-center justify-center gap-2"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
Törlés
</button>
</div>
</div>
<!-- Evidence Image -->
<div v-if="provider.evidence_image_path" class="bg-slate-800 rounded-xl border border-slate-700 p-6">
<h2 class="text-lg font-semibold text-white mb-4">Bizonyíték kép</h2>
<img
:src="provider.evidence_image_path"
alt="Evidence"
class="w-full rounded-lg border border-slate-600"
/>
</div>
</div>
</div>
</template>
<!-- Reject Modal -->
<div v-if="showRejectModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" @click.self="showRejectModal = false">
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-lg mx-4 shadow-2xl">
<h2 class="text-lg font-semibold text-white mb-2">Szolgáltató elutasítása</h2>
<p class="text-sm text-slate-400 mb-6">
Biztosan elutasítod a(z) <strong class="text-white">{{ provider?.name }}</strong> szolgáltatót?
</p>
<form @submit.prevent="rejectProvider">
<div class="mb-4">
<label class="block text-sm font-medium text-slate-300 mb-1">Indoklás (opcionális)</label>
<textarea
v-model="rejectReason"
rows="3"
placeholder="Add meg az elutasítás okát..."
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-rose-500/50 focus:border-rose-500 text-sm resize-none"
></textarea>
</div>
<div class="flex justify-end gap-3">
<button type="button" @click="showRejectModal = false" class="px-4 py-2 text-sm text-slate-400 hover:text-white transition">Mégse</button>
<button type="submit" :disabled="actionLoading" class="px-4 py-2 bg-rose-600 hover:bg-rose-500 disabled:bg-rose-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2">
<svg v-if="actionLoading" class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
Elutasítás
</button>
</div>
</form>
</div>
</div>
<!-- Flag Modal -->
<div v-if="showFlagModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" @click.self="showFlagModal = false">
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-lg mx-4 shadow-2xl">
<h2 class="text-lg font-semibold text-white mb-2">Szolgáltató megjelölése</h2>
<p class="text-sm text-slate-400 mb-6">
Megjelölöd a(z) <strong class="text-white">{{ provider?.name }}</strong> szolgáltatót? Ez visszavonja a jóváhagyását.
</p>
<form @submit.prevent="flagProvider">
<div class="mb-4">
<label class="block text-sm font-medium text-slate-300 mb-1">Indoklás (opcionális)</label>
<textarea
v-model="flagReason"
rows="3"
placeholder="Add meg a megjelölés okát..."
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-purple-500/50 focus:border-purple-500 text-sm resize-none"
></textarea>
</div>
<div class="flex justify-end gap-3">
<button type="button" @click="showFlagModal = false" class="px-4 py-2 text-sm text-slate-400 hover:text-white transition">Mégse</button>
<button type="submit" :disabled="actionLoading" class="px-4 py-2 bg-purple-600 hover:bg-purple-500 disabled:bg-purple-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2">
<svg v-if="actionLoading" class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
Megjelölés
</button>
</div>
</form>
</div>
</div>
<!-- Success Toast -->
<div v-if="toast" class="fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2 animate-slide-up">
<svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
{{ toast }}
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
middleware: 'auth',
})
const route = useRoute()
const router = useRouter()
const { formatDate } = useFormatter()
interface ProviderDetail {
id: number
name: string
address: string
city: string | null
address_zip: string | null
address_street_name: string | null
address_street_type: string | null
address_house_number: string | null
plus_code: string | null
contact_phone: string | null
contact_email: string | null
website: string | null
category: string | null
status: string
source: string
validation_score: number
evidence_image_path: string | null
added_by_user_id: number | null
created_at: string | null
}
const loading = ref(true)
const error = ref(false)
const provider = ref<ProviderDetail | null>(null)
const toast = ref('')
const actionLoading = ref(false)
// Reject modal
const showRejectModal = ref(false)
const rejectReason = ref('')
// Flag modal
const showFlagModal = ref(false)
const flagReason = ref('')
function getHeaders(): Record<string, string> {
const tokenCookie = useCookie('access_token')
const token = tokenCookie.value
return token ? { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } : { 'Content-Type': 'application/json' }
}
function showToast(msg: string) {
toast.value = msg
setTimeout(() => { toast.value = '' }, 3000)
}
function goBack() {
router.push('/providers')
}
function statusLabel(status: string): string {
const map: Record<string, string> = {
pending: 'Függőben lévő szolgáltató',
approved: 'Jóváhagyott szolgáltató',
rejected: 'Elutasított szolgáltató',
flagged: 'Megjelölt szolgáltató',
}
return map[status] || status
}
function statusDescription(status: string): string {
const map: Record<string, string> = {
pending: 'Ez a szolgáltató még moderálásra vár. Jóváhagyhatod vagy elutasíthatod.',
approved: 'A szolgáltató jóváhagyásra került és elérhető a felhasználók számára.',
rejected: 'A szolgáltató elutasításra került és nem elérhető.',
flagged: 'A szolgáltató megjelölésre került és visszavonásra került a jóváhagyása.',
}
return map[status] || ''
}
const statusBannerClass = computed(() => {
const map: Record<string, string> = {
pending: 'bg-amber-500/10 border-amber-500/30',
approved: 'bg-emerald-500/10 border-emerald-500/30',
rejected: 'bg-rose-500/10 border-rose-500/30',
flagged: 'bg-purple-500/10 border-purple-500/30',
}
return map[provider.value?.status || ''] || 'bg-slate-500/10 border-slate-500/30'
})
const statusIconClass = computed(() => {
const map: Record<string, string> = {
pending: 'bg-amber-500/20 text-amber-400',
approved: 'bg-emerald-500/20 text-emerald-400',
rejected: 'bg-rose-500/20 text-rose-400',
flagged: 'bg-purple-500/20 text-purple-400',
}
return map[provider.value?.status || ''] || 'bg-slate-500/20 text-slate-400'
})
const statusTextClass = computed(() => {
const map: Record<string, string> = {
pending: 'text-amber-400',
approved: 'text-emerald-400',
rejected: 'text-rose-400',
flagged: 'text-purple-400',
}
return map[provider.value?.status || ''] || 'text-slate-400'
})
const statusSubtextClass = computed(() => {
const map: Record<string, string> = {
pending: 'text-amber-400/70',
approved: 'text-emerald-400/70',
rejected: 'text-rose-400/70',
flagged: 'text-purple-400/70',
}
return map[provider.value?.status || ''] || 'text-slate-400/70'
})
async function fetchProvider() {
loading.value = true
error.value = false
try {
const data = await $fetch<ProviderDetail>(`/api/v1/admin/providers/${route.params.id}`, { headers: getHeaders() })
provider.value = data
} catch (e) {
console.error('Failed to fetch provider:', e)
error.value = true
} finally {
loading.value = false
}
}
async function approveProvider() {
if (!provider.value) return
actionLoading.value = true
try {
await $fetch(`/api/v1/admin/providers/${provider.value.id}/approve`, {
method: 'POST',
headers: getHeaders(),
body: { reason: 'Admin approved via detail page' },
})
showToast(`"${provider.value.name}" sikeresen jóváhagyva`)
await fetchProvider()
} catch (e: any) {
const detail = e?.response?._data?.detail || e?.data?.detail || 'Ismeretlen hiba'
showToast(`Hiba: ${detail}`)
console.error('Failed to approve provider:', e)
} finally {
actionLoading.value = false
}
}
function openRejectModal() {
rejectReason.value = ''
showRejectModal.value = true
}
async function rejectProvider() {
if (!provider.value) return
actionLoading.value = true
try {
await $fetch(`/api/v1/admin/providers/${provider.value.id}/reject`, {
method: 'POST',
headers: getHeaders(),
body: { reason: rejectReason.value || 'Admin rejected via detail page' },
})
showToast(`"${provider.value.name}" elutasítva`)
showRejectModal.value = false
await fetchProvider()
} catch (e: any) {
const detail = e?.response?._data?.detail || e?.data?.detail || 'Ismeretlen hiba'
showToast(`Hiba: ${detail}`)
console.error('Failed to reject provider:', e)
} finally {
actionLoading.value = false
}
}
function openFlagModal() {
flagReason.value = ''
showFlagModal.value = true
}
async function flagProvider() {
if (!provider.value) return
actionLoading.value = true
try {
await $fetch(`/api/v1/admin/providers/${provider.value.id}/flag`, {
method: 'POST',
headers: getHeaders(),
body: { reason: flagReason.value || 'Admin flagged via detail page' },
})
showToast(`"${provider.value.name}" megjelölve`)
showFlagModal.value = false
await fetchProvider()
} catch (e: any) {
const detail = e?.response?._data?.detail || e?.data?.detail || 'Ismeretlen hiba'
showToast(`Hiba: ${detail}`)
console.error('Failed to flag provider:', e)
} finally {
actionLoading.value = false
}
}
async function deleteProvider() {
if (!provider.value) return
actionLoading.value = true
try {
await $fetch(`/api/v1/admin/providers/${provider.value.id}`, {
method: 'DELETE',
headers: getHeaders(),
})
showToast(`"${provider.value.name}" törölve`)
setTimeout(() => router.push('/providers'), 1500)
} catch (e: any) {
const detail = e?.response?._data?.detail || e?.data?.detail || 'Ismeretlen hiba'
showToast(`Hiba: ${detail}`)
console.error('Failed to delete provider:', e)
} finally {
actionLoading.value = false
}
}
onMounted(() => {
fetchProvider()
})
</script>
<style scoped>
.animate-slide-up {
animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(1rem);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -84,6 +84,8 @@
<option value="manual">Kézi</option>
<option value="ocr">OCR</option>
<option value="import">Import</option>
<option value="bot">Bot (Staging)</option>
<option value="verified_org">Szervezet</option>
</select>
<!-- Sort -->
@@ -139,7 +141,10 @@
</span>
</td>
<td class="px-6 py-4">
<code class="text-xs font-mono text-slate-400 bg-slate-700/50 px-2 py-0.5 rounded">{{ provider.source }}</code>
<div class="flex items-center gap-1.5">
<code class="text-xs font-mono text-slate-400 bg-slate-700/50 px-2 py-0.5 rounded">{{ provider.source }}</code>
<span v-if="provider.source_table" class="text-[10px] font-mono text-slate-500 bg-slate-700/30 px-1.5 py-0.5 rounded">{{ provider.source_table }}</span>
</div>
</td>
<td class="px-6 py-4">
<div class="flex items-center gap-2">
@@ -230,6 +235,7 @@ interface ProviderListItem {
category: string | null
status: string
source: string
source_table?: string
validation_score: number
added_by_user_id: number | null
created_at: string | null
@@ -242,6 +248,7 @@ interface ProviderStats {
rejected: number
flagged: number
total_validations: number
staging_pending?: number
}
const loading = ref(true)
@@ -254,6 +261,7 @@ const stats = ref<ProviderStats>({
rejected: 0,
flagged: 0,
total_validations: 0,
staging_pending: 0,
})
const toast = ref('')
let searchTimeout: ReturnType<typeof setTimeout> | null = null

View File

@@ -168,6 +168,7 @@ interface ProviderListItem {
category: string | null
status: string
source: string
source_table?: string
validation_score: number
added_by_user_id: number | null
created_at: string | null

View File

@@ -0,0 +1,253 @@
<template>
<div>
<!-- Page Header -->
<div class="mb-8">
<h1 class="text-2xl font-bold text-white">Elutasított szolgáltatók</h1>
<p class="text-slate-400 mt-1">Elutasított szolgáltatók visszaállítása az aktív kereshető szolgáltatók közé</p>
</div>
<!-- Loading State -->
<div v-if="loading" class="flex items-center justify-center py-20">
<div class="text-slate-400 flex items-center gap-3">
<svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
<span>Elutasított szolgáltatók betöltése...</span>
</div>
</div>
<!-- Error State -->
<div v-else-if="error" class="bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8">
<p class="text-rose-400">Hiba történt a szolgáltatók betöltése közben.</p>
<button @click="fetchRejectedProviders" class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline">Újrapróbálkozás</button>
</div>
<template v-else>
<!-- Rejected Queue -->
<div class="space-y-4">
<div
v-for="provider in providers"
:key="provider.id"
class="bg-slate-800 rounded-xl border border-slate-700 p-6 hover:border-rose-500/30 transition"
>
<div class="flex items-start justify-between gap-4">
<!-- Left: Provider Info -->
<div class="flex-1 min-w-0">
<div class="flex items-center gap-3 mb-2">
<h3 class="text-lg font-semibold text-white truncate">{{ provider.name }}</h3>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-rose-500/10 text-rose-400">
Elutasított
</span>
<code class="text-xs font-mono text-slate-400 bg-slate-700/50 px-2 py-0.5 rounded">{{ provider.source }}</code>
<span v-if="provider.source_table" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-mono bg-slate-700/50 text-slate-400">
{{ provider.source_table }}
</span>
</div>
<div class="grid grid-cols-2 gap-x-8 gap-y-2 text-sm">
<div v-if="provider.address" class="text-slate-300">
<span class="text-slate-500">Cím:</span> {{ provider.address }}
</div>
<div v-if="provider.city" class="text-slate-300">
<span class="text-slate-500">Város:</span> {{ provider.city }}
</div>
<div v-if="provider.category" class="text-slate-300">
<span class="text-slate-500">Kategória:</span> {{ provider.category }}
</div>
<div class="text-slate-300">
<span class="text-slate-500">Validációs pontszám:</span>
<span class="text-rose-400 font-medium ml-1">{{ provider.validation_score }}</span>
</div>
<div v-if="provider.created_at" class="text-slate-300">
<span class="text-slate-500">Létrehozva:</span> {{ formatDate(provider.created_at) }}
</div>
</div>
</div>
<!-- Right: Actions -->
<div class="flex flex-col gap-2 flex-shrink-0">
<button
@click="openRestoreModal(provider)"
:disabled="actionLoading === provider.id"
class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2"
>
<svg v-if="actionLoading === provider.id" class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
<svg v-else class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
Visszaállítás
</button>
<NuxtLink
:to="`/providers/${provider.id}`"
class="px-4 py-2 bg-slate-700 hover:bg-slate-600 text-slate-300 rounded-lg text-sm font-medium transition flex items-center gap-2 text-center"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
Részletek
</NuxtLink>
</div>
</div>
</div>
<!-- Empty State -->
<div v-if="providers.length === 0" class="bg-slate-800 rounded-xl border border-slate-700 p-12 text-center">
<svg class="w-12 h-12 mx-auto text-slate-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<h3 class="text-lg font-medium text-slate-400 mb-1">Nincs elutasított szolgáltató</h3>
<p class="text-sm text-slate-500">Minden szolgáltató jóváhagyott státuszban van.</p>
</div>
</div>
</template>
<!-- Restore Modal -->
<div v-if="showRestoreModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" @click.self="showRestoreModal = false">
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-lg mx-4 shadow-2xl">
<h2 class="text-lg font-semibold text-white mb-2">Szolgáltató visszaállítása</h2>
<p class="text-sm text-slate-400 mb-6">
Biztosan visszaállítod a(z) <strong class="text-white">{{ restoringProvider?.name }}</strong> szolgáltatót?
A visszaállítás után a szolgáltató újra elérhető lesz a keresőben és a listákban.
</p>
<form @submit.prevent="restoreProvider">
<div class="mb-4">
<label class="block text-sm font-medium text-slate-300 mb-1">Indoklás (opcionális)</label>
<textarea
v-model="restoreReason"
rows="3"
placeholder="Add meg a visszaállítás okát..."
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-emerald-500/50 focus:border-emerald-500 text-sm resize-none"
></textarea>
</div>
<div class="flex justify-end gap-3">
<button type="button" @click="showRestoreModal = false" class="px-4 py-2 text-sm text-slate-400 hover:text-white transition">Mégse</button>
<button type="submit" :disabled="restoreLoading" class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2">
<svg v-if="restoreLoading" class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
Visszaállítás
</button>
</div>
</form>
</div>
</div>
<!-- Success Toast -->
<div v-if="toast" class="fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2 animate-slide-up">
<svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
{{ toast }}
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
middleware: 'auth',
})
const { formatDate } = useFormatter()
interface ProviderListItem {
id: number
name: string
address: string | null
city: string | null
category: string | null
status: string
source: string
source_table?: string
validation_score: number
added_by_user_id: number | null
created_at: string | null
}
const loading = ref(true)
const error = ref(false)
const providers = ref<ProviderListItem[]>([])
const toast = ref('')
const actionLoading = ref<number | null>(null)
const showRestoreModal = ref(false)
const restoringProvider = ref<ProviderListItem | null>(null)
const restoreReason = ref('')
const restoreLoading = ref(false)
function getHeaders(): Record<string, string> {
const tokenCookie = useCookie('access_token')
const token = tokenCookie.value
return token ? { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } : { 'Content-Type': 'application/json' }
}
function showToast(msg: string) {
toast.value = msg
setTimeout(() => { toast.value = '' }, 3000)
}
async function fetchRejectedProviders() {
loading.value = true
error.value = false
try {
const data = await $fetch<ProviderListItem[]>('/api/v1/admin/providers?status=rejected&limit=100&sort_by=created_at&sort_order=desc', { headers: getHeaders() })
providers.value = data
} catch (e) {
console.error('Failed to fetch rejected providers:', e)
error.value = true
} finally {
loading.value = false
}
}
function openRestoreModal(provider: ProviderListItem) {
restoringProvider.value = provider
restoreReason.value = ''
showRestoreModal.value = true
}
async function restoreProvider() {
if (!restoringProvider.value) return
restoreLoading.value = true
try {
await $fetch(`/api/v1/admin/providers/${restoringProvider.value.id}/restore`, {
method: 'POST',
headers: getHeaders(),
body: { reason: restoreReason.value || 'Admin restored via rejected queue' },
})
showToast(`"${restoringProvider.value.name}" sikeresen visszaállítva`)
providers.value = providers.value.filter(p => p.id !== restoringProvider.value!.id)
showRestoreModal.value = false
restoringProvider.value = null
} catch (e: any) {
const detail = e?.response?._data?.detail || e?.data?.detail || 'Ismeretlen hiba'
showToast(`Hiba: ${detail}`)
console.error('Failed to restore provider:', e)
} finally {
restoreLoading.value = false
}
}
onMounted(() => {
fetchRejectedProviders()
})
</script>
<style scoped>
.animate-slide-up {
animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(1rem);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>

View File

@@ -123,7 +123,7 @@
<p class="text-sm text-white font-mono">{{ user.id }}</p>
</div>
<div>
<label class="block text-xs text-slate-400 mb-1">{{ $t('users.email') }}</label>
<label class="block text-xs text-slate-400 mb-1">{{ $t('common.email') }}</label>
<p class="text-sm text-white">{{ user.email }}</p>
</div>
<div>
@@ -376,7 +376,7 @@
<!-- Account Fields -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('users.email') }}</label>
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('common.email') }}</label>
<input
v-model="editForm.email"
type="email"

View File

@@ -15,7 +15,7 @@
<input
v-model="searchQuery"
type="text"
:placeholder="$t('users.search_placeholder')"
:placeholder="$t('common.search_placeholder')"
class="w-full pl-10 pr-4 py-2.5 bg-slate-800 border border-slate-700 rounded-lg text-sm text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 transition"
/>
</div>
@@ -62,7 +62,7 @@
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
</svg>
<p class="text-slate-400 text-sm">{{ $t('users.loading') }}</p>
<p class="text-slate-400 text-sm">{{ $t('common.loading') }}</p>
</div>
</div>
@@ -73,7 +73,7 @@
</svg>
<p class="text-red-400 text-sm mb-2">{{ error }}</p>
<button @click="fetchUsers" class="px-4 py-2 text-sm bg-indigo-600/20 text-indigo-300 hover:bg-indigo-600/30 rounded-lg transition">
{{ $t('users.retry') }}
{{ $t('common.retry') }}
</button>
</div>
@@ -205,14 +205,14 @@
/>
</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">ID</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.email') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.name') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('common.email') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('common.name') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.role') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.status') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('common.status') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.package') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.registration') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.language') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('users.actions') }}</th>
<th class="text-left py-3.5 px-4 text-xs font-semibold uppercase tracking-wider text-slate-400">{{ $t('common.actions') }}</th>
</tr>
</thead>
<tbody>
@@ -291,7 +291,7 @@
:to="'/users/' + user.id"
class="px-3 py-1.5 text-xs font-medium bg-slate-600/20 text-slate-300 hover:bg-slate-600/30 rounded-lg transition"
>
{{ $t('users.view') }}
{{ $t('common.view') }}
</NuxtLink>
<button
v-if="!user.is_deleted && canEditUsers"
@@ -301,7 +301,7 @@
? 'bg-red-500/10 text-red-300 hover:bg-red-500/20'
: 'bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20'"
>
{{ user.is_active ? $t('users.deactivate') : $t('users.activate') }}
{{ user.is_active ? $t('common.deactivate') : $t('common.activate') }}
</button>
</div>
</td>
@@ -318,7 +318,7 @@
<svg class="w-12 h-12 text-slate-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
</svg>
<p class="text-slate-400 text-sm">{{ $t('users.no_results') }}</p>
<p class="text-slate-400 text-sm">{{ $t('common.no_results') }}</p>
</div>
</div>
@@ -334,7 +334,7 @@
class="px-3 py-1.5 text-xs font-medium rounded-lg transition disabled:opacity-30 disabled:cursor-not-allowed"
:class="skip > 0 ? 'bg-slate-700 text-slate-300 hover:bg-slate-600' : 'bg-slate-800 text-slate-600'"
>
{{ $t('users.prev') }}
{{ $t('common.prev') }}
</button>
<button
@click="nextPage"
@@ -342,7 +342,7 @@
class="px-3 py-1.5 text-xs font-medium rounded-lg transition disabled:opacity-30 disabled:cursor-not-allowed"
:class="skip + limit < totalCount ? 'bg-slate-700 text-slate-300 hover:bg-slate-600' : 'bg-slate-800 text-slate-600'"
>
{{ $t('users.next') }}
{{ $t('common.next') }}
</button>
</div>
</div>