Skip to content

Commit

Permalink
fixup! frontend: Fix undefined appId breaking group edit
Browse files Browse the repository at this point in the history
  • Loading branch information
yolossn committed Sep 1, 2022
1 parent d69703f commit ebfd59b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions frontend/src/components/Groups/GroupEditDialog/GroupEditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Tabs from '@material-ui/core/Tabs';
import { Form, Formik } from 'formik';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import * as Yup from 'yup';
import { Group } from '../../../api/apiDataTypes';
import { applicationsStore } from '../../../stores/Stores';
Expand Down Expand Up @@ -42,6 +43,8 @@ export default function GroupEditDialog(props: GroupEditDialogProps) {
const [groupEditActiveTab, setGroupEditActiveTab] = React.useState(0);
const { t } = useTranslation();
const theme = useTheme();
const params = useParams<{ appID: string }>();
const appID = params.appID;

function handleSubmit(values: { [key: string]: any }, actions: { [key: string]: any }) {
const updatesPeriodPolicy =
Expand All @@ -67,7 +70,7 @@ export default function GroupEditDialog(props: GroupEditDialogProps) {
if (values.timezone) data['policy_timezone'] = values.timezone;

let packageFunctionCall;
data['application_id'] = props.data.appID || props.data.group.application_id;
data['application_id'] = appID;
if (isCreation) {
packageFunctionCall = applicationsStore().createGroup(data as Group);
} else {
Expand Down Expand Up @@ -184,10 +187,15 @@ export default function GroupEditDialog(props: GroupEditDialogProps) {
updatesTimeout: positiveNum(),
});

let initialValues = {};
let initialValues: {
[key: string]: any;
} = {
appID,
};

if (isCreation) {
initialValues = {
appID: appID,
maxUpdates: 1,
updatesPeriodRange: 1,
updatesPeriodUnit: 'hours',
Expand Down

0 comments on commit ebfd59b

Please sign in to comment.