Skip to content

Commit

Permalink
rm Timeline from paginatedList
Browse files Browse the repository at this point in the history
  • Loading branch information
konavivekramakrishna committed Jan 30, 2024
1 parent 59321fd commit a8d895f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 62 deletions.
29 changes: 13 additions & 16 deletions src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ButtonV2, {
import CareIcon from "../icons/CareIcon";
import { classNames } from "../../Utils/utils";
import Pagination from "../../Components/Common/Pagination";
import Timeline from "../display/Timeline";

const DEFAULT_PER_PAGE_LIMIT = 14;

Expand Down Expand Up @@ -135,21 +134,19 @@ const Items = <TItem extends object>(props: ItemsProps<TItem>) => {
}

return (
<Timeline className="rounded-lg bg-white p-2 shadow" name="log update">
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
</Timeline>
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
);
};

Expand Down
97 changes: 51 additions & 46 deletions src/Components/Facility/Consultations/DailyRoundsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PageTitle from "../../Common/PageTitle";
import DailyRoundsFilter from "./DailyRoundsFilter";
import { ConsultationModel } from "../models";
import { useSlugs } from "../../../Common/hooks/useSlug";
import { TimelineNode } from "../../../CAREUI/display/Timeline";
import Timeline, { TimelineNode } from "../../../CAREUI/display/Timeline";

interface Props {
consultation: ConsultationModel;
Expand Down Expand Up @@ -44,69 +44,74 @@ export default function DailyRoundsList({ consultation }: Props) {
<PaginatedList.WhenLoading>
<LoadingLogUpdateCard />
</PaginatedList.WhenLoading>
<PaginatedList.Items<DailyRoundsModel> className="flex grow flex-col gap-3">
{(item, items) => {
if (item.rounds_type === "AUTOMATED") {
<Timeline
className="rounded-lg bg-white p-2 shadow"
name="log update"
>
<PaginatedList.Items<DailyRoundsModel> className="flex grow flex-col gap-3">
{(item, items) => {
if (item.rounds_type === "AUTOMATED") {
return (
<TimelineNode
event={{
type: "created",
timestamp: item.taken_at?.toString() ?? "",
by: {
user_type: "",
first_name: "Virtual",
last_name: "Assistant",
username: "",
id: "",
email: "",
last_login: "",
},
icon: "l-robot",
}}
isLast={items.indexOf(item) == items.length - 1}
>
<VirtualNursingAssistantLogUpdateCard
round={item}
previousRound={items[items.indexOf(item) + 1]}
/>
</TimelineNode>
);
}

const itemUrl = ["NORMAL", "TELEMEDICINE"].includes(
item.rounds_type as string
)
? `${consultationUrl}/daily-rounds/${item.id}`
: `${consultationUrl}/daily_rounds/${item.id}`;

return (
<TimelineNode
event={{
type: "created",
timestamp: item.taken_at?.toString() ?? "",
by: {
user_type: "",
first_name: "Virtual",
last_name: "Assistant",
user_type: item.created_by?.user_type ?? "",
first_name: item.created_by?.first_name ?? "",
last_name: item.created_by?.last_name ?? "",
username: "",
id: "",
email: "",
last_login: "",
},
icon: "l-robot",
icon: "l-user-nurse",
}}
isLast={items.indexOf(item) == items.length - 1}
>
<VirtualNursingAssistantLogUpdateCard
<DefaultLogUpdateCard
round={item}
previousRound={items[items.indexOf(item) + 1]}
consultationData={consultation}
onViewDetails={() => navigate(itemUrl)}
onUpdateLog={() => navigate(`${itemUrl}/update`)}
/>
</TimelineNode>
);
}

const itemUrl = ["NORMAL", "TELEMEDICINE"].includes(
item.rounds_type
)
? `${consultationUrl}/daily-rounds/${item.id}`
: `${consultationUrl}/daily_rounds/${item.id}`;

return (
<TimelineNode
event={{
type: "created",
timestamp: item.taken_at?.toString() ?? "",
by: {
user_type: item.created_by?.user_type ?? "",
first_name: item.created_by?.first_name ?? "",
last_name: item.created_by?.last_name ?? "",
username: "",
id: "",
email: "",
last_login: "",
},
icon: "l-user-nurse",
}}
isLast={items.indexOf(item) == items.length - 1}
>
<DefaultLogUpdateCard
round={item}
consultationData={consultation}
onViewDetails={() => navigate(itemUrl)}
onUpdateLog={() => navigate(`${itemUrl}/update`)}
/>
</TimelineNode>
);
}}
</PaginatedList.Items>
}}
</PaginatedList.Items>
</Timeline>
<div className="flex w-full items-center justify-center">
<PaginatedList.Paginator hideIfSinglePage />
</div>
Expand Down

0 comments on commit a8d895f

Please sign in to comment.