Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/viewCharactersPage #24

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion components/SideMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,26 @@ const slideover = useSlideover();
class="flex p-2 ml-2 gap-2 hover:bg-green-400 hover:text-black hover:cursor-pointer"
>
<UIcon
name="material-symbols:person-book"
name="material-symbols:add-box"
class="w-5 h-5 mt-1 ml-4"
/>
<p class="text-lg">Create a Character</p>
</div>
</NuxtLink>
</li>
<li>
<NuxtLink to="/view-characters" @click="slideover.close">
<div
class="flex p-2 ml-2 gap-2 hover:bg-green-400 hover:text-black hover:cursor-pointer"
>
<UIcon
name="material-symbols:folder-open-rounded"
class="w-5 h-5 mt-1 ml-4"
/>
<p class="text-lg">View Characters</p>
</div>
</NuxtLink>
</li>
<li>
<div
class="flex p-2 ml-2 gap-2 hover:bg-green-400 hover:text-black hover:cursor-pointer"
Expand Down
49 changes: 49 additions & 0 deletions components/View-Character.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<script setup lang="ts">
type Character = {
uuid: string;
campaignUuid: string;
creatorUuid: string;
ownerUuid: string;
firstName: string;
lastName: string;
race: string;
class: string;
age: number;
height: number;
weight: number;
eyeColor: string;
skinColor: string;
hairColor: string;
ruleset: string;
created: {
time: string;
valid: boolean;
};
lastUpdated: null | string;
};

type Props = {
character: Character;
};

const { character } = defineProps<Props>();
</script>

<template>
<UCard>
<template #header>
<h3 class="text-xl capitalize">{{ character.firstName || "none" }}</h3>
</template>
<div class="flex gap-2">
<UIcon name="heroicons:user-group-solid" class="w-5 h-5" />
<p class="capitalize">Race: {{ character.race || "none" }}</p>
</div>
<div class="flex gap-2">
<UIcon name="material-symbols-light:book-2-rounded" class="w-5 h-5" />
<p class="capitalize">Class: {{ character.class || "none" }}</p>
</div>
<template #footer>
<UButton block>View Details</UButton>
</template>
</UCard>
</template>
70 changes: 70 additions & 0 deletions pages/view-characters.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<script setup lang="ts">
type Character = {
uuid: string;
campaignUuid: string;
creatorUuid: string;
ownerUuid: string;
firstName: string;
lastName: string;
race: string;
class: string;
age: number;
height: number;
weight: number;
eyeColor: string;
skinColor: string;
hairColor: string;
ruleset: string;
created: {
time: string;
valid: boolean;
};
lastUpdated: null | string;
};

type ApiResponse = {
data: {
characters: Character;
};
message: string;
status: number;
statusText: string;
timestamp: string;
};

definePageMeta({
middleware: "fresh-token",
});
const config = useRuntimeConfig();
const authStore = useAuthStore();

const { data: apiResponse } = await useFetch<ApiResponse>(
"/account/owned-characters",
{
baseURL: config.public.baseURL,
headers: {
Authorization: `Bearer ${authStore.token}`,
"Content-Type": "application/json",
},
},
);

const characters = computed(() => apiResponse.value?.data.characters ?? []);
</script>

<template>
<div>
<h2 class="text-5xl text-center p-2 mb-4">Characters</h2>
<div
v-if="characters.length > 0"
class="grid gap-6 mb-6 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
>
<ViewCharacter
v-for="character in characters"
:key="character.uuid"
:character="character"
/>
</div>
<p v-else>No characters found.</p>
</div>
</template>
Loading