Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Aug 31, 2023
1 parent 38e8ad3 commit 7bccf65
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Application, Assessment, Questionnaire } from "@app/api/models";
import { useFetchAssessmentsByAppId } from "@app/queries/assessments";
import { Button } from "@patternfly/react-core";
import { Td } from "@patternfly/react-table";
import React, { FunctionComponent } from "react";

interface DynamicAssessmentButtonProps {
questionnaire: Questionnaire;
application: Application;
handleAssessmentAction: (
questionnaire: Questionnaire,
assessment: Assessment,
action: any
) => void;
}

const DynamicAssessmentButton: FunctionComponent<
DynamicAssessmentButtonProps
> = ({ questionnaire, application, handleAssessmentAction }) => {
const { assessments } = useFetchAssessmentsByAppId(application?.id);
const matchingAssessment = assessments?.find(
(assessment) => assessment.questionnaire.id === questionnaire.id
);

// const actionName = status === "active" ? "Take" : "View"; // Dynamic action name based on status

return (
<Td>
<Button
type="button"
variant="primary"
onClick={() => {
if (matchingAssessment) {
handleAssessmentAction(questionnaire, matchingAssessment, "take");
}
}}
// disabled={!matchingAssessment}
>
{/* {actionName} */}
</Button>
</Td>
);
};

export default DynamicAssessmentButton;

0 comments on commit 7bccf65

Please sign in to comment.