Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.idea/
log
.DS_Store
backend/tmp/

.vscode/
5 changes: 5 additions & 0 deletions backend/src/modules/location-address/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ export class LocationAddressService implements ILocationAddressService {
const transformedPayload = await Promise.all(
payload.map(async (element) => {
const currFips = await this.locationMatcher.getLocationFips(element);
if (!currFips || currFips.fipsStateCode === null || currFips.fipsCountyCode === null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add this to the createLocationAddress method in this file for single creation? That way we see a good error in the business profile page? You may also have to modify the createLocation method in frontend/api/location.ts

throw Boom.badRequest(
`Please enter a valid address. Unable to validate address: ${element.streetAddress}, ${element.city}, ${element.stateProvince}.`
);
}
return { ...element, ...currFips };
})
);
Expand Down
10 changes: 5 additions & 5 deletions backend/src/types/Location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const LocationAddressSchema = z.object({
city: z.string(),
streetAddress: z.string(),
postalCode: z.string().nonempty().regex(/^\d+$/, {
message: "Must be a non-negative number string",
message: "Please enter a valid Postal Code. Must be a non-negative number.",
}),
county: z.string().optional(),
companyId: z.uuid(),
Expand All @@ -29,7 +29,7 @@ export const LocationAddressSchemaType = z.object({
city: z.string(),
streetAddress: z.string(),
postalCode: z.string().nonempty().regex(/^\d+$/, {
message: "Must be a non-negative number string",
message: "Please enter a valid Postal Code. Must be a non-negative number.",
}),
county: z.string().optional(),
companyId: z.uuid(),
Expand All @@ -45,7 +45,7 @@ export const CreateLocationAddressSchema = z.object({
city: z.string().nonempty(),
streetAddress: z.string().nonempty(),
postalCode: z.string().nonempty().regex(/^\d+$/, {
message: "Must be a non-negative number string",
message: "Please enter a valid Postal Code. Must be a non-negative number.",
}),
county: z.string().nonempty().optional(),
});
Expand All @@ -72,7 +72,7 @@ export const GetAllLocationAddressesSchema = z.array(
city: z.string().nonempty(),
streetAddress: z.string().nonempty(),
postalCode: z.string().nonempty().regex(/^\d+$/, {
message: "Must be a non-negative number string",
message: "Please enter a valid Postal Code. Must be a non-negative number.",
}),
county: z.string().nonempty().optional(),
companyId: z.uuid(),
Expand All @@ -93,7 +93,7 @@ export const UpdateLocationAddressDTOSchema = z.object({
postalCode: z
.string()
.regex(/^\d+$/, {
message: "Must be a non-negative number string",
message: "Please enter a valid Postal Code. Must be a non-negative number.",
})
.optional(),
county: z.string().optional().nullable(),
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utilities/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const withServiceErrorHandling = <T extends any[], R>(handler: (...args:
case "23502":
throw Boom.badRequest("Missing required field");
default:
throw Boom.internal(error, { message: "An expected error occured" });
throw Boom.internal(error, { message: "An unexpected error occured" });
}
} else {
throw Boom.boomify(error);
Expand Down
8 changes: 7 additions & 1 deletion frontend/api/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ export const createLocationBulk = async (payload: CreateLocationBulkRequest): Pr
if (response.ok) {
return data!;
} else {
throw Error(error?.error);
const apiError = new Error(error?.error || "Failed to create locations - Unkown Error") as Error & {
status: number;
statusText: string;
};
apiError.status = response.status;
apiError.statusText = response.statusText;
throw apiError;
}
};
return authWrapper<Location[]>()(req);
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/signup/company.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export default function Company({ handleNext: incrementNext }: CompanyInfoProps)
incrementNext();
},
onError: (_error: Error) => {
setLocError("Error creating locations. Check required fields and try again");
const errorMessage = _error.message || "Error creating locations. Check required fields and try again";
setLocError(errorMessage);
},
});

Expand Down
Loading