Skip to content

Commit c2c8908

Browse files
committed
fix: set empty comment to null
1 parent 9aefeac commit c2c8908

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

frontend/src/core/observations/ObservationAssessment.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
const ObservationAssessment = () => {
3737
const observation = useRecordContext();
3838
const dialogRef = useRef<HTMLDivElement>(null);
39-
const [comment, setComment] = useState("");
39+
const [comment, setComment] = useState<string | null>("");
4040
const [open, setOpen] = useState(false);
4141
const [status, setStatus] = useState(observation?.current_status);
4242
const justificationEnabled = justificationIsEnabledForStatus(status);
@@ -45,6 +45,9 @@ const ObservationAssessment = () => {
4545
const notify = useNotify();
4646

4747
const observationUpdate = async (data: any) => {
48+
if (comment === "") {
49+
setComment(null);
50+
}
4851
const patch = {
4952
severity: data.current_severity,
5053
status: data.current_status,

frontend/src/core/observations/ObservationBulkAssessment.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type ObservationBulkAssessmentButtonProps = {
4343

4444
const ObservationBulkAssessment = ({ product, storeKey }: ObservationBulkAssessmentButtonProps) => {
4545
const dialogRef = useRef<HTMLDivElement>(null);
46-
const [comment, setComment] = useState("");
46+
const [comment, setComment] = useState<string | null>("");
4747
const [open, setOpen] = useState(false);
4848
const [status, setStatus] = useState(OBSERVATION_STATUS_OPEN);
4949
const justificationEnabled = justificationIsEnabledForStatus(status);
@@ -62,6 +62,9 @@ const ObservationBulkAssessment = ({ product, storeKey }: ObservationBulkAssessm
6262
} else {
6363
url = window.__RUNTIME_CONFIG__.API_BASE_URL + "/observations/bulk_assessment/";
6464
}
65+
if (comment === "") {
66+
setComment(null);
67+
}
6568
const assessment_data = {
6669
severity: data.current_severity,
6770
status: data.current_status,

0 commit comments

Comments
 (0)