Skip to content

Commit

Permalink
fixed function names and tried to remove any from some parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahil-Sinha-11 committed Oct 9, 2024
1 parent e82d0d0 commit aca95b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import LogUpdateAnalayseTable from "../Consultations/components/SharedTable";
import { formatDateTime } from "../../../Utils/utils";

import PageTitle from "@/Components/Common/PageTitle";
import { ConsultationTabProps } from ".";
import { ProcedureType } from "@/Components/Common/prescription-builder/ProcedureBuilder";

const REVERSE_CHOICES = {
appetite: {
Expand Down Expand Up @@ -90,7 +92,7 @@ const ROUTINE_ROWS = [
{ subField: true, field: "appetite" } as const,
];

const NursingPlot = ({ consultationId }: any) => {
const NursingPlot = ({ consultationId }: ConsultationTabProps) => {
const { t } = useTranslation();
const [results, setResults] = useState<any>({});
const [currentPage, setCurrentPage] = useState(1);
Expand Down Expand Up @@ -131,7 +133,9 @@ const NursingPlot = ({ consultationId }: any) => {
.reduce((accumulator, value) => accumulator.concat(value), []);

const filterEmpty = (field: (typeof NURSING_CARE_PROCEDURES)[number]) => {
const filtered = dataToDisplay.filter((i: any) => i.procedure === field);
const filtered = dataToDisplay.filter(
(i: ProcedureType) => i.procedure === field,
);
return filtered.length > 0;
};

Expand Down Expand Up @@ -187,7 +191,7 @@ const NursingPlot = ({ consultationId }: any) => {
);
};

const RoutineSection = ({ consultationId }: any) => {
const RoutineSection = ({ consultationId }: ConsultationTabProps) => {
const { t } = useTranslation();
const [page, setPage] = useState(1);
const [totalCount, setTotalCount] = useState<number>();
Expand Down Expand Up @@ -251,7 +255,7 @@ const RoutineSection = ({ consultationId }: any) => {
);
};

export default function ConsultationNursingTab({ consultationId }: any) {
export default function ConsultationNursingTab(props: ConsultationTabProps) {
const { t } = useTranslation();
return (
<div>
Expand All @@ -262,11 +266,11 @@ export default function ConsultationNursingTab({ consultationId }: any) {
/>
<div>
<h4>{t("routine")}</h4>
<RoutineSection consultationId={consultationId} />
<RoutineSection {...props} />
</div>
<div>
<h4>{t("nursing_care")}</h4>
<NursingPlot consultationId={consultationId} />
<NursingPlot {...props} />
</div>
</div>
);
Expand Down
17 changes: 10 additions & 7 deletions src/Components/Facility/Consultations/components/SharedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const LogUpdateAnalayseTable: React.FC<SharedSectionTableProps> = ({
const { t } = useTranslation();

// Helper function to get the display value
const getDisplayValue = (value: any, field?: string): string => {
const getDisplayValue = (
value: string | boolean | null | undefined,
field?: string,
): string => {
if (value == null) {
return " ";
}
Expand All @@ -35,7 +38,7 @@ const LogUpdateAnalayseTable: React.FC<SharedSectionTableProps> = ({
return "-";
};

const isddm_mm = (str: string) => {
const isValidDate = (str: string) => {
let ct = 0;
for (let i = 0; i < str.length; i++) {
if (str[i] == "/") ct++;
Expand All @@ -45,7 +48,7 @@ const LogUpdateAnalayseTable: React.FC<SharedSectionTableProps> = ({
return false;
};

const ddmm_mmdd = (str: string) => {
const dateConversion = (str: string) => {
const time = str.split(";")[0].trim();

const date = str.split(";")[1].trim();
Expand All @@ -72,13 +75,13 @@ const LogUpdateAnalayseTable: React.FC<SharedSectionTableProps> = ({
>
{/* DD/MM/YYYY -> MM/DD/YYYY */}
<p>
{isddm_mm(date)
? formatDate(ddmm_mmdd(date))
{isValidDate(date)
? formatDate(dateConversion(date))
: formatDate(date)}
</p>
<p>
{isddm_mm(date)
? formatTime(ddmm_mmdd(date))
{isValidDate(date)
? formatTime(dateConversion(date))
: formatTime(date)}
</p>
</th>
Expand Down

0 comments on commit aca95b7

Please sign in to comment.