Skip to content

Commit

Permalink
add warning box
Browse files Browse the repository at this point in the history
  • Loading branch information
JamalAlabdullah committed Nov 4, 2024
1 parent 5a3082b commit 4fa4fa8
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
StudioCombobox,
StudioDeleteButton,
StudioDivider,
StudioError,
StudioParagraph,
StudioTextfield,
} from '@studio/components';
Expand Down Expand Up @@ -40,6 +41,7 @@ export const EditColumnElement = ({
const [tableColumn, setTableColumn] = useState(sourceColumn);
const { data: formLayouts } = useFormLayoutsQuery(org, app, subformLayout);
const { data: textResources } = useTextResourcesQuery(org, app);
const [showError, setShowError] = useState(false);

const textKeyValue = textResourceByLanguageAndIdSelector(
'nb',
Expand All @@ -55,12 +57,14 @@ export const EditColumnElement = ({
const selectedComponentId = values[0];
const selectedComponent = components.find((comp) => comp.id === selectedComponentId);

const selectedComponentTitle = selectedComponent.textResourceBindings?.title;
const updatedTableColumn = {
...sourceColumn,
headerContent: selectedComponent.textResourceBindings?.title,
headerContent: selectedComponentTitle,
cellContent: { query: selectedComponent.dataModelBindings?.simpleBinding },
};
setTableColumn(updatedTableColumn);
setShowError(!selectedComponentTitle);
};

return (
Expand All @@ -71,6 +75,7 @@ export const EditColumnElement = ({
components={components}
onSelectComponent={selectComponent}
/>
{showError && <StudioError>{'Ledetekst er tomt'}</StudioError>}
<StudioTextfield
label={
<>
Expand Down

0 comments on commit 4fa4fa8

Please sign in to comment.