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

Commit

Permalink
fixed, childProfilesRfIds & removed unsed props
Browse files Browse the repository at this point in the history
  • Loading branch information
Toan Do authored and Toan Do committed Dec 1, 2020
1 parent 933aef3 commit 1998829
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/containers/AddProfile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const AddProfile = ({
}

if (profileType === 'equipment_ap') {
if (values.rfProfileId === null) {
if (!values.rfProfileId) {
notification.error({
message: 'Error',
description: 'A Rf Profile is required.',
Expand Down
6 changes: 4 additions & 2 deletions src/containers/ProfileDetails/components/AccessPoint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const AccessPointForm = ({
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 handleOnChangeSsid = selectedItem => {
form.setFieldsValue({
Expand All @@ -45,12 +46,13 @@ const AccessPointForm = ({
};

const handleOnChangeRf = selectedItem => {
const newChildProfileList = childProfiles.filter(i => i.profileType !== 'rf').map(o => o.id);
const newChildProfileList = selectedChildProfiles.filter(i => i !== previousRfId);

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

useEffect(() => {
Expand All @@ -76,7 +78,7 @@ const AccessPointForm = ({
},
syntheticClientEnabled: details?.syntheticClientEnabled ? 'true' : 'false',
equipmentDiscovery: details?.equipmentDiscovery ? 'true' : 'false',
rfProfileId: childProfiles.filter(i => i.profileType === 'rf')[0]?.name || null,
rfProfileId: previousRfId,
childProfileIds,
});
}, [form, details, childProfileIds]);
Expand Down
4 changes: 2 additions & 2 deletions src/containers/ProfileDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ const ProfileDetails = ({
formattedData = Object.assign(formattedData, formatSsidProfileForm(values));
}
if (profileType === 'equipment_ap') {
if (values.rfProfileId === null) {
if (!values.rfProfileId) {
notification.error({
message: 'Error',
description: 'A Rf Profile is required.',
});
return;
}
formattedData = Object.assign(formattedData, formatApProfileForm(values, rfProfiles));
formattedData = Object.assign(formattedData, formatApProfileForm(values));
}
if (profileType === 'radius') {
if (values.services.length === 0) {
Expand Down

0 comments on commit 1998829

Please sign in to comment.