Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U4X-290 : Editing stock items Edit links not fully operational #48

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { Button } from "@carbon/react";
import { useTranslation } from "react-i18next";
import { StockItemDTO } from "../../core/api/types/stockItem/StockItem";
import { launchAddOrEditDialog } from "../stock-item.utils";

interface EditStockItemActionsMenuProps {
data: StockItemDTO;
}

const EditStockItemActionsMenu: React.FC<EditStockItemActionsMenuProps> = ({
data,
}) => {
const { t } = useTranslation();

return (
<Button
kind="ghost"
size="md"
onClick={() => {
data.isDrug = !!data.drugUuid;
launchAddOrEditDialog(data, true);
}}
iconDescription={t("editStockItem", "Edit Stock Item")}
>
{`${data?.drugName ?? data.conceptName}`}
</Button>
);
};
export default EditStockItemActionsMenu;
11 changes: 3 additions & 8 deletions src/stock-items/stock-items-table.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import FilterStockItems from "./components/filter-stock-items/filter-stock-items
import { launchAddOrEditDialog } from "./stock-item.utils";
import { useStockItemsPages } from "./stock-items-table.resource";
import styles from "./stock-items-table.scss";
import EditStockItemActionsMenu from "./edit-stock-item/edit-stock-item-action-menu.component";

interface StockItemsTableProps {
from?: string;
Expand All @@ -47,22 +48,16 @@ const StockItemsTableComponent: React.FC<StockItemsTableProps> = () => {
setCurrentPage,
isDrug,
setDrug,
setSearchString,
} = useStockItemsPages(ResourceRepresentation.Full);

const tableRows = useMemo(() => {
return items?.map((stockItem) => ({
return items?.map((stockItem, index) => ({
...stockItem,
id: stockItem?.uuid,
key: `key-${stockItem?.uuid}`,
uuid: `${stockItem?.uuid}`,
type: stockItem?.drugUuid ? t("drug", "Drug") : t("other", "Other"),
genericName: (
<Link to={URL_STOCK_ITEM(stockItem?.uuid || "")}>
{" "}
{`${stockItem?.drugName ?? stockItem.conceptName}`}
</Link>
),
genericName: <EditStockItemActionsMenu data={items[index]} />,
commonName: stockItem?.commonName,
tradeName: stockItem?.drugUuid ? stockItem?.conceptName : "",
preferredVendorName: stockItem?.preferredVendorName,
Expand Down
Loading