mirror of
https://github.com/System-End/scraps.git
synced 2026-04-20 00:25:18 +00:00
activity for all!
This commit is contained in:
parent
b9861611ee
commit
32baf94eb2
3 changed files with 13 additions and 44 deletions
|
|
@ -275,8 +275,8 @@ projects.get('/:id', async ({ params, headers }) => {
|
|||
reviewer?: { id: number; username: string | null; avatar: string | null } | null
|
||||
}> = []
|
||||
|
||||
if (isOwner) {
|
||||
const reviews = await db
|
||||
// Fetch reviews for activity
|
||||
const reviews = await db
|
||||
.select({
|
||||
id: reviewsTable.id,
|
||||
reviewerId: reviewsTable.reviewerId,
|
||||
|
|
@ -356,7 +356,6 @@ projects.get('/:id', async ({ params, headers }) => {
|
|||
const dateB = b.createdAt ? new Date(b.createdAt).getTime() : 0
|
||||
return dateB - dateA
|
||||
})
|
||||
}
|
||||
|
||||
// Check if the user has ever submitted feedback on any project
|
||||
let hasSubmittedFeedback = false
|
||||
|
|
@ -401,7 +400,7 @@ projects.get('/:id', async ({ params, headers }) => {
|
|||
owner: projectOwner[0] || null,
|
||||
isOwner,
|
||||
hasSubmittedFeedback: isOwner ? hasSubmittedFeedback : undefined,
|
||||
activity: isOwner ? activity : undefined
|
||||
activity
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@
|
|||
|
||||
let confirmAction = $state<'approved' | 'denied' | 'permanently_rejected' | null>(null);
|
||||
let errorModal = $state<string | null>(null);
|
||||
let syncingHours = $state(false);
|
||||
|
||||
let projectId = $derived(page.params.id);
|
||||
|
||||
|
|
@ -206,28 +205,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
async function syncHours() {
|
||||
if (!project || syncingHours) return;
|
||||
syncingHours = true;
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/admin/projects/${project.id}/sync-hours`, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
errorModal = data.error;
|
||||
} else if (data.updated && project) {
|
||||
project.hours = data.hours;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to sync hours:', e);
|
||||
errorModal = 'Failed to sync hours from Hackatime';
|
||||
} finally {
|
||||
syncingHours = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getActionLabel(action: string) {
|
||||
switch (action) {
|
||||
case 'approved':
|
||||
|
|
@ -415,15 +392,6 @@
|
|||
<span>{$t.project.tryItOut}</span>
|
||||
</span>
|
||||
{/if}
|
||||
<button
|
||||
onclick={syncHours}
|
||||
disabled={syncingHours}
|
||||
title="Sync hours from Hackatime"
|
||||
class="inline-flex cursor-pointer items-center gap-2 rounded-full border-4 border-black px-4 py-2 font-bold transition-all duration-200 hover:border-dashed disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<RefreshCw size={18} class={syncingHours ? 'animate-spin' : ''} />
|
||||
{syncingHours ? 'syncing...' : 'sync hours'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- User Info (clickable) -->
|
||||
|
|
|
|||
|
|
@ -481,16 +481,19 @@
|
|||
{error}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<!-- Activity Timeline (only for owner) -->
|
||||
<div>
|
||||
<h2 class="mb-6 text-2xl font-bold">{$t.project.activity}</h2>
|
||||
<!-- Activity Timeline -->
|
||||
<div>
|
||||
<h2 class="mb-6 text-2xl font-bold">{$t.project.activity}</h2>
|
||||
|
||||
{#if activity.length === 0}
|
||||
<div class="rounded-2xl border-4 border-dashed border-gray-300 p-8 text-center">
|
||||
<p class="text-gray-500">{$t.project.noActivityYet}</p>
|
||||
{#if activity.length === 0}
|
||||
<div class="rounded-2xl border-4 border-dashed border-gray-300 p-8 text-center">
|
||||
<p class="text-gray-500">{$t.project.noActivityYet}</p>
|
||||
{#if isOwner}
|
||||
<p class="mt-2 text-sm text-gray-400">{$t.project.submitToGetStarted}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="relative">
|
||||
<!-- Timeline line -->
|
||||
|
|
@ -592,7 +595,6 @@
|
|||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue