added working profile page. set up settings page

This commit is contained in:
Edward Tirado Jr 2025-07-08 00:37:10 -05:00
parent d1f51177b3
commit bfed1c892a
6 changed files with 55 additions and 50 deletions

View file

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { logout } from "~/composables/logout"; import { logout } from "~/composables/logout";
const isAuthenticated = ref(false);
let isOpened = ref(false); let isOpened = ref(false);
const menuRef = ref<HTMLElement>(); const menuRef = ref<HTMLElement>();
@ -51,9 +50,11 @@ onMounted(() => {
<li role="none"> <li role="none">
<NuxtLink class="menu-link" to="/user/profile"> Profile</NuxtLink> <NuxtLink class="menu-link" to="/user/profile"> Profile</NuxtLink>
</li> </li>
<!--
<li role="none"> <li role="none">
<NuxtLink class="menu-link" to="/user/settings"> Settings</NuxtLink> <NuxtLink class="menu-link" to="/user/settings"> Settings</NuxtLink>
</li> </li>
-->
<li <li
id="logout" id="logout"
class="menu-link" class="menu-link"

View file

@ -2,7 +2,7 @@
<div <div
class="grid grid-rows-2 text-center sm:text-left sm:grid-rows-none sm:grid-cols-2 my-5 navbar w-full" class="grid grid-rows-2 text-center sm:text-left sm:grid-rows-none sm:grid-cols-2 my-5 navbar w-full"
> >
<NuxtLink class="block" to="/admin"> <NuxtLink class="block" to="/">
<h1 class="block site-title bloodseeker">Cinema Corona</h1> <h1 class="block site-title bloodseeker">Cinema Corona</h1>
</NuxtLink> </NuxtLink>
@ -15,17 +15,17 @@
<li> <li>
<NuxtLink class="text-xl header-link" to="/schedule">Schedule</NuxtLink> <NuxtLink class="text-xl header-link" to="/schedule">Schedule</NuxtLink>
</li> </li>
<li> <li v-if="authenticated">
<ProfileMenu /> <ProfileMenu />
</li> </li>
</ul> </ul>
</div> </div>
</template> </template>
<script> <script lang="ts" setup>
export default { import { hasToken } from "~/composables/hasToken";
name: "navbar",
}; const authenticated = computed(() => hasToken());
</script> </script>
<style scoped></style> <style scoped></style>

View file

@ -0,0 +1,6 @@
import { useCookie } from "#app";
export function hasToken() {
const token = useCookie("token").value;
return token !== null && token !== undefined && token !== "";
}

View file

@ -17,10 +17,3 @@ export function logout() {
}) })
.catch((err) => console.log(err)); .catch((err) => console.log(err));
} }
onMounted(() => {
const token = useCookie("token").value;
if (!token) {
navigateTo("/");
}
});

View file

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useCookie } from "#app"; import { useCookie } from "#app";
import type { UserProfile } from "~/types/user_profile"; import type { UserProfile } from "~/types/userProfile";
const config = useRuntimeConfig(); const config = useRuntimeConfig();
@ -29,49 +29,54 @@ const getProfile = async function () {
const formatDate = function (date_string: string) { const formatDate = function (date_string: string) {
return new Date(date_string).toLocaleDateString(); return new Date(date_string).toLocaleDateString();
} };
onMounted(getProfile); onMounted(getProfile);
</script> </script>
<template> <template>
<h2 class="page-header">Profile</h2> <LoadingIcon v-if="loading" show-quote="true" />
<div id="profile-card" class="movie-card neon-border"> <div v-else>
<div id="user-data"> <h2 class="page-header">Profile</h2>
<div id="profile-picture"> <div id="profile-card" class="movie-card neon-border">
<img <div id="user-data">
alt="profile image" <div id="profile-picture">
class="user-icon neon-border" <img
src="https://placecage.lucidinternets.com/g/200/200" alt="profile image"
/> class="user-icon neon-border"
</div> src="https://placecage.lucidinternets.com/g/200/200"
<ul class="profile-details"> />
<li class="user-detail"> </div>
<label for="name">Name</label> <ul class="profile-details">
<span id="name">{{profile?.name || profile?.username}}</span> <li class="user-detail">
</li> <label for="name">Name</label>
<li class="user-detail"> <span id="name">{{ profile?.name || profile?.username }}</span>
<label for="username">Username</label> </li>
<span id="username">{{ profile?.username }}@movienight.social</span> <li class="user-detail">
</li> <label for="username">Username</label>
<li class="user-detail"> <span id="username">{{ profile?.username }}@movienight.social</span>
<label for="date-joined">Date Joined</label> </li>
<span id="date-joined">{{ formatDate(profile?.date_joined || "") }}</span> <li class="user-detail">
</li> <label for="date-joined">Date Joined</label>
</ul> <span id="date-joined">{{
</div> formatDate(profile?.date_joined || "")
}}</span>
<hr class="neon-border my-5" />
<div id="extra-fields">
<div id="movielists">
<h3 class="section-header">Lists</h3>
<ul id="movielist-list">
<li v-for="list in profile?.lists">
<NuxtLink :to="`/lists/${list.id}`">{{ list.name }}</NuxtLink>
</li> </li>
</ul> </ul>
</div> </div>
<hr class="neon-border my-5" />
<div id="extra-fields">
<div id="movielists">
<h3 class="section-header">Lists</h3>
<ul id="movielist-list">
<li v-for="list in profile?.lists">
<NuxtLink :to="`/lists/${list.id}`">{{ list.name }}</NuxtLink>
</li>
</ul>
</div>
</div>
</div> </div>
</div> </div>
</template> </template>