add verified mappools
This commit is contained in:
@@ -60,7 +60,12 @@
|
||||
class="group flex items-center justify-between rounded-lg border border-border bg-surface-800 p-4 transition-colors hover:border-accent/40 hover:bg-surface-700"
|
||||
>
|
||||
<div>
|
||||
<h2 class="text-sm font-600">{pool.name}</h2>
|
||||
<div class="flex items-center gap-2">
|
||||
<h2 class="text-sm font-600">{pool.name}</h2>
|
||||
{#if pool.verifiedAt}
|
||||
<span class="rounded border border-green-500/30 bg-green-500/10 px-1.5 py-0.5 text-[10px] font-600 text-green-400">✓ Verified</span>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-text-secondary">
|
||||
{pool.slots.length} map{pool.slots.length !== 1 ? 's' : ''}
|
||||
{#if avgSr}· {avgSr}★{/if}
|
||||
|
||||
@@ -88,7 +88,8 @@ export const load: PageServerLoad = async ({ params, locals }) => {
|
||||
|
||||
return {
|
||||
pool: { ...pool, slots: slotsWithBeatmaps },
|
||||
canEdit: isOwner || isAdmin
|
||||
canEdit: isOwner || isAdmin,
|
||||
isAdmin
|
||||
};
|
||||
};
|
||||
|
||||
@@ -188,6 +189,30 @@ export const actions: Actions = {
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
verify: async ({ params, locals }) => {
|
||||
requireAuth(locals);
|
||||
if (locals.user!.role !== 'admin') error(403, 'Admins only');
|
||||
|
||||
await db
|
||||
.update(mappool)
|
||||
.set({ verifiedAt: new Date() })
|
||||
.where(eq(mappool.id, params.id));
|
||||
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
unverify: async ({ params, locals }) => {
|
||||
requireAuth(locals);
|
||||
if (locals.user!.role !== 'admin') error(403, 'Admins only');
|
||||
|
||||
await db
|
||||
.update(mappool)
|
||||
.set({ verifiedAt: null })
|
||||
.where(eq(mappool.id, params.id));
|
||||
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
deletePool: async ({ params, locals }) => {
|
||||
const pool = await db.query.mappool.findFirst({
|
||||
where: eq(mappool.id, params.id)
|
||||
|
||||
@@ -108,6 +108,11 @@
|
||||
{:else}
|
||||
<div class="flex items-center gap-2">
|
||||
<h1 class="text-2xl font-700 tracking-tight">{data.pool.name}</h1>
|
||||
{#if data.pool.verifiedAt}
|
||||
<span class="flex items-center gap-1 rounded border border-green-500/30 bg-green-500/10 px-2 py-0.5 text-xs font-600 text-green-400">
|
||||
✓ Verified
|
||||
</span>
|
||||
{/if}
|
||||
{#if data.canEdit}
|
||||
<button
|
||||
onclick={() => {
|
||||
@@ -128,19 +133,42 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if data.canEdit}
|
||||
<form method="post" action="?/deletePool" use:enhance>
|
||||
<button
|
||||
type="submit"
|
||||
onclick={(e) => {
|
||||
if (!confirm('Delete this mappool?')) e.preventDefault();
|
||||
}}
|
||||
class="rounded-md border border-red-500/30 px-3 py-1.5 text-sm text-red-400 transition-colors hover:bg-red-500/10"
|
||||
>
|
||||
Delete Pool
|
||||
</button>
|
||||
</form>
|
||||
{/if}
|
||||
<div class="flex items-center gap-2">
|
||||
{#if data.isAdmin}
|
||||
{#if data.pool.verifiedAt}
|
||||
<form method="post" action="?/unverify" use:enhance>
|
||||
<button
|
||||
type="submit"
|
||||
class="rounded-md border border-green-500/30 px-3 py-1.5 text-sm text-green-400 transition-colors hover:bg-green-500/10"
|
||||
>
|
||||
Unverify
|
||||
</button>
|
||||
</form>
|
||||
{:else}
|
||||
<form method="post" action="?/verify" use:enhance>
|
||||
<button
|
||||
type="submit"
|
||||
class="rounded-md border border-green-500/30 px-3 py-1.5 text-sm text-green-400 transition-colors hover:bg-green-500/10"
|
||||
>
|
||||
✓ Verify
|
||||
</button>
|
||||
</form>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if data.canEdit}
|
||||
<form method="post" action="?/deletePool" use:enhance>
|
||||
<button
|
||||
type="submit"
|
||||
onclick={(e) => {
|
||||
if (!confirm('Delete this mappool?')) e.preventDefault();
|
||||
}}
|
||||
class="rounded-md border border-red-500/30 px-3 py-1.5 text-sm text-red-400 transition-colors hover:bg-red-500/10"
|
||||
>
|
||||
Delete Pool
|
||||
</button>
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Map -->
|
||||
|
||||
Reference in New Issue
Block a user