Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Commit

Permalink
changes for childProfileIds
Browse files Browse the repository at this point in the history
  • Loading branch information
Toan Do authored and Toan Do committed Dec 2, 2020
1 parent 1998829 commit 81446be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/containers/AddProfile/index.js
Expand Up @@ -86,7 +86,7 @@ const AddProfile = ({
});
return;
}

formattedData.childProfileIds.push(values.rfProfileId);
formattedData.model_type = 'ApNetworkConfiguration';
formattedData = Object.assign(formattedData, formatApProfileForm(values));
}
Expand Down Expand Up @@ -125,7 +125,7 @@ const AddProfile = ({
formattedData.model_type = 'RfConfiguration';
formattedData = Object.assign(formattedData, formatRfProfileForm(values));
}

onCreateProfile(profileType, name, formattedData, formattedData.childProfileIds);
setIsFormDirty(false);
})
Expand Down
19 changes: 4 additions & 15 deletions src/containers/ProfileDetails/components/AccessPoint/index.js
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useMemo } from 'react';
import PropTypes from 'prop-types';
import { Card, Form, Input, Checkbox, Radio, Select, Table } from 'antd';
import { DeleteFilled } from '@ant-design/icons';
Expand Down Expand Up @@ -28,8 +28,8 @@ const AccessPointForm = ({
const [rtls, setRtls] = useState(details?.rtlsSettings?.enabled);
const [syslog, setSyslog] = useState(details?.syslogRelay?.enabled);

const [selectedChildProfiles, setSelectdChildProfiles] = useState(childProfileIds);
const [previousRfId, setPreviousRfId] = useState(childProfiles.filter(i => i.profileType === 'rf')[0]?.id);
const currentRfId = useMemo(() => childProfiles.find( i => i. profileType === 'rf')?.id, [childProfiles]);
const [selectedChildProfiles, setSelectdChildProfiles] = useState(childProfileIds.filter(i => i !== currentRfId ));

const handleOnChangeSsid = selectedItem => {
form.setFieldsValue({
Expand All @@ -44,16 +44,6 @@ const AccessPointForm = ({
});
setSelectdChildProfiles(selectedChildProfiles.filter(i => i !== id));
};

const handleOnChangeRf = selectedItem => {
const newChildProfileList = selectedChildProfiles.filter(i => i !== previousRfId);

form.setFieldsValue({
childProfileIds: [...newChildProfileList, selectedItem],
});
setSelectdChildProfiles([...newChildProfileList, selectedItem]);
setPreviousRfId(selectedItem);
};

useEffect(() => {
setSelectdChildProfiles(childProfileIds);
Expand All @@ -78,7 +68,7 @@ const AccessPointForm = ({
},
syntheticClientEnabled: details?.syntheticClientEnabled ? 'true' : 'false',
equipmentDiscovery: details?.equipmentDiscovery ? 'true' : 'false',
rfProfileId: previousRfId,
rfProfileId: childProfiles.find( i => i. profileType === 'rf')?.id,
childProfileIds,
});
}, [form, details, childProfileIds]);
Expand Down Expand Up @@ -370,7 +360,6 @@ const AccessPointForm = ({
onPopupScroll={onFetchMoreRfProfiles}
showSearch
placeholder="Select a RF Profile"
onChange={handleOnChangeRf}
>
{rfProfiles.map(i => (
<Option key={i.id} value={i.id}>
Expand Down
1 change: 1 addition & 0 deletions src/containers/ProfileDetails/index.js
Expand Up @@ -95,6 +95,7 @@ const ProfileDetails = ({
});
return;
}
formattedData.childProfileIds.push(values.rfProfileId);
formattedData = Object.assign(formattedData, formatApProfileForm(values));
}
if (profileType === 'radius') {
Expand Down

0 comments on commit 81446be

Please sign in to comment.