diff --git a/src/views/tenant/administration/GDAPInviteWizard.jsx b/src/views/tenant/administration/GDAPInviteWizard.jsx index 34b8dfad775e..23fa60e962e6 100644 --- a/src/views/tenant/administration/GDAPInviteWizard.jsx +++ b/src/views/tenant/administration/GDAPInviteWizard.jsx @@ -1,5 +1,14 @@ -import React from 'react' -import { CCol, CRow, CForm, CCallout, CSpinner, CButton } from '@coreui/react' +import React, { useState } from 'react' +import { + CCol, + CRow, + CForm, + CCallout, + CSpinner, + CFormInput, + CFormLabel, + CFormRange, +} from '@coreui/react' import { Field, FormSpy } from 'react-final-form' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons' @@ -32,11 +41,21 @@ Error.propTypes = { const requiredArray = (value) => (value && value.length !== 0 ? undefined : 'Required') const GDAPInviteWizard = () => { + const [inviteCount, setInviteCount] = useState(1) + const [loopRunning, setLoopRunning] = React.useState(false) + const [massResults, setMassResults] = React.useState([]) const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery() const [genericGetRequest, getResults] = useLazyGenericGetRequestQuery() const handleSubmit = async (values) => { - genericPostRequest({ path: '/api/ExecGDAPInvite', values: values }) + const resultsarr = [] + setLoopRunning(true) + for (var x = 0; x < inviteCount; x++) { + const results = await genericPostRequest({ path: '/api/ExecGDAPInvite', values: values }) + resultsarr.push(results) + setMassResults(resultsarr) + } + setLoopRunning(false) } const formValues = {} @@ -95,13 +114,40 @@ const GDAPInviteWizard = () => {
- +

Step 2

+
Invite Options
+
+
+ Number of Invites + + + setInviteCount(e.target.value)} + /> + + + setInviteCount(e.target.value)} + /> + + +
+ +
+

Step 3

Confirm and apply

- {!postResults.isSuccess && ( + {massResults.length < 1 && ( {/* eslint-disable react/prop-types */} {(props) => { @@ -136,23 +182,29 @@ const GDAPInviteWizard = () => { }} )} - {postResults.isFetching && ( - - Loading - - )} - {postResults.isSuccess && ( - - {postResults.data.Results.map((message, idx) => { - return
  • {message}
  • - })} - -
    + {(massResults.length >= 1 || loopRunning) && + massResults.map((message, idx) => { + const results = message?.data + const displayResults = Array.isArray(results) ? results.join(', ') : results + return ( + + {results.Results.map((message, idx) => { + return
  • {message}
  • + })} + +
    + ) + })} + {loopRunning && ( +
  • + +
  • )}