From 8d50bd6ab5fb0398cb0798e140f067ed8639fc74 Mon Sep 17 00:00:00 2001 From: s1lvax Date: Thu, 31 Oct 2024 13:39:23 +0100 Subject: [PATCH] fix timeline --- src/lib/components/MyProfile/Timeline.svelte | 35 ++++++++++---- src/routes/profile/+page.server.ts | 2 +- src/routes/profile/+page.svelte | 50 ++++++++++++++++++-- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/lib/components/MyProfile/Timeline.svelte b/src/lib/components/MyProfile/Timeline.svelte index c062a4f..893661f 100644 --- a/src/lib/components/MyProfile/Timeline.svelte +++ b/src/lib/components/MyProfile/Timeline.svelte @@ -10,26 +10,41 @@ } else if (activityType.includes('DELETED') || activityType === 'UNLINK_SPOTIFY') { return 'bg-red-700'; // Removing something } - return 'bg-gray-400'; + return 'bg-gray-700'; + }; + + // Function to format the date + const formatDate = (date: Date): string => { + const today = new Date(); + const isToday = + date.getDate() === today.getDate() && + date.getMonth() === today.getMonth() && + date.getFullYear() === today.getFullYear(); + + if (isToday) { + return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); + } else { + return `${date.getFullYear()}.${String(date.getMonth() + 1).padStart(2, '0')}.${String(date.getDate()).padStart(2, '0')}`; + } }; -
+
    - {#each recentActivity as activity} + {#each recentActivity as activity, i (activity.id)}
  • - + {#if i < recentActivity.length - 1} + + + {/if}
    - +
    @@ -40,7 +55,7 @@
    diff --git a/src/routes/profile/+page.server.ts b/src/routes/profile/+page.server.ts index 727d06e..22c5643 100644 --- a/src/routes/profile/+page.server.ts +++ b/src/routes/profile/+page.server.ts @@ -24,7 +24,7 @@ export const load: PageServerLoad = async (event) => { const recentActivity = await prisma.recentActivity.findMany({ where: { userId: userId }, orderBy: { createdAt: 'desc' }, - take: 10 + take: 5 }); return { recentActivity }; diff --git a/src/routes/profile/+page.svelte b/src/routes/profile/+page.svelte index 6899890..2d0c803 100644 --- a/src/routes/profile/+page.svelte +++ b/src/routes/profile/+page.svelte @@ -1,13 +1,53 @@ -
    -
    - -
    -
    ddddd
    + + +
    + + + Recent Activity + + + + + + + + We need something here + You made 265 sales this month. + + ddddd +