Add event list feature (009-list-events)
Enable users to see all their saved events on the home screen, sorted by date with upcoming events first. Key capabilities: - EventCard with title, relative time display, and organizer/attendee role badge - Sortable EventList with past-event visual distinction (faded style) - Empty state when no events are stored - Swipe-to-delete gesture with confirmation dialog - Floating action button for quick event creation - Rename router param :token → :eventToken across all views - useRelativeTime composable (Intl.RelativeTimeFormat) - useEventStorage: add validation, removeEvent(), reactive versioning - Full E2E and unit test coverage for all new components Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -215,7 +215,7 @@ async function handleSubmit() {
|
||||
expiryDate: data.expiryDate,
|
||||
})
|
||||
|
||||
router.push({ name: 'event', params: { token: data.eventToken } })
|
||||
router.push({ name: 'event', params: { eventToken: data.eventToken } })
|
||||
}
|
||||
} catch {
|
||||
submitting.value = false
|
||||
|
||||
@@ -131,7 +131,7 @@ async function fetchEvent() {
|
||||
|
||||
try {
|
||||
const { data, error, response } = await api.GET('/events/{token}', {
|
||||
params: { path: { token: route.params.token as string } },
|
||||
params: { path: { token: route.params.eventToken as string } },
|
||||
})
|
||||
|
||||
if (error) {
|
||||
@@ -173,7 +173,7 @@ async function submitRsvp() {
|
||||
|
||||
try {
|
||||
const { data, error } = await api.POST('/events/{token}/rsvps', {
|
||||
params: { path: { token: route.params.token as string } },
|
||||
params: { path: { token: route.params.eventToken as string } },
|
||||
body: { name: nameInput.value },
|
||||
})
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const route = useRoute()
|
||||
const copyState = ref<'idle' | 'copied' | 'failed'>('idle')
|
||||
|
||||
const eventUrl = computed(() => {
|
||||
return window.location.origin + '/events/' + route.params.token
|
||||
return window.location.origin + '/events/' + route.params.eventToken
|
||||
})
|
||||
|
||||
const copyLabel = computed(() => {
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
<template>
|
||||
<main class="home">
|
||||
<h1 class="home__title">fete</h1>
|
||||
<p class="home__subtitle">No events yet.<br />Create your first one!</p>
|
||||
<RouterLink to="/create" class="btn-primary home__cta">+ Create Event</RouterLink>
|
||||
<template v-if="events.length > 0">
|
||||
<EventList />
|
||||
<CreateEventFab />
|
||||
</template>
|
||||
<template v-else>
|
||||
<EmptyState />
|
||||
</template>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { RouterLink } from 'vue-router'
|
||||
import { computed } from 'vue'
|
||||
import { useEventStorage, isValidStoredEvent } from '../composables/useEventStorage'
|
||||
import EventList from '../components/EventList.vue'
|
||||
import EmptyState from '../components/EmptyState.vue'
|
||||
import CreateEventFab from '../components/CreateEventFab.vue'
|
||||
|
||||
const { getStoredEvents } = useEventStorage()
|
||||
|
||||
const events = computed(() => getStoredEvents().filter(isValidStoredEvent))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -15,27 +28,15 @@ import { RouterLink } from 'vue-router'
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing-lg);
|
||||
text-align: center;
|
||||
padding-top: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.home__title {
|
||||
font-size: 2rem;
|
||||
font-weight: 800;
|
||||
color: var(--color-text-on-gradient);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.home__subtitle {
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
color: var(--color-text-on-gradient);
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.home__cta {
|
||||
margin-top: var(--spacing-md);
|
||||
max-width: 280px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -25,7 +25,7 @@ function createTestRouter() {
|
||||
routes: [
|
||||
{ path: '/', name: 'home', component: { template: '<div />' } },
|
||||
{ path: '/create', name: 'create-event', component: EventCreateView },
|
||||
{ path: '/events/:token', name: 'event', component: { template: '<div />' } },
|
||||
{ path: '/events/:eventToken', name: 'event', component: { template: '<div />' } },
|
||||
],
|
||||
})
|
||||
}
|
||||
@@ -169,6 +169,7 @@ describe('EventCreateView', () => {
|
||||
getOrganizerToken: vi.fn(),
|
||||
saveRsvp: vi.fn(),
|
||||
getRsvp: vi.fn(),
|
||||
removeEvent: vi.fn(),
|
||||
})
|
||||
|
||||
vi.mocked(api.POST).mockResolvedValueOnce({
|
||||
@@ -221,7 +222,7 @@ describe('EventCreateView', () => {
|
||||
|
||||
expect(pushSpy).toHaveBeenCalledWith({
|
||||
name: 'event',
|
||||
params: { token: 'abc-123' },
|
||||
params: { eventToken: 'abc-123' },
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ vi.mock('@/composables/useEventStorage', () => ({
|
||||
getOrganizerToken: mockGetOrganizerToken,
|
||||
saveRsvp: mockSaveRsvp,
|
||||
getRsvp: mockGetRsvp,
|
||||
removeEvent: vi.fn(),
|
||||
})),
|
||||
}))
|
||||
|
||||
@@ -30,7 +31,7 @@ function createTestRouter(_token?: string) {
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/', name: 'home', component: { template: '<div />' } },
|
||||
{ path: '/events/:token', name: 'event', component: EventDetailView },
|
||||
{ path: '/events/:eventToken', name: 'event', component: EventDetailView },
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ function createTestRouter() {
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/', name: 'home', component: { template: '<div />' } },
|
||||
{ path: '/events/:token', name: 'event', component: EventStubView },
|
||||
{ path: '/events/:eventToken', name: 'event', component: EventStubView },
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user