Show pending account invites and polish sign editor recovery
This commit is contained in:
@@ -8,3 +8,12 @@ test("saved designs reject unsafe assets, invalid settings, and embedded runtime
|
||||
expect(savedSignSchema.safeParse({ ...design, ...patch }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
test("custom paper dimensions enforce print limits in inches and millimeters", () => {
|
||||
const base = { title: "Event", headline: "Share", message: "Welcome", paper: "custom", ink: "indigo" };
|
||||
expect(savedSignSchema.safeParse({ ...base, unit: "mm", customWidth: 152.4, customHeight: 101.6 }).success).toBe(true);
|
||||
expect(savedSignSchema.safeParse({ ...base, customWidth: 6, customHeight: 4 }).success).toBe(true);
|
||||
for (const [customWidth, customHeight] of [[2, 4], [49, 40], [3, 48]]) {
|
||||
expect(savedSignSchema.safeParse({ ...base, customWidth, customHeight }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,10 +23,21 @@ export const savedSignSchema = z.object({
|
||||
message: z.string().trim().min(1).max(120),
|
||||
paper: z.enum(papers),
|
||||
ink: z.enum(["indigo", "black"]), layout: z.enum(["photo", "typography", "compact"]).optional(),
|
||||
customWidth: z.number().finite().positive().optional(), customHeight: z.number().finite().positive().optional(),
|
||||
customWidth: z.number().finite().optional(), customHeight: z.number().finite().optional(),
|
||||
unit: z.enum(["in", "mm"]).optional(), background: z.string().regex(/^#[a-f0-9]{6}$/i).optional(),
|
||||
accent: z.string().regex(/^#[a-f0-9]{6}$/i).optional(), font: z.enum(["funnel", "inter", "geologica"]).optional(),
|
||||
decoration: z.enum(["arch", "frame", "minimal"]).optional(), showBrand: z.boolean().optional(),
|
||||
backgroundImage: image, logoImage: image,
|
||||
}).strict();
|
||||
}).strict().superRefine((design, ctx) => {
|
||||
if (design.paper !== "custom") return;
|
||||
const divisor = design.unit === "mm" ? 25.4 : 1;
|
||||
const width = (design.customWidth ?? 8.5) / divisor;
|
||||
const height = (design.customHeight ?? 11) / divisor;
|
||||
if (width < 3 || width > 48 || height < 3 || height > 48) {
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["customWidth"], message: "Choose dimensions between 3 and 48 inches (76.2–1219.2 mm)." });
|
||||
}
|
||||
if (Math.max(width / height, height / width) > 2.5) {
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["customHeight"], message: "Keep the long edge within 2.5 times the short edge." });
|
||||
}
|
||||
});
|
||||
export type SavedSign = z.infer<typeof savedSignSchema>;
|
||||
|
||||
Reference in New Issue
Block a user