-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from DaleMcGrew/Dale_WCC-Feb9-2025
Making it easier to get a link to any questionnaire for any person. Stopped processing TaskGroups and TaskDefinitions from `task-status-list-retrieve` and started using the more limited APIs 'task-definition-list-retrieve' and 'task-group-list-retrieve'. Updated the Add Team Member quick-person-add list to work with new data flow.
- Loading branch information
Showing
15 changed files
with
295 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,88 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { renderLog } from '../../common/utils/logging'; | ||
import { useConnectAppContext } from '../../contexts/ConnectAppContext'; | ||
// import useGetFullNamePreferredReactQuery from '../../react-query/useGetFullNamePreferredReactQuery'; | ||
import { useConnectAppContext, useConnectDispatch } from '../../contexts/ConnectAppContext'; | ||
import CopyQuestionnaireLink from '../Questionnaire/CopyQuestionnaireLink'; | ||
import { useGetFullNamePreferred, useGetPersonById } from '../../models/PersonModel'; | ||
import { useGetFullNamePreferred } from '../../models/PersonModel'; | ||
import { SpanWithLinkStyle } from '../Style/linkStyles'; | ||
import { METHOD, useFetchData } from '../../react-query/WeConnectQuery'; | ||
import { captureQuestionnaireListRetrieveData } from '../../models/QuestionnaireModel'; | ||
|
||
|
||
const PersonProfile = () => { | ||
renderLog('PersonProfile'); // Set LOG_RENDER_EVENTS to log all renders | ||
const { getAppContextValue, setAppContextValue } = useConnectAppContext(); | ||
const { getAppContextValue } = useConnectAppContext(); | ||
const { apiDataCache } = useConnectAppContext(); | ||
const { allQuestionnairesCache } = apiDataCache; | ||
const dispatch = useConnectDispatch(); | ||
|
||
// const [person] = useState(getAppContextValue('personDrawersPerson')); | ||
const [person] = useState(useGetPersonById(getAppContextValue('personDrawersPersonId'))); | ||
const [personId] = useState(getAppContextValue('personDrawersPersonId')); | ||
const [questionnaireList, setQuestionnaireList] = useState([]); | ||
const [showQuestionnaireList, setShowQuestionnaireList] = useState(false); | ||
|
||
const questionnaireListRetrieveResults = useFetchData(['questionnaire-list-retrieve'], {}, METHOD.GET); | ||
useEffect(() => { | ||
// Hard coded temporarily while we are in development | ||
setAppContextValue('QuestionnaireId', 1); | ||
}, []); | ||
// console.log('questionnaireListRetrieveResults in Questionnaire useEffect captureQuestionnaireListRetrieveData'); | ||
if (questionnaireListRetrieveResults) { | ||
captureQuestionnaireListRetrieveData(questionnaireListRetrieveResults, apiDataCache, dispatch); | ||
} | ||
}, [questionnaireListRetrieveResults, allQuestionnairesCache]); | ||
|
||
useEffect(() => { | ||
if (allQuestionnairesCache) { | ||
setQuestionnaireList(Object.values(allQuestionnairesCache)); | ||
} | ||
}, [allQuestionnairesCache]); | ||
|
||
return ( | ||
<PersonProfileWrapper> | ||
<FullName> | ||
{useGetFullNamePreferred(person.personId)} | ||
{useGetFullNamePreferred(personId)} | ||
</FullName> | ||
{/* <PersonDetails /> This was commented out as of January 28th, 2025 */} | ||
<CopyQuestionnaireLink /> | ||
<ShowQuestionnaireOptions> | ||
<div> | ||
Questionnaires | ||
{' '} | ||
( | ||
{showQuestionnaireList ? ( | ||
<SpanWithLinkStyle onClick={() => setShowQuestionnaireList(false)}>hide</SpanWithLinkStyle> | ||
) : ( | ||
<SpanWithLinkStyle onClick={() => setShowQuestionnaireList(true)}>show</SpanWithLinkStyle> | ||
)} | ||
) | ||
</div> | ||
</ShowQuestionnaireOptions> | ||
{showQuestionnaireList && ( | ||
<QuestionnaireOptions> | ||
{questionnaireList.map((questionnaire) => ( | ||
<OneQuestionnaire key={`questionnaire-${questionnaire.questionnaireId}`}> | ||
<div>{questionnaire.questionnaireName}</div> | ||
<CopyQuestionnaireLink personId={personId} questionnaireId={questionnaire.questionnaireId} /> | ||
</OneQuestionnaire> | ||
))} | ||
</QuestionnaireOptions> | ||
)} | ||
</PersonProfileWrapper> | ||
); | ||
}; | ||
|
||
const FullName = styled('div')` | ||
const FullName = styled('h2')` | ||
`; | ||
|
||
const OneQuestionnaire = styled('div')` | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 10px; | ||
`; | ||
|
||
const PersonProfileWrapper = styled('div')` | ||
`; | ||
|
||
const QuestionnaireOptions = styled('div')` | ||
`; | ||
|
||
const ShowQuestionnaireOptions = styled('div')` | ||
`; | ||
|
||
export default PersonProfile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.