Passed down radius&captive profiles to AddProfile

This commit is contained in:
ToanDo
2021-01-04 18:02:00 -05:00
parent cae23638ee
commit b84e156f74

View File

@@ -38,6 +38,18 @@ const AddProfile = () => {
const { data: ssidProfiles, fetchMore } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'ssid' },
});
const { data: radiusProfiles, fetchMore: fetchMoreRadiusProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'radius' },
}
);
const { data: captiveProfiles, fetchMore: fetchMoreCaptiveProfiles } = useQuery(
GET_ALL_PROFILES(),
{
variables: { customerId, type: 'captive_portal' },
}
);
const { data: venueProfiles, fetchMore: fetchMoreVenueProfiles } = useQuery(GET_ALL_PROFILES(), {
variables: { customerId, type: 'passpoint_venue' },
});
@@ -102,6 +114,42 @@ const AddProfile = () => {
return true;
};
const handleFetchRadiusProfiles = e => {
if (radiusProfiles.getAllProfiles.context.lastPage) {
return false;
}
e.persist();
const { target } = e;
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
fetchMoreRadiusProfiles({
variables: { context: { ...radiusProfiles.getAllProfiles.context } },
updateQuery: updateQueryGetAllProfiles,
});
}
return true;
};
const handleFetchCaptiveProfiles = e => {
if (captiveProfiles.getAllProfiles.context.lastPage) {
return false;
}
e.persist();
const { target } = e;
if (target.scrollTop + target.offsetHeight === target.scrollHeight) {
fetchMoreCaptiveProfiles({
variables: { context: { ...captiveProfiles.getAllProfiles.context } },
updateQuery: updateQueryGetAllProfiles,
});
}
return true;
};
const handleFetchVenueProfiles = e => {
if (venueProfiles.getAllProfiles.context.lastPage) {
return false;
@@ -177,14 +225,16 @@ const AddProfile = () => {
return (
<AddProfilePage
onCreateProfile={handleAddProfile}
ssidProfiles={
(ssidProfiles && ssidProfiles.getAllProfiles && ssidProfiles.getAllProfiles.items) || []
}
ssidProfiles={ssidProfiles?.getAllProfiles?.items}
radiusProfiles={radiusProfiles?.getAllProfiles?.items}
captiveProfiles={captiveProfiles?.getAllProfiles?.items}
venueProfiles={venueProfiles?.getAllProfiles?.items}
operatorProfiles={operatorProfiles?.getAllProfiles?.items}
idProviderProfiles={idProviderProfiles?.getAllProfiles?.items}
rfProfiles={rfProfiles?.getAllProfiles?.items}
onFetchMoreProfiles={handleFetchProfiles}
onFetchMoreRadiusProfiles={handleFetchRadiusProfiles}
onFetchMoreCaptiveProfiles={handleFetchCaptiveProfiles}
onFetchMoreVenueProfiles={handleFetchVenueProfiles}
onFetchMoreOperatorProfiles={handleFetchOperatorProfiles}
onFetchMoreIdProviderProfiles={handleFetchIdProviderProfiles}