Skip to content

Commit

Permalink
fix: family page returning 500 and conditionally show link to family …
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
cybercoder-naj committed Sep 29, 2024
1 parent 2b93f37 commit 51b60dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/pages/family.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script setup lang="ts">
const headers = useRequestHeaders();
// TODO specify the type of data
const { data, status, error } = useFetch<any>('/api/family/myFamily', {
headers
});
definePageMeta({
middleware: ['require-auth']
});
throw Error('Not implemented');
</script>

<template>
Expand All @@ -29,7 +28,7 @@ throw Error('Not implemented');

<div v-if="!data.kids.length">
You currently have 0 kids assigned. Return to this page soon to see
more information about your kids
more information about your kids.
</div>
<div v-else>
<Student
Expand Down
21 changes: 17 additions & 4 deletions app/pages/portal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const { currentState } = useAppState();
definePageMeta({
middleware: ['require-auth']
});
const { status } = useFetch('/api/family/myFamily', {
immediate: false
});
</script>

<template>
Expand All @@ -31,7 +35,7 @@ definePageMeta({
to start sending proposals.
</CardText>
<div v-else>
<Student :student="currentUser!"/>
<Student :student="currentUser!" />
<CardText>
Visit the
<NuxtLink to="/proposals">proposals page</NuxtLink>
Expand All @@ -53,11 +57,14 @@ definePageMeta({
</CardDetails>
<CardDetails v-else>
<strong>Parent's survey & proposals. [CLOSED]</strong>
<CardText>
<CardText v-if="status == 'success'">
Visit your
<NuxtLink to="/family">family page</NuxtLink>
to see your family details.
</CardText>
<CardText v-else-if="status == 'error'">
Sorry, we could not fetch your family details. Please try again.
</CardText>
</CardDetails>
</div>
<div v-else-if="currentState == 'freshers_open'">
Expand All @@ -71,11 +78,14 @@ definePageMeta({
</CardDetails>
<CardDetails v-else>
<strong>Parent's survey & proposals. [CLOSED]</strong>
<CardText>
<CardText v-if="status == 'success'">
Visit your
<NuxtLink to="/family">family page</NuxtLink>
to see your family details.
</CardText>
<CardText v-else-if="status == 'error'">
Sorry, we could not fetch your family details. Please try again.
</CardText>
</CardDetails>
</div>
<div v-else-if="currentState == 'closed'">
Expand All @@ -88,11 +98,14 @@ definePageMeta({
}}
[CLOSED]
</strong>
<CardText>
<CardText v-if="status == 'success'">
Visit your
<NuxtLink to="/family">family page</NuxtLink>
to see your family details.
</CardText>
<CardText v-else-if="status == 'error'">
Sorry, we could not fetch your family details. Please try again.
</CardText>
</CardDetails>
</div>
</div>
Expand Down

0 comments on commit 51b60dd

Please sign in to comment.