|
1 |
| -import React from 'react' |
| 1 | +import React, { useState, useEffect } from 'react' |
2 | 2 | import { useRouter } from 'next/router'
|
3 | 3 | import { useSession } from 'next-auth/react'
|
4 | 4 | import {
|
@@ -37,14 +37,30 @@ const Request = () => {
|
37 | 37 | const { uuid } = router.query
|
38 | 38 | const { request, isLoadingRequest, isRequestError } = useOneRequest(uuid, session?.accessToken)
|
39 | 39 | const { allSOWs, isLoadingSOWs, isSOWError } = useAllSOWs(uuid, request?.identifier, session?.accessToken)
|
40 |
| - const { allPOs, isLoadingPOs, isPOError } = useAllPOs(request?.quotedWareID, uuid, request?.identifier, session?.accessToken) |
41 |
| - //console.log(allPOs, 'uuid.js all POS') |
42 | 40 | const { messages, isLoadingMessages, isMessagesError, mutateMessages, messagesData } = useMessages(uuid, session?.accessToken)
|
43 | 41 | const { files, isLoadingFiles, isFilesError, mutateFiles, filesData } = useFiles(uuid, session?.accessToken)
|
44 |
| - const documents = (allSOWs) ? [...allSOWs] : [] |
45 | 42 |
|
46 |
| - const isLoading = isLoadingRequest || isLoadingSOWs || isLoadingFiles || isLoadingMessages |
| 43 | + const [allPOs, setAllPOs] = useState(false) |
| 44 | + const [isPOError, setIsPOError] = useState(false) |
| 45 | + const [isPOLoading, setIsPOLoading] = useState(false) |
| 46 | + useEffect(() => { |
| 47 | + const getPOsAsync = async () => { |
| 48 | + const response = await useAllPOs(request?.quotedWareID, uuid, request?.identifier, session?.accessToken) |
| 49 | + if (response.allPOs) { |
| 50 | + setAllPOs(response.allPOs) |
| 51 | + } else if (response.isPOError) { |
| 52 | + setIsPOError(response.isPOError) |
| 53 | + } else { |
| 54 | + setIsPOLoading(true) |
| 55 | + } |
| 56 | + } |
| 57 | + getPOsAsync() |
| 58 | + }, [allPOs]); |
| 59 | + |
| 60 | + console.log(allPOs) |
| 61 | + const isLoading = isLoadingRequest || isLoadingSOWs || isLoadingFiles || isLoadingMessages || isPOLoading |
47 | 62 | const isError = isRequestError || isSOWError || isFilesError|| isMessagesError
|
| 63 | + const documents = (allSOWs) ? [...allSOWs] : [] |
48 | 64 |
|
49 | 65 | if (isLoading) return <Loading wrapperClass='item-page mt-5' />
|
50 | 66 |
|
|
0 commit comments