From 51deb2ac657fd450eff775f4057d7b13126027b4 Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Sat, 26 Nov 2022 21:34:43 +0100 Subject: [PATCH 01/30] feat: Add getAll functionality for groups and members --- server/logic/group.ts | 12 ++++++++++++ server/logic/member.ts | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/server/logic/group.ts b/server/logic/group.ts index 2ee9c8c..0728ee9 100644 --- a/server/logic/group.ts +++ b/server/logic/group.ts @@ -66,6 +66,18 @@ export const get = async (id: string): Promise => { }); }; +/** + * Get all groups from the database. + * @returns The requested group if found, otherwise null. + */ +export const getAll = async (): Promise => { + return await prisma.group.findMany({ + include: { + contacts: true, + }, + }); +}; + /** * Delete group from the database. * @param id The id of the group diff --git a/server/logic/member.ts b/server/logic/member.ts index f34068f..95de0bd 100644 --- a/server/logic/member.ts +++ b/server/logic/member.ts @@ -66,6 +66,20 @@ export const get = async (id: string): Promise => { }); }; +/** + * Get all members from the database. + * @returns The requested member if found, otherwise null. + */ +export const getAll = async (): Promise => { + return await prisma.member.findMany({ + include: { + contacts: true, + studies: true, + memberships: true, + }, + }); +}; + /** * Delete member from the database. * @param id The id of the member. From 65be92d6695b6f37020027684da4e68f0eed443b Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Sat, 26 Nov 2022 21:36:21 +0100 Subject: [PATCH 02/30] feat: Add getAll endpoints for groups and members --- server/api/groups/index.get.ts | 5 +++++ server/api/members/index.get.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 server/api/groups/index.get.ts create mode 100644 server/api/members/index.get.ts diff --git a/server/api/groups/index.get.ts b/server/api/groups/index.get.ts new file mode 100644 index 0000000..1583fb2 --- /dev/null +++ b/server/api/groups/index.get.ts @@ -0,0 +1,5 @@ +import { group } from "~~/server/logic"; + +export default defineEventHandler(async () => { + return await group.getAll(); +}); diff --git a/server/api/members/index.get.ts b/server/api/members/index.get.ts new file mode 100644 index 0000000..094d1bb --- /dev/null +++ b/server/api/members/index.get.ts @@ -0,0 +1,5 @@ +import { member } from "~/server/logic"; + +export default defineEventHandler(async () => { + return await member.getAll(); +}); From 2a34a158e23b5d27fd2016189ed922910de52ee8 Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Thu, 8 Dec 2022 17:21:43 +0100 Subject: [PATCH 03/30] feat: table with all groups/members and group/member page --- .eslintrc.json | 1 + components/NavBar/NavBar.vue | 14 ++++--- components/SideMenu.vue | 38 ++++++++++++++++++ composables/useDateFormatter.ts | 13 ++++++ pages/groepen.vue | 18 +++++++++ pages/groepen/[id].vue | 47 ++++++++++++++++++++++ pages/groepen/mijn-groepen.vue | 37 +++++++++++++++++ pages/groepen/zoeken.vue | 63 +++++++++++++++++++++++++++++ pages/leden.vue | 28 +++++++++++++ pages/leden/zoeken.vue | 70 +++++++++++++++++++++++++++++++++ pages/me.vue | 64 ++++++++++++++++++++++++++++++ 11 files changed, 388 insertions(+), 5 deletions(-) create mode 100644 components/SideMenu.vue create mode 100644 composables/useDateFormatter.ts create mode 100644 pages/groepen.vue create mode 100644 pages/groepen/[id].vue create mode 100644 pages/groepen/mijn-groepen.vue create mode 100644 pages/groepen/zoeken.vue create mode 100644 pages/leden.vue create mode 100644 pages/leden/zoeken.vue create mode 100644 pages/me.vue diff --git a/.eslintrc.json b/.eslintrc.json index f06f524..0c4c3ba 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -31,6 +31,7 @@ "vue/no-multiple-template-root": "off", "vue/component-api-style": ["error", ["script-setup"]], "vue/define-emits-declaration": ["error", "type-based"], + "vue/no-v-for-template-key": "off", "vue/block-lang": [ "error", { diff --git a/components/NavBar/NavBar.vue b/components/NavBar/NavBar.vue index a18f674..afdfc13 100644 --- a/components/NavBar/NavBar.vue +++ b/components/NavBar/NavBar.vue @@ -57,28 +57,32 @@ const menuItems: MenuItem[] = [ }, ], }, - { name: "Foto's", icon: "material-symbols:camera", target: "/foto" }, + { + name: "Foto's", + icon: "material-symbols:camera", + target: "https://proteus-eretes.nl/fotos", + }, { name: "Leden", icon: "material-symbols:person", - target: "/lid", + target: "/leden", children: [ { name: "Groepen", icon: "material-symbols:group", - target: "/groups", + target: "/groepen", }, { name: "Lebberlijst", icon: "ph:graph", - target: "/lebberlijst", + target: "https://proteus-eretes.nl/lebberlijst", }, ], }, { name: "Evenementen", icon: "material-symbols:calendar-today", - target: "/event", + target: "https://proteus-eretes.nl/eetlijst", }, ]; diff --git a/components/SideMenu.vue b/components/SideMenu.vue new file mode 100644 index 0000000..34dd62e --- /dev/null +++ b/components/SideMenu.vue @@ -0,0 +1,38 @@ + + + diff --git a/composables/useDateFormatter.ts b/composables/useDateFormatter.ts new file mode 100644 index 0000000..7b4bb18 --- /dev/null +++ b/composables/useDateFormatter.ts @@ -0,0 +1,13 @@ +export const useDateFormatter = () => { + return function toDateString(dateTimeString?: string | Date): string { + if (!dateTimeString) return "-"; + const date = + typeof dateTimeString === "string" + ? new Date(dateTimeString) + : dateTimeString; + const day = date.getDate(); + const month = date.getMonth() + 1; + const year = date.getFullYear(); + return `${day}-${month}-${year}`; + }; +}; diff --git a/pages/groepen.vue b/pages/groepen.vue new file mode 100644 index 0000000..1a8a9b2 --- /dev/null +++ b/pages/groepen.vue @@ -0,0 +1,18 @@ + + + diff --git a/pages/groepen/[id].vue b/pages/groepen/[id].vue new file mode 100644 index 0000000..8f95ad2 --- /dev/null +++ b/pages/groepen/[id].vue @@ -0,0 +1,47 @@ + + + diff --git a/pages/groepen/mijn-groepen.vue b/pages/groepen/mijn-groepen.vue new file mode 100644 index 0000000..fddc611 --- /dev/null +++ b/pages/groepen/mijn-groepen.vue @@ -0,0 +1,37 @@ + + + diff --git a/pages/groepen/zoeken.vue b/pages/groepen/zoeken.vue new file mode 100644 index 0000000..684e4e2 --- /dev/null +++ b/pages/groepen/zoeken.vue @@ -0,0 +1,63 @@ + + + diff --git a/pages/leden.vue b/pages/leden.vue new file mode 100644 index 0000000..af35dfc --- /dev/null +++ b/pages/leden.vue @@ -0,0 +1,28 @@ + + + diff --git a/pages/leden/zoeken.vue b/pages/leden/zoeken.vue new file mode 100644 index 0000000..f9ace7a --- /dev/null +++ b/pages/leden/zoeken.vue @@ -0,0 +1,70 @@ + + + diff --git a/pages/me.vue b/pages/me.vue new file mode 100644 index 0000000..15bbdac --- /dev/null +++ b/pages/me.vue @@ -0,0 +1,64 @@ + + + From 3d2186ba5a9dedd693ca44f4eee726c08feec2dd Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Sat, 10 Dec 2022 14:43:37 +0100 Subject: [PATCH 04/30] fix(logic): remove wrong return types --- server/logic/contact.ts | 8 ++++---- server/logic/group.ts | 12 +++++------- server/logic/member.ts | 12 ++++++------ server/logic/membership.ts | 10 ++++------ server/logic/study.ts | 18 +++++++++--------- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/server/logic/contact.ts b/server/logic/contact.ts index 82307c9..9a47245 100644 --- a/server/logic/contact.ts +++ b/server/logic/contact.ts @@ -1,4 +1,4 @@ -import { Contact, ContactType } from "@prisma/client"; +import { ContactType } from "@prisma/client"; import { prisma } from "../prisma/client"; import { apiError } from "../utils"; @@ -15,7 +15,7 @@ export const create = async (data: { type: ContactType; memberId?: string; groupId?: string; -}): Promise => { +}) => { if (!data.memberId && !data.memberId) { throw apiError(ErrorCode.ValidationFailed, { message: "No memberId or groupId provided", @@ -47,7 +47,7 @@ export const update = async ( data: { value?: string; }, -): Promise => { +) => { return await prisma.contact.update({ where: { id }, data, @@ -58,6 +58,6 @@ export const update = async ( * Delete contact information from the database. * @returns The deleted contact information. */ -export const remove = async (id: string): Promise => { +export const remove = async (id: string) => { return await prisma.contact.delete({ where: { id } }); }; diff --git a/server/logic/group.ts b/server/logic/group.ts index 0728ee9..85cc5db 100644 --- a/server/logic/group.ts +++ b/server/logic/group.ts @@ -1,5 +1,3 @@ -import { Group } from "@prisma/client"; - import { prisma } from "../prisma/client"; import { apiError } from "../utils"; import { ErrorCode } from "../error"; @@ -15,7 +13,7 @@ export const create = async (data: { startDate?: string; stopDate?: string; parentId?: string; -}): Promise => { +}) => { if (data.parentId) { const parent = await get(data.parentId); @@ -45,7 +43,7 @@ export const update = async ( allowMembers?: boolean; allowSubgroups?: boolean; }, -): Promise => { +) => { return await prisma.group.update({ where: { id }, data, @@ -57,7 +55,7 @@ export const update = async ( * @param id The id of the group * @returns The requested group if found, otherwise null. */ -export const get = async (id: string): Promise => { +export const get = async (id: string) => { return await prisma.group.findUnique({ where: { id }, include: { @@ -70,7 +68,7 @@ export const get = async (id: string): Promise => { * Get all groups from the database. * @returns The requested group if found, otherwise null. */ -export const getAll = async (): Promise => { +export const getAll = async () => { return await prisma.group.findMany({ include: { contacts: true, @@ -83,6 +81,6 @@ export const getAll = async (): Promise => { * @param id The id of the group * @returns The deleted group. */ -export const remove = async (id: string): Promise => { +export const remove = async (id: string) => { return await prisma.group.delete({ where: { id } }); }; diff --git a/server/logic/member.ts b/server/logic/member.ts index 95de0bd..a561243 100644 --- a/server/logic/member.ts +++ b/server/logic/member.ts @@ -1,4 +1,4 @@ -import type { Member, NameTitle, Sex, Prisma } from "@prisma/client"; +import type { NameTitle, Sex, Prisma } from "@prisma/client"; import { prisma } from "../prisma/client"; @@ -21,7 +21,7 @@ export const create = async (data: { zipcode: string; country: string; contacts?: Prisma.ContactCreateWithoutMemberInput[]; -}): Promise => { +}) => { return await prisma.member.create({ data: { ...data, contacts: { create: data.contacts } }, }); @@ -43,7 +43,7 @@ export const update = async ( zipcode?: string; country?: string; }, -): Promise => { +) => { return await prisma.member.update({ where: { id }, data, @@ -55,7 +55,7 @@ export const update = async ( * @param id The id of the member. * @returns The requested member if found, otherwise null. */ -export const get = async (id: string): Promise => { +export const get = async (id: string) => { return await prisma.member.findUnique({ where: { id }, include: { @@ -70,7 +70,7 @@ export const get = async (id: string): Promise => { * Get all members from the database. * @returns The requested member if found, otherwise null. */ -export const getAll = async (): Promise => { +export const getAll = async () => { return await prisma.member.findMany({ include: { contacts: true, @@ -85,6 +85,6 @@ export const getAll = async (): Promise => { * @param id The id of the member. * @returns The deleted member. */ -export const remove = async (id: string): Promise => { +export const remove = async (id: string) => { return await prisma.member.delete({ where: { id } }); }; diff --git a/server/logic/membership.ts b/server/logic/membership.ts index e0a6df1..53c95e1 100644 --- a/server/logic/membership.ts +++ b/server/logic/membership.ts @@ -1,5 +1,3 @@ -import { Membership } from "@prisma/client"; - import { prisma } from "../prisma/client"; import { apiError } from "../utils"; import { ErrorCode } from "../error"; @@ -17,7 +15,7 @@ export const create = async (data: { isAdmin?: boolean; memberId: string; groupId: string; -}): Promise => { +}) => { if (data.memberId && !(await member.get(data.memberId))) { throw apiError(ErrorCode.NotFound, "Member not found!"); } @@ -44,7 +42,7 @@ export const update = async ( stopDate?: Date; isAdmin?: boolean; }, -): Promise => { +) => { return await prisma.membership.update({ where: { id }, data, @@ -56,7 +54,7 @@ export const update = async ( * @param id The id of the membership. * @returns The requested membership if found, otherwise null. */ -export const get = async (id: string): Promise => { +export const get = async (id: string) => { return await prisma.membership.findUnique({ where: { id } }); }; @@ -65,6 +63,6 @@ export const get = async (id: string): Promise => { * @param id The id of the membership. * @returns The deleted membership. */ -export const remove = async (id: string): Promise => { +export const remove = async (id: string) => { return await prisma.membership.delete({ where: { id } }); }; diff --git a/server/logic/study.ts b/server/logic/study.ts index 65f2d59..b04bb41 100644 --- a/server/logic/study.ts +++ b/server/logic/study.ts @@ -1,4 +1,4 @@ -import { MemberStudy, Study, StudyLevel, Institution } from "@prisma/client"; +import { StudyLevel, Institution } from "@prisma/client"; import { prisma } from "../prisma/client"; import { apiError } from "../utils"; @@ -13,7 +13,7 @@ export const createOption = async (data: { name: string; level: StudyLevel; institution: Institution; -}): Promise => { +}) => { return await prisma.study.create({ data, }); @@ -32,7 +32,7 @@ export const updateOption = async ( level?: StudyLevel; institution?: Institution; }, -): Promise => { +) => { return await prisma.study.update({ where: { id }, data, @@ -44,7 +44,7 @@ export const updateOption = async ( * @param id The id of the study. * @returns A study if found, otherwise null. */ -export const getOption = async (id: string): Promise => { +export const getOption = async (id: string) => { return await prisma.study.findUnique({ where: { id } }); }; @@ -52,7 +52,7 @@ export const getOption = async (id: string): Promise => { * Get all studies from the database. * @returns An array of studies. */ -export const getAllOptions = async (): Promise => { +export const getAllOptions = async () => { return await prisma.study.findMany(); }; @@ -60,7 +60,7 @@ export const getAllOptions = async (): Promise => { * Delete study from the database. * @returns The deleted study. */ -export const removeOption = async (id: string): Promise => { +export const removeOption = async (id: string) => { return await prisma.study.delete({ where: { id } }); }; @@ -75,7 +75,7 @@ export const create = async (data: { stopDate?: Date; memberId: string; studyId: string; -}): Promise => { +}) => { if (!(await getOption(data.studyId))) { throw apiError(ErrorCode.NotFound, "The study was not found!"); } @@ -98,7 +98,7 @@ export const update = async ( startDate?: Date; stopDate?: Date; }, -): Promise => { +) => { return await prisma.memberStudy.update({ where: { id }, data, @@ -109,6 +109,6 @@ export const update = async ( * Delete memberStudy from the database. * @returns The deleted memberStudy. */ -export const remove = async (id: string): Promise => { +export const remove = async (id: string) => { return await prisma.memberStudy.delete({ where: { id } }); }; From 5cc0ac888ca77c9c6560c04c922232ab8fec6fe9 Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Mon, 12 Dec 2022 16:09:15 +0100 Subject: [PATCH 05/30] feat: update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 198b005..f75828e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ yarn.lock .DS_Store .pnp.* .yarn +.idea From 8f7ad49f43169bf894b715e2138af50b851ecaa7 Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Mon, 12 Dec 2022 16:54:32 +0100 Subject: [PATCH 06/30] fix: lint and typecheck --- components/SideMenu.vue | 18 +++++++----------- pages/groepen.vue | 2 -- pages/leden.vue | 2 -- server/logic/member.ts | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/components/SideMenu.vue b/components/SideMenu.vue index 34dd62e..d76f223 100644 --- a/components/SideMenu.vue +++ b/components/SideMenu.vue @@ -1,16 +1,6 @@ diff --git a/pages/leden.vue b/pages/leden.vue index d9799e8..da16787 100644 --- a/pages/leden.vue +++ b/pages/leden.vue @@ -12,7 +12,7 @@ const notification = undefined; // Als je hier een nummer invult, dan krijg je e const items = [ { title: "Zoeken", to: "/leden/zoeken" }, - { title: "Mijn Profiel", to: "/me" }, + { title: "Mijn Profiel", to: "/leden/mijn-profiel" }, { title: "Administratie" }, { title: "Persoon toevoegen", to: "/leden/admin/toevoegen" }, { title: "Lidmaatschap toevoegen", to: "/leden/admin/lidmaatschappen" }, diff --git a/pages/leden/[id].vue b/pages/leden/[id].vue new file mode 100644 index 0000000..c841c9e --- /dev/null +++ b/pages/leden/[id].vue @@ -0,0 +1,67 @@ + + + diff --git a/pages/me.vue b/pages/leden/mijn-profiel.vue similarity index 86% rename from pages/me.vue rename to pages/leden/mijn-profiel.vue index 15bbdac..66760c2 100644 --- a/pages/me.vue +++ b/pages/leden/mijn-profiel.vue @@ -1,7 +1,5 @@ diff --git a/pages/leden/[id]/gegevens.vue b/pages/leden/[id]/gegevens.vue index 16864d3..e52c072 100644 --- a/pages/leden/[id]/gegevens.vue +++ b/pages/leden/[id]/gegevens.vue @@ -116,10 +116,14 @@ diff --git a/pages/leden/[id]/instellingen.vue b/pages/leden/[id]/instellingen.vue index bb7f2d4..8b829a9 100644 --- a/pages/leden/[id]/instellingen.vue +++ b/pages/leden/[id]/instellingen.vue @@ -8,7 +8,13 @@ diff --git a/pages/leden/[id]/profiel.vue b/pages/leden/[id]/profiel.vue index 9ba8fc2..2280952 100644 --- a/pages/leden/[id]/profiel.vue +++ b/pages/leden/[id]/profiel.vue @@ -53,9 +53,15 @@ diff --git a/pages/leden/[id]/studies.vue b/pages/leden/[id]/studies.vue index 1dcc09c..e301dc1 100644 --- a/pages/leden/[id]/studies.vue +++ b/pages/leden/[id]/studies.vue @@ -8,7 +8,13 @@ diff --git a/pages/leden/zoeken.vue b/pages/leden/zoeken.vue index 206873e..d852b49 100644 --- a/pages/leden/zoeken.vue +++ b/pages/leden/zoeken.vue @@ -5,7 +5,9 @@ type="search" placeholder="Zoeken…" class="input input-bordered w-full" - @input="filter = $event.target.value.toLowerCase()" + @input=" + filter = ($event.target as HTMLTextAreaElement).value.toLowerCase() + " /> From 7fd947807f7a2c92ce48b9f58c6f7c5c74026b0e Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Fri, 16 Dec 2022 16:38:11 +0100 Subject: [PATCH 25/30] fix: additional typecheck / codestyle --- pages/leden/[id]/contact.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/leden/[id]/contact.vue b/pages/leden/[id]/contact.vue index 8394efe..4484221 100644 --- a/pages/leden/[id]/contact.vue +++ b/pages/leden/[id]/contact.vue @@ -8,9 +8,13 @@ From 67feb8143fe7f989cddbb6c47535f71263667f6f Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Mon, 19 Dec 2022 16:06:13 +0100 Subject: [PATCH 26/30] fix: apply requested changes --- .eslintrc.json | 16 ++++-- components/Breadcrumbs.vue | 18 +++++++ components/Input/Date.vue | 69 ------------------------ components/Input/Text.vue | 5 +- components/NavBar/Search.vue | 2 +- components/Page/Material/TypesCreate.vue | 1 + components/SideMenu.vue | 35 ------------ components/TwoColumn.vue | 32 ++++++++++- composables/useDateFormatter.ts | 40 +++++++++----- middleware/validateRouteUUID.global.ts | 8 ++- package.json | 2 +- pages/groepen.vue | 10 ++-- pages/groepen/[id]/instellingen.vue | 45 +++++++++++----- pages/groepen/[id]/overzicht.vue | 26 ++++----- pages/groepen/[id]/toevoegen.vue | 8 ++- pages/groepen/mijn-groepen.vue | 6 +-- pages/groepen/nieuw.vue | 8 ++- pages/groepen/zoeken.vue | 4 +- pages/leden.vue | 15 +++--- pages/leden/[id]/contact.vue | 23 +++++--- pages/leden/[id]/gegevens.vue | 33 +++++++++--- pages/leden/[id]/groepen.vue | 23 +++++--- pages/leden/[id]/instellingen.vue | 23 +++++--- pages/leden/[id]/profiel.vue | 17 ++++-- pages/leden/[id]/studies.vue | 23 +++++--- pages/leden/toevoegen.vue | 12 ++++- pages/leden/zoeken.vue | 4 +- server/logic/group.ts | 7 +++ server/prisma/seed/testdata/group.json | 2 +- server/validation/group.ts | 2 +- 30 files changed, 304 insertions(+), 215 deletions(-) create mode 100644 components/Breadcrumbs.vue delete mode 100644 components/Input/Date.vue delete mode 100644 components/SideMenu.vue diff --git a/.eslintrc.json b/.eslintrc.json index 3fad6f3..82b1cad 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,12 @@ { "root": true, - "ignorePatterns": ["dist/**", ".output/**", ".nuxt/**", "dockerdata/**"], + "ignorePatterns": [ + "dist/**", + ".output/**", + ".nuxt/**", + "dockerdata/**", + "node_modules/**" + ], "extends": [ "eslint:recommended", "plugin:json/recommended", @@ -9,7 +15,11 @@ "@nuxtjs/eslint-config-typescript", "plugin:prettier/recommended" ], - "plugins": ["json", "nuxt", "@typescript-eslint"], + "plugins": [ + "json", + "nuxt", + "@typescript-eslint" + ], "parser": "vue-eslint-parser", "parserOptions": { "ecmaVersion": "latest", @@ -37,6 +47,7 @@ "*~/server/logic", "*~/server/prisma", "*~/server/sync", + "*~/server/types", "*~/server/validation", "*~/server/utils", "*~/utils/*" @@ -48,7 +59,6 @@ "vue/no-multiple-template-root": "off", "vue/component-api-style": ["error", ["script-setup"]], "vue/define-emits-declaration": ["error", "type-based"], - "vue/no-v-for-template-key": "off", "import/order": [ "warn", { diff --git a/components/Breadcrumbs.vue b/components/Breadcrumbs.vue new file mode 100644 index 0000000..d0877b2 --- /dev/null +++ b/components/Breadcrumbs.vue @@ -0,0 +1,18 @@ + + + diff --git a/components/Input/Date.vue b/components/Input/Date.vue deleted file mode 100644 index 2241cc1..0000000 --- a/components/Input/Date.vue +++ /dev/null @@ -1,69 +0,0 @@ - - - diff --git a/components/Input/Text.vue b/components/Input/Text.vue index f283742..5ed3cbe 100644 --- a/components/Input/Text.vue +++ b/components/Input/Text.vue @@ -5,7 +5,7 @@ * interface Props { modelValue?: string; + type: "text" | "search" | "date"; title?: string; error?: string; - placeholder: string; + placeholder?: string; size?: "xs" | "sm" | "md" | "lg"; color?: | "primary" diff --git a/components/NavBar/Search.vue b/components/NavBar/Search.vue index 60e9077..aa23d67 100644 --- a/components/NavBar/Search.vue +++ b/components/NavBar/Search.vue @@ -1,6 +1,6 @@ - - diff --git a/components/TwoColumn.vue b/components/TwoColumn.vue index 9b0c76e..3e1937b 100644 --- a/components/TwoColumn.vue +++ b/components/TwoColumn.vue @@ -8,7 +8,24 @@ {{ title }}
- +
@@ -19,7 +36,20 @@ diff --git a/composables/useDateFormatter.ts b/composables/useDateFormatter.ts index 0c551bd..31685c6 100644 --- a/composables/useDateFormatter.ts +++ b/composables/useDateFormatter.ts @@ -1,15 +1,31 @@ export const useDateFormatter = () => { - return function toDateString( - dateTimeString: string | Date | undefined | null, - ): string { - if (!dateTimeString) return "-"; - const date = - typeof dateTimeString === "string" - ? new Date(dateTimeString) - : dateTimeString; - const day = date.getDate(); - const month = date.getMonth() + 1; - const year = date.getFullYear(); - return `${day}-${month}-${year}`; + const dateToString = (date?: Date) => + computed(() => { + if (!date) return "-"; + const day = date.getDate(); + const month = date.getMonth() + 1; + const year = date.getFullYear(); + return `${day}-${month}-${year}`; + }); + + const ISOToString = (date?: string) => + computed(() => { + if (!date) return "-"; + const day = date.slice(8, 10); + const month = date.slice(5, 7); + const year = date.slice(0, 4); + return `${day}-${month}-${year}`; + }); + + const ISOToDateInputString = (date?: string) => + computed(() => { + if (!date) return ""; + return date.slice(0, 10); + }); + + return { + dateToString, + ISOToString, + ISOToDateInputString, }; }; diff --git a/middleware/validateRouteUUID.global.ts b/middleware/validateRouteUUID.global.ts index a5be4e4..c0950b4 100644 --- a/middleware/validateRouteUUID.global.ts +++ b/middleware/validateRouteUUID.global.ts @@ -1,7 +1,13 @@ import validator from "validator"; export default defineNuxtRouteMiddleware((to) => { - if (to.params.id && !validator.isUUID(to.params.id as string)) { + if (!to.params.id) { + return true; + } + + if (typeof to.params.id !== "string") { return false; } + + return validator.isUUID(to.params.id); }); diff --git a/package.json b/package.json index 75097df..7c0afd7 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "vue-eslint-parser": "^9.1.0" }, "dependencies": { - "@sidebase/nuxt-auth": "^0.3.0-alpha.1", + "@sidebase/nuxt-auth": "^0.3.0", "daisyui": "^2.38.0", "superstruct": "^1.0.3", "validator": "^13.7.0" diff --git a/pages/groepen.vue b/pages/groepen.vue index e3abc71..11bfcd6 100644 --- a/pages/groepen.vue +++ b/pages/groepen.vue @@ -1,21 +1,17 @@ diff --git a/pages/groepen/[id]/overzicht.vue b/pages/groepen/[id]/overzicht.vue index e259b46..586a100 100644 --- a/pages/groepen/[id]/overzicht.vue +++ b/pages/groepen/[id]/overzicht.vue @@ -19,11 +19,11 @@
- + - + -

+

Leden

-
+
Sinds{{ dateFormatter(group.startDate) }}{{ ISOToString(group.startDate) }}
Tot{{ dateFormatter(group.stopDate) }}{{ ISOToString(group.stopDate) }}
@@ -68,20 +65,17 @@ > - +
{{ member.id }} {{ member.function }}{{ dateFormatter(member.startDate) }}{{ ISOToString(member.startDate) }} {{ member.isAdmin ? "Beheerder" : "Lid" }}
-

+

Subgroepen

-
+
@@ -100,8 +94,8 @@ > - - + +
{{ child.name }} {{ child.description }}{{ dateFormatter(child.startDate) }}{{ dateFormatter(child.stopDate) }}{{ ISOToString(child.startDate) }}{{ ISOToString(child.stopDate) }}
@@ -111,7 +105,7 @@ diff --git a/pages/groepen/mijn-groepen.vue b/pages/groepen/mijn-groepen.vue index 1249b2d..4d906eb 100644 --- a/pages/groepen/mijn-groepen.vue +++ b/pages/groepen/mijn-groepen.vue @@ -27,8 +27,8 @@ > {{ membership.group.name }} {{ membership.function }} - {{ dateFormatter(membership.startDate) }} - {{ dateFormatter(membership.stopDate) }} + {{ ISOToString(membership.startDate) }} + {{ ISOToString(membership.stopDate) }} @@ -36,7 +36,7 @@ diff --git a/pages/leden/[id]/gegevens.vue b/pages/leden/[id]/gegevens.vue index e52c072..fe32a6d 100644 --- a/pages/leden/[id]/gegevens.vue +++ b/pages/leden/[id]/gegevens.vue @@ -1,14 +1,11 @@