feat: implement Zod schemas for runtime validation across various components to enhance data integrity and error handling

This commit is contained in:
Anish Sarkar 2025-12-23 02:42:48 +05:30
parent 7ca490c740
commit 5fd872b798
6 changed files with 253 additions and 214 deletions

View file

@ -67,6 +67,8 @@ function ImageCancelledState({ src }: { src: string }) {
/**
* Parsed Image component with error handling
* Note: Image component has built-in click handling via href/src,
* so no additional responseActions needed.
*/
function ParsedImage({ result }: { result: unknown }) {
const image = parseSerializableImage(result);
@ -75,14 +77,6 @@ function ParsedImage({ result }: { result: unknown }) {
<Image
{...image}
maxWidth="420px"
responseActions={[
{ id: "open", label: "Open", variant: "default" },
]}
onResponseAction={(id) => {
if (id === "open" && image.src) {
window.open(image.src, "_blank", "noopener,noreferrer");
}
}}
/>
);
}