diff --git a/packages/frontend/src/lib/i18n/locales/en.ts b/packages/frontend/src/lib/i18n/locales/en.ts index 356d0ee..da393d4 100644 --- a/packages/frontend/src/lib/i18n/locales/en.ts +++ b/packages/frontend/src/lib/i18n/locales/en.ts @@ -223,6 +223,13 @@ export default { toast_reset: "Your password has been reset!", }, }, + profile: { + member_since: "Member since {date}", + comments: "Comments", + likes: "Likes", + edit: "Edit Profile", + activity: "Activity", + }, models: { title: "Our Models", description: diff --git a/packages/frontend/src/routes/users/[id]/+page.server.ts b/packages/frontend/src/routes/users/[id]/+page.server.ts new file mode 100644 index 0000000..a63eb23 --- /dev/null +++ b/packages/frontend/src/routes/users/[id]/+page.server.ts @@ -0,0 +1,45 @@ +import { redirect } from "@sveltejs/kit"; +import type { PageServerLoad } from "./$types"; + +export const load: PageServerLoad = async ({ params, locals, fetch }) => { + // Guard: Redirect to login if not authenticated + if (!locals.authStatus.authenticated) { + throw redirect(302, "/login"); + } + + const { id } = params; + + try { + // Fetch user profile data from Directus + const userResponse = await fetch(`/api/users/${id}?fields=id,first_name,last_name,email,description,avatar,date_created,location`); + + if (!userResponse.ok) { + throw redirect(404, "/"); + } + + const userData = await userResponse.json(); + const user = userData.data; + + // Fetch user's comments count + const commentsResponse = await fetch(`/api/comments?filter[user_created][_eq]=${id}&aggregate[count]=*`); + const commentsData = await commentsResponse.json(); + const commentsCount = commentsData.data?.[0]?.count || 0; + + // Fetch user's video likes count + const likesResponse = await fetch(`/api/items/sexy_video_likes?filter[user_id][_eq]=${id}&aggregate[count]=*`); + const likesData = await likesResponse.json(); + const likesCount = likesData.data?.[0]?.count || 0; + + return { + user, + stats: { + comments_count: commentsCount, + likes_count: likesCount, + }, + isOwnProfile: locals.authStatus.user?.id === id, + }; + } catch (error) { + console.error("Failed to load user profile:", error); + throw redirect(404, "/"); + } +}; diff --git a/packages/frontend/src/routes/users/[id]/+page.svelte b/packages/frontend/src/routes/users/[id]/+page.svelte new file mode 100644 index 0000000..d3476dd --- /dev/null +++ b/packages/frontend/src/routes/users/[id]/+page.svelte @@ -0,0 +1,141 @@ + + + + +
+ + +
+ + + + +
+ + + {#if data.isOwnProfile} + + {/if} +
+ + +
+ +
+ {#if data.user.avatar} + {displayName} + {:else} +
+ + {displayName.charAt(0).toUpperCase()} + +
+ {/if} +
+ + +
+

{displayName}

+ +
+ + {$_("profile.member_since", { + values: { date: joinDate }, + })} +
+ + {#if data.user.location} +
+ + {data.user.location} +
+ {/if} + + {#if data.user.description} +

+ {data.user.description} +

+ {/if} + + +
+
+
+ {data.stats.comments_count} +
+
+ {$_("profile.comments")} +
+
+
+
+ {data.stats.likes_count} +
+
+ {$_("profile.likes")} +
+
+
+
+
+
+
+
+
diff --git a/packages/frontend/src/routes/videos/[slug]/+page.svelte b/packages/frontend/src/routes/videos/[slug]/+page.svelte index 2034e9c..b7a5a11 100644 --- a/packages/frontend/src/routes/videos/[slug]/+page.svelte +++ b/packages/frontend/src/routes/videos/[slug]/+page.svelte @@ -442,26 +442,28 @@ let showPlayer = $state(false);
{#each data.comments as comment}
- - - + - {getUserInitials(data.authStatus.user!.artist_name)} - - + + + {getUserInitials(comment.user_created.artist_name)} + + +
- {comment.user_created.artist_name}{comment.user_created.artist_name} {timeAgo.format(