Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,26 @@ export const CaseOverview = ({ processes }: { processes: string[] }) => {
?.map(([domain, riskIndicators]) => {
const domainTitle = domain ?? '';
const tabEntry = Object.entries(TabToLabel).find(([_, label]) => label === domainTitle);
const tab = tabEntry ? tabEntry[0] : camelCase(domainTitle.toLowerCase());
const isValidCaseTab = CaseTabs.includes(tab as keyof typeof CaseTabs);
const tabTitle = riskIndicators?.find(riskIndicator => riskIndicator.tabTitle)?.tabTitle;
const tabLink = riskIndicators?.find(riskIndicator => riskIndicator.tabLink)?.tabLink;
const tab = (() => {
if (tabTitle) {
return camelCase(tabTitle.toLowerCase());
}

if (tabEntry) {
return camelCase(tabEntry[0].toLowerCase());
}

return camelCase(domainTitle.toLowerCase());
})();
Comment on lines +42 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Reconsider the priority logic for tab determination.

The current logic prioritizes tabTitle for tab calculation, but tabLink is used for navigation and validation (lines 53, 59). This creates potential inconsistency since tabTitle is meant for display while tabLink is for navigation.

Consider revising the priority order to prioritize tabLink first:

const tab = (() => {
-  if (tabTitle) {
-    return camelCase(tabTitle.toLowerCase());
-  }
+  if (tabLink && CaseTabs.includes(tabLink)) {
+    return tabLink;
+  }

  if (tabEntry) {
    return camelCase(tabEntry[0].toLowerCase());
  }

  return camelCase(domainTitle.toLowerCase());
})();

This ensures consistency between tab calculation and navigation usage.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const tab = (() => {
if (tabTitle) {
return camelCase(tabTitle.toLowerCase());
}
if (tabEntry) {
return camelCase(tabEntry[0].toLowerCase());
}
return camelCase(domainTitle.toLowerCase());
})();
const tab = (() => {
if (tabLink && CaseTabs.includes(tabLink)) {
return tabLink;
}
if (tabEntry) {
return camelCase(tabEntry[0].toLowerCase());
}
return camelCase(domainTitle.toLowerCase());
})();
🤖 Prompt for AI Agents
In
apps/backoffice-v2/src/pages/Entity/components/Case/components/CaseOverview/CaseOverview.tsx
around lines 42 to 52, the tab calculation currently prioritizes tabTitle, which
can cause inconsistency with navigation that uses tabLink. Update the logic to
prioritize tabLink first for tab determination, then fallback to tabTitle and
domainTitle, ensuring consistent tab identification aligned with navigation and
validation.

const isValidCaseTab = CaseTabs.includes(tabLink ?? tab);

return {
title: domain,
title: tabTitle ?? domain,
search: isValidCaseTab
? getUpdatedSearchParamsWithActiveTab({
tab: tab,
tab: tabLink ?? tab,
})
: undefined,
indicators:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const RiskEvaluationPluginSchema = Type.Optional(
Type.Object({
name: Type.Optional(Type.String()),
domain: Type.Optional(Type.String()),
tabTitle: Type.Optional(Type.String()),
tabLink: Type.Optional(Type.String()),
}),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class RiskRulePlugin {
name: rule.indicator,
riskLevel: rule.riskLevel,
domain: rule.domain,
tabTitle: rule.tabTitle,
tabLink: rule.tabLink,
};
});

Expand Down
2 changes: 2 additions & 0 deletions packages/workflow-core/src/lib/plugins/common-plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export interface RiskRulesPluginParams {
id: string;
domain: string;
indicator: string;
tabTitle?: string;
tabLink?: string;
riskLevel: 'critical' | 'high' | 'moderate' | 'positive';
baseRiskScore: number;
additionalRiskScore: number;
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const NotionRiskRuleRecordSchema = z
'Additional risk score': z.number().min(0).max(100),
'Min risk score': z.number().min(0).max(100),
'Max risk score': z.number().min(0).max(100),
'Tab link': z.string().optional(),
'Tab title': z.string().optional(),
})
.transform(value => ({
id: value.ID,
Expand All @@ -40,6 +42,8 @@ const NotionRiskRuleRecordSchema = z
additionalRiskScore: value['Additional risk score'],
minRiskScore: value['Min risk score'],
maxRiskScore: value['Max risk score'],
tabLink: value['Tab link'],
tabTitle: value['Tab title'],
}));

export interface TFindAllRulesOptions {
Expand Down