Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "noharm-app",
"private": true,
"version": "6.2.12",
"version": "6.2.13",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Screening/columns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ export const expandedRowRender = (bag) => (record) => {

if (
parent === `${record.grp_solution}` &&
record.idPrescriptionDrug !== d.idPrescriptionDrug
record.idPrescriptionDrug !== d.idPrescriptionDrug &&
record.idPrescription === d.idPrescription
) {
return true;
}
Expand Down
64 changes: 36 additions & 28 deletions src/components/SlashMenu/SlashMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { Menu as AntMenu, type MenuProps } from "antd";

Expand Down Expand Up @@ -129,6 +129,19 @@ export const useSlashMenu = ({
const [cursorCoords, setCursorCoords] = useState<CursorCoords | null>(null);
const [activeMenuKey, setActiveMenuKey] = useState<string | null>(null);
const [openMenuKeys, setOpenMenuKeys] = useState<string[]>([]);
const menuContainerRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (!slashMenuOpen) return;
const handleMouseDown = (e: MouseEvent) => {
const target = e.target as HTMLElement;
const insideMenu = menuContainerRef.current?.contains(target);
const insidePopup = !!target.closest(".ant-menu-submenu-popup");
if (!insideMenu && !insidePopup) closeSlashMenu();
};
document.addEventListener("mousedown", handleMouseDown);
return () => document.removeEventListener("mousedown", handleMouseDown);
}, [slashMenuOpen]);

useEffect(() => {
if (!slashMenuOpen) {
Expand Down Expand Up @@ -221,35 +234,30 @@ export const useSlashMenu = ({
const portal =
slashMenuOpen && cursorCoords
? createPortal(
<>
<div
style={{ position: "fixed", inset: 0, zIndex: 9998 }}
onClick={closeSlashMenu}
/>
<div
<div
ref={menuContainerRef}
style={{
position: "fixed",
left: cursorCoords.x,
top: cursorCoords.y,
zIndex: 9999,
}}
>
<AntMenu
mode="vertical"
openKeys={openMenuKeys}
onOpenChange={setOpenMenuKeys}
items={items as MenuProps["items"]}
onClick={handleMenuSelect}
selectedKeys={activeMenuKey ? [activeMenuKey] : []}
style={{
position: "fixed",
left: cursorCoords.x,
top: cursorCoords.y,
zIndex: 9999,
minWidth: 160,
borderRadius: 8,
boxShadow:
"0 6px 16px 0 rgba(0,0,0,0.08),0 3px 6px -4px rgba(0,0,0,0.12),0 9px 28px 8px rgba(0,0,0,0.05)",
}}
>
<AntMenu
mode="vertical"
openKeys={openMenuKeys}
onOpenChange={setOpenMenuKeys}
items={items as MenuProps["items"]}
onClick={handleMenuSelect}
selectedKeys={activeMenuKey ? [activeMenuKey] : []}
style={{
minWidth: 160,
borderRadius: 8,
boxShadow:
"0 6px 16px 0 rgba(0,0,0,0.08),0 3px 6px -4px rgba(0,0,0,0.12),0 9px 28px 8px rgba(0,0,0,0.05)",
}}
/>
</div>
</>,
/>
</div>,
document.body,
)
: null;
Expand Down
9 changes: 6 additions & 3 deletions src/utils/transformers/prescriptionDrugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ export const isWhitelistedChild = (
return true;
};

const hasParent = (list, groupSolution) => {
const hasParent = (list, groupSolution, idPrescription) => {
const obj = list.find(
(i) => `${i.grp_solution}` === `${groupSolution}` && !i.whiteList,
(i) =>
`${i.grp_solution}` === `${groupSolution}` &&
!i.whiteList &&
`${i.idPrescription}` === `${idPrescription}`,
);

return obj != null;
Expand All @@ -127,7 +130,7 @@ export const filterWhitelistedChildren = (list) => {
return list.filter((i) => {
if (
isWhitelistedChild(i.whiteList, i.grp_solution, i.idPrescriptionDrug) &&
hasParent(list, i.grp_solution)
hasParent(list, i.grp_solution, i.idPrescription)
) {
console.debug("removed", i);
return false;
Expand Down
Loading