diff --git a/src/command/communicationTypeCommand.ts b/src/command/communicationTypeCommand.ts index 992ef1c..fdc686e 100644 --- a/src/command/communicationTypeCommand.ts +++ b/src/command/communicationTypeCommand.ts @@ -1,12 +1,14 @@ +import { CommunicationFieldType } from "../type/fieldTypes"; + export interface CreateCommunicationTypeCommand { type: string; - useColumns: Array; + useColumns: Array; } export interface UpdateCommunicationTypeCommand { id: number; type: string; - useColumns: Array; + useColumns: Array; } export interface DeleteCommunicationTypeCommand { diff --git a/src/controller/admin/memberController.ts b/src/controller/admin/memberController.ts index 0f1ea37..71b349b 100644 --- a/src/controller/admin/memberController.ts +++ b/src/controller/admin/memberController.ts @@ -116,6 +116,12 @@ export async function getCommunicationsByMember(req: Request, res: Response): Pr * @returns {Promise<*>} */ export async function createMember(req: Request, res: Response): Promise { + const salutation = req.body.salutation; + const firstname = req.body.firstname; + const lastname = req.body.lastname; + const nameaffix = req.body.nameaffix; + const birthdate = req.body.birthdate; + res.status(200).send(0); } @@ -187,6 +193,11 @@ export async function addCommunicationToMember(req: Request, res: Response): Pro */ export async function updateMemberById(req: Request, res: Response): Promise { const memberId = parseInt(req.params.id); + const salutation = req.body.salutation; + const firstname = req.body.firstname; + const lastname = req.body.lastname; + const nameaffix = req.body.nameaffix; + const birthdate = req.body.birthdate; res.sendStatus(204); } diff --git a/src/entity/communicationType.ts b/src/entity/communicationType.ts index c40d20b..c9161df 100644 --- a/src/entity/communicationType.ts +++ b/src/entity/communicationType.ts @@ -1,5 +1,6 @@ import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm"; import { communication } from "./communication"; +import { CommunicationFieldType, communicationFieldTypes } from "../type/fieldTypes"; @Entity() export class communicationType { @@ -14,15 +15,15 @@ export class communicationType { length: 255, default: "", transformer: { - from(value: string): Array { - return (value ?? "").split(","); + from(value: string): Array { + return communicationFieldTypes.filter((e) => value?.includes(e)); }, - to(value: Array): string { - return (value ?? []).join(","); + to(value: Array): string { + return value.filter((e) => communicationFieldTypes.includes(e)).join(","); }, }, }) - useColumns: Array; + useColumns: Array; @OneToMany(() => communication, (communication) => communication.type) communications: communication[]; diff --git a/src/type/fieldTypes.ts b/src/type/fieldTypes.ts new file mode 100644 index 0000000..934d24d --- /dev/null +++ b/src/type/fieldTypes.ts @@ -0,0 +1,10 @@ +export type CommunicationFieldType = "mobile" | "email" | "city" | "street" | "streetNumber" | "streetNumberAddition"; + +export const communicationFieldTypes: Array = [ + "mobile", + "email", + "city", + "street", + "streetNumber", + "streetNumberAddition", +]; diff --git a/src/viewmodel/admin/communicationType.models.ts b/src/viewmodel/admin/communicationType.models.ts index ac46507..845b555 100644 --- a/src/viewmodel/admin/communicationType.models.ts +++ b/src/viewmodel/admin/communicationType.models.ts @@ -1,5 +1,7 @@ +import { CommunicationFieldType } from "../../type/fieldTypes"; + export interface CommunicationTypeViewModel { id: number; type: string; - fields: Array; + fields: Array; }