Skip to content

Commit

Permalink
refactor(components): use NuxtUI for elements instead of hand rolling
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnVonNeumann committed Nov 25, 2024
1 parent fd34d66 commit 5734c79
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
44 changes: 32 additions & 12 deletions frontend/components/AuthForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { useRouter } from 'vue-router'
const { state, validate, onSubmit } = useAuth()
const router = useRouter()
async function handleSubmit(event: Event) {
event.preventDefault()
async function handleSubmit(event: FormSubmitEvent<any>) {
const success = await onSubmit(event)
if (success) {
router.push('/dashboard')
Expand All @@ -15,20 +14,41 @@ async function handleSubmit(event: Event) {
</script>

<template>
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-2xl font-bold mb-4 text-gray-800">Login</h2>
<UForm :validate="validate" :state="state" class="space-y-4" @submit="handleSubmit">
<UFormGroup label="Email" name="email" class="text-gray-700">
<UInput v-model="state.email" class="border-gray-300" />
<UCard class="max-w-md mx-auto">
<UCardTitle class="text-2xl font-bold mb-4">Login</UCardTitle>
<UForm
:validate="validate"
:state="state"
class="space-y-4"
@submit="handleSubmit"
>
<UFormGroup label="Email" name="email">
<UInput
v-model="state.email"
color="primary"
variant="outline"
placeholder="Enter your email"
/>
</UFormGroup>

<UFormGroup label="Password" name="password" class="text-gray-700">
<UInput v-model="state.password" type="password" class="border-gray-300" />
<UFormGroup label="Password" name="password">
<UInput
v-model="state.password"
type="password"
color="primary"
variant="outline"
placeholder="Enter your password"
/>
</UFormGroup>

<UButton type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white">
Submit
<UButton
type="submit"
color="primary"
variant="solid"
block
>
Login
</UButton>
</UForm>
</div>
</UCard>
</template>
9 changes: 5 additions & 4 deletions frontend/components/FootprintList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const { footprints, fetchFootprints } = useFootprints()
</script>

<template>
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-2xl font-bold mb-4 text-gray-800">Footprints Dashboard</h2>
<UCard class="p-6">
<UCardTitle>Footprints Dashboard</UCardTitle>
<UButton
@click="fetchFootprints"
class="mb-4 bg-blue-600 hover:bg-blue-700 text-white"
class="mb-4"
color="primary"
>
Fetch Footprints
</UButton>
Expand All @@ -20,5 +21,5 @@ const { footprints, fetchFootprints } = useFootprints()
</li>
</ul>
<p v-else class="text-gray-700">No footprints data available. Click the button to fetch data.</p>
</div>
</UCard>
</template>
1 change: 0 additions & 1 deletion frontend/pages/dashboard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<section>
<p>This page will be displayed at the /about route.</p>
<FootprintList />
</section>
</template>

0 comments on commit 5734c79

Please sign in to comment.