Umbau zu location / companyLocation

This commit is contained in:
2024-08-07 19:00:34 +02:00
parent 1a77656d8a
commit 7df5d32cc4
29 changed files with 1229 additions and 2869 deletions

View File

@@ -56,6 +56,7 @@ const USStates = z.enum([
'CA',
'CO',
'CT',
'DC',
'DE',
'FL',
'GA',
@@ -111,7 +112,9 @@ export const LicensedInSchema = z.object({
});
export const GeoSchema = z.object({
city: z.string(),
state: z.string(),
state: z.string().refine(val => USStates.safeParse(val).success, {
message: 'Invalid state. Must be a valid 2-letter US state code.',
}),
latitude: z.number().refine(
value => {
return value >= -90 && value <= 90;
@@ -142,7 +145,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,
companyLocation: GeoSchema.optional().nullable(),
offeredServices: z.string().optional().nullable(),
areasServed: z.array(AreasServedSchema).optional().nullable(),
hasProfile: z.boolean().optional().nullable(),
@@ -226,13 +229,8 @@ export const BusinessListingSchema = z.object({
}),
title: z.string().min(10),
description: z.string().min(10),
city: z.string(),
state: z.string().refine(val => USStates.safeParse(val).success, {
message: 'Invalid state. Must be a valid 2-letter US state code.',
}),
zipCode: z.number().int().positive().optional().nullable(),
county: z.string().optional().nullable(),
price: z.number().positive().max(100000000),
location: GeoSchema,
price: z.number().positive().max(1000000000),
favoritesForUser: z.array(z.string()),
draft: z.boolean(),
listingsCategory: ListingsCategoryEnum,
@@ -251,24 +249,6 @@ export const BusinessListingSchema = z.object({
imageName: z.string().optional().nullable(),
created: z.date(),
updated: z.date(),
visits: z.number().int().positive().optional().nullable(),
lastVisit: z.date().optional().nullable(),
latitude: z.number().refine(
value => {
return value >= -90 && value <= 90;
},
{
message: 'Latitude muss zwischen -90 und 90 liegen',
},
),
longitude: z.number().refine(
value => {
return value >= -180 && value <= 180;
},
{
message: 'Longitude muss zwischen -180 und 180 liegen',
},
),
});
export type BusinessListing = z.infer<typeof BusinessListingSchema>;
@@ -277,44 +257,20 @@ export const CommercialPropertyListingSchema = z
id: z.string().uuid().optional().nullable(),
serialId: z.number().int().positive().optional().nullable(),
email: z.string().email(),
//type: PropertyTypeEnum.optional(),
type: z.string().refine(val => PropertyTypeEnum.safeParse(val).success, {
message: 'Invalid type. Must be one of: ' + PropertyTypeEnum.options.join(', '),
}),
title: z.string().min(10),
description: z.string().min(10),
city: z.string(), // You might want to add a custom validation for valid US cities
state: z.string().refine(val => USStates.safeParse(val).success, {
message: 'Invalid state. Must be a valid 2-letter US state code.',
}), // You might want to add a custom validation for valid US states
price: z.number().positive().max(100000000),
location: GeoSchema,
price: z.number().positive().max(1000000000),
favoritesForUser: z.array(z.string()),
listingsCategory: ListingsCategoryEnum,
draft: z.boolean(),
zipCode: z.number().int().positive().nullable().optional(), // You might want to add a custom validation for valid US zip codes
county: z.string().nullable().optional(), // You might want to add a custom validation for valid US counties
imageOrder: z.array(z.string()),
imagePath: z.string().nullable().optional(),
created: z.date(),
updated: z.date(),
visits: z.number().int().positive().nullable().optional(),
lastVisit: z.date().nullable().optional(),
latitude: z.number().refine(
value => {
return value >= -90 && value <= 90;
},
{
message: 'Latitude muss zwischen -90 und 90 liegen',
},
),
longitude: z.number().refine(
value => {
return value >= -180 && value <= 180;
},
{
message: 'Longitude muss zwischen -180 und 180 liegen',
},
),
})
.strict();