From 983099069b081dbb3a2e764447fec384bb69e2b1 Mon Sep 17 00:00:00 2001 From: Pier Dolique Date: Sat, 23 Nov 2024 23:40:36 +0200 Subject: [PATCH] Account page Fixes #96 --- app/components/IconTitle.vue | 44 +++++++++ app/components/PageHeader.vue | 7 ++ app/components/PerdCard.vue | 14 +++ app/pages/account.vue | 148 +++++++++++++++++++++++++++++ app/pages/index.vue | 17 +--- server/api/account/index.delete.ts | 15 +++ server/database/schema.ts | 2 +- 7 files changed, 233 insertions(+), 14 deletions(-) create mode 100644 app/components/IconTitle.vue create mode 100644 app/components/PerdCard.vue create mode 100644 app/pages/account.vue create mode 100644 server/api/account/index.delete.ts diff --git a/app/components/IconTitle.vue b/app/components/IconTitle.vue new file mode 100644 index 0000000..ab2ff7e --- /dev/null +++ b/app/components/IconTitle.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/app/components/PageHeader.vue b/app/components/PageHeader.vue index 97ac976..7ce8abf 100644 --- a/app/components/PageHeader.vue +++ b/app/components/PageHeader.vue @@ -26,6 +26,13 @@ + + Account + + +
+ +
+ + + diff --git a/app/pages/account.vue b/app/pages/account.vue new file mode 100644 index 0000000..1fd0268 --- /dev/null +++ b/app/pages/account.vue @@ -0,0 +1,148 @@ + + + + + diff --git a/app/pages/index.vue b/app/pages/index.vue index 72eb43d..2feba6b 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -1,12 +1,6 @@ @@ -14,15 +8,12 @@ definePageMeta({ layout: 'page' }) - - const { user } = useUserStore() diff --git a/server/api/account/index.delete.ts b/server/api/account/index.delete.ts new file mode 100644 index 0000000..12646a5 --- /dev/null +++ b/server/api/account/index.delete.ts @@ -0,0 +1,15 @@ +import { and, eq } from 'drizzle-orm' + +export default defineEventHandler(async (event) => { + const userId = await validateSessionUser(event) + + await event.context.db + .delete(tables.users) + .where( + and( + eq(tables.users.id, userId) + ) + ) + + setResponseStatus(event, 204) +}) diff --git a/server/database/schema.ts b/server/database/schema.ts index 0760318..05d0e10 100644 --- a/server/database/schema.ts +++ b/server/database/schema.ts @@ -281,7 +281,7 @@ export const equipment = pgTable('equipment', { check( 'equipment_description_check', sql.raw(`char_length(description) <= ${limits.maxEquipmentDescriptionLength}`) - ), + ) ]) /**