Skip to content

Commit

Permalink
lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Jul 22, 2024
1 parent aca7ca3 commit 9c414fe
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions app/src/pages/trace/SpanAnnotationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from "react";
import React, { useCallback, useRef } from "react";
import { Controller, useForm } from "react-hook-form";
import { css } from "@emotion/react";

Expand Down Expand Up @@ -41,20 +41,24 @@ export function SpanAnnotationForm(props: SpanAnnotationFormProps) {
});

// Internal onSubmit that performs validation
const _onSubmit = (data: AnnotationInterface) => {
if (!data.label && data.score === "") {
setError("label", {
type: "manual",
message: "Label or score is required",
});
setError("score", {
type: "manual",
message: "Label or score is required",
});
return;
}
onSubmit(data);
};
const _onSubmit = useCallback(
(data: AnnotationInterface) => {
if (!data.label && data.score === "") {
setError("label", {
type: "manual",
message: "Label or score is required",
});
setError("score", {
type: "manual",
message: "Label or score is required",
});
return;
}
onSubmit && onSubmit(data);
},
[onSubmit, setError]
);

return (
<form onSubmit={handleSubmit(_onSubmit)} ref={formRef}>
<View padding="size-200">
Expand Down

0 comments on commit 9c414fe

Please sign in to comment.