Skip to content

Commit

Permalink
refactor: Renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
nesadrian committed Dec 3, 2024
1 parent a8e9ae2 commit 351a7b9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NodeDataCommon } from "@/types/NodeData";
import { Task } from "@/types/Task";
import { taskSorter } from "@/utils/taskSorter";
import { Accordion, Typography } from "@equinor/eds-core-react";
import { PQIRListELement } from "./PQIRListElement";
import styles from "./QIPRSection.module.scss";
import { NewPQIR } from "./NewPQIR";
import { NodeDataCommon } from "@/types/NodeData";
import { taskSorter } from "@/utils/taskSorter";
import { PQIRListELement } from "./PQIRListElement";
import styles from "./PQIRSection.module.scss";

type QIPRSectionProps = {
type PQIRSectionProps = {
title: string;
pqirs?: Task[];
emptyPQIRsText: string;
Expand All @@ -15,25 +15,34 @@ type QIPRSectionProps = {
userCanEdit: boolean;
};

export const QIPRSection = ({
export const PQIRSection = ({
title,
pqirs,
emptyPQIRsText,
isSelectedSection,
selectedNode,
userCanEdit,
}: QIPRSectionProps) => {
const pqirList = pqirs
?.sort(taskSorter())
.map((pqir, index) => (
<PQIRListELement
key={index}
pqir={pqir}
isSelectedSection={isSelectedSection}
selectedNode={selectedNode}
userCanEdit={userCanEdit}
/>
));
}: PQIRSectionProps) => {
const pqirList = () => {
if (!pqirs?.length) {
return (
<Typography style={{ textAlign: "center" }}>
{emptyPQIRsText}
</Typography>
);
}
return pqirs
?.sort(taskSorter())
.map((pqir, index) => (
<PQIRListELement
key={index}
pqir={pqir}
isSelectedSection={isSelectedSection}
selectedNode={selectedNode}
userCanEdit={userCanEdit}
/>
));
};

return (
<div className={styles.container}>
Expand All @@ -44,13 +53,7 @@ export const QIPRSection = ({
{userCanEdit && isSelectedSection && (
<NewPQIR selectedNode={selectedNode} />
)}
{pqirList?.length ? (
pqirList
) : (
<Typography style={{ textAlign: "center" }}>
{emptyPQIRsText}
</Typography>
)}
{pqirList()}
</Accordion>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions components/canvas/Sidebar/SideBarBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { usePQIRs } from "@/components/canvas/hooks/usePQIRs";
import { NodeDataCommon } from "../../../types/NodeData";
import { QIPRSection } from "./QIPRSection";
import { PQIRSection } from "./PQIRSection";
import styles from "./SidebarBody.module.scss";
import { CircularProgress, Typography } from "@equinor/eds-core-react";
import { unknownErrorToString } from "@/utils/isError";
Expand Down Expand Up @@ -31,15 +31,15 @@ export const SideBarBody = ({
}
return (
<div className={styles.container}>
<QIPRSection
<PQIRSection
title="Selected card's PQIRs"
emptyPQIRsText="This card has no PQIRs"
pqirs={selectedNode.tasks}
isSelectedSection
selectedNode={selectedNode}
userCanEdit={userCanEdit}
/>
<QIPRSection
<PQIRSection
title="Other PQIR's in this process"
emptyPQIRsText="This process has no other PQIRs"
pqirs={otherPQIRs}
Expand Down

0 comments on commit 351a7b9

Please sign in to comment.