Skip to content

Commit

Permalink
PUT Case implementation + more Cases Context (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
JennyVong authored Apr 14, 2024
1 parent cd0f4f1 commit d66ff19
Show file tree
Hide file tree
Showing 17 changed files with 2,602 additions and 2,510 deletions.
22 changes: 22 additions & 0 deletions backend/python/app/services/implementations/intake_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ def update_intake(self, intake_id: int, updated_data):
intake.intake_meeting_notes = updated_data["intake_meeting_notes"]
if "referring_worker_name" in updated_data:
intake.referring_worker_name = updated_data["referring_worker_name"]
if "referring_worker_contact" in updated_data:
intake.referring_worker_contact = updated_data[
"referring_worker_contact"
]
if "cpin_number" in updated_data:
intake.cpin_number = updated_data["cpin_number"]
if "cpin_file_type" in updated_data:
intake.cpin_file_type = updated_data["cpin_file_type"]
if "court_status" in updated_data:
intake.court_status = updated_data["court_status"]
if "court_order_file" in updated_data:
intake.court_order_file = updated_data["court_order_file"]
if "first_nation_heritage" in updated_data:
intake.first_nation_heritage = updated_data["first_nation_heritage"]
if "first_nation_band" in updated_data:
intake.first_nation_band = updated_data["first_nation_band"]
if "transportation_requirements" in updated_data:
intake.transportation_requirements = updated_data[
"transportation_requirements"
]
if "scheduling_requirements" in updated_data:
intake.scheduling_requirements = updated_data["scheduling_requirements"]
db.session.commit()
return IntakeDTO(**intake.to_dict())
except Exception as error:
Expand Down
30 changes: 16 additions & 14 deletions frontend/src/APIClients/IntakeAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ const search = async (searchParam: string): Promise<Case[]> => {
intakeStatus: <CaseStatus>intake.intakeStatus,
intakeMeetingNotes: intake.intakeMeetingNotes,
caseReferral: {
referringWorkerName: intake.caseReferral.referringWorker,
referringWorker: intake.caseReferral.referringWorker,
referringWorkerContact: intake.caseReferral.referringWorkerContact,
cpinFileNumber: parseInt(intake.caseReferral.cpinFileNumber, 10),
cpinFileNumber: intake.caseReferral.cpinFileNumber,
cpinFileType: intake.caseReferral.cpinFileType,
familyName: intake.caseReferral.familyName,
referralDate: new Date(
Expand All @@ -79,7 +79,7 @@ const search = async (searchParam: string): Promise<Case[]> => {
},
courtInformation: {
courtStatus: intake.courtInformation.courtStatus,
orderReferral: 0,
orderReferral: null,
firstNationHeritage: intake.courtInformation.firstNationHeritage,
firstNationBand: intake.courtInformation.firstNationBand,
},
Expand Down Expand Up @@ -126,17 +126,18 @@ const search = async (searchParam: string): Promise<Case[]> => {
},
],
programDetails: {
transportRequirements: intake.programDetails.transportationRequirements,
transportationRequirements:
intake.programDetails.transportationRequirements,
schedulingRequirements: intake.programDetails.schedulingRequirements,
suggestedStartDate: intake.programDetails.suggestedStartDate,
shortTermGoals: [],
longTermGoals: [],
familialConcerns: [],
permittedIndividuals: [
{
name: "",
phoneNumber: 0,
relationshipToChildren: "",
providerName: "",
phoneNo: "",
relationshipToChild: "",
additionalNotes: "",
},
],
Expand Down Expand Up @@ -177,9 +178,9 @@ const get = async (
intakeStatus: <CaseStatus>intake.intakeStatus,
intakeMeetingNotes: intake.intakeMeetingNotes,
caseReferral: {
referringWorkerName: intake.caseReferral.referringWorker,
referringWorker: intake.caseReferral.referringWorker,
referringWorkerContact: intake.caseReferral.referringWorkerContact,
cpinFileNumber: parseInt(intake.caseReferral.cpinFileNumber, 10),
cpinFileNumber: intake.caseReferral.cpinFileNumber,
cpinFileType: intake.caseReferral.cpinFileType,
familyName: intake.caseReferral.familyName,
referralDate: new Date(
Expand All @@ -188,7 +189,7 @@ const get = async (
},
courtInformation: {
courtStatus: intake.courtInformation.courtStatus,
orderReferral: 0,
orderReferral: null,
firstNationHeritage: intake.courtInformation.firstNationHeritage,
firstNationBand: intake.courtInformation.firstNationBand,
},
Expand Down Expand Up @@ -235,17 +236,18 @@ const get = async (
},
],
programDetails: {
transportRequirements: intake.programDetails.transportationRequirements,
transportationRequirements:
intake.programDetails.transportationRequirements,
schedulingRequirements: intake.programDetails.schedulingRequirements,
suggestedStartDate: intake.programDetails.suggestedStartDate,
shortTermGoals: [],
longTermGoals: [],
familialConcerns: [],
permittedIndividuals: [
{
name: "",
phoneNumber: 0,
relationshipToChildren: "",
providerName: "",
phoneNo: "",
relationshipToChild: "",
additionalNotes: "",
},
],
Expand Down
26 changes: 15 additions & 11 deletions frontend/src/components/common/FilteredCaseDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Center, Flex, Text } from "@chakra-ui/react";
import React from "react";
import CaseCard, { CaseCardProps } from "../dashboard/CaseCard";
import React, { useContext } from "react";
import CaseCard from "../dashboard/CaseCard";
import { Case } from "../../types/CasesContextTypes";
import CasesContext from "../../contexts/CasesContext";

interface Props {
cases: CaseCardProps[];
numberOfRows: number;
status: string;
}

const FilteredCaseDisplay = ({
cases,
numberOfRows,
status,
}: Props): React.ReactElement => {
const cases = useContext(CasesContext);

if (cases.length <= 0) {
return (
<Center height="full">
Expand All @@ -37,16 +39,18 @@ const FilteredCaseDisplay = ({
pb="24px"
alignItems="flex-start"
>
{casesDisplayed.map((caseData: CaseCardProps) => {
{casesDisplayed.map((caseData: Case) => {
return (
<CaseCard
key={caseData.caseId}
caseId={caseData.caseId}
referringWorker={caseData.referringWorker}
key={caseData.case_id}
caseDetails={caseData}
caseId={
typeof caseData.case_id === "string"
? parseInt(caseData.case_id, 10)
: caseData.case_id
}
caseTag={caseData.intakeStatus}
intakeMeetingNotes={caseData.intakeMeetingNotes}
date={caseData.date}
familyName={caseData.familyName}
caseTag={caseData.caseTag}
/>
);
})}
Expand Down
36 changes: 16 additions & 20 deletions frontend/src/components/dashboard/CaseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ import React from "react";
import { Box, Text, Tag, Icon, useDisclosure } from "@chakra-ui/react";
import { useHistory } from "react-router-dom";
import { ArrowUpRight } from "react-feather";
import CaseStatus from "../../types/CaseStatus";
import StatusModal from "./StatusModal";
import PermanentDeleteModal from "./PermanentDeleteModal";
import StatusModal from "./StatusModal";
import { Case } from "../../types/CasesContextTypes";

export type CaseCardProps = {
caseId: number;
referringWorker: string;
caseDetails: Case;
intakeMeetingNotes: string;
date: string;
familyName: string;
caseTag: CaseStatus;
caseTag: string;
};

const colorChange = (value: string) => {
Expand All @@ -32,12 +30,12 @@ const colorChange = (value: string) => {

const CaseCard = ({
caseId,
referringWorker,
intakeMeetingNotes,
date,
familyName,
caseDetails,
caseTag,
intakeMeetingNotes,
}: CaseCardProps): React.ReactElement => {
const history = useHistory();

const {
onOpen: onOpenStatusModal,
isOpen: isOpenStatusModal,
Expand All @@ -50,18 +48,18 @@ const CaseCard = ({
onClose: onClosePermanentDelete,
} = useDisclosure();

const history = useHistory();

const goToIntake = () => {
history.push("/intake");
history.push({
pathname: "/intake",
});
};

// TODO refactor to display proper case data
const onCardClick = (status: string) => {
if (status === "ACTIVE") {
history.push({
pathname: `/caseoverview/${caseId}`,
state: { referringWorker },
state: `${caseDetails.caseReferral.referringWorker}`,
});
} else {
onOpenStatusModal();
Expand Down Expand Up @@ -102,13 +100,13 @@ const CaseCard = ({
marginBottom="10px"
>
<Text textStyle="body-medium" marginBottom="15px">
{referringWorker}
{caseDetails.caseReferral.referringWorker}
</Text>
<Text textStyle="body-medium" marginBottom="15px">
{date}
{caseDetails.caseReferral.referralDate}
</Text>
<Text textStyle="body-medium" marginBottom="25px">
{familyName}
{caseDetails.caseReferral.familyName}
</Text>
</Box>
<Box display="flex" justifyContent="end">
Expand Down Expand Up @@ -136,9 +134,7 @@ const CaseCard = ({
<StatusModal
caseId={caseId}
status={caseTag}
referringWorkerName={referringWorker}
referralDate={date}
familyName={familyName}
caseDetails={caseDetails}
intakeNotes={intakeMeetingNotes}
isOpen={isOpenStatusModal}
onClick={onClickStatusUpdate}
Expand Down
16 changes: 4 additions & 12 deletions frontend/src/components/dashboard/FilteredSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@ const FilteredSection = ({
{row.map((caseData) => (
<CaseCard
key={caseData.case_id}
caseDetails={caseData}
caseId={
typeof caseData.case_id === "string"
? parseInt(caseData.case_id, 10)
: caseData.case_id
}
referringWorker={
caseData.caseReferral.referringWorkerName
}
date={caseData.caseReferral.referralDate}
familyName={caseData.caseReferral.familyName}
caseTag={caseData.intakeStatus}
caseTag={status}
intakeMeetingNotes={caseData.intakeMeetingNotes}
/>
))}
Expand All @@ -93,17 +89,13 @@ const FilteredSection = ({
.map((caseData) => (
<CaseCard
key={caseData.case_id}
caseDetails={caseData}
caseId={
typeof caseData.case_id === "string"
? parseInt(caseData.case_id, 10)
: caseData.case_id
}
referringWorker={
caseData.caseReferral.referringWorkerName
}
date={caseData.caseReferral.referralDate}
familyName={caseData.caseReferral.familyName}
caseTag={caseData.intakeStatus}
caseTag={status}
intakeMeetingNotes={caseData.intakeMeetingNotes}
/>
))}
Expand Down
Loading

0 comments on commit d66ff19

Please sign in to comment.