Skip to content
Snippets Groups Projects
Commit 0f7d8b1f authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-60: Not using file with API calls

parent 9974bad9
No related branches found
No related tags found
1 merge request!77GREG-60: Adding stepper for use in registation
......@@ -12,7 +12,6 @@ import StepPersonForm from './stepPersonForm'
import { PersonFormMethods } from './personFormMethods'
import { SummaryFormMethods } from './summaryFormMethods'
import { fetchRoletypes } from '../../utils/apiCalls'
import { RolesContext } from '../../context'
const steps = ['Register', 'Summary']
......@@ -36,6 +35,17 @@ export default function StepRegistration() {
const REGISTER_STEP = 0
const SUMMARY_STEP = 1
async function fetchRoletypes(onSuccess: (result: Array<any>) => void, onError: (error: any) => void) {
fetch(`http://localhost:3000/api/ui/v1/roletypes/`)
.then(data => data.text())
.then((result => {
// The response is a JSON-array
onSuccess(JSON.parse(result))
}))
.catch(error => {
onError(error)
})
}
useEffect(() => {
fetchRoletypes(
......@@ -87,6 +97,7 @@ export default function StepRegistration() {
{/* Stepper at top of wizard */}
<Stepper activeStep={activeStep}>
{/* eslint-disable-next-line @typescript-eslint/no-unused-vars */}
{steps.map((label, index) => {
const stepProps = {}
const labelProps = {}
......
export async function fetchRoletypes(onSuccess: (result: Array<any>) => void, onError: (error: any) => void) {
fetch(`http://localhost:3000/api/ui/v1/roletypes/`)
.then(data => data.text())
.then((result => {
// The response is a JSON-array
onSuccess(JSON.parse(result))
}))
.catch(error => {
onError(error)
})
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment