This commit is contained in:
2024-09-10 21:30:03 +02:00
parent 17213ba4b0
commit 83307684ee
25 changed files with 799 additions and 477 deletions

View File

@@ -144,6 +144,10 @@ export const GeoSchema = z.object({
message: 'Longitude muss zwischen -180 und 180 liegen',
},
),
county: z.string().optional().nullable(),
housenumber: z.string().optional().nullable(),
street: z.string().optional().nullable(),
zipCode: z.number().optional().nullable(),
});
const phoneRegex = /^(\+1|1)?[-.\s]?\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/;
export const UserSchema = z
@@ -157,7 +161,7 @@ export const UserSchema = z
companyName: z.string().optional().nullable(),
companyOverview: z.string().optional().nullable(),
companyWebsite: z.string().url({ message: 'Invalid URL format' }).optional().nullable(),
companyLocation: GeoSchema.optional().nullable(),
location: GeoSchema.optional().nullable(),
offeredServices: z.string().optional().nullable(),
areasServed: z.array(AreasServedSchema).optional().nullable(),
hasProfile: z.boolean().optional().nullable(),
@@ -213,7 +217,7 @@ export const UserSchema = z
});
}
if (!data.companyLocation) {
if (!data.location) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Company location is required for professional customers',

View File

@@ -233,6 +233,10 @@ export interface UploadParams {
export interface GeoResult {
id: number;
name: string;
street?: string;
housenumber?: string;
county?: string;
zipCode?: number;
state: string;
latitude: number;
longitude: number;
@@ -318,7 +322,7 @@ export function createDefaultUser(email: string, firstname: string, lastname: st
companyName: null,
companyOverview: null,
companyWebsite: null,
companyLocation: null,
location: null,
offeredServices: null,
areasServed: [],
hasProfile: false,

View File

@@ -70,3 +70,34 @@ export interface CountyRequest {
prefix: string;
states: string[];
}
export interface Address {
house_number: string;
road: string;
quarter: string;
suburb: string;
city: string;
county: string;
state: string;
ISO3166_2_lvl4: string;
postcode: string;
country: string;
country_code: string;
}
export interface Place {
place_id: number;
licence: string;
osm_type: string;
osm_id: number;
lat: string;
lon: string;
class: string;
type: string;
place_rank: number;
importance: number;
addresstype: string;
name: string;
display_name: string;
address: Address;
boundingbox: [string, string, string, string];
}