Validierung Part II, neue Komponenten
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { sql } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
import { businesses, commercials, users } from './drizzle/schema.js';
|
||||
import { AreasServedSchema, CustomerSubTypeEnum, CustomerTypeEnum, GenderEnum, LicensedInSchema, User } from './models/db.model.js';
|
||||
export const EARTH_RADIUS_KM = 6371; // Erdradius in Kilometern
|
||||
export const EARTH_RADIUS_MILES = 3959; // Erdradius in Meilen
|
||||
|
||||
@@ -28,3 +30,33 @@ export const getDistanceQuery = (schema: typeof businesses | typeof commercials
|
||||
))
|
||||
`;
|
||||
};
|
||||
|
||||
export function toDrizzleUser(user: User): {
|
||||
email: string;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
phoneNumber?: string;
|
||||
description?: string;
|
||||
companyName?: string;
|
||||
companyOverview?: string;
|
||||
companyWebsite?: string;
|
||||
companyLocation?: string;
|
||||
offeredServices?: string;
|
||||
areasServed?: (typeof AreasServedSchema._type)[];
|
||||
hasProfile?: boolean;
|
||||
hasCompanyLogo?: boolean;
|
||||
licensedIn?: (typeof LicensedInSchema._type)[];
|
||||
gender?: z.infer<typeof GenderEnum>;
|
||||
customerType?: z.infer<typeof CustomerTypeEnum>;
|
||||
customerSubType?: z.infer<typeof CustomerSubTypeEnum>;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
} {
|
||||
const { id, created, updated, ...drizzleUser } = user;
|
||||
return {
|
||||
...drizzleUser,
|
||||
email: drizzleUser.email,
|
||||
firstname: drizzleUser.firstname,
|
||||
lastname: drizzleUser.lastname,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user