Skip to content

Commit

Permalink
Merge pull request #178 from dinesh-aot/COMP-276
Browse files Browse the repository at this point in the history
Cr links
  • Loading branch information
nitheesh-aot authored Dec 30, 2024
2 parents b329b27 + 3f96a9b commit b45621a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def post_dump_actions(
): # pylint: disable=no-self-use, unused-argument
"""Extract the value of key_context enum."""
if "key_context" in data and data["key_context"] is not None:
data["key_context"] = ContextEnum(data["key_context"]).name
data["key_context"] = ContextEnum(data["key_context"]).value
else:
data["key_context"] = ""
return data
Expand Down Expand Up @@ -87,7 +87,7 @@ def post_dump_actions(
): # pylint: disable=no-self-use, unused-argument
"""Extract the value of context enum."""
if "context_type" in data and data["context_type"] is not None:
data["context_type"] = ContextEnum(data["context_type"]).name
data["context_type"] = ContextEnum(data["context_type"]).value
else:
data["context_type"] = ""
return data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { KC_USER_GROUPS, useIsRolesAllowed } from "@/hooks/useAuthorization";
import { ContinuationReport } from "@/models/ContinuationReport";
import { useModal } from "@/store/modalStore";
import { notify } from "@/store/snackbarStore";
import dateUtils from "@/utils/dateUtils";
import Timeline from "@mui/lab/Timeline";
import TimelineItem from "@mui/lab/TimelineItem";
import TimelineSeparator from "@mui/lab/TimelineSeparator";
import TimelineConnector from "@mui/lab/TimelineConnector";
import TimelineDot from "@mui/lab/TimelineDot";
import TimelineItem from "@mui/lab/TimelineItem";
import TimelineOppositeContent from "@mui/lab/TimelineOppositeContent";
import TimelineSeparator from "@mui/lab/TimelineSeparator";
import { Stack, Typography } from "@mui/material";
import { ContinuationReport } from "@/models/ContinuationReport";
import ContinuationReportTimelineEntry from "./ContinuationReportTimelineEntry";
import { useQueryClient } from "@tanstack/react-query";
import { BCDesignTokens } from "epic.theme";
import { useCallback } from "react";
import { useModal } from "@/store/modalStore";
import ContinuationReportEntryModal from "./ContinuationReportEntryModal";
import { useQueryClient } from "@tanstack/react-query";
import { notify } from "@/store/snackbarStore";
import { useAuth } from "react-oidc-context";
import { useIsRolesAllowed, KC_USER_GROUPS } from "@/hooks/useAuthorization";
import ContinuationReportEntryModal from "./ContinuationReportEntryModal";
import ContinuationReportTimelineEntry from "./ContinuationReportTimelineEntry";

interface ContinuationReportTimelineProps {
crtList: ContinuationReport[];
Expand Down Expand Up @@ -125,6 +125,7 @@ export default function ContinuationReportTimeline({
<ContinuationReportTimelineEntry
key={crt.id}
renderText={crt.rich_text}
keys={crt.keys}
createdByUser={crt.created_by_user?.name}
isSystemGenerated={crt.system_generated}
searchText={searchText}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
import ParagraphWithReadMore from "@/components/Shared/ParagraphWithReadMore";
import { CRKeys } from "@/models/ContinuationReport";
import { CR_CONTEXT_LINK } from "@/utils/constants";
import TimelineContent from "@mui/lab/TimelineContent";
import { Typography } from "@mui/material";
import { BCDesignTokens } from "epic.theme";

export default function ContinuationReportTimelineEntry({
renderText,
keys,
createdByUser,
isSystemGenerated,
searchText,
}: {
renderText: string;
keys: CRKeys[];
createdByUser?: string;
isSystemGenerated: boolean;
searchText?: string;
}) {
const applyNavigationLinks = () => {
if (keys && keys.length > 0) {
keys.forEach((key) => {
const regEx = new RegExp(key.key, "gi");
renderText = renderText.replace(
regEx,
`<a href="${CR_CONTEXT_LINK[key.key_context]}/${key.key}">${key.key}</a>`
);
});
}
return renderText;
};
const getFormattedText = () => {
renderText = applyNavigationLinks();
if (!searchText) return renderText;

// Create a temporary DOM element to parse the HTML
Expand Down
2 changes: 1 addition & 1 deletion compliance-web/src/models/ContinuationReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ContinuationReport {
keys: CRKeys[];
}

interface CRKeys {
export interface CRKeys {
key_context: string;
id: number;
key: string;
Expand Down
6 changes: 6 additions & 0 deletions compliance-web/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ export const CR_CONTEXT_TYPE = {
CASEFILE: "Casefile",
}

export const CR_CONTEXT_LINK: Record<string, string> = {
"Inspection": "/ce-database/inspections",
"Complaint": "/ce-database/complaints",
"Casefile": "/ce-database/case-files",
}

export const FILE_PROFILE_CONTEXT = CR_CONTEXT_TYPE;

0 comments on commit b45621a

Please sign in to comment.