validatedCity, mask for input, confirmatonService, Version Info,
This commit is contained in:
@@ -109,8 +109,27 @@ export const LicensedInSchema = z.object({
|
||||
registerNo: z.string().nonempty('Registration number is required'),
|
||||
state: z.string().nonempty('State is required'),
|
||||
});
|
||||
|
||||
const phoneRegex = /^\+1 \(\d{3}\) \d{3}-\d{4}$/;
|
||||
export const GeoSchema = z.object({
|
||||
city: z.string(),
|
||||
state: z.string(),
|
||||
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',
|
||||
},
|
||||
),
|
||||
});
|
||||
const phoneRegex = /^\(\d{3}\)\s\d{3}-\d{4}$/;
|
||||
|
||||
export const UserSchema = z
|
||||
.object({
|
||||
@@ -123,7 +142,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: z.string().optional().nullable(),
|
||||
companyLocation: GeoSchema,
|
||||
offeredServices: z.string().optional().nullable(),
|
||||
areasServed: z.array(AreasServedSchema).optional().nullable(),
|
||||
hasProfile: z.boolean().optional().nullable(),
|
||||
@@ -134,8 +153,6 @@ export const UserSchema = z
|
||||
customerSubType: CustomerSubTypeEnum.optional().nullable(),
|
||||
created: z.date().optional().nullable(),
|
||||
updated: z.date().optional().nullable(),
|
||||
latitude: z.number().optional().nullable(),
|
||||
longitude: z.number().optional().nullable(),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
if (data.customerType === 'professional') {
|
||||
@@ -150,7 +167,7 @@ export const UserSchema = z
|
||||
if (!data.phoneNumber || !phoneRegex.test(data.phoneNumber)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Phone number is required and must be in US format (+1 (XXX) XXX-XXXX) for professional customers',
|
||||
message: 'Phone number is required and must be in US format (XXX) XXX-XXXX for professional customers',
|
||||
path: ['phoneNumber'],
|
||||
});
|
||||
}
|
||||
@@ -236,8 +253,22 @@ export const BusinessListingSchema = z.object({
|
||||
updated: z.date(),
|
||||
visits: z.number().int().positive().optional().nullable(),
|
||||
lastVisit: z.date().optional().nullable(),
|
||||
latitude: z.number().optional().nullable(),
|
||||
longitude: z.number().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>;
|
||||
|
||||
@@ -268,8 +299,22 @@ export const CommercialPropertyListingSchema = z
|
||||
updated: z.date(),
|
||||
visits: z.number().int().positive().nullable().optional(),
|
||||
lastVisit: z.date().nullable().optional(),
|
||||
latitude: z.number().nullable().optional(),
|
||||
longitude: z.number().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();
|
||||
|
||||
|
||||
@@ -228,13 +228,15 @@ export interface GeoResult {
|
||||
id: number;
|
||||
city: string;
|
||||
state: string;
|
||||
state_code: string;
|
||||
// state_code: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
export interface CityAndStateResult {
|
||||
id: number;
|
||||
name: string;
|
||||
type: string;
|
||||
state_code: string;
|
||||
state: string;
|
||||
}
|
||||
export interface CountyResult {
|
||||
id: number;
|
||||
|
||||
@@ -18,8 +18,8 @@ export interface Geo {
|
||||
nationality: string;
|
||||
timezones: Timezone[];
|
||||
translations: Translations;
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
emoji: string;
|
||||
emojiU: string;
|
||||
states: State[];
|
||||
@@ -28,16 +28,16 @@ export interface State {
|
||||
id: number;
|
||||
name: string;
|
||||
state_code: string;
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
type: string;
|
||||
cities: City[];
|
||||
}
|
||||
export interface City {
|
||||
id: number;
|
||||
name: string;
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
export interface Translations {
|
||||
kr: string;
|
||||
|
||||
Reference in New Issue
Block a user