Skip to content

Commit

Permalink
resolve merge conflicts again
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Oct 16, 2024
2 parents 9b7903a + a8fd4c1 commit 50558aa
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 109 deletions.
198 changes: 118 additions & 80 deletions src/Components/Facility/Investigations/InvestigationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import TextFormField from "../../Form/FormFields/TextFormField";
import { classNames } from "../../../Utils/utils";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { navigate } from "raviger";

const TestRow = ({ data, i, onChange, showForm, value, isChanged }: any) => {
const { t } = useTranslation();
return (
<tr
className={classNames(
Expand All @@ -15,10 +17,24 @@ const TestRow = ({ data, i, onChange, showForm, value, isChanged }: any) => {
)}
x-description="Even row"
>
<td className="whitespace-nowrap px-6 py-4 text-sm font-medium text-secondary-900">
{data?.investigation_object?.name || "---"}
<td className="whitespace-nowrap px-6 py-4 text-xs">
<p className="text-sm font-medium text-secondary-900">
{data?.investigation_object.name || "---"}
</p>
<p className="flex flex-row gap-x-2">
<span>
{t("investigations__range")}:{" "}
{data?.investigation_object.min_value || ""}
{data?.investigation_object.min_value ? " - " : ""}
{data?.investigation_object.max_value || ""}
</span>
</p>
<p className="text-secondary-600">
{t("investigations__unit")}:{" "}
{data?.investigation_object.unit || "---"}
</p>
</td>
<td className="whitespace-nowrap px-6 py-4 text-sm text-secondary-700">
<td className="whitespace-nowrap px-3 py-4 text-center text-sm text-secondary-700 xl:px-6">
{showForm ? (
data?.investigation_object?.investigation_type === "Choice" ? (
<SelectFormField
Expand Down Expand Up @@ -46,22 +62,44 @@ const TestRow = ({ data, i, onChange, showForm, value, isChanged }: any) => {
value || "---"
)}
</td>
<td className="whitespace-nowrap px-6 py-4 text-sm text-secondary-700">
{data.investigation_object.unit || "---"}
</td>
<td className="whitespace-nowrap px-6 py-4 text-sm text-secondary-700">
{data.investigation_object.min_value || "---"}
</td>
<td className="whitespace-nowrap px-6 py-4 text-sm text-secondary-700">
{data.investigation_object.max_value || "---"}
</td>
<td className="whitespace-nowrap px-6 py-4 text-sm text-secondary-700">
<td className="whitespace-nowrap px-6 py-4 text-center text-sm text-secondary-700">
{data.investigation_object.ideal_value || "---"}
</td>
</tr>
);
};

const HeadingRow = () => {
const { t } = useTranslation();
const commonClass =
"px-6 py-3 text-xs font-semibold uppercase tracking-wider text-secondary-800";
return (
<tr>
<th
key={t("investigations__name")}
scope="col"
className={`w-1/6 text-left md:w-1/6 ${commonClass}`}
>
{t("investigations__name")}
</th>
<th
key={t("investigations__result")}
scope="col"
className={`w-2/6 text-center md:w-1/6 ${commonClass}`}
>
{t("investigations__result")}
</th>
<th
key={t("investigations__ideal_value")}
scope="col"
className={`w-3/6 text-center md:w-4/6 ${commonClass}`}
>
{t("investigations__ideal_value")}
</th>
</tr>
);
};

export const InvestigationTable = ({
title,
data,
Expand All @@ -70,6 +108,10 @@ export const InvestigationTable = ({
changedFields,
handleUpdateCancel,
handleSave,
facilityId,
patientId,
consultationId,
sessionId,
}: any) => {
const { t } = useTranslation();
const [searchFilter, setSearchFilter] = useState("");
Expand All @@ -85,11 +127,9 @@ export const InvestigationTable = ({

return (
<div className="m-4 p-4">
<div className="mb flex flex-col items-center justify-between sm:flex-row">
{title && (
<div className="text-xl font-bold print:text-xs">{title}</div>
)}
<div className="flex flex-col py-2 sm:flex-row print:hidden">
<div className="mb flex flex-col items-center justify-between gap-x-3 sm:flex-row">
{title && <div className="text-xl font-bold">{title}</div>}
<div className="flex flex-col py-2 sm:flex-row">
<ButtonV2
disabled={isDischargedPatient}
variant="primary"
Expand All @@ -105,83 +145,81 @@ export const InvestigationTable = ({
{showForm && (
<ButtonV2
variant="primary"
onClick={() => handleSave()}
onClick={() => {
handleSave();
setShowForm((prev) => !prev);
}}
className="my-2 mr-2"
>
Save
{t("save")}
</ButtonV2>
)}
<ButtonV2
className="my-2 mr-2"
onClick={() =>
navigate(
`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/investigation/${sessionId}/print`,
)
}
>
<CareIcon icon="l-print" className="text-lg" />
{t("print")}
</ButtonV2>
</div>
</div>
<TextFormField
name="test_search"
label="Search Test"
className="mt-2 print:hidden"
className="mt-2"
placeholder="Search test"
value={searchFilter}
onChange={(e) => setSearchFilter(e.value)}
/>
<br />
<div className="print:w-full">
<div className="overflow-x-scroll border-b border-secondary-200 shadow sm:rounded-lg print:overflow-visible print:border-none print:shadow-none">
<table className="min-w-full divide-y divide-secondary-200 print:min-w-0 print:divide-none">
<thead className="bg-secondary-50 print:bg-white">
<tr>
{["Name", "Value", "Unit", "Min", "Max", "Ideal"].map(
(heading) => (
<th
key={heading}
scope="col"
className="px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-secondary-800 print:text-sm print:font-normal print:tracking-normal print:text-black"
>
{heading}
</th>
),
)}
<div className="overflow-x-scroll border-b border-secondary-200 shadow sm:rounded-lg">
<table className="min-w-full divide-y divide-secondary-200">
<thead className="bg-secondary-50">
<HeadingRow />
</thead>
<tbody>
{filterTests.length > 0 ? (
filterTests.map((t: any, i) => {
const value =
changedFields[t.id]?.notes ??
changedFields[t.id]?.value ??
null;
const isChanged = changedFields[t.id]?.initialValue !== value;
return (
<TestRow
data={t}
key={t.id}
i={i}
showForm={showForm}
value={value}
isChanged={isChanged}
onChange={(e: any) => {
const { target, value } =
t?.investigation_object?.investigation_type === "Float"
? {
target: `${t.id}.value`,
value: Number(e.value) || null,
}
: {
target: `${t.id}.notes`,
value: e.value,
};
handleValueChange(value, target);
}}
/>
);
})
) : (
<tr className="text-center text-secondary-500">
<td className="col-span-6">{t("no_tests_taken")}</td>
</tr>
</thead>
<tbody className="print:divide-none">
{filterTests.length > 0 ? (
filterTests.map((t: any, i) => {
const value =
changedFields[t.id]?.notes ??
changedFields[t.id]?.value ??
null;
const isChanged = changedFields[t.id]?.initialValue !== value;
return (
<TestRow
data={t}
key={t.id}
i={i}
showForm={showForm}
value={value}
isChanged={isChanged}
onChange={(e: any) => {
const { target, value } =
t?.investigation_object?.investigation_type ===
"Float"
? {
target: `${t.id}.value`,
value: Number(e.value) || null,
}
: {
target: `${t.id}.notes`,
value: e.value,
};
handleValueChange(value, target);
}}
className="print:text-black"
/>
);
})
) : (
<tr className="text-center text-secondary-500 print:text-black">
<td className="col-span-6">{t("no_tests_taken")}</td>
</tr>
)}
</tbody>
</table>
</div>
)}
</tbody>
</table>
</div>
</div>
);
Expand Down
Loading

0 comments on commit 50558aa

Please sign in to comment.