Skip to content

Commit

Permalink
refactor(report-schema): simplify isAlert field handling
Browse files Browse the repository at this point in the history
- Update isAlert to be a nullable boolean instead of a preprocessed value
- Streamline schema validation for better clarity and usability

(your code is so convoluted, even a GPS can't find its way through)
  • Loading branch information
tomer-shvadron committed Jan 14, 2025
1 parent 19fb361 commit 01c2c7b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 1 addition & 3 deletions apps/backoffice-v2/src/domains/business-reports/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ export const BusinessReportSchema = z
parentCompanyName: z.string().nullable(),
merchantId: z.string(),
workflowVersion: z.enum([MERCHANT_REPORT_VERSIONS[0]!, ...MERCHANT_REPORT_VERSIONS.slice(1)]),
isAlert: z
.preprocess(value => (typeof value === 'string' ? JSON.parse(value) : value), z.boolean())
.optional(),
isAlert: z.boolean().nullish(),
companyName: z.string().nullish(),
monitoringStatus: z.boolean(),
website: z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import * as errors from '@/errors';

const CreateReportResponseSchema = z.object({});

const ReportSchema = z.object({
id: z.string(),
websiteId: z.string(),
Expand All @@ -27,9 +28,7 @@ const ReportSchema = z.object({
})
.nullable(),
riskScore: z.number().nullable(),
isAlert: z
.preprocess(value => (typeof value === 'string' ? JSON.parse(value) : value), z.boolean())
.optional(),
isAlert: z.boolean().nullable(),
companyName: z.string().nullish(),
website: z.object({
id: z.string(),
Expand Down

0 comments on commit 01c2c7b

Please sign in to comment.