communication type typing

This commit is contained in:
Julian Krauser 2024-09-18 09:43:02 +02:00
parent f673dec5fa
commit 72c47ba212
5 changed files with 34 additions and 8 deletions

View file

@ -1,12 +1,14 @@
import { CommunicationFieldType } from "../type/fieldTypes";
export interface CreateCommunicationTypeCommand {
type: string;
useColumns: Array<string>;
useColumns: Array<CommunicationFieldType>;
}
export interface UpdateCommunicationTypeCommand {
id: number;
type: string;
useColumns: Array<string>;
useColumns: Array<CommunicationFieldType>;
}
export interface DeleteCommunicationTypeCommand {

View file

@ -116,6 +116,12 @@ export async function getCommunicationsByMember(req: Request, res: Response): Pr
* @returns {Promise<*>}
*/
export async function createMember(req: Request, res: Response): Promise<any> {
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<any> {
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);
}

View file

@ -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<string> {
return (value ?? "").split(",");
from(value: string): Array<CommunicationFieldType> {
return communicationFieldTypes.filter((e) => value?.includes(e));
},
to(value: Array<string>): string {
return (value ?? []).join(",");
to(value: Array<CommunicationFieldType>): string {
return value.filter((e) => communicationFieldTypes.includes(e)).join(",");
},
},
})
useColumns: Array<string>;
useColumns: Array<CommunicationFieldType>;
@OneToMany(() => communication, (communication) => communication.type)
communications: communication[];

10
src/type/fieldTypes.ts Normal file
View file

@ -0,0 +1,10 @@
export type CommunicationFieldType = "mobile" | "email" | "city" | "street" | "streetNumber" | "streetNumberAddition";
export const communicationFieldTypes: Array<CommunicationFieldType> = [
"mobile",
"email",
"city",
"street",
"streetNumber",
"streetNumberAddition",
];

View file

@ -1,5 +1,7 @@
import { CommunicationFieldType } from "../../type/fieldTypes";
export interface CommunicationTypeViewModel {
id: number;
type: string;
fields: Array<string>;
fields: Array<CommunicationFieldType>;
}