Skip to content

Commit

Permalink
added invalid json do not send marker
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Sep 6, 2023
1 parent 7318fc3 commit 46c7a4b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/utilities/CippCodeOffcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ function CippCodeOffCanvas({ row, state, hideFunction, type }) {
const [SaveTemplate, templateDetails] = useLazyGenericPostRequestQuery()
const currentTheme = useSelector((state) => state.app.currentTheme)
const [templateData, setFormData] = useState(row)
const [invalidJSON, setInvalid] = useState(false)

function handleEditorChange(value, event) {
setFormData(JSON.parse(value))
try {
setFormData(JSON.parse(value))
setInvalid(false)
} catch {
setInvalid(true)
}
}
return (
<>
Expand All @@ -37,6 +44,7 @@ function CippCodeOffCanvas({ row, state, hideFunction, type }) {
<CRow className="mb-3">
<CCol>
<CButton
disabled={invalidJSON}
onClick={() =>
SaveTemplate({
path: `/api/ExecEditTemplate?type=${type}`,
Expand Down

0 comments on commit 46c7a4b

Please sign in to comment.