Migrate frontend to Nuxt 4 and Nuxt UI

- Upgrade to Nuxt 4 (sources under app/), add @nuxt/ui, Tailwind v4 and
  Lucide icons; drop @nuxtjs/tailwindcss
- Replace the custom Yale* components, Modal, Navbar and icon components with
  UButton/UInput/UModal/UTable/UCard/UHeader/UBadge/UAlert and toasts
- Add dark/light mode toggle and a logout button
- Add a useApi composable: central base URL/credentials, JSON-encoded bodies,
  error handling, and redirect to login when the session expires
- Fix modal listener leak, missing People heading, unhandled fetch errors and
  login redirect for already-authenticated users
- Make the code and people tables fit on phone screens
- Retake README screenshots
This commit is contained in:
LiamPietralla committed 2026-11-16 12:23:31 +11:00
1 parent d0425c8cb2
commit a9bef7b50d
22 files changed
+4732 -3472

No files matched your search

+51 -57
View File
@@ -1,67 +1,61 @@
<script setup lang='ts'>
import { ref } from 'vue';
import { type ApiResponse } from '~/types/api-response';
<script setup lang="ts">
const api = useApi()
const authenticated = useCookie<boolean>('authenticated')
const password = ref('');
const passwordError = ref('');
const authenticated = useCookie<boolean>('authenticated');
const runtimeConfig = useRuntimeConfig();
const password = ref('')
const showPassword = ref(false)
const error = ref('')
const loading = ref(false)
const handleLogin = async (event: Event) => {
// Prevent default form submission
event.preventDefault();
// Reset the error
passwordError.value = '';
const handleLogin = async () => {
error.value = ''
loading.value = true
// Send a request to the api to login
const response = await fetch(`${runtimeConfig.public.apiBaseUrl}/api/Authentication/login`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
body: `"${password.value}"`
});
const response = await api.post<boolean>('/api/Authentication/login', password.value)
loading.value = false
// Parse the response
const apiResponse = await response.json() as ApiResponse<boolean>;
if (apiResponse.success) {
// If the response was successful, login and redirect to the home page
authenticated.value = true;
navigateTo('/');
} else {
// Otherwise, set the error
passwordError.value = apiResponse.error ?? 'Unknown error';
}
if (response.success) {
authenticated.value = true
await navigateTo('/')
} else {
error.value = response.error ?? 'Unknown error'
}
}
</script>
<template>
<div class="bg-zinc-800 text-slate-300 text-center w-full md:w-96 rounded-md">
<h1 class="text-7xl mt-5">Yale</h1>
<div>
<h4 class="hr text-2xl mt-3">User Access</h4>
</div>
<UCard class="w-full md:w-96">
<template #header>
<div class="text-center">
<h1 class="text-5xl font-bold">Yale</h1>
<p class="text-muted mt-1">User Access</p>
</div>
</template>
<form @submit="handleLogin">
<YaleFormInput type="password" v-model="password" placeholder="Password" class="block mt-10 w-5/6 mx-auto" />
<p class="mt-3 w-5/6 mx-auto text-red-600" v-if="passwordError">{{ passwordError }}</p>
<YaleButton type="submit" class="mb-8 mt-3 w-5/6 mx-auto ">Login</YaleButton>
</form>
</div>
<UForm :state="{ password }" class="space-y-4" @submit="handleLogin">
<UFormField name="password" :error="error || undefined">
<UInput
v-model="password"
:type="showPassword ? 'text' : 'password'"
placeholder="Password"
autocomplete="current-password"
class="w-full"
autofocus
>
<template #trailing>
<UButton
color="neutral"
variant="link"
size="sm"
:icon="showPassword ? 'i-lucide-eye-off' : 'i-lucide-eye'"
:aria-label="showPassword ? 'Hide password' : 'Show password'"
@click="showPassword = !showPassword"
/>
</template>
</UInput>
</UFormField>
<UButton type="submit" block :loading="loading" :disabled="!password">Login</UButton>
</UForm>
</UCard>
</template>
<style>
.hr {
display: inline-block;
}
.hr::after {
content: '';
display: block;
border-top: 2px solid theme('colors.slate.300');
margin-top: .1rem;
}
</style>