Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 16c1469

Browse files
committed
fix: cant save new top level space
1 parent 558e36c commit 16c1469

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

apps/admin-ui/src/spa/unit/space/ParentSelector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export function ParentSelector({
108108
error: errorText,
109109
assistive: helperText,
110110
}}
111-
required
112111
disabled={options.length === 0}
113112
clearable={false}
114113
options={hdsOptions}

apps/admin-ui/src/spa/unit/space/SpaceEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ function SpaceEditor({ space, unit }: Props): JSX.Element {
4242

4343
const { t } = useTranslation();
4444

45-
const [updateSpaceMutation, { loading: isMutationLoading }] =
46-
useUpdateSpaceMutation();
45+
const [mutation, { loading: isMutationLoading }] = useUpdateSpaceMutation();
4746

4847
const updateSpace = (input: SpaceUpdateMutationInput) =>
49-
updateSpaceMutation({ variables: { input } });
48+
mutation({ variables: { input } });
5049

5150
const {
5251
data,
@@ -110,14 +109,15 @@ function SpaceEditor({ space, unit }: Props): JSX.Element {
110109

111110
const onSubmit = async (values: SpaceUpdateForm) => {
112111
try {
113-
const { surfaceArea, pk, ...rest } = values;
112+
const { parent, surfaceArea, pk, ...rest } = values;
114113
if (pk == null || pk === 0) {
115114
errorToast({ text: t("SpaceEditor.saveFailed") });
116115
return;
117116
}
118117
await updateSpace({
119118
...rest,
120119
pk,
120+
parent: parent != null && parent > 0 ? parent : null,
121121
surfaceArea: Math.ceil(surfaceArea ?? 0),
122122
});
123123
successToast({

apps/admin-ui/src/spa/unit/space/new-space-modal/NewSpaceModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ export function NewSpaceModal({
4646
},
4747
});
4848

49-
async function createSpaces(values: SpaceUpdateForm) {
49+
async function createSpaces({ parent, ...values }: SpaceUpdateForm) {
5050
try {
5151
await createSpace({
5252
...values,
53+
parent: parent != null && parent > 0 ? parent : null,
5354
name: values.nameFi,
5455
});
5556
closeModal();

0 commit comments

Comments
 (0)