Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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: 0 additions & 1 deletion .ncurc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
if (
(name === "@types/node" &&
parseInt(upgradedVersionSemver?.major, 10) >= 22) ||
(name === "zod" && parseInt(upgradedVersionSemver?.major, 10) >= 4) ||
(name === "@hookform/resolvers" &&
parseInt(upgradedVersionSemver?.major, 10) >= 4)
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
"swr": "^2.4.0",
"ts-invariant": "^0.10.3",
"type-fest": "^5.4.4",
"zod": "^3.25.76"
"zod": "^4.0.5"
},
"devDependencies": {
"@hookform/resolvers": "^3.10.0",
"@hookform/resolvers": "^5.1.1",
"@phosphor-icons/react": "v2.1.10",
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/postcss": "^4.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type { ResourceAddressProps } from "./ResourceAddress"

const zodRequiredField = z
.string({
required_error: "Required field",
invalid_type_error: "Invalid format",
error: (iss) =>
iss.input === undefined ? "Required field" : "Invalid format",
})
.min(1, {
message: "Required field",
Expand All @@ -37,12 +37,19 @@ export const getResourceAddressFormFieldsSchema = ({
state_code: zodRequiredField,
country_code: zodRequiredField,
phone: zodRequiredField,
billing_info: requiresBillingInfo
? zodRequiredField
: z.string().nullish(),
billing_info: z.string().nullish(),
notes: z.string().nullish(),
})
.superRefine((data, ctx) => {
if (requiresBillingInfo) {
if (data.billing_info == null || data.billing_info.length === 0) {
ctx.addIssue({
code: "custom",
path: ["billing_info"],
message: t("common.forms.required_field"),
})
}
}
if (data.business === true) {
if (data.company == null || data.company.length === 0) {
ctx.addIssue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function adaptFormValuesToSdk<
if (predicateWhitelist.includes(key)) {
return {
...acc,
[key]: formValues[key],
[key]: formValues[key] ?? undefined,
}
}

Expand All @@ -80,7 +80,8 @@ export function adaptFormValuesToSdk<
) {
return {
...acc,
[key]: instructionItem.sdk.parseFormValue(formValues[key]),
[key]:
instructionItem.sdk.parseFormValue(formValues[key]) ?? undefined,
}
}

Expand All @@ -90,7 +91,7 @@ export function adaptFormValuesToSdk<
) {
return {
...acc,
[key]: castArray(formValues[key]).join(","),
[key]: castArray(formValues[key]).join(",") ?? undefined,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const timeRangeValidationSchema = z
timeTo: z.date().optional().nullable(),
timePreset: z.enum(filterableTimeRangePreset).optional().nullable(),
})
.passthrough()
.superRefine((data, ctx) => {
if (data.timePreset === "custom" && data.timeFrom == null) {
ctx.addIssue({
Expand All @@ -125,7 +124,9 @@ export const timeRangeValidationSchema = z
data.timeFrom > data.timeTo
) {
ctx.addIssue({
code: "invalid_date",
code: "invalid_type",
expected: "date",
input: data.timeTo,
path: ["timeTo"],
message: 'The "To" date must be greater than the "From" date',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ export const filterableTimeRangePreset = [
] as const

export type UiFilterName = string
export type UiFilterValue = string | string[] | boolean | Date | undefined
export type UiFilterValue =
| string
| string[]
| boolean
| Date
| undefined
| null

export type TimeRangePreset = (typeof filterableTimeRangePreset)[number]

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"typescript": "~5.9.3",
"vite": "^7.3.1",
"vite-tsconfig-paths": "^5.1.4",
"zod": "^3.25.76"
"zod": "^4.0.5"
},
"msw": {
"workerDirectory": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ export const ReuseTheAddressForm: StoryFn = () => {
z.object({
name: z
.string({
required_error: "Required field",
invalid_type_error: "Invalid format",
error: (iss) =>
iss.input === undefined ? "Required field" : "Invalid format",
})
.min(1, {
message: "Required field",
Expand Down Expand Up @@ -228,8 +228,8 @@ export const ShowNameOrCompany: StoryFn = () => {
z.object({
name: z
.string({
required_error: "Required field",
invalid_type_error: "Invalid format",
error: (iss) =>
iss.input === undefined ? "Required field" : "Invalid format",
})
.min(1, {
message: "Required field",
Expand Down
Loading
Loading