Skip to content

Commit

Permalink
PR comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Aug 31, 2023
1 parent ebfe5e8 commit 8f64628
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import { getAxiosErrorMessage } from "@app/utils/utils";
import { WizardStepNavDescription } from "../wizard-step-nav-description";
import { QuestionnaireForm } from "../questionnaire-form";
import { ConfirmDialog } from "@app/components/ConfirmDialog";
import {
useFetchQuestionnaireById,
useFetchQuestionnaires,
} from "@app/queries/questionnaires";
import { useFetchQuestionnaires } from "@app/queries/questionnaires";
import {
COMMENTS_KEY,
QUESTIONS_KEY,
Expand Down Expand Up @@ -70,7 +67,7 @@ export const ApplicationAssessmentWizard: React.FC<
const [currentStep, setCurrentStep] = useState(0);

const [isConfirmDialogOpen, setIsConfirmDialogOpen] =
React.useState<Boolean>(false);
React.useState<boolean>(false);

const history = useHistory();

Expand All @@ -80,7 +77,7 @@ export const ApplicationAssessmentWizard: React.FC<
return (matchingQuestionnaire ? matchingQuestionnaire.sections : []).sort(
(a, b) => a.order - b.order
);
}, [assessment]);
}, [matchingQuestionnaire]);

// const initialComments = useMemo(() => {
// let comments: { [key: string]: string } = {};
Expand Down Expand Up @@ -188,7 +185,7 @@ export const ApplicationAssessmentWizard: React.FC<
console.error("form errors", errors);

const onSubmit = (formValues: ApplicationAssessmentWizardValues) => {
if (!assessment) {
if (!assessment?.application?.id) {
console.log("An assessment must exist in order to save the form");
return;
}
Expand Down Expand Up @@ -235,8 +232,8 @@ export const ApplicationAssessmentWizard: React.FC<
history.push(Paths.applications);
break;
case SAVE_ACTION_VALUE.SAVE_AND_REVIEW:
assessment &&
getApplicationById(assessment?.application?.id || 0)
assessment?.application?.id &&
getApplicationById(assessment.application.id)
.then((data) => {
history.push(
formatPath(Paths.applicationsReview, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const AssessmentActionsTable: React.FC<AssessmentActionsTableProps> = ({
numRenderedColumns={numRenderedColumns}
noDataEmptyState={
<div>
<NoDataEmptyState title="No Questionnaires are currently available. " />
<NoDataEmptyState title="No Questionnaires are currently available to be taken. " />
</div>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const ApplicationAssessmentStatus: React.FC<
ApplicationAssessmentStatusProps
> = ({ assessments, isLoading, fetchError }) => {
const { t } = useTranslation();
//TODO: remove this once we have a proper assessment status
const { assessment } = useFetchAssessmentByID(assessments?.[0]?.id || 0);

if (fetchError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ const Questionnaire: React.FC = () => {

const [assessmentData, setAssessmentData] = useState<Assessment | null>(null);

// useEffect(() => {
// fetch("/questionnaire-data.yaml") // adjust this path
// .then((response) => response.text())
// .then((data) => {
// const parsedData = yaml.load(data) as Assessment;
// setAssessmentData(parsedData);
// });
// }, []);
// // ------------------------!!
const { questionnaires, isFetching, fetchError } = useFetchQuestionnaires();

const [searchValue, setSearchValue] = React.useState("");
Expand All @@ -62,8 +53,8 @@ const Questionnaire: React.FC = () => {
sections: assessmentData?.sections.map((section) => ({
...section,
questions: section.questions.filter(({ text, explanation }) =>
[text, explanation].some((text) =>
text?.toLowerCase().includes(searchValue.toLowerCase())
[text, explanation].some(
(text) => text?.toLowerCase().includes(searchValue.toLowerCase())
)
),
})),
Expand Down
4 changes: 0 additions & 4 deletions client/src/app/queries/questionnaires.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
updateQuestionnaire,
} from "@app/api/rest";
import { Questionnaire } from "@app/api/models";
import { c_options_menu__toggle_BackgroundColor } from "@patternfly/react-tokens";

export const QuestionnairesTasksQueryKey = "questionnaires";
export const QuestionnaireByIdQueryKey = "questionnaireById";
Expand Down Expand Up @@ -71,9 +70,6 @@ export const useFetchQuestionnaireById = (id: number | string) => {
queryFn: () => getQuestionnaireById(id),
onError: (error: AxiosError) => console.log("error, ", error),
});
console.log("data, ", data);
console.log("isLoading, ", isLoading);
console.log("error, ", error);
return {
questionnaire: data,
isFetching: isLoading,
Expand Down

0 comments on commit 8f64628

Please sign in to comment.