Skip to content

Commit aff6ce5

Browse files
committed
added id/shortcode to family/student,
1 parent e55fbcf commit aff6ce5

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
lines changed

app/components/Family.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div>
3+
<p class="text-center">ID: {{ family.id }}</p>
34
<CardDetails>
45
<strong>Parents:</strong>
56
<Student :student="family.parents[0]!" />
@@ -24,5 +25,5 @@
2425
</template>
2526

2627
<script setup lang="ts">
27-
const { family } = defineProps<{ family: IFamily}>();
28+
const { family } = defineProps<{ family: IFamily }>();
2829
</script>

app/components/Student.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const mildInterests = computed(() => {
3030
<CardTitle>
3131
<h3>{{ props.student.name }}</h3>
3232
</CardTitle>
33+
<CardText class="text-center">{{ props.student.shortcode }}</CardText>
3334
<CardText v-if="props.student.aboutMe" class="mt-2">
3435
<strong>About Me:</strong>
3536
{{ props.student.aboutMe }}

app/pages/admin.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ const filteredFamilies = ref<IFamily[]>(familyData.value);
2626
2727
async function setApiState(state: State) {
2828
try {
29-
if (!confirm('This will update the state of the website. Are you sure you want to do this?')) return;
29+
if (
30+
!confirm(
31+
'This will update the state of the website. Are you sure you want to do this?'
32+
)
33+
)
34+
return;
3035
await $fetch('/api/admin/state', {
3136
method: 'PUT',
3237
headers,
@@ -50,7 +55,10 @@ function filterFamilies() {
5055
family.parents.some(student =>
5156
student.shortcode.startsWith(search.value)
5257
) ||
53-
family.kids.some(student => student.shortcode.startsWith(search.value))
58+
family.kids.some(student =>
59+
student.shortcode.startsWith(search.value)
60+
) ||
61+
family.id == search.value
5462
);
5563
}
5664
}
@@ -89,6 +97,12 @@ definePageMeta({
8997
<b>Freshers who successfully completed survey:</b>
9098
{{ statsData.registered_freshers }}
9199
</p>
100+
<p>
101+
<b>Minimum to reasonably expect (all parents + all kids):</b> {{ statsData.families * 2 + statsData.registered_freshers }}
102+
</p>
103+
<p>
104+
<b>Maximum to unreasonably expect (all freshers + all parents)</b> {{ statsData.families * 2 + statsData.all_freshers }}
105+
</p>
92106
</div>
93107
</div>
94108
</Card>
@@ -116,7 +130,7 @@ definePageMeta({
116130
<CardTitle>All families</CardTitle>
117131
<input
118132
class="my-2"
119-
placeholder="search by shortcode"
133+
placeholder="search by shortcode or family ID"
120134
v-model="search"
121135
@input="filterFamilies" />
122136
<div v-for="family of filteredFamilies" class="m-1 border-4 p-1">

app/utils/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare const stateOptions = [
2121
declare type State = (typeof stateOptions)[number];
2222

2323
declare type IFamily = {
24+
id: number,
2425
parents: IStudent[],
2526
kids: IStudent[]
2627
}

hono/admin/admin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ export const admin = factory
289289
.get(
290290
'/all-families',
291291
grantAccessTo('admin'),
292-
// zValidator('json', z.object({ shortcode: z.string() })),
293292
async ctx => {
294293
// This differs from the allocations/all-families as this uses our sensible types.
295294
const parent1 = aliasedTable(students, 'parent1');
@@ -301,7 +300,7 @@ export const admin = factory
301300
.innerJoin(parent1, eq(marriages.parent1, parent1.shortcode))
302301
.innerJoin(parent2, eq(marriages.parent2, parent2.shortcode));
303302

304-
const familiesToRet = [] as { parents: Student[]; kids: Student[] }[];
303+
const familiesToRet = [] as { id: number, parents: Student[]; kids: Student[] }[];
305304

306305
for (const family of familiesAndParents) {
307306
const familyId = family.marriage.id;
@@ -322,6 +321,7 @@ export const admin = factory
322321
.innerJoin(students, eq(families.kid, students.shortcode));
323322

324323
familiesToRet.push({
324+
id: familyId,
325325
// @ts-ignore This is an issue with Drizzle aliasedTable.
326326
parents: [family.parent1, family.parent2],
327327
kids: kids

hono/family/family.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ export const family = factory
342342

343343
return ctx.json(
344344
{
345+
id: familyId,
345346
parents: [parent1[0], parent2[0]],
346347
kids: kids
347348
},

hono/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { string, type z } from 'zod';
1+
import { type z } from 'zod';
22
import type { selectStudentSchema } from './family/schema';
33

44
export const interestKeys = [

0 commit comments

Comments
 (0)