Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: prototype BoP list

Brad Barbin6ffe179095a4
diff --git a/apps/carbon/app/components/DirectionAwareTabs.tsx b/apps/carbon/app/components/DirectionAwareTabs.tsx
new file mode 100644
index 0000000000..d139d10272
--- /dev/null
+++ b/apps/carbon/app/components/DirectionAwareTabs.tsx
@@ -0,0 +1,129 @@
+"use client";
+
+import { cn } from "@carbon/react";
+import { AnimatePresence, MotionConfig, motion } from "framer-motion";
+import type { ReactNode } from "react";
+import { useMemo, useState } from "react";
+import useMeasure from "react-use-measure";
+
+type Tab = {
+ id: number;
+ label: string;
+ content: ReactNode;
+};
+
+interface OgImageSectionProps {
+ tabs: Tab[];
+ className?: string;
+ rounded?: string;
+ onChange?: () => void;
+}
+
+function DirectionAwareTabs({
+ tabs,
+ className,
+ rounded,
+ onChange,
+}: OgImageSectionProps) {
+ const [activeTab, setActiveTab] = useState(0);
+ const [direction, setDirection] = useState(0);
+ const [isAnimating, setIsAnimating] = useState(false);
+ const [ref, bounds] = useMeasure();
+
+ const content = useMemo(() => {
+ const activeTabContent = tabs.find((tab) => tab.id === activeTab)?.content;
+ return activeTabContent || null;
+ }, [activeTab, tabs]);
+
+ const handleTabClick = (newTabId: number) => {
+ if (newTabId !== activeTab && !isAnimating) {
+ const newDirection = newTabId > activeTab ? 1 : -1;
+ setDirection(newDirection);
+ setActiveTab(newTabId);
+ onChange?.();
+ }
+ };
+
+ const variants = {
+ initial: (direction: number) => ({
+ x: 300 * direction,
+ opacity: 0,
+ filter: "blur(4px)",
+ }),
+ active: {
+ x: 0,
+ opacity: 1,
+ filter: "blur(0px)",
+ },
+ exit: (direction: number) => ({
+ x: -300 * direction,
+ opacity: 0,
+ filter: "blur(4px)",
+ }),
+ };
+
+ return (
+ <div className=" flex flex-col items-center w-full">
+ <div
+ className={cn(
+ "flex space-x-1 rounded-lg cursor-pointer bg-muted px-[3px] py-[3.2px] shadow-inner-shadow",
+ className,
+ rounded
+ )}
+ >
+ {tabs.map((tab) => (
+ <button
+ key={tab.id}
+ onClick={() => handleTabClick(tab.id)}
+ className={cn(
+ "relative rounded-md px-3.5 py-1.5 text-xs sm:text-sm font-medium text-foreground/80 transition focus-visible:outline-1 focus-visible:ring-1 focus-visible:outline-none flex gap-2 items-center ",
+ activeTab === tab.id
+ ? "text-foreground"
+ : "hover:text-foreground/60 text-foreground/80",
+ rounded
+ )}
+ style={{ WebkitTapHighlightColor: "transparent" }}
+ >
+ {activeTab === tab.id && (
+ <motion.span
+ layoutId="bubble"
+ className="absolute inset-0 z-10 bg-background text-foreground rounded-md shadow-md"
+ transition={{ type: "spring", bounce: 0.19, duration: 0.4 }}
+ />
+ )}
+ <span className="z-20">{tab.label}</span>
+ </button>
+ ))}
+ </div>
+ <MotionConfig transition={{ duration: 0.4, type: "spring", bounce: 0.2 }}>
+ <motion.div
+ className="relative mx-auto w-full h-full overflow-hidden"
+ initial={false}
+ animate={{ height: bounds.height }}
+ >
+ <div className="p-1" ref={ref}>
+ <AnimatePresence
+ custom={direction}
+ mode="popLayout"
+ onExitComplete={() => setIsAnimating(false)}
+ >
+ <motion.div
+ key={activeTab}
+ variants={variants}
+ initial="initial"
+ animate="active"
+ exit="exit"
+ custom={direction}
+ onAnimationStart={() => setIsAnimating(true)}
+ onAnimationComplete={() => setIsAnimating(false)}
+ >
+ {content}
+ </motion.div>
+ </AnimatePresence>
+ </div>
+ </motion.div>
+ </MotionConfig>
+ </div>
+ );
+}
+export { DirectionAwareTabs };
diff --git a/apps/carbon/app/components/Form/Supplier.tsx b/apps/carbon/app/components/Form/Supplier.tsx
index 6df478104d..a201e19c4b 100644
--- a/apps/carbon/app/components/Form/Supplier.tsx
+++ b/apps/carbon/app/components/Form/Supplier.tsx
@@ -3,6 +3,7 @@ import { useMemo, useRef, useState } from "react";
import { SupplierForm } from "~/modules/purchasing";
import { useSuppliers } from "~/stores";
import type { ComboboxProps } from "./Combobox";
+import Combobox from "./Combobox";
import CreatableCombobox from "./CreatableCombobox";
type SupplierSelectProps = Omit<ComboboxProps, "options"> & {
@@ -27,7 +28,9 @@ const Supplier = ({ allowedSuppliers, ...props }: SupplierSelectProps) => {
return result;
}, [suppliers, allowedSuppliers]);
- return (
+ return allowedSuppliers ? (
+ <Combobox options={options} {...props} label={props?.label ?? "Supplier"} />
+ ) : (
<>
<CreatableCombobox
ref={triggerRef}
diff --git a/apps/carbon/app/components/SortableList.tsx b/apps/carbon/app/components/SortableList.tsx
new file mode 100644
index 0000000000..a19dc655dc
--- /dev/null
+++ b/apps/carbon/app/components/SortableList.tsx
@@ -0,0 +1,293 @@
+"use client";
+
+import {
+ AnimatePresence,
+ LayoutGroup,
+ Reorder,
+ motion,
+ useDragControls,
+} from "framer-motion";
+import type { Dispatch, ReactNode, SetStateAction } from "react";
+import { useState } from "react";
+import useMeasure from "react-use-measure";
+
+import { Checkbox, cn } from "@carbon/react";
+import { LuTrash } from "react-icons/lu";
+
+export type Item = {
+ text: string;
+ checked: boolean;
+ id: string;
+ description: string;
+};
+
+interface SortableListItemProps {
+ item: Item;
+ order: number;
+ onCompleteItem: (id: string) => void;
+ onRemoveItem: (id: string) => void;
+ renderExtra?: (item: Item) => React.ReactNode;
+ isExpanded?: boolean;
+ className?: string;
+ handleDrag: () => void;
+}
+
+function SortableListItem({
+ item,
+ order,
+ onCompleteItem,
+ onRemoveItem,
+ renderExtra,
+ handleDrag,
+ isExpanded,
+ className,
+}: SortableListItemProps) {
+ let [ref, bounds] = useMeasure();
+ const [isDragging, setIsDragging] = useState(false);
+ const [isDraggable] = useState(true);
+ const dragControls = useDragControls();
+
+ const handleDragStart = (event: any) => {
+ setIsDragging(true);
+ dragControls.start(event, { snapToCursor: true });
+ handleDrag();
+ };
+
+ const handleDragEnd = () => {
+ setIsDragging(false);
+ };
+
+ return (
+ <motion.div className={cn("", className)} key={item.id}>
+ <div className="flex w-full items-center">
+ <Reorder.Item
+ value={item}
+ className={cn(
+ "relative z-auto grow",
+ "h-full rounded-xl bg-card",
+ "border border-border shadow-md",
+ "dark:border-0 dark:shadow-[0px_1px_0px_0px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_rgba(0,0,0,.1),0px_2px_2px_0px_rgba(0,0,0,.1),0px_4px_4px_0px_rgba(0,0,0,.1),0px_8px_8px_0px_rgba(0,0,0,.1)]",
+ item.checked ? "cursor-not-allowed" : "cursor-grab",
+ item.checked && !isDragging ? "w-7/10" : "w-full"
+ )}
+ key={item.id}
+ initial={{ opacity: 0 }}
+ animate={{
+ opacity: 1,
+ height: bounds.height > 0 ? bounds.height : undefined,
+ transition: {
+ type: "spring",
+ bounce: 0,
+ duration: 0.4,
+ },
+ }}
+ exit={{
+ opacity: 0,
+ transition: {
+ duration: 0.05,
+ type: "spring",
+ bounce: 0.1,
+ },
+ }}
+ layout
+ layoutId={`item-${item.id}`}
+ dragListener={!item.checked}
+ dragControls={dragControls}
+ onDragEnd={handleDragEnd}
+ style={
+ isExpanded
+ ? {
+ zIndex: 9999,
+ marginTop: 10,
+ marginBottom: 10,
+ position: "relative",
+ overflow: "hidden",
+ }
+ : {
+ position: "relative",
+ overflow: "hidden",
+ }
+ }
+ whileDrag={{ zIndex: 9999 }}
+ >
+ <div ref={ref} className={cn(isExpanded ? "" : "", "z-20 ")}>
+ <motion.div
+ layout="position"
+ className="flex items-center justify-center "
+ >
+ <AnimatePresence>
+ {!isExpanded ? (
+ <motion.div
+ initial={{ opacity: 0, filter: "blur(4px)" }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ exit={{ opacity: 0, filter: "blur(4px)" }}
+ transition={{ duration: 0.001 }}
+ className="flex items-center space-x-2 "
+ >
+ {/* List Remove Actions */}
+ <Checkbox
+ checked={item.checked}
+ id={`checkbox-${item.id}`}
+ aria-label="Mark to delete"
+ onCheckedChange={() => onCompleteItem(item.id)}
+ className=" ml-3 h-5 w-5 rounded-md border-foreground/20 bg-background/30 data-[state=checked]:bg-background data-[state=checked]:text-red-200"
+ />
+ {/* List Order */}
+ <p className="font-mono text-xs pl-1 text-foreground/50 flex flex-shrink-0">
+ {order + 1}
+ </p>
+
+ {/* List Title */}
+ <motion.div
+ key={`${item.checked}`}
+ className=" px-1 flex flex-grow truncate"
+ initial={{
+ opacity: 0,
+ filter: "blur(4px)",
+ }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ transition={{
+ bounce: 0.2,
+ delay: item.checked ? 0.2 : 0,
+ type: "spring",
+ }}
+ >
+ <h4
+ className={cn(
+ "tracking-tighter text-base md:text-lg ",
+ item.checked
+ ? "text-red-400"
+ : "text-foreground dark:text-foreground/70"
+ )}
+ >
+ {item.text}
+ </h4>
+ </motion.div>
+ </motion.div>
+ ) : null}
+ </AnimatePresence>
+
+ {/* List Item Children */}
+ {renderExtra && renderExtra(item)}
+ </motion.div>
+ </div>
+ <div
+ onPointerDown={isDraggable ? handleDragStart : undefined}
+ style={{ touchAction: "none" }}
+ />
+ </Reorder.Item>
+ {/* List Delete Action Animation */}
+ <AnimatePresence mode="popLayout">
+ {item.checked ? (
+ <motion.div
+ layout
+ initial={{ opacity: 0, x: -10 }}
+ animate={{
+ opacity: 1,
+ x: 0,
+ transition: {
+ delay: 0.17,
+ duration: 0.17,
+ type: "spring",
+ bounce: 0.6,
+ },
+ zIndex: 5,
+ }}
+ exit={{
+ opacity: 0,
+ x: -5,
+ transition: {
+ delay: 0,
+ duration: 0.0,
+ type: "spring",
+ bounce: 0,
+ },
+ }}
+ className="h-[1.5rem] w-3"
+ />
+ ) : null}
+ </AnimatePresence>
+ <AnimatePresence mode="popLayout">
+ {item.checked ? (
+ <motion.div
+ layout
+ initial={{ opacity: 0, x: -5, filter: "blur(4px)" }}
+ animate={{
+ opacity: 1,
+ x: 0,
+ filter: "blur(0px)",
+ transition: {
+ delay: 0.3,
+ duration: 0.15,
+ type: "spring",
+ bounce: 0.9,
+ },
+ }}
+ exit={{
+ opacity: 0,
+ filter: "blur(4px)",
+ x: -10,
+ transition: { delay: 0, duration: 0.12 },
+ }}
+ className="inset-0 z-0 rounded-full bg-card border-border border dark:shadow-[0_1px_0_0_rgba(255,255,255,0.03)_inset,0_0_0_1px_rgba(255,255,255,0.03)_inset,0_0_0_1px_rgba(0,0,0,0.1),0_2px_2px_0_rgba(0,0,0,0.1),0_4px_4px_0_rgba(0,0,0,0.1),0_8px_8px_0_rgba(0,0,0,0.1)] dark:bg-[#161716]/50"
+ >
+ <button
+ className="inline-flex h-10 items-center justify-center space-nowrap rounded-md px-3 text-sm font-medium transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
+ onClick={() => onRemoveItem(item.id)}
+ >
+ <LuTrash className="h-4 w-4 text-red-400 transition-colors duration-150 fill-red-400/60 " />
+ </button>
+ </motion.div>
+ ) : null}
+ </AnimatePresence>
+ </div>
+ </motion.div>
+ );
+}
+
+SortableListItem.displayName = "SortableListItem";
+
+interface SortableListProps {
+ items: Item[];
+ setItems: Dispatch<SetStateAction<Item[]>>;
+ onCompleteItem: (id: string) => void;
+ renderItem: (
+ item: Item,
+ order: number,
+ onCompleteItem: (id: string) => void,
+ onRemoveItem: (id: string) => void
+ ) => ReactNode;
+}
+
+function SortableList({
+ items,
+ setItems,
+ onCompleteItem,
+ renderItem,
+}: SortableListProps) {
+ if (items) {
+ return (
+ <LayoutGroup>
+ <Reorder.Group
+ axis="y"
+ values={items}
+ onReorder={setItems}
+ className="flex flex-col"
+ >
+ <AnimatePresence>
+ {items?.map((item, index) =>
+ renderItem(item, index, onCompleteItem, (id: string) =>
+ setItems((items) => items.filter((item) => item.id !== id))
+ )
+ )}
+ </AnimatePresence>
+ </Reorder.Group>
+ </LayoutGroup>
+ );
+ }
+ return null;
+}
+
+SortableList.displayName = "SortableList";
+
+export { SortableList, SortableListItem };
diff --git a/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
index c009bd0a5c..362a873f76 100644
--- a/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
@@ -101,7 +101,7 @@ const ChartOfAccountForm = ({ initialValues }: ChartOfAccountFormProps) => {
<DrawerBody>
<Hidden name="id" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Input name="number" label="Account Number" />
<Input name="name" label="Name" />
<Select
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
index 9a7c431a7e..1ddf1594c3 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
@@ -80,7 +80,7 @@ const ReceiptForm = ({ initialValues, status }: ReceiptFormProps) => {
<Hidden name="id" />
<Hidden name="supplierId" value={supplierId ?? ""} />
<VStack spacing={4} className="min-h-full">
- <div className="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4 w-full">
<Input name="receiptId" label="Receipt ID" isReadOnly />
<ComboboxControlled
name="locationId"
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx
index ba3a500d64..ef32d71a90 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx
@@ -82,7 +82,7 @@ const PurchaseInvoiceForm = ({
<VStack>
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx
index 41df77bfcd..6622f2f15e 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx
@@ -95,7 +95,7 @@ const ConsumableForm = ({
<Hidden name="type" value={type} />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
index 71e84f40a7..c7fb4869d9 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
@@ -1,28 +1,14 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Enumerable,
- HStack,
- Menubar,
- VStack,
-} from "@carbon/react";
+import { Enumerable, HStack, Heading, VStack } from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
+import { DetailsTopbar } from "~/components/Layout";
+import { useRouteData } from "~/hooks";
import type { Consumable } from "~/modules/items";
import { path } from "~/utils/path";
+import { useConsumableNavigation } from "./useConsumableNavigation";
const ConsumableHeader = () => {
- const permissions = usePermissions();
+ const links = useConsumableNavigation();
const { itemId } = useParams();
if (!itemId) throw new Error("itemId not found");
@@ -30,78 +16,18 @@ const ConsumableHeader = () => {
path.to.consumable(itemId)
);
- const optimisticAssignment = useOptimisticAssignment({
- id: itemId,
- table: "item",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.consumableSummary?.assignee;
-
return (
- <VStack>
- {permissions.is("employee") && !!routeData?.consumableSummary?.id && (
- <Menubar>
- <Assign
- id={itemId}
- table="item"
- value={routeData?.consumableSummary?.assignee ?? ""}
- />
- </Menubar>
- )}
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.consumableSummary?.id}</CardTitle>
- <CardDescription>
- {routeData?.consumableSummary?.name}
- </CardDescription>
- </CardHeader>
- <CardAction>
- {/* <Button
- variant="secondary"
- onClick={() => alert("TODO")}
- leftIcon={<FaHistory />}
- >
- View History
- </Button> */}
- </CardAction>
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <VStack spacing={0} className="flex-grow">
+ <HStack>
+ <Heading size="h2">{routeData?.consumableSummary?.id}</Heading>
+ <Enumerable value="Consumable" />
</HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Inventory Type</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={
- routeData?.consumableSummary?.itemInventoryType ?? null
- }
- />
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>UoM</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.consumableSummary?.unitOfMeasure ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- </VStack>
+ </VStack>
+ <VStack spacing={0} className="flex-shrink justify-center items-end">
+ <DetailsTopbar links={links} />
+ </VStack>
+ </div>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
new file mode 100644
index 0000000000..1b4c199cb5
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
@@ -0,0 +1,153 @@
+import {
+ Button,
+ Enumerable,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ VStack,
+ cn,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+import { useOptimisticAssignment } from "~/components";
+import Assignee from "~/components/Assignee";
+import { useRouteData } from "~/hooks";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+import type { BuyMethod, Consumable, PickMethod } from "../../types";
+import { MethodBadge } from "../Item/MethodBadge";
+
+const ConsumableProperties = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const sharedConsumablesData = useRouteData<{ locations: ListItem[] }>(
+ path.to.consumableRoot
+ );
+ const routeData = useRouteData<{
+ consumableSummary: Consumable;
+ buyMethods: BuyMethod[];
+ pickMethods: PickMethod[];
+ }>(path.to.consumable(itemId));
+
+ const locations = sharedConsumablesData?.locations ?? [];
+ const buyMethods = routeData?.buyMethods ?? [];
+ const pickMethods = routeData?.pickMethods ?? [];
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.consumableSummary?.assignee;
+
+ return (
+ <VStack
+ spacing={4}
+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"
+ >
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.consumable(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to consumable</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ routeData?.consumableSummary?.id ?? ""
+ )
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy consumable number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">{routeData?.consumableSummary?.name}</span>
+ </VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Assignee</h3>
+ <Assignee id={itemId} table="item" value={assignee ?? ""} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Inventory Type</h3>
+ <Enumerable
+ className={cn(
+ (routeData?.consumableSummary?.active === false ||
+ routeData?.consumableSummary?.blocked) &&
+ "opacity-50"
+ )}
+ value={routeData?.consumableSummary?.itemInventoryType ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>
+ <Enumerable
+ value={routeData?.consumableSummary?.unitOfMeasure ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Methods</h3>
+ </HStack>
+ {buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.consumablePurchasing(itemId)}
+ />
+ ))}
+ {pickMethods.map((method) => (
+ <MethodBadge
+ key={method.locationId}
+ type="Pick"
+ text={
+ method.defaultShelfId ??
+ locations.find((l) => l.id === method.locationId)?.name ??
+ ""
+ }
+ to={path.to.consumableInventoryLocation(itemId, method.locationId)}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ );
+};
+
+export default ConsumableProperties;
diff --git a/apps/carbon/app/modules/items/ui/Consumables/index.ts b/apps/carbon/app/modules/items/ui/Consumables/index.ts
index 6a4835a640..03c04e979f 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/index.ts
+++ b/apps/carbon/app/modules/items/ui/Consumables/index.ts
@@ -1,11 +1,11 @@
import ConsumableForm from "./ConsumableForm";
import ConsumableHeader from "./ConsumableHeader";
-import ConsumableNavigation from "./ConsumableNavigation";
+import ConsumableProperties from "./ConsumableProperties";
import ConsumablesTable from "./ConsumablesTable";
export {
ConsumableForm,
ConsumableHeader,
- ConsumableNavigation,
+ ConsumableProperties,
ConsumablesTable,
};
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableNavigation.tsx b/apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
similarity index 74%
rename from apps/carbon/app/modules/items/ui/Consumables/ConsumableNavigation.tsx
rename to apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
index 240ebfb0f9..4ac1f01657 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
@@ -4,11 +4,9 @@ import {
LuBox,
LuFileBarChart,
LuFileText,
- LuShare2,
LuShoppingCart,
LuTags,
} from "react-icons/lu";
-import { DetailSidebar } from "~/components/Layout";
import { usePermissions } from "~/hooks";
import type { Role } from "~/types";
import { path } from "~/utils/path";
@@ -32,14 +30,6 @@ export function useConsumableNavigation() {
icon: LuShoppingCart,
shortcut: "Command+Shift+p",
},
- {
- name: "Suppliers",
- to: path.to.consumableSuppliers(itemId),
- role: ["employee", "supplier"],
- icon: LuShare2,
- shortcut: "Command+Shift+s",
- },
-
{
name: "Costing",
to: path.to.consumableCosting(itemId),
@@ -67,14 +57,3 @@ export function useConsumableNavigation() {
item.role.some((role) => permissions.is(role as Role))
);
}
-
-const ConsumableNavigation = () => {
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const links = useConsumableNavigation();
-
- return <DetailSidebar links={links} />;
-};
-
-export default ConsumableNavigation;
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
index 4156c1b0fa..c467bd40b3 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
@@ -96,7 +96,7 @@ const FixtureForm = ({
<Hidden name="unitOfMeasureCode" value="EA" />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
index c7e7871886..d4d61f567c 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
@@ -1,33 +1,14 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Enumerable,
- HStack,
- Menubar,
- VStack,
-} from "@carbon/react";
+import { Enumerable, HStack, Heading, VStack } from "@carbon/react";
import { useParams } from "@remix-run/react";
-import {
- Assign,
- CustomerAvatar,
- EmployeeAvatar,
- useOptimisticAssignment,
-} from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
+import { DetailsTopbar } from "~/components/Layout";
+import { useRouteData } from "~/hooks";
import type { Fixture } from "~/modules/items";
import { path } from "~/utils/path";
+import { useFixtureNavigation } from "./useFixtureNavigation";
const FixtureHeader = () => {
- const permissions = usePermissions();
+ const links = useFixtureNavigation();
const { itemId } = useParams();
if (!itemId) throw new Error("itemId not found");
@@ -35,74 +16,18 @@ const FixtureHeader = () => {
path.to.fixture(itemId)
);
- const optimisticAssignment = useOptimisticAssignment({
- id: itemId,
- table: "item",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.fixtureSummary?.assignee;
-
return (
- <VStack>
- {permissions.is("employee") && !!routeData?.fixtureSummary?.id && (
- <Menubar>
- <Assign
- id={itemId}
- table="item"
- value={routeData?.fixtureSummary?.assignee ?? ""}
- />
- </Menubar>
- )}
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.fixtureSummary?.id}</CardTitle>
- <CardDescription>{routeData?.fixtureSummary?.name}</CardDescription>
- </CardHeader>
- <CardAction>
- {/* <Button
- variant="secondary"
- onClick={() => alert("TODO")}
- leftIcon={<FaHistory />}
- >
- View History
- </Button> */}
- </CardAction>
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <VStack spacing={0} className="flex-grow">
+ <HStack>
+ <Heading size="h2">{routeData?.fixtureSummary?.id}</Heading>
+ <Enumerable value="Fixture" />
</HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Inventory Type</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.fixtureSummary?.itemInventoryType ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Customer</CardAttributeLabel>
- <CardAttributeValue>
- <CustomerAvatar
- customerId={routeData?.fixtureSummary?.customerId ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- </VStack>
+ </VStack>
+ <VStack spacing={0} className="flex-shrink justify-center items-end">
+ <DetailsTopbar links={links} />
+ </VStack>
+ </div>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
new file mode 100644
index 0000000000..d22e9ebdeb
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
@@ -0,0 +1,141 @@
+import {
+ Button,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ VStack,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+import { CustomerAvatar, useOptimisticAssignment } from "~/components";
+import Assignee from "~/components/Assignee";
+import { useRouteData } from "~/hooks";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+import type { BuyMethod, Fixture, PickMethod } from "../../types";
+import { MethodBadge } from "../Item/MethodBadge";
+
+const FixtureProperties = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const sharedFixturesData = useRouteData<{ locations: ListItem[] }>(
+ path.to.fixtureRoot
+ );
+ const routeData = useRouteData<{
+ fixtureSummary: Fixture;
+ buyMethods: BuyMethod[];
+ pickMethods: PickMethod[];
+ }>(path.to.fixture(itemId));
+
+ const locations = sharedFixturesData?.locations ?? [];
+ const buyMethods = routeData?.buyMethods ?? [];
+ const pickMethods = routeData?.pickMethods ?? [];
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.fixtureSummary?.assignee;
+
+ return (
+ <VStack
+ spacing={4}
+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"
+ >
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.fixture(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to fixture</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ routeData?.fixtureSummary?.id ?? ""
+ )
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy fixture number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">{routeData?.fixtureSummary?.name}</span>
+ </VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Assignee</h3>
+ <Assignee id={itemId} table="item" value={assignee ?? ""} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Customer</h3>
+ {routeData?.fixtureSummary?.customerId ? (
+ <CustomerAvatar customerId={routeData?.fixtureSummary?.customerId} />
+ ) : (
+ <span>--</span>
+ )}
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Methods</h3>
+ </HStack>
+ {buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.fixturePurchasing(itemId)}
+ />
+ ))}
+ {pickMethods.map((method) => (
+ <MethodBadge
+ key={method.locationId}
+ type="Pick"
+ text={
+ method.defaultShelfId ??
+ locations.find((l) => l.id === method.locationId)?.name ??
+ ""
+ }
+ to={path.to.fixtureInventoryLocation(itemId, method.locationId)}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ );
+};
+
+export default FixtureProperties;
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/index.ts b/apps/carbon/app/modules/items/ui/Fixtures/index.ts
index 63354d953e..625fcd7fb4 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/index.ts
+++ b/apps/carbon/app/modules/items/ui/Fixtures/index.ts
@@ -1,6 +1,6 @@
import FixtureForm from "./FixtureForm";
import FixtureHeader from "./FixtureHeader";
-import FixtureNavigation from "./FixtureNavigation";
+import FixtureProperties from "./FixtureProperties";
import FixturesTable from "./FixturesTable";
-export { FixtureForm, FixtureHeader, FixtureNavigation, FixturesTable };
+export { FixtureForm, FixtureHeader, FixtureProperties, FixturesTable };
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureNavigation.tsx b/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
similarity index 66%
rename from apps/carbon/app/modules/items/ui/Fixtures/FixtureNavigation.tsx
rename to apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
index cb2573f0a4..9ff3b11b53 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
@@ -1,13 +1,6 @@
import { useParams } from "@remix-run/react";
-import {
- LuBox,
- LuFileText,
- LuShare2,
- LuShoppingCart,
- LuTags,
-} from "react-icons/lu";
-import { DetailSidebar } from "~/components/Layout";
+import { LuBox, LuFileText, LuShoppingCart, LuTags } from "react-icons/lu";
import { usePermissions } from "~/hooks";
import type { Role } from "~/types";
import { path } from "~/utils/path";
@@ -31,14 +24,6 @@ export function useFixtureNavigation() {
icon: LuShoppingCart,
shortcut: "Command+Shift+p",
},
- {
- name: "Suppliers",
- to: path.to.fixtureSuppliers(itemId),
- role: ["employee", "supplier"],
- icon: LuShare2,
- shortcut: "Command+Shift+s",
- },
-
{
name: "Costing",
to: path.to.fixtureCosting(itemId),
@@ -59,14 +44,3 @@ export function useFixtureNavigation() {
item.role.some((role) => permissions.is(role as Role))
);
}
-
-const FixtureNavigation = () => {
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const links = useFixtureNavigation();
-
- return <DetailSidebar links={links} />;
-};
-
-export default FixtureNavigation;
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
new file mode 100644
index 0000000000..05a60d753c
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -0,0 +1,489 @@
+"use client";
+import type { JSONContent } from "@carbon/react";
+import {
+ Button,
+ Card,
+ CardAction,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Editor,
+ HStack,
+ cn,
+ toast,
+} from "@carbon/react";
+import { ValidatedForm } from "@carbon/remix-validated-form";
+import { AnimatePresence, LayoutGroup, motion } from "framer-motion";
+import { useCallback, useState } from "react";
+import { LuSettings2, LuX } from "react-icons/lu";
+import { DirectionAwareTabs } from "~/components/DirectionAwareTabs";
+import {
+ EquipmentType,
+ InputControlled,
+ Number,
+ NumberControlled,
+ StandardFactor,
+ WorkCellType,
+} from "~/components/Form";
+import type { Item } from "~/components/SortableList";
+import { SortableList, SortableListItem } from "~/components/SortableList";
+
+// type Process = {
+// workCenterTypeId: string;
+// equipmentTypeId?: string;
+// setupHours: number;
+// standardFactor: StandardFactor;
+// productionStandard: number;
+// };
+
+export const workInstructions = {
+ type: "doc",
+ content: [
+ {
+ type: "heading",
+ attrs: {
+ level: 2,
+ },
+ content: [
+ {
+ type: "text",
+ text: "Work Instruction",
+ },
+ ],
+ },
+ {
+ type: "heading",
+ attrs: {
+ level: 3,
+ },
+ content: [
+ {
+ type: "text",
+ text: "Setup ",
+ },
+ ],
+ },
+ {
+ type: "paragraph",
+ content: [
+ {
+ type: "text",
+ text: "I'm baby letterpress franzen palo santo offal. XOXO lumbersexual farm-to-table mustache neutra selfies chillwave aesthetic green juice blue bottle letterpress fanny pack try-hard gorpcore. Selvage marfa butcher kale chips craft beer fashion axe lumbersexual mlkshk truffaut etsy same salvia activated charcoal kogi woke. Hoodie green juice put a bird on it, echo park swag disrupt ugh air plant vaporware vice hammock.",
+ },
+ ],
+ },
+ {
+ type: "taskList",
+ content: [
+ {
+ type: "taskItem",
+ attrs: {
+ checked: false,
+ },
+ content: [
+ {
+ type: "paragraph",
+ content: [
+ {
+ type: "text",
+
+ text: "Slow-carb fam same vexillologist bitters.",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ type: "taskItem",
+ attrs: {
+ checked: false,
+ },
+ content: [
+ {
+ type: "paragraph",
+ content: [
+ {
+ type: "text",
+
+ text: "Roof party franzen slow-carb heirloom viral small batch. ",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ type: "taskItem",
+ attrs: {
+ checked: false,
+ },
+ content: [
+ {
+ type: "paragraph",
+ content: [
+ {
+ type: "text",
+
+ text: "Bitters next level listicle, +1 same godard 90's big mood heirloom shabby chic hella.",
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ {
+ type: "heading",
+ attrs: {
+ level: 3,
+ },
+ content: [
+ {
+ type: "text",
+ text: "Run",
+ },
+ ],
+ },
+ {
+ type: "taskList",
+ content: [
+ {
+ type: "taskItem",
+ attrs: {
+ checked: false,
+ },
+ content: [
+ {
+ type: "paragraph",
+ content: [
+ {
+ type: "text",
+
+ text: "DIY enamel pin viral ramps banjo DSA chartreuse.",
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ {
+ type: "paragraph",
+ },
+ ],
+};
+
+const initialState = [
+ {
+ id: "1",
+ text: "Plasma Cut",
+ checked: false,
+ description: "",
+ },
+ {
+ id: "2",
+ text: "Deburring",
+ checked: false,
+ description: "",
+ },
+ {
+ id: "3",
+ text: "Brake Press",
+ checked: false,
+ description: "",
+ },
+ {
+ id: "5",
+ text: "Paint",
+ checked: false,
+ description: "",
+ },
+];
+
+const BillOfProcess = () => {
+ const [items, setItems] = useState<Item[]>(initialState);
+ const [openItemId, setOpenItemId] = useState<string | null>(null);
+ const [tabChangeRerender, setTabChangeRerender] = useState<number>(1);
+
+ const onCompleteItem = (id: string) => {
+ setItems((prevItems) =>
+ prevItems.map((item) =>
+ item.id === id ? { ...item, checked: !item.checked } : item
+ )
+ );
+ };
+
+ const onAddItem = () => {
+ setItems((prevItems) => [
+ ...prevItems,
+ {
+ text: `Item ${prevItems.length + 1}`,
+ checked: false,
+ id: Math.random().toString(16).slice(2),
+ description: "",
+ },
+ ]);
+ };
+
+ const onCloseOnDrag = useCallback(() => {
+ setItems((prevItems) => {
+ const updatedItems = prevItems.map((item) =>
+ item.checked ? { ...item, checked: false } : item
+ );
+ return updatedItems.some(
+ (item, index) => item.checked !== prevItems[index].checked
+ )
+ ? updatedItems
+ : prevItems;
+ });
+ }, []);
+
+ const renderListItem = (
+ item: Item,
+ order: number,
+ onCompleteItem: (id: string) => void,
+ onRemoveItem: (id: string) => void
+ ) => {
+ const isOpen = item.id === openItemId;
+
+ const tabs = [
+ {
+ id: 0,
+ label: "Details",
+ content: (
+ <div className="flex w-full flex-col pr-2 py-2">
+ <motion.div
+ initial={{ opacity: 0, filter: "blur(4px)" }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ transition={{
+ type: "spring",
+ bounce: 0.2,
+ duration: 0.75,
+ delay: 0.15,
+ }}
+ >
+ <ValidatedForm className="w-full flex flex-col gap-y-4">
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
+ <WorkCellType
+ name="workCellTypeId"
+ label="Work Cell"
+ onChange={(value) => {
+ // onWorkCellChange(value?.value as string);
+ }}
+ />
+ <EquipmentType
+ name="equipmentTypeId"
+ label="Equipment"
+ onChange={(value) =>
+ // onEquipmentChange(value?.value as string)
+ console.log(value)
+ }
+ />
+ </div>
+ <InputControlled
+ name="description"
+ label="Description"
+ value={""}
+ // value={workCellData.description}
+ onChange={(newValue) => {
+ // setWorkCellData((d) => ({ ...d, description: newValue }));
+ }}
+ />
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
+ <NumberControlled
+ name="setupHours"
+ label="Setup Time (hours)"
+ minValue={0}
+ value={0}
+ // value={equipmentData.setupHours}
+ onChange={(newValue) => {
+ console.log(newValue);
+ // setEquipmentData((d) => ({ ...d, setupHours: newValue }));
+ }}
+ />
+ <Number
+ name="productionStandard"
+ label="Production Standard"
+ minValue={0}
+ />
+ <StandardFactor
+ name="standardFactor"
+ label="Standard Factor"
+ />
+ </div>
+ </ValidatedForm>
+ </motion.div>
+ </div>
+ ),
+ },
+ {
+ id: 1,
+ label: "Work Instructions",
+ content: (
+ <div className="flex flex-col p-2">
+ <motion.div
+ initial={{ opacity: 0, filter: "blur(4px)" }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ transition={{
+ type: "spring",
+ bounce: 0.2,
+ duration: 0.75,
+ delay: 0.15,
+ }}
+ >
+ <Editor
+ initialValue={workInstructions as JSONContent}
+ onChange={(value) => console.log(value)}
+ />
+ </motion.div>
+ </div>
+ ),
+ },
+ ];
+
+ return (
+ <SortableListItem
+ item={item}
+ order={order}
+ key={item.id}
+ isExpanded={isOpen}
+ onCompleteItem={onCompleteItem}
+ onRemoveItem={onRemoveItem}
+ handleDrag={onCloseOnDrag}
+ className="my-2 "
+ renderExtra={(item) => (
+ <div
+ key={`${isOpen}`}
+ className={cn(
+ "flex h-full w-full flex-col items-center justify-center gap-2 ",
+ isOpen ? "py-1 px-1" : "py-3 "
+ )}
+ >
+ <motion.button
+ layout
+ onClick={() => setOpenItemId(!isOpen ? item.id : null)}
+ key="collapse"
+ className={cn(
+ isOpen
+ ? "absolute right-3 top-3 z-10 "
+ : "relative z-10 ml-auto mr-3 "
+ )}
+ >
+ {isOpen ? (
+ <motion.span
+ initial={{ opacity: 0, filter: "blur(4px)" }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ exit={{ opacity: 1, filter: "blur(0px)" }}
+ transition={{
+ type: "spring",
+ duration: 1.95,
+ }}
+ >
+ <LuX className="h-5 w-5 text-foreground" />
+ </motion.span>
+ ) : (
+ <motion.span
+ initial={{ opacity: 0, filter: "blur(4px)" }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ exit={{ opacity: 1, filter: "blur(0px)" }}
+ transition={{
+ type: "spring",
+ duration: 0.95,
+ }}
+ >
+ <LuSettings2 className="stroke-1 h-5 w-5 text-foreground/80 hover:stroke-primary/70 " />
+ </motion.span>
+ )}
+ </motion.button>
+
+ <LayoutGroup id={`${item.id}`}>
+ <AnimatePresence mode="popLayout">
+ {isOpen ? (
+ <motion.div className="flex w-full flex-col ">
+ <div className=" w-full p-2">
+ <motion.div
+ initial={{
+ y: 0,
+ opacity: 0,
+ filter: "blur(4px)",
+ }}
+ animate={{
+ y: 0,
+ opacity: 1,
+ filter: "blur(0px)",
+ }}
+ transition={{
+ type: "spring",
+ duration: 0.15,
+ }}
+ layout
+ className="w-full "
+ >
+ <DirectionAwareTabs
+ className="mr-auto"
+ tabs={tabs}
+ onChange={() =>
+ setTabChangeRerender(tabChangeRerender + 1)
+ }
+ />
+ </motion.div>
+ </div>
+
+ <motion.div
+ key={`re-render-${tabChangeRerender}`} // re-animates the button section on tab change
+ className="flex w-full items-center justify-end p-2"
+ initial={{ opacity: 0, filter: "blur(4px)" }}
+ animate={{ opacity: 1, filter: "blur(0px)" }}
+ transition={{
+ type: "spring",
+ bounce: 0,
+ duration: 0.55,
+ }}
+ >
+ <motion.div layout className="ml-auto mr-1 pt-2">
+ <Button
+ size="sm"
+ onClick={() => {
+ setOpenItemId(null);
+ toast.info("Changes saved");
+ }}
+ >
+ Save
+ </Button>
+ </motion.div>
+ </motion.div>
+ </motion.div>
+ ) : null}
+ </AnimatePresence>
+ </LayoutGroup>
+ </div>
+ )}
+ />
+ );
+ };
+
+ return (
+ <Card>
+ <HStack className="justify-between">
+ <CardHeader>
+ <CardTitle>Bill of Processes</CardTitle>
+ </CardHeader>
+
+ <CardAction>
+ <Button variant="secondary" onClick={onAddItem}>
+ Add Process
+ </Button>
+ </CardAction>
+ </HStack>
+ <CardContent>
+ <SortableList
+ items={items}
+ setItems={setItems}
+ onCompleteItem={onCompleteItem}
+ renderItem={renderListItem}
+ />
+ </CardContent>
+ </Card>
+ );
+};
+
+export default BillOfProcess;
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx
index ed1231fb46..e9b88bc209 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemCostingForm.tsx
@@ -50,7 +50,7 @@ const ItemCostingForm = ({ initialValues }: ItemCostingFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="itemId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Select
name="costingMethod"
label="Part Costing Method"
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
index f79530a364..3c2a62e89b 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
@@ -49,7 +49,7 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="id" />
- <div className="grid w-full gap-x-8 gap-y-2 grid-cols-1 md:grid-cols-3">
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 md:grid-cols-3">
<Input
isReadOnly
name="readableId"
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx
index a54ee29bbe..54dbeddea7 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx
@@ -74,7 +74,7 @@ const ItemPlanningForm = ({
<CardContent>
<Hidden name="itemId" />
<Hidden name="locationId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<SelectForm
name="reorderingPolicy"
label="Reordering Policy"
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx
index ad6a747b6c..60a27d21cc 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemPurchasingForm.tsx
@@ -57,7 +57,7 @@ const ItemPurchasingForm = ({
</CardHeader>
<CardContent>
<Hidden name="itemId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Supplier
name="preferredSupplierId"
label="Preferred Supplier"
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx
index 381245cef8..4d76db47a2 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemSalePriceForm.tsx
@@ -40,7 +40,7 @@ const ItemSalePriceForm = ({ initialValues }: ItemSalePriceFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="itemId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Number
name="unitSalePrice"
label="Unit Sale Price"
diff --git a/apps/carbon/app/modules/items/ui/Item/MethodBadge.tsx b/apps/carbon/app/modules/items/ui/Item/MethodBadge.tsx
new file mode 100644
index 0000000000..a087575656
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Item/MethodBadge.tsx
@@ -0,0 +1,37 @@
+import { Badge, HStack, cn } from "@carbon/react";
+import { Link } from "@remix-run/react";
+import { LuExternalLink } from "react-icons/lu";
+import { MethodIcon } from "./MethodIcon";
+
+type MethodBadgeProps = {
+ type: "Buy" | "Make" | "Pick";
+ text: string;
+ to: string;
+ className?: string;
+};
+
+export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {
+ return (
+ <HStack className="group" spacing={1}>
+ <Badge className={cn(getBadgeColor(type), className)}>
+ <MethodIcon type={type} className="w-3 h-3 mr-1 text-white" />
+ {text}
+ </Badge>
+ <Link
+ className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
+ to={to}
+ prefetch="intent"
+ >
+ <LuExternalLink />
+ </Link>
+ </HStack>
+ );
+}
+
+function getBadgeColor(type: "Buy" | "Make" | "Pick") {
+ return type === "Buy"
+ ? "bg-blue-500 hover:bg-blue-600 text-white"
+ : type === "Make"
+ ? "bg-green-500 hover:bg-green-600 text-white"
+ : "bg-orange-500 hover:bg-orange-600 text-white";
+}
diff --git a/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx b/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx
index f400ba4124..1175d224e6 100644
--- a/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx
@@ -83,7 +83,7 @@ const PickMethodForm = ({
<CardContent>
<Hidden name="itemId" />
<Hidden name="locationId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<CreatableCombobox
name="defaultShelfId"
label="Default Shelf"
diff --git a/apps/carbon/app/modules/items/ui/Item/index.ts b/apps/carbon/app/modules/items/ui/Item/index.ts
index 1f870cb4ac..bea12dddb3 100644
--- a/apps/carbon/app/modules/items/ui/Item/index.ts
+++ b/apps/carbon/app/modules/items/ui/Item/index.ts
@@ -1,3 +1,4 @@
+import BillOfProcess from "./BillOfProcess";
import BuyMethodForm from "./BuyMethodForm";
import BuyMethods from "./BuyMethods";
import ItemCostingForm from "./ItemCostingForm";
@@ -9,6 +10,7 @@ import { MethodIcon } from "./MethodIcon";
import PickMethodForm from "./PickMethodForm";
export {
+ BillOfProcess,
BuyMethodForm,
BuyMethods,
ItemCostingForm,
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
index 76cf966343..a8cd3da3af 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
@@ -103,7 +103,7 @@ const MaterialForm = ({
<Hidden name="type" value={type} />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
index 461abd517e..d6af518a12 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
@@ -1,28 +1,14 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Enumerable,
- HStack,
- Menubar,
- VStack,
-} from "@carbon/react";
+import { Enumerable, HStack, Heading, VStack } from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
+import { DetailsTopbar } from "~/components/Layout";
+import { useRouteData } from "~/hooks";
import type { Material } from "~/modules/items";
import { path } from "~/utils/path";
+import { useMaterialNavigation } from "./useMaterialNavigation";
const MaterialHeader = () => {
- const permissions = usePermissions();
+ const links = useMaterialNavigation();
const { itemId } = useParams();
if (!itemId) throw new Error("itemId not found");
@@ -30,96 +16,18 @@ const MaterialHeader = () => {
path.to.material(itemId)
);
- const optimisticAssignment = useOptimisticAssignment({
- id: itemId,
- table: "item",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.materialSummary?.assignee;
-
return (
- <VStack>
- {permissions.is("employee") && !!routeData?.materialSummary?.id && (
- <Menubar>
- <Assign
- id={itemId}
- table="item"
- value={routeData?.materialSummary?.assignee ?? ""}
- />
- </Menubar>
- )}
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.materialSummary?.id}</CardTitle>
- <CardDescription>
- {routeData?.materialSummary?.name}
- </CardDescription>
- </CardHeader>
- <CardAction>
- {/* <Button
- variant="secondary"
- onClick={() => alert("TODO")}
- leftIcon={<FaHistory />}
- >
- View History
- </Button> */}
- </CardAction>
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <VStack spacing={0} className="flex-grow">
+ <HStack>
+ <Heading size="h2">{routeData?.materialSummary?.id}</Heading>
+ <Enumerable value="Material" />
</HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Form</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.materialSummary?.materialForm ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Substance</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.materialSummary?.materialSubstance ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Finish</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.materialSummary?.finish ?? "-"}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Grade</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.materialSummary?.grade ?? "-"}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>UoM</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.materialSummary?.unitOfMeasure ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- </VStack>
+ </VStack>
+ <VStack spacing={0} className="flex-shrink justify-center items-end">
+ <DetailsTopbar links={links} />
+ </VStack>
+ </div>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
new file mode 100644
index 0000000000..5358687ed6
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
@@ -0,0 +1,163 @@
+import {
+ Button,
+ Enumerable,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ VStack,
+ cn,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+import { useOptimisticAssignment } from "~/components";
+import Assignee from "~/components/Assignee";
+import { useRouteData } from "~/hooks";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+import type { BuyMethod, Material, PickMethod } from "../../types";
+import { MethodBadge } from "../Item/MethodBadge";
+
+const MaterialProperties = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const sharedMaterialsData = useRouteData<{ locations: ListItem[] }>(
+ path.to.materialRoot
+ );
+ const routeData = useRouteData<{
+ materialSummary: Material;
+ buyMethods: BuyMethod[];
+ pickMethods: PickMethod[];
+ }>(path.to.material(itemId));
+
+ const locations = sharedMaterialsData?.locations ?? [];
+ const buyMethods = routeData?.buyMethods ?? [];
+ const pickMethods = routeData?.pickMethods ?? [];
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.materialSummary?.assignee;
+
+ return (
+ <VStack
+ spacing={4}
+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"
+ >
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.material(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to material</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ routeData?.materialSummary?.id ?? ""
+ )
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy material number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">{routeData?.materialSummary?.name}</span>
+ </VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Assignee</h3>
+ <Assignee id={itemId} table="item" value={assignee ?? ""} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Shape</h3>
+ <Enumerable value={routeData?.materialSummary?.materialForm ?? null} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Substance</h3>
+ <Enumerable
+ value={routeData?.materialSummary?.materialSubstance ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Inventory Type</h3>
+ <Enumerable
+ className={cn(
+ (routeData?.materialSummary?.active === false ||
+ routeData?.materialSummary?.blocked) &&
+ "opacity-50"
+ )}
+ value={routeData?.materialSummary?.itemInventoryType ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>
+ <Enumerable value={routeData?.materialSummary?.unitOfMeasure ?? null} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Methods</h3>
+ </HStack>
+ {buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.materialPurchasing(itemId)}
+ />
+ ))}
+ {pickMethods.map((method) => (
+ <MethodBadge
+ key={method.locationId}
+ type="Pick"
+ text={
+ method.defaultShelfId ??
+ locations.find((l) => l.id === method.locationId)?.name ??
+ ""
+ }
+ to={path.to.materialInventoryLocation(itemId, method.locationId)}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ );
+};
+
+export default MaterialProperties;
diff --git a/apps/carbon/app/modules/items/ui/Materials/index.ts b/apps/carbon/app/modules/items/ui/Materials/index.ts
index 49b8126d1a..6109f4948c 100644
--- a/apps/carbon/app/modules/items/ui/Materials/index.ts
+++ b/apps/carbon/app/modules/items/ui/Materials/index.ts
@@ -1,6 +1,6 @@
import MaterialForm from "./MaterialForm";
import MaterialHeader from "./MaterialHeader";
-import MaterialNavigation from "./MaterialNavigation";
+import MaterialProperties from "./MaterialProperties";
import MaterialsTable from "./MaterialsTable";
-export { MaterialForm, MaterialHeader, MaterialNavigation, MaterialsTable };
+export { MaterialForm, MaterialHeader, MaterialProperties, MaterialsTable };
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialNavigation.tsx b/apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx
similarity index 74%
rename from apps/carbon/app/modules/items/ui/Materials/MaterialNavigation.tsx
rename to apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx
index 410c9f353f..165e3fddc8 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/useMaterialNavigation.tsx
@@ -4,11 +4,9 @@ import {
LuBox,
LuFileBarChart,
LuFileText,
- LuShare2,
LuShoppingCart,
LuTags,
} from "react-icons/lu";
-import { DetailSidebar } from "~/components/Layout";
import { usePermissions } from "~/hooks";
import type { Role } from "~/types";
import { path } from "~/utils/path";
@@ -32,14 +30,6 @@ export function useMaterialNavigation() {
icon: LuShoppingCart,
shortcut: "Command+Shift+p",
},
- {
- name: "Suppliers",
- to: path.to.materialSuppliers(itemId),
- role: ["employee", "supplier"],
- icon: LuShare2,
- shortcut: "Command+Shift+s",
- },
-
{
name: "Costing",
to: path.to.materialCosting(itemId),
@@ -67,14 +57,3 @@ export function useMaterialNavigation() {
item.role.some((role) => permissions.is(role as Role))
);
}
-
-const MaterialNavigation = () => {
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const links = useMaterialNavigation();
-
- return <DetailSidebar links={links} />;
-};
-
-export default MaterialNavigation;
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
index 73a93ec343..6fbef12f19 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
@@ -101,7 +101,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
<Hidden name="type" value={type} />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx
index 4e739586b8..d2d62126ed 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartManufacturingForm.tsx
@@ -48,7 +48,7 @@ const PartManufacturingForm = ({
</CardHeader>
<CardContent>
<Hidden name="itemId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Select
name="manufacturingPolicy"
label="Manufacturing Policy"
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsx b/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsx
deleted file mode 100644
index 334a85b3d9..0000000000
--- a/apps/carbon/app/modules/items/ui/Parts/PartNavigation.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { DetailSidebar } from "~/components/Layout";
-import { usePartNavigation } from "./usePartNavigation";
-
-const PartNavigation = () => {
- const links = usePartNavigation();
-
- return <DetailSidebar links={links} />;
-};
-
-export default PartNavigation;
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
new file mode 100644
index 0000000000..a15c0f9a29
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
@@ -0,0 +1,163 @@
+import {
+ Button,
+ Enumerable,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ VStack,
+ cn,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+import { useOptimisticAssignment } from "~/components";
+import Assignee from "~/components/Assignee";
+import { useRouteData } from "~/hooks";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+import type { BuyMethod, PartSummary, PickMethod } from "../../types";
+import { MethodBadge } from "../Item/MethodBadge";
+
+const PartProperties = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const sharedPartsData = useRouteData<{ locations: ListItem[] }>(
+ path.to.partRoot
+ );
+ const routeData = useRouteData<{
+ partSummary: PartSummary;
+ buyMethods: BuyMethod[];
+ pickMethods: PickMethod[];
+ }>(path.to.part(itemId));
+
+ const locations = sharedPartsData?.locations ?? [];
+ const buyMethods = routeData?.buyMethods ?? [];
+ const pickMethods = routeData?.pickMethods ?? [];
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.partSummary?.assignee;
+
+ return (
+ <VStack
+ spacing={4}
+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"
+ >
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.part(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to part</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ routeData?.partSummary?.id ?? ""
+ )
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy part number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">{routeData?.partSummary?.name}</span>
+ </VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Assignee</h3>
+ <Assignee id={itemId} table="item" value={assignee ?? ""} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Replenishment</h3>
+ <Enumerable
+ className={cn(
+ (routeData?.partSummary?.active === false ||
+ routeData?.partSummary?.blocked) &&
+ "opacity-50"
+ )}
+ value={routeData?.partSummary?.replenishmentSystem ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Inventory Type</h3>
+ <Enumerable
+ className={cn(
+ (routeData?.partSummary?.active === false ||
+ routeData?.partSummary?.blocked) &&
+ "opacity-50"
+ )}
+ value={routeData?.partSummary?.itemInventoryType ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>
+ <Enumerable value={routeData?.partSummary?.unitOfMeasure ?? null} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Methods</h3>
+ </HStack>
+ {buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.partPurchasing(itemId)}
+ />
+ ))}
+ {pickMethods.map((method) => (
+ <MethodBadge
+ key={method.locationId}
+ type="Pick"
+ text={
+ method.defaultShelfId ??
+ locations.find((l) => l.id === method.locationId)?.name ??
+ ""
+ }
+ to={path.to.partInventoryLocation(itemId, method.locationId)}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ );
+};
+
+export default PartProperties;
diff --git a/apps/carbon/app/modules/items/ui/Parts/index.ts b/apps/carbon/app/modules/items/ui/Parts/index.ts
index 2d742601e5..e5541735be 100644
--- a/apps/carbon/app/modules/items/ui/Parts/index.ts
+++ b/apps/carbon/app/modules/items/ui/Parts/index.ts
@@ -1,13 +1,13 @@
import PartForm from "./PartForm";
import PartHeader from "./PartHeader";
import PartManufacturingForm from "./PartManufacturingForm";
-import PartNavigation from "./PartNavigation";
+import PartProperties from "./PartProperties";
import PartsTable from "./PartsTable";
export {
PartForm,
PartHeader,
PartManufacturingForm,
- PartNavigation,
+ PartProperties,
PartsTable,
};
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx
index f77a998ee1..0a20505c26 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx
@@ -61,7 +61,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
<Hidden name="unitOfMeasureCode" value="EA" />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
index 5f2a1a7edd..0d49c34d53 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
@@ -1,91 +1,34 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Enumerable,
- HStack,
- Menubar,
- VStack,
-} from "@carbon/react";
+import { Enumerable, HStack, Heading, VStack } from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
+import { DetailsTopbar } from "~/components/Layout";
+import { useRouteData } from "~/hooks";
import type { Service } from "~/modules/items";
import { path } from "~/utils/path";
+import { useServiceNavigation } from "./useServiceNavigation";
const ServiceHeader = () => {
- const permissions = usePermissions();
const { itemId } = useParams();
if (!itemId) throw new Error("itemId not found");
const routeData = useRouteData<{ service: Service }>(path.to.service(itemId));
- const optimisticAssignment = useOptimisticAssignment({
- id: itemId,
- table: "item",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.service?.assignee;
+ const links = useServiceNavigation(
+ routeData?.service?.serviceType ?? "External"
+ );
return (
- <VStack>
- {permissions.is("employee") && (
- <Menubar>
- <Assign
- id={itemId}
- table="item"
- value={routeData?.service?.assignee ?? ""}
- />
- </Menubar>
- )}
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.service?.id}</CardTitle>
- <CardDescription>{routeData?.service?.name}</CardDescription>
- </CardHeader>
- <CardAction>
- {/* <Button
- variant="secondary"
- onClick={() => alert("TODO")}
- leftIcon={<FaHistory />}
- >
- View History
- </Button> */}
- </CardAction>
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <VStack spacing={0} className="flex-grow">
+ <HStack>
+ <Heading size="h2">{routeData?.service?.id}</Heading>
+ <Enumerable value="Service" />
</HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Service Type</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable value={routeData?.service?.serviceType ?? null} />
- </CardAttributeValue>
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- </VStack>
+ </VStack>
+ <VStack spacing={0} className="flex-shrink justify-center items-end">
+ <DetailsTopbar links={links} />
+ </VStack>
+ </div>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceNavigation.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceNavigation.tsx
deleted file mode 100644
index f301f94e5a..0000000000
--- a/apps/carbon/app/modules/items/ui/Services/ServiceNavigation.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { useParams } from "@remix-run/react";
-import { LuFileText, LuShare2 } from "react-icons/lu";
-import { DetailSidebar } from "~/components/Layout";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { Service, ServiceType } from "~/modules/items/types";
-import type { Role } from "~/types";
-import { path } from "~/utils/path";
-
-export function useServiceNavigation(type: ServiceType) {
- const permissions = usePermissions();
- return [
- {
- name: "Details",
- to: "details",
- icon: LuFileText,
- },
- {
- name: "Suppliers",
- to: "suppliers",
- isDisabled: type === "Internal",
- role: ["employee", "supplier"],
- icon: LuShare2,
- },
- ].filter(
- (item) =>
- !item.isDisabled &&
- (item.role === undefined ||
- item.role.some((role) => permissions.is(role as Role)))
- );
-}
-
-const ServiceNavigation = () => {
- const { itemId } = useParams();
-
- if (!itemId) throw new Error("itemId not found");
-
- const routeData = useRouteData<{ service: Service }>(path.to.service(itemId));
- if (!routeData?.service?.serviceType)
- throw new Error("Could not find service type in routeData");
-
- const links = useServiceNavigation(routeData.service.serviceType);
-
- return <DetailSidebar links={links} />;
-};
-
-export default ServiceNavigation;
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
new file mode 100644
index 0000000000..bdf9f4018e
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
@@ -0,0 +1,118 @@
+import {
+ Button,
+ Enumerable,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ VStack,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+import { useOptimisticAssignment } from "~/components";
+import Assignee from "~/components/Assignee";
+import { useRouteData } from "~/hooks";
+import { path } from "~/utils/path";
+import type { BuyMethod, PickMethod, Service } from "../../types";
+import { MethodBadge } from "../Item/MethodBadge";
+
+const ServiceProperties = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const routeData = useRouteData<{
+ service: Service;
+ buyMethods: BuyMethod[];
+ pickMethods: PickMethod[];
+ }>(path.to.service(itemId));
+
+ const buyMethods = routeData?.buyMethods ?? [];
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.service?.assignee;
+
+ return (
+ <VStack
+ spacing={4}
+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"
+ >
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.service(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to service</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(routeData?.service?.id ?? "")
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy service number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">{routeData?.service?.name}</span>
+ </VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Assignee</h3>
+ <Assignee id={itemId} table="item" value={assignee ?? ""} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Service Type</h3>
+ <Enumerable value={routeData?.service?.serviceType ?? null} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Methods</h3>
+ </HStack>
+ {buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.servicePurchasing(itemId)}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ );
+};
+
+export default ServiceProperties;
diff --git a/apps/carbon/app/modules/items/ui/Services/index.ts b/apps/carbon/app/modules/items/ui/Services/index.ts
index 05632c36e9..6f7f5bd211 100644
--- a/apps/carbon/app/modules/items/ui/Services/index.ts
+++ b/apps/carbon/app/modules/items/ui/Services/index.ts
@@ -1,6 +1,6 @@
import ServiceForm from "./ServiceForm";
import ServiceHeader from "./ServiceHeader";
-import ServiceNavigation from "./ServiceNavigation";
+import ServiceProperties from "./ServiceProperties";
import ServicesTable from "./ServicesTable";
-export { ServiceForm, ServiceHeader, ServiceNavigation, ServicesTable };
+export { ServiceForm, ServiceHeader, ServiceProperties, ServicesTable };
diff --git a/apps/carbon/app/modules/items/ui/Services/useServiceNavigation.tsx b/apps/carbon/app/modules/items/ui/Services/useServiceNavigation.tsx
new file mode 100644
index 0000000000..18bab805f2
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Services/useServiceNavigation.tsx
@@ -0,0 +1,29 @@
+import { LuFileText, LuShoppingCart } from "react-icons/lu";
+import { usePermissions } from "~/hooks";
+import type { ServiceType } from "~/modules/items/types";
+import type { Role } from "~/types";
+
+export function useServiceNavigation(type: ServiceType) {
+ const permissions = usePermissions();
+ return [
+ {
+ name: "Details",
+ to: "details",
+ icon: LuFileText,
+ shortcut: "Command+Shift+d",
+ },
+ {
+ name: "Purchasing",
+ to: "purchasing",
+ isDisabled: type === "Internal",
+ role: ["employee", "supplier"],
+ icon: LuShoppingCart,
+ shortcut: "Command+Shift+p",
+ },
+ ].filter(
+ (item) =>
+ !item.isDisabled &&
+ (item.role === undefined ||
+ item.role.some((role) => permissions.is(role as Role)))
+ );
+}
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx
index 0abfc53fba..14d9ad0c3e 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx
@@ -91,7 +91,7 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
<Hidden name="type" value={type} />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
index 6647b2c086..5d2a5f8968 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
@@ -1,103 +1,31 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Enumerable,
- HStack,
- Menubar,
- VStack,
-} from "@carbon/react";
+import { Enumerable, HStack, Heading, VStack } from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { ToolSummary } from "~/modules/items";
+import { DetailsTopbar } from "~/components/Layout";
+import { useRouteData } from "~/hooks";
+import type { Tool } from "~/modules/items";
import { path } from "~/utils/path";
+import { useToolNavigation } from "./useToolNavigation";
const ToolHeader = () => {
- const permissions = usePermissions();
+ const links = useToolNavigation();
const { itemId } = useParams();
if (!itemId) throw new Error("itemId not found");
- const routeData = useRouteData<{ toolSummary: ToolSummary }>(
- path.to.tool(itemId)
- );
-
- const optimisticAssignment = useOptimisticAssignment({
- id: itemId,
- table: "item",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.toolSummary?.assignee;
+ const routeData = useRouteData<{ toolSummary: Tool }>(path.to.tool(itemId));
return (
- <VStack>
- {permissions.is("employee") && !!routeData?.toolSummary?.id && (
- <Menubar>
- <Assign
- id={itemId}
- table="item"
- value={routeData?.toolSummary?.assignee ?? ""}
- />
- </Menubar>
- )}
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.toolSummary?.id}</CardTitle>
- <CardDescription>{routeData?.toolSummary?.name}</CardDescription>
- </CardHeader>
- <CardAction>
- {/* <Button
- variant="secondary"
- onClick={() => alert("TODO")}
- leftIcon={<FaHistory />}
- >
- View History
- </Button> */}
- </CardAction>
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <VStack spacing={0} className="flex-grow">
+ <HStack>
+ <Heading size="h2">{routeData?.toolSummary?.id}</Heading>
+ <Enumerable value="Tool" />
</HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Inventory Type</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.toolSummary?.itemInventoryType ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>UoM</CardAttributeLabel>
- <CardAttributeValue>
- <Enumerable
- value={routeData?.toolSummary?.unitOfMeasure ?? null}
- />
- </CardAttributeValue>
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- </VStack>
+ </VStack>
+ <VStack spacing={0} className="flex-shrink justify-center items-end">
+ <DetailsTopbar links={links} />
+ </VStack>
+ </div>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
new file mode 100644
index 0000000000..5a32e62f2f
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -0,0 +1,151 @@
+import {
+ Button,
+ Enumerable,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ VStack,
+ cn,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+import { useOptimisticAssignment } from "~/components";
+import Assignee from "~/components/Assignee";
+import { useRouteData } from "~/hooks";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+import type { BuyMethod, PickMethod, Tool } from "../../types";
+import { MethodBadge } from "../Item/MethodBadge";
+
+const ToolProperties = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const sharedToolsData = useRouteData<{ locations: ListItem[] }>(
+ path.to.toolRoot
+ );
+ const routeData = useRouteData<{
+ toolSummary: Tool;
+ buyMethods: BuyMethod[];
+ pickMethods: PickMethod[];
+ }>(path.to.tool(itemId));
+
+ const locations = sharedToolsData?.locations ?? [];
+ const buyMethods = routeData?.buyMethods ?? [];
+ const pickMethods = routeData?.pickMethods ?? [];
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.toolSummary?.assignee;
+
+ return (
+ <VStack
+ spacing={4}
+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"
+ >
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.tool(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to tool</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ routeData?.toolSummary?.id ?? ""
+ )
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy tool number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">{routeData?.toolSummary?.name}</span>
+ </VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Assignee</h3>
+ <Assignee id={itemId} table="item" value={assignee ?? ""} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Inventory Type</h3>
+ <Enumerable
+ className={cn(
+ (routeData?.toolSummary?.active === false ||
+ routeData?.toolSummary?.blocked) &&
+ "opacity-50"
+ )}
+ value={routeData?.toolSummary?.itemInventoryType ?? null}
+ />
+ </VStack>
+
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>
+ <Enumerable value={routeData?.toolSummary?.unitOfMeasure ?? null} />
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Methods</h3>
+ </HStack>
+ {buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.toolPurchasing(itemId)}
+ />
+ ))}
+ {pickMethods.map((method) => (
+ <MethodBadge
+ key={method.locationId}
+ type="Pick"
+ text={
+ method.defaultShelfId ??
+ locations.find((l) => l.id === method.locationId)?.name ??
+ ""
+ }
+ to={path.to.toolInventoryLocation(itemId, method.locationId)}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ );
+};
+
+export default ToolProperties;
diff --git a/apps/carbon/app/modules/items/ui/Tools/index.ts b/apps/carbon/app/modules/items/ui/Tools/index.ts
index 2ae24e79b5..25705671e4 100644
--- a/apps/carbon/app/modules/items/ui/Tools/index.ts
+++ b/apps/carbon/app/modules/items/ui/Tools/index.ts
@@ -1,6 +1,6 @@
import ToolForm from "./ToolForm";
import ToolHeader from "./ToolHeader";
-import ToolNavigation from "./ToolNavigation";
+import ToolProperties from "./ToolProperties";
import ToolsTable from "./ToolsTable";
-export { ToolForm, ToolHeader, ToolNavigation, ToolsTable };
+export { ToolForm, ToolHeader, ToolProperties, ToolsTable };
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolNavigation.tsx b/apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx
similarity index 74%
rename from apps/carbon/app/modules/items/ui/Tools/ToolNavigation.tsx
rename to apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx
index 52c1ded2c9..ff850ce2f7 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolNavigation.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/useToolNavigation.tsx
@@ -4,11 +4,9 @@ import {
LuBox,
LuFileBarChart,
LuFileText,
- LuShare2,
LuShoppingCart,
LuTags,
} from "react-icons/lu";
-import { DetailSidebar } from "~/components/Layout";
import { usePermissions } from "~/hooks";
import type { Role } from "~/types";
import { path } from "~/utils/path";
@@ -32,14 +30,6 @@ export function useToolNavigation() {
icon: LuShoppingCart,
shortcut: "Command+Shift+p",
},
- {
- name: "Suppliers",
- to: path.to.toolSuppliers(itemId),
- role: ["employee", "supplier"],
- icon: LuShare2,
- shortcut: "Command+Shift+s",
- },
-
{
name: "Costing",
to: path.to.toolCosting(itemId),
@@ -67,14 +57,3 @@ export function useToolNavigation() {
item.role.some((role) => permissions.is(role as Role))
);
}
-
-const ToolNavigation = () => {
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const links = useToolNavigation();
-
- return <DetailSidebar links={links} />;
-};
-
-export default ToolNavigation;
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
index df6d5bdcc4..63603dd106 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
@@ -67,7 +67,7 @@ const PurchaseOrderDeliveryForm = ({
</CardHeader>
<CardContent>
<Hidden name="id" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Location
name="locationId"
label="Delivery Location"
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx
index 680d0ed617..7e8a2113a2 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx
@@ -77,7 +77,7 @@ const PurchaseOrderForm = ({ initialValues }: PurchaseOrderFormProps) => {
<VStack>
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
index 939dcc5f8f..c27a83a846 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
@@ -55,7 +55,7 @@ const PurchaseOrderPaymentForm = ({
</CardHeader>
<CardContent>
<Hidden name="id" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Supplier
name="invoiceSupplierId"
label="Invoice Supplier"
diff --git a/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx b/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx
index 61a75a8f74..487e7ac1cf 100644
--- a/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx
@@ -66,7 +66,7 @@ const RequestForQuoteForm = ({ initialValues }: RequestForQuoteFormProps) => {
<VStack>
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
index b80bb0e9cf..937da7f647 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
@@ -88,7 +88,7 @@ const SupplierForm = ({
<Hidden name="type" value={type} />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx
index 261e978e4f..61f9345c14 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx
@@ -58,7 +58,7 @@ const SupplierPaymentForm = ({ initialValues }: SupplierPaymentFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="supplierId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Supplier
name="invoiceSupplierId"
label="Invoice Supplier"
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx
index 33deff4985..52277b4912 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx
@@ -64,7 +64,7 @@ const SupplierShippingForm = ({ initialValues }: SupplierShippingFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="supplierId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Supplier
name="shippingSupplierId"
label="Shipping Supplier"
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
index e43b38ea85..03dc4bc4ea 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
@@ -88,7 +88,7 @@ const CustomerForm = ({
<Hidden name="type" value={type} />
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx
index 250848ccfb..ed1b79bd64 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx
@@ -58,7 +58,7 @@ const CustomerPaymentForm = ({ initialValues }: CustomerPaymentFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="customerId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Customer
name="invoiceCustomerId"
label="Invoice Customer"
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx
index 905a3f6210..135ae5ee69 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx
@@ -64,7 +64,7 @@ const CustomerShippingForm = ({ initialValues }: CustomerShippingFormProps) => {
</CardHeader>
<CardContent>
<Hidden name="customerId" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<VStack>
<Customer
name="shippingCustomerId"
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
index 0763958cdb..d419c605fa 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
@@ -155,7 +155,7 @@ const QuotationAssemblyForm = ({
/>
<Hidden name="unitOfMeasureCode" value={partData?.uom} />
<VStack>
- <div className="grid w-full gap-x-8 gap-y-2 grid-cols-1 lg:grid-cols-3">
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
<Part
name="itemId"
label="Manufactured Part"
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
index b69befe305..388a45013d 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
@@ -68,7 +68,7 @@ const QuotationForm = ({ initialValues }: QuotationFormProps) => {
<VStack>
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
index c6497cf583..184b1dee2d 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
@@ -167,7 +167,7 @@ const QuotationLineForm = ({ initialValues }: QuotationLineFormProps) => {
<Hidden name="itemReadableId" value={itemData?.itemReadableId} />
<Hidden name="unitOfMeasureCode" value={itemData?.uom} />
<VStack>
- <div className="grid w-full gap-x-8 gap-y-2 grid-cols-1 lg:grid-cols-3">
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
<Item
name="itemId"
type="Part"
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
index c56e49facd..0cccfa546f 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
@@ -169,7 +169,7 @@ const QuotationOperationForm = ({
<Hidden name="quoteAssemblyId" value={quoteAssemblyId ?? undefined} />
<VStack>
- <div className="grid w-full gap-x-8 gap-y-2 grid-cols-1 lg:grid-cols-3">
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
<WorkCellType
name="workCellTypeId"
label="Work Cell"
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx
index ea2d24f105..76fc82d052 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx
@@ -271,7 +271,7 @@ export default function QuotationPricing({
</CardHeader>
<CardContent>
<Hidden name="intent" value="pricing" />
- <div className="grid w-full gap-x-8 gap-y-2 grid-cols-1 lg:grid-cols-3">
+ <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
<NumberControlled
name="quantity"
label="Quantity"
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
index d2d13761bc..6e43ee4d7e 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
@@ -66,7 +66,7 @@ const SalesOrderForm = ({ initialValues }: SalesOrderFormProps) => {
<VStack>
<div
className={cn(
- "grid w-full gap-x-8 gap-y-2",
+ "grid w-full gap-x-8 gap-y-4",
isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
)}
>
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
index 1f6cf42f42..cef9a20598 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
@@ -67,7 +67,7 @@ const SalesOrderShipmentForm = ({
</CardHeader>
<CardContent>
<Hidden name="id" />
- <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-2 w-full">
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Location
name="locationId"
label="Shipment Location"
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
similarity index 95%
rename from apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsx
rename to apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
index f238b35b99..71b8199088 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.new.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (createConsumableSupplier.error) {
throw redirect(
- path.to.consumableSuppliers(itemId),
+ path.to.consumablePurchasing(itemId),
await flash(
request,
error(
@@ -52,7 +52,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- throw redirect(path.to.consumableSuppliers(itemId));
+ throw redirect(path.to.consumablePurchasing(itemId));
}
export default function NewConsumableSupplierRoute() {
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.tsx
index e5e989e832..73ae1a694a 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.purchasing.tsx
@@ -1,8 +1,11 @@
import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
+import { useLoaderData, useParams } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { BuyMethod } from "~/modules/items";
import {
+ BuyMethods,
ItemPurchasingForm,
getItemReplenishment,
itemPurchasingValidator,
@@ -22,11 +25,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const consumablePurchasing = await getItemReplenishment(
- client,
- itemId,
- companyId
- );
+ const [consumablePurchasing] = await Promise.all([
+ getItemReplenishment(client, itemId, companyId),
+ ]);
if (consumablePurchasing.error) {
throw redirect(
@@ -91,6 +92,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
export default function ConsumablePurchasingRoute() {
const { consumablePurchasing } = useLoaderData<typeof loader>();
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ const routeData = useRouteData<{ buyMethods: BuyMethod[] }>(
+ path.to.consumable(itemId)
+ );
+ const buyMethods = routeData?.buyMethods ?? [];
+
const initialValues = {
...consumablePurchasing,
preferredSupplierId: consumablePurchasing?.preferredSupplierId ?? undefined,
@@ -102,9 +110,15 @@ export default function ConsumablePurchasingRoute() {
};
return (
- <ItemPurchasingForm
- key={initialValues.itemId}
- initialValues={initialValues}
- />
+ <>
+ <ItemPurchasingForm
+ key={initialValues.itemId}
+ initialValues={initialValues}
+ allowedSuppliers={
+ buyMethods.map((s) => s.supplier?.id).filter(Boolean) as string[]
+ }
+ />
+ <BuyMethods buyMethods={buyMethods} />
+ </>
);
}
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsx
deleted file mode 100644
index 573da9f518..0000000000
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.suppliers.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
-import { BuyMethods, getBuyMethods } from "~/modules/items";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const [suppliers] = await Promise.all([
- getBuyMethods(client, itemId, companyId),
- ]);
-
- if (suppliers.error) {
- throw redirect(
- path.to.consumable(itemId),
- await flash(
- request,
- error(suppliers.error, "Failed to load consumable suppliers")
- )
- );
- }
-
- return json({
- suppliers: suppliers.data ?? [],
- });
-}
-
-export default function ConsumableSuppliersRoute() {
- const { suppliers } = useLoaderData<typeof loader>();
-
- return <BuyMethods buyMethods={suppliers} />;
-}
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.tsx
index 64ae1da224..aed7b8c6e4 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.tsx
@@ -1,10 +1,13 @@
+import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import {
ConsumableHeader,
- ConsumableNavigation,
+ ConsumableProperties,
+ getBuyMethods,
getConsumable,
+ getPickMethods,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -26,8 +29,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [consumableSummary] = await Promise.all([
+ const [consumableSummary, buyMethods, pickMethods] = await Promise.all([
getConsumable(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
]);
if (consumableSummary.error) {
@@ -42,17 +47,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
consumableSummary: consumableSummary.data,
+ buyMethods: buyMethods.data ?? [],
+ pickMethods: pickMethods.data ?? [],
});
}
export default function ConsumableRoute() {
return (
- <>
+ <div className="flex flex-col h-[calc(100vh-49px)] w-full">
<ConsumableHeader />
- <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
- <ConsumableNavigation />
- <Outlet />
+ <div className="flex h-[calc(100vh-99px)] w-full">
+ <div className="flex h-full w-full overflow-y-auto">
+ <VStack spacing={2} className="p-2">
+ <Outlet />
+ </VStack>
+ </div>
+ <ConsumableProperties />
</div>
- </>
+ </div>
);
}
diff --git a/apps/carbon/app/routes/x+/consumable+/_layout.tsx b/apps/carbon/app/routes/x+/consumable+/_layout.tsx
index 5947870220..fb26e3596e 100644
--- a/apps/carbon/app/routes/x+/consumable+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/_layout.tsx
@@ -1,4 +1,3 @@
-import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import { getUnitOfMeasuresList } from "~/modules/items";
@@ -34,9 +33,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function ConsumableRoute() {
- return (
- <VStack spacing={4} className="h-full p-4">
- <Outlet />
- </VStack>
- );
+ return <Outlet />;
}
diff --git a/apps/carbon/app/routes/x+/consumable+/new.tsx b/apps/carbon/app/routes/x+/consumable+/new.tsx
index 9432d5090f..3f5c8f630b 100644
--- a/apps/carbon/app/routes/x+/consumable+/new.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/new.tsx
@@ -73,7 +73,7 @@ export default function ConsumablesNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<ConsumableForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/customer+/new.tsx b/apps/carbon/app/routes/x+/customer+/new.tsx
index 21f4edb81f..fc2a53638c 100644
--- a/apps/carbon/app/routes/x+/customer+/new.tsx
+++ b/apps/carbon/app/routes/x+/customer+/new.tsx
@@ -64,7 +64,7 @@ export default function CustomersNewRoute() {
name: "",
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<CustomerForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.new.tsx
similarity index 95%
rename from apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsx
rename to apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.new.tsx
index da9d92dbdf..b13020e452 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.new.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.new.tsx
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (createFixtureSupplier.error) {
throw redirect(
- path.to.fixtureSuppliers(itemId),
+ path.to.fixturePurchasing(itemId),
await flash(
request,
error(createFixtureSupplier.error, "Failed to create fixture supplier")
@@ -49,7 +49,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- throw redirect(path.to.fixtureSuppliers(itemId));
+ throw redirect(path.to.fixturePurchasing(itemId));
}
export default function NewFixtureSupplierRoute() {
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx
index 7e25ee3b5e..4845904751 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx
@@ -1,8 +1,11 @@
import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
+import { useLoaderData, useParams } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { BuyMethod } from "~/modules/items";
import {
+ BuyMethods,
ItemPurchasingForm,
getItemReplenishment,
itemPurchasingValidator,
@@ -22,11 +25,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const fixturePurchasing = await getItemReplenishment(
- client,
- itemId,
- companyId
- );
+ const [fixturePurchasing] = await Promise.all([
+ getItemReplenishment(client, itemId, companyId),
+ ]);
if (fixturePurchasing.error) {
throw redirect(
@@ -88,6 +89,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
export default function FixturePurchasingRoute() {
const { fixturePurchasing } = useLoaderData<typeof loader>();
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ const routeData = useRouteData<{ buyMethods: BuyMethod[] }>(
+ path.to.fixture(itemId)
+ );
+ const buyMethods = routeData?.buyMethods ?? [];
+
const initialValues = {
...fixturePurchasing,
preferredSupplierId: fixturePurchasing?.preferredSupplierId ?? undefined,
@@ -99,9 +107,15 @@ export default function FixturePurchasingRoute() {
};
return (
- <ItemPurchasingForm
- key={initialValues.itemId}
- initialValues={initialValues}
- />
+ <>
+ <ItemPurchasingForm
+ key={initialValues.itemId}
+ initialValues={initialValues}
+ allowedSuppliers={
+ buyMethods.map((s) => s.supplier?.id).filter(Boolean) as string[]
+ }
+ />
+ <BuyMethods buyMethods={buyMethods} />
+ </>
);
}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsx
deleted file mode 100644
index 98faa27725..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.suppliers.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
-import { BuyMethods, getBuyMethods } from "~/modules/items";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const [suppliers] = await Promise.all([
- getBuyMethods(client, itemId, companyId),
- ]);
-
- if (suppliers.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(suppliers.error, "Failed to load fixture suppliers")
- )
- );
- }
-
- return json({
- suppliers: suppliers.data ?? [],
- });
-}
-
-export default function ConsumableSuppliersRoute() {
- const { suppliers } = useLoaderData<typeof loader>();
-
- return <BuyMethods buyMethods={suppliers} />;
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
index d86a4e2521..af31e3624f 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
@@ -1,7 +1,14 @@
+import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
-import { FixtureHeader, FixtureNavigation, getFixture } from "~/modules/items";
+import {
+ FixtureHeader,
+ FixtureProperties,
+ getBuyMethods,
+ getFixture,
+ getPickMethods,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -21,8 +28,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [fixtureSummary] = await Promise.all([
+ const [fixtureSummary, buyMethods, pickMethods] = await Promise.all([
getFixture(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
]);
if (fixtureSummary.error) {
@@ -37,17 +46,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
fixtureSummary: fixtureSummary.data,
+ buyMethods: buyMethods.data ?? [],
+ pickMethods: pickMethods.data ?? [],
});
}
export default function FixtureRoute() {
return (
- <>
+ <div className="flex flex-col h-[calc(100vh-49px)] w-full">
<FixtureHeader />
- <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
- <FixtureNavigation />
- <Outlet />
+ <div className="flex h-[calc(100vh-99px)] w-full">
+ <div className="flex h-full w-full overflow-y-auto">
+ <VStack spacing={2} className="p-2">
+ <Outlet />
+ </VStack>
+ </div>
+ <FixtureProperties />
</div>
- </>
+ </div>
);
}
diff --git a/apps/carbon/app/routes/x+/fixture+/_layout.tsx b/apps/carbon/app/routes/x+/fixture+/_layout.tsx
index 597d1f98f3..64d7b84c60 100644
--- a/apps/carbon/app/routes/x+/fixture+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/_layout.tsx
@@ -1,4 +1,3 @@
-import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import { getUnitOfMeasuresList } from "~/modules/items";
@@ -34,9 +33,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function FixtureRoute() {
- return (
- <VStack spacing={4} className="h-full p-4">
- <Outlet />
- </VStack>
- );
+ return <Outlet />;
}
diff --git a/apps/carbon/app/routes/x+/fixture+/new.tsx b/apps/carbon/app/routes/x+/fixture+/new.tsx
index 2bdfb955f9..471f6ce173 100644
--- a/apps/carbon/app/routes/x+/fixture+/new.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/new.tsx
@@ -69,7 +69,7 @@ export default function FixturesNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<FixtureForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/material+/$itemId.purchasing.new.tsx
similarity index 95%
rename from apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsx
rename to apps/carbon/app/routes/x+/material+/$itemId.purchasing.new.tsx
index bb43396dde..82169a56a1 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.new.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.purchasing.new.tsx
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (createMaterialSupplier.error) {
throw redirect(
- path.to.materialSuppliers(itemId),
+ path.to.materialPurchasing(itemId),
await flash(
request,
error(
@@ -52,7 +52,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- throw redirect(path.to.materialSuppliers(itemId));
+ throw redirect(path.to.materialPurchasing(itemId));
}
export default function NewMaterialSupplierRoute() {
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/material+/$itemId.purchasing.tsx
index 734615c1fe..985b45e65e 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.purchasing.tsx
@@ -1,8 +1,11 @@
import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
+import { useLoaderData, useParams } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { BuyMethod } from "~/modules/items";
import {
+ BuyMethods,
ItemPurchasingForm,
getItemReplenishment,
itemPurchasingValidator,
@@ -22,11 +25,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const materialPurchasing = await getItemReplenishment(
- client,
- itemId,
- companyId
- );
+ const [materialPurchasing] = await Promise.all([
+ getItemReplenishment(client, itemId, companyId),
+ ]);
if (materialPurchasing.error) {
throw redirect(
@@ -88,6 +89,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
export default function MaterialPurchasingRoute() {
const { materialPurchasing } = useLoaderData<typeof loader>();
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ const routeData = useRouteData<{ buyMethods: BuyMethod[] }>(
+ path.to.material(itemId)
+ );
+ const buyMethods = routeData?.buyMethods ?? [];
+
const initialValues = {
...materialPurchasing,
preferredSupplierId: materialPurchasing?.preferredSupplierId ?? undefined,
@@ -99,9 +107,15 @@ export default function MaterialPurchasingRoute() {
};
return (
- <ItemPurchasingForm
- key={initialValues.itemId}
- initialValues={initialValues}
- />
+ <>
+ <ItemPurchasingForm
+ key={initialValues.itemId}
+ initialValues={initialValues}
+ allowedSuppliers={
+ buyMethods.map((s) => s.supplier?.id).filter(Boolean) as string[]
+ }
+ />
+ <BuyMethods buyMethods={buyMethods} />
+ </>
);
}
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsx
deleted file mode 100644
index b6742c13af..0000000000
--- a/apps/carbon/app/routes/x+/material+/$itemId.suppliers.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
-import { BuyMethods, getBuyMethods } from "~/modules/items";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const [suppliers] = await Promise.all([
- getBuyMethods(client, itemId, companyId),
- ]);
-
- if (suppliers.error) {
- throw redirect(
- path.to.material(itemId),
- await flash(
- request,
- error(suppliers.error, "Failed to load material suppliers")
- )
- );
- }
-
- return json({
- suppliers: suppliers.data ?? [],
- });
-}
-
-export default function MaterialSuppliersRoute() {
- const { suppliers } = useLoaderData<typeof loader>();
-
- return <BuyMethods buyMethods={suppliers} />;
-}
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.tsx b/apps/carbon/app/routes/x+/material+/$itemId.tsx
index 4a527a2321..06cefc3bb6 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.tsx
@@ -1,10 +1,13 @@
+import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import {
MaterialHeader,
- MaterialNavigation,
+ MaterialProperties,
+ getBuyMethods,
getMaterial,
+ getPickMethods,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -26,8 +29,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [materialSummary] = await Promise.all([
+ const [materialSummary, buyMethods, pickMethods] = await Promise.all([
getMaterial(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
]);
if (materialSummary.error) {
@@ -42,17 +47,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
materialSummary: materialSummary.data,
+ buyMethods: buyMethods.data ?? [],
+ pickMethods: pickMethods.data ?? [],
});
}
export default function MaterialRoute() {
return (
- <>
+ <div className="flex flex-col h-[calc(100vh-49px)] w-full">
<MaterialHeader />
- <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
- <MaterialNavigation />
- <Outlet />
+ <div className="flex h-[calc(100vh-99px)] w-full">
+ <div className="flex h-full w-full overflow-y-auto">
+ <VStack spacing={2} className="p-2">
+ <Outlet />
+ </VStack>
+ </div>
+ <MaterialProperties />
</div>
- </>
+ </div>
);
}
diff --git a/apps/carbon/app/routes/x+/material+/_layout.tsx b/apps/carbon/app/routes/x+/material+/_layout.tsx
index 935ca8e511..457f4dafec 100644
--- a/apps/carbon/app/routes/x+/material+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/material+/_layout.tsx
@@ -1,4 +1,3 @@
-import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import {
@@ -42,9 +41,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function MaterialRoute() {
- return (
- <VStack spacing={4} className="h-full p-4">
- <Outlet />
- </VStack>
- );
+ return <Outlet />;
}
diff --git a/apps/carbon/app/routes/x+/material+/new.tsx b/apps/carbon/app/routes/x+/material+/new.tsx
index f1ed447156..6f0909e188 100644
--- a/apps/carbon/app/routes/x+/material+/new.tsx
+++ b/apps/carbon/app/routes/x+/material+/new.tsx
@@ -75,7 +75,7 @@ export default function MaterialsNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<MaterialForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
index c926028035..a8cfaec621 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
@@ -1,11 +1,5 @@
import {
Badge,
- Button,
- Card,
- CardAction,
- CardContent,
- CardHeader,
- CardTitle,
ClientOnly,
HStack,
IconButton,
@@ -15,6 +9,7 @@ import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
+ ScrollArea,
VStack,
cn,
} from "@carbon/react";
@@ -27,13 +22,13 @@ import { useRef, useState } from "react";
import { LuChevronDown, LuChevronUp, LuPlus, LuSearch } from "react-icons/lu";
import { redirect, typedjson, useTypedLoaderData } from "remix-typedjson";
import {
+ BillOfProcess,
MethodIcon,
PartManufacturingForm,
getItemManufacturing,
partManufacturingValidator,
upsertItemManufacturing,
} from "~/modules/items";
-import type { StandardFactor } from "~/modules/shared";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { getCustomFields, setCustomFields } from "~/utils/form";
@@ -219,14 +214,16 @@ export default function Item() {
defaultSize={20}
className="bg-card"
>
- <div className="grid h-full overflow-hidden p-2">
- <BoMExplorer
- methods={methods}
- onSelectedIdChanged={(selectedId) => {
- console.log(selectedId);
- }}
- />
- </div>
+ <ScrollArea className="h-[calc(100vh-99px)]">
+ <div className="grid h-full overflow-hidden p-2">
+ <BoMExplorer
+ methods={methods}
+ onSelectedIdChanged={(selectedId) => {
+ console.log(selectedId);
+ }}
+ />
+ </div>
+ </ScrollArea>
</ResizablePanel>
<ResizableHandle withHandle />
@@ -236,24 +233,28 @@ export default function Item() {
defaultSize={60}
className="border-t border-border"
>
- <VStack spacing={2} className="p-2">
- <PartManufacturingForm
- key={itemId}
- initialValues={manufacturingInitialValues}
- />
- <BillOfProcesses key={itemId} processes={[]} />
- </VStack>
+ <ScrollArea className="h-[calc(100vh-99px)]">
+ <VStack spacing={2} className="p-2">
+ <PartManufacturingForm
+ key={itemId}
+ initialValues={manufacturingInitialValues}
+ />
+ <BillOfProcess key={itemId} processes={[]} />
+ </VStack>
+ </ScrollArea>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel
order={3}
minSize={20}
defaultSize={20}
- className="bg-card p-4 overflow-y-auto flex flex-col gap-4"
+ className="bg-card"
>
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Properties</h3>
- </VStack>
+ <ScrollArea className="h-[calc(100vh-99px)]">
+ <VStack spacing={2} className="px-4 py-2">
+ <h3 className="text-xs text-muted-foreground">Properties</h3>
+ </VStack>
+ </ScrollArea>
</ResizablePanel>
</ResizablePanelGroup>
)}
@@ -262,31 +263,6 @@ export default function Item() {
);
}
-type Process = {
- workCenterTypeId: string;
- equipmentTypeId?: string;
- setupHours: number;
- standardFactor: StandardFactor;
- productionStandard: number;
-};
-
-function BillOfProcesses({ processes }: { processes: Process[] }) {
- return (
- <Card>
- <HStack className="justify-between">
- <CardHeader>
- <CardTitle>Bill of Processes</CardTitle>
- </CardHeader>
-
- <CardAction>
- <Button variant="secondary">Add Process</Button>
- </CardAction>
- </HStack>
- <CardContent></CardContent>
- </Card>
- );
-}
-
type BoMExplorerProps = {
methods: Method[];
selectedId?: string;
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.tsx
index 574b4d63f5..39752a3c00 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.tsx
@@ -1,31 +1,15 @@
-import {
- Badge,
- Button,
- Enumerable,
- HStack,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- VStack,
- cn,
-} from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
-import { Link, Outlet, useMatches, useParams } from "@remix-run/react";
-import { LuCopy, LuExternalLink, LuLink } from "react-icons/lu";
-import Assignee, { useOptimisticAssignment } from "~/components/Assignee";
-import { useRouteData } from "~/hooks";
-import type { BuyMethod, PartSummary, PickMethod } from "~/modules/items";
+import { Outlet, useMatches } from "@remix-run/react";
import {
- MethodIcon,
PartHeader,
+ PartProperties,
getBuyMethods,
getPart,
getPickMethods,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
-import type { ListItem } from "~/types";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
import { error } from "~/utils/result";
@@ -85,178 +69,3 @@ export default function PartRoute() {
</div>
);
}
-
-export const PartProperties = () => {
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const sharedPartsData = useRouteData<{ locations: ListItem[] }>(
- path.to.partRoot
- );
- const routeData = useRouteData<{
- partSummary: PartSummary;
- buyMethods: BuyMethod[];
- pickMethods: PickMethod[];
- }>(path.to.part(itemId));
-
- const locations = sharedPartsData?.locations ?? [];
- const buyMethods = routeData?.buyMethods ?? [];
- const pickMethods = routeData?.pickMethods ?? [];
-
- const optimisticAssignment = useOptimisticAssignment({
- id: itemId,
- table: "item",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.partSummary?.assignee;
-
- return (
- <VStack
- spacing={4}
- className="w-96 bg-card h-full overflow-y-auto border-l border-border p-4"
- >
- <VStack spacing={2}>
- <HStack className="w-full justify-between">
- <h3 className="text-xs text-muted-foreground">Properties</h3>
- <HStack spacing={1}>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- aria-label="Link"
- size="sm"
- className="p-1"
- onClick={() =>
- navigator.clipboard.writeText(
- window.location.origin + path.to.part(itemId)
- )
- }
- >
- <LuLink className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <span>Copy link to part</span>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- aria-label="Copy"
- size="sm"
- className="p-1"
- onClick={() =>
- navigator.clipboard.writeText(
- routeData?.partSummary?.id ?? ""
- )
- }
- >
- <LuCopy className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <span>Copy part number</span>
- </TooltipContent>
- </Tooltip>
- </HStack>
- </HStack>
- <span className="text-sm">{routeData?.partSummary?.name}</span>
- </VStack>
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Assignee</h3>
- <Assignee id={itemId} table="item" value={assignee ?? ""} />
- </VStack>
-
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Replenishment</h3>
- <Enumerable
- className={cn(
- (routeData?.partSummary?.active === false ||
- routeData?.partSummary?.blocked) &&
- "opacity-50"
- )}
- value={routeData?.partSummary?.replenishmentSystem ?? null}
- />
- </VStack>
-
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Inventory Type</h3>
- <Enumerable
- className={cn(
- (routeData?.partSummary?.active === false ||
- routeData?.partSummary?.blocked) &&
- "opacity-50"
- )}
- value={routeData?.partSummary?.itemInventoryType ?? null}
- />
- </VStack>
-
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>
- <Enumerable value={routeData?.partSummary?.unitOfMeasure ?? null} />
- </VStack>
-
- <VStack spacing={2}>
- <HStack className="w-full justify-between">
- <h3 className="text-xs text-muted-foreground">Methods</h3>
- </HStack>
- {buyMethods.map((method) => (
- <MethodBadge
- key={method.id}
- type="Buy"
- text={method?.supplier?.name ?? ""}
- to={path.to.partPurchasing(itemId)}
- />
- ))}
- {pickMethods.map((method) => (
- <MethodBadge
- key={method.locationId}
- type="Pick"
- text={
- method.defaultShelfId ??
- locations.find((l) => l.id === method.locationId)?.name ??
- ""
- }
- to={path.to.partInventoryLocation(itemId, method.locationId)}
- />
- ))}
- </VStack>
- </VStack>
- );
-};
-
-type MethodBadgeProps = {
- type: "Buy" | "Make" | "Pick";
- text: string;
- to: string;
- className?: string;
-};
-
-function MethodBadge({ type, text, to, className }: MethodBadgeProps) {
- return (
- <HStack className="group" spacing={1}>
- <Badge className={cn(getBadgeColor(type), className)}>
- <MethodIcon type={type} className="w-3 h-3 mr-1 text-white" />
- {text}
- </Badge>
- <Link
- className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
- to={to}
- prefetch="intent"
- >
- <LuExternalLink />
- </Link>
- </HStack>
- );
-}
-
-function getBadgeColor(type: "Buy" | "Make" | "Pick") {
- return type === "Buy"
- ? "bg-blue-500 hover:bg-blue-600 text-white"
- : type === "Make"
- ? "bg-green-500 hover:bg-green-600 text-white"
- : "bg-orange-500 hover:bg-orange-600 text-white";
-}
diff --git a/apps/carbon/app/routes/x+/part+/new.tsx b/apps/carbon/app/routes/x+/part+/new.tsx
index 3a05b560f2..0adc11baf4 100644
--- a/apps/carbon/app/routes/x+/part+/new.tsx
+++ b/apps/carbon/app/routes/x+/part+/new.tsx
@@ -64,7 +64,7 @@ export default function PartsNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<PartForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/purchase-invoice+/new.tsx b/apps/carbon/app/routes/x+/purchase-invoice+/new.tsx
index 4ae85552b7..de740c4e19 100644
--- a/apps/carbon/app/routes/x+/purchase-invoice+/new.tsx
+++ b/apps/carbon/app/routes/x+/purchase-invoice+/new.tsx
@@ -129,7 +129,7 @@ export default function PurchaseInvoiceNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<PurchaseInvoiceForm
initialValues={initialValues}
paymentTerms={sharedData?.paymentTerms ?? []}
diff --git a/apps/carbon/app/routes/x+/purchase-order+/new.tsx b/apps/carbon/app/routes/x+/purchase-order+/new.tsx
index af5d48dd19..424e8b76ad 100644
--- a/apps/carbon/app/routes/x+/purchase-order+/new.tsx
+++ b/apps/carbon/app/routes/x+/purchase-order+/new.tsx
@@ -86,7 +86,7 @@ export default function PurchaseOrderNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<PurchaseOrderForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/rfq+/new.tsx b/apps/carbon/app/routes/x+/rfq+/new.tsx
index fa71642004..ee3f08d543 100644
--- a/apps/carbon/app/routes/x+/rfq+/new.tsx
+++ b/apps/carbon/app/routes/x+/rfq+/new.tsx
@@ -78,7 +78,7 @@ export default function RequestForQuoteNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<RequestForQuoteForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/sales-order+/new.tsx b/apps/carbon/app/routes/x+/sales-order+/new.tsx
index 5f16291c1c..c0930a5843 100644
--- a/apps/carbon/app/routes/x+/sales-order+/new.tsx
+++ b/apps/carbon/app/routes/x+/sales-order+/new.tsx
@@ -80,7 +80,7 @@ export default function SalesOrderNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<SalesOrderForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/service+/$itemId.purchasing.new.tsx
similarity index 95%
rename from apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsx
rename to apps/carbon/app/routes/x+/service+/$itemId.purchasing.new.tsx
index 4c409a25bd..66b5619a32 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.new.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.purchasing.new.tsx
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (createPartSupplier.error) {
throw redirect(
- path.to.serviceSuppliers(itemId),
+ path.to.servicePurchasing(itemId),
await flash(
request,
error(createPartSupplier.error, "Failed to create service supplier")
@@ -49,7 +49,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- throw redirect(path.to.serviceSuppliers(itemId));
+ throw redirect(path.to.servicePurchasing(itemId));
}
export default function NewPartSupplierRoute() {
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/service+/$itemId.purchasing.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/service+/$itemId.suppliers.tsx
rename to apps/carbon/app/routes/x+/service+/$itemId.purchasing.tsx
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.tsx b/apps/carbon/app/routes/x+/service+/$itemId.tsx
index a9d8fa8cec..71c65c3358 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.tsx
@@ -1,7 +1,14 @@
+import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
-import { ServiceHeader, ServiceNavigation, getService } from "~/modules/items";
+import {
+ ServiceHeader,
+ ServiceProperties,
+ getBuyMethods,
+ getPickMethods,
+ getService,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -21,7 +28,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [service] = await Promise.all([getService(client, itemId, companyId)]);
+ const [service, buyMethods, pickMethods] = await Promise.all([
+ getService(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ ]);
if (service.error) {
throw redirect(
@@ -32,17 +43,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
service: service.data,
+ buyMethods: buyMethods.data ?? [],
+ pickMethods: pickMethods.data ?? [],
});
}
export default function ServiceRoute() {
return (
- <>
+ <div className="flex flex-col h-[calc(100vh-49px)] w-full">
<ServiceHeader />
- <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
- <ServiceNavigation />
- <Outlet />
+ <div className="flex h-[calc(100vh-99px)] w-full">
+ <div className="flex h-full w-full overflow-y-auto">
+ <VStack spacing={2} className="p-2">
+ <Outlet />
+ </VStack>
+ </div>
+ <ServiceProperties />
</div>
- </>
+ </div>
);
}
diff --git a/apps/carbon/app/routes/x+/service+/_layout.tsx b/apps/carbon/app/routes/x+/service+/_layout.tsx
index a1d9de3a5d..fc09764c6c 100644
--- a/apps/carbon/app/routes/x+/service+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/service+/_layout.tsx
@@ -1,4 +1,3 @@
-import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import { getItemGroupsList } from "~/modules/items";
@@ -34,9 +33,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function ServiceRoute() {
- return (
- <VStack spacing={4} className="h-full p-2">
- <Outlet />
- </VStack>
- );
+ return <Outlet />;
}
diff --git a/apps/carbon/app/routes/x+/service+/new.tsx b/apps/carbon/app/routes/x+/service+/new.tsx
index e3e000b9b9..bbc3d1f751 100644
--- a/apps/carbon/app/routes/x+/service+/new.tsx
+++ b/apps/carbon/app/routes/x+/service+/new.tsx
@@ -67,7 +67,7 @@ export default function ServiceNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
{/* @ts-ignore */}
<ServiceForm initialValues={initialValues} />
</div>
diff --git a/apps/carbon/app/routes/x+/supplier+/new.tsx b/apps/carbon/app/routes/x+/supplier+/new.tsx
index db05808425..f8670a0d29 100644
--- a/apps/carbon/app/routes/x+/supplier+/new.tsx
+++ b/apps/carbon/app/routes/x+/supplier+/new.tsx
@@ -64,7 +64,7 @@ export default function SuppliersNewRoute() {
name: "",
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<SupplierForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.purchasing.new.tsx
similarity index 95%
rename from apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsx
rename to apps/carbon/app/routes/x+/tool+/$itemId.purchasing.new.tsx
index 401a03f48b..4c8674e52d 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.new.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.purchasing.new.tsx
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (createToolSupplier.error) {
throw redirect(
- path.to.toolSuppliers(itemId),
+ path.to.toolPurchasing(itemId),
await flash(
request,
error(createToolSupplier.error, "Failed to create tool supplier")
@@ -49,7 +49,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- throw redirect(path.to.toolSuppliers(itemId));
+ throw redirect(path.to.toolPurchasing(itemId));
}
export default function NewToolSupplierRoute() {
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.purchasing.tsx
index 9148c752d1..3a08cb5eff 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.purchasing.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.purchasing.tsx
@@ -1,8 +1,11 @@
import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
+import { useLoaderData, useParams } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { BuyMethod } from "~/modules/items";
import {
+ BuyMethods,
ItemPurchasingForm,
getItemReplenishment,
itemPurchasingValidator,
@@ -22,7 +25,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const toolPurchasing = await getItemReplenishment(client, itemId, companyId);
+ const [toolPurchasing] = await Promise.all([
+ getItemReplenishment(client, itemId, companyId),
+ ]);
if (toolPurchasing.error) {
throw redirect(
@@ -81,6 +86,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
export default function ToolPurchasingRoute() {
const { toolPurchasing } = useLoaderData<typeof loader>();
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ const routeData = useRouteData<{ buyMethods: BuyMethod[] }>(
+ path.to.tool(itemId)
+ );
+ const buyMethods = routeData?.buyMethods ?? [];
+
const initialValues = {
...toolPurchasing,
preferredSupplierId: toolPurchasing?.preferredSupplierId ?? undefined,
@@ -92,9 +104,15 @@ export default function ToolPurchasingRoute() {
};
return (
- <ItemPurchasingForm
- key={initialValues.itemId}
- initialValues={initialValues}
- />
+ <>
+ <ItemPurchasingForm
+ key={initialValues.itemId}
+ initialValues={initialValues}
+ allowedSuppliers={
+ buyMethods.map((s) => s.supplier?.id).filter(Boolean) as string[]
+ }
+ />
+ <BuyMethods buyMethods={buyMethods} />
+ </>
);
}
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsx
deleted file mode 100644
index 714e879e46..0000000000
--- a/apps/carbon/app/routes/x+/tool+/$itemId.suppliers.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
-import { BuyMethods, getBuyMethods } from "~/modules/items";
-import { requirePermissions } from "~/services/auth/auth.server";
-import { flash } from "~/services/session.server";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const [suppliers] = await Promise.all([
- getBuyMethods(client, itemId, companyId),
- ]);
-
- if (suppliers.error) {
- throw redirect(
- path.to.tool(itemId),
- await flash(
- request,
- error(suppliers.error, "Failed to load tool suppliers")
- )
- );
- }
-
- return json({
- suppliers: suppliers.data ?? [],
- });
-}
-
-export default function ToolSuppliersRoute() {
- const { suppliers } = useLoaderData<typeof loader>();
-
- return <BuyMethods buyMethods={suppliers} />;
-}
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.tsx
index 8eb566c562..1b24a970d8 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.tsx
@@ -1,7 +1,14 @@
+import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
-import { ToolHeader, ToolNavigation, getTool } from "~/modules/items";
+import {
+ ToolHeader,
+ ToolProperties,
+ getBuyMethods,
+ getPickMethods,
+ getTool,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -22,7 +29,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [toolSummary] = await Promise.all([getTool(client, itemId, companyId)]);
+ const [toolSummary, buyMethods, pickMethods] = await Promise.all([
+ getTool(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ ]);
if (toolSummary.error) {
throw redirect(
@@ -36,17 +47,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
toolSummary: toolSummary.data,
+ buyMethods: buyMethods.data ?? [],
+ pickMethods: pickMethods.data ?? [],
});
}
export default function ToolRoute() {
return (
- <>
+ <div className="flex flex-col h-[calc(100vh-49px)] w-full">
<ToolHeader />
- <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
- <ToolNavigation />
- <Outlet />
+ <div className="flex h-[calc(100vh-99px)] w-full">
+ <div className="flex h-full w-full overflow-y-auto">
+ <VStack spacing={2} className="p-2">
+ <Outlet />
+ </VStack>
+ </div>
+ <ToolProperties />
</div>
- </>
+ </div>
);
}
diff --git a/apps/carbon/app/routes/x+/tool+/_layout.tsx b/apps/carbon/app/routes/x+/tool+/_layout.tsx
index bcc18b668f..51a220e0cd 100644
--- a/apps/carbon/app/routes/x+/tool+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/tool+/_layout.tsx
@@ -1,4 +1,3 @@
-import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import { getUnitOfMeasuresList } from "~/modules/items";
@@ -34,9 +33,5 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function ToolRoute() {
- return (
- <VStack spacing={4} className="h-full p-4">
- <Outlet />
- </VStack>
- );
+ return <Outlet />;
}
diff --git a/apps/carbon/app/routes/x+/tool+/new.tsx b/apps/carbon/app/routes/x+/tool+/new.tsx
index 496f8da2f2..bf3798fadb 100644
--- a/apps/carbon/app/routes/x+/tool+/new.tsx
+++ b/apps/carbon/app/routes/x+/tool+/new.tsx
@@ -63,7 +63,7 @@ export default function ToolsNewRoute() {
};
return (
- <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto">
+ <div className="w-1/2 max-w-[600px] min-w-[420px] mx-auto mt-8">
<ToolForm initialValues={initialValues} />
</div>
);
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index b36da70812..a28bf52161 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -588,6 +588,8 @@ export const path = {
services: `${x}/items/services`,
serviceDetails: (id: string) => `${x}/service/${id}/details`,
serviceRoot: `${x}/service`,
+ servicePurchasing: (id: string) =>
+ generatePath(`${x}/service/${id}/purchasing`),
serviceSupplier: (serviceId: string, id: string) =>
generatePath(`${x}/service/${serviceId}/suppliers/${id}`),
serviceSuppliers: (id: string) =>
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index 6154969cb4..ad5d559415 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -64,6 +64,7 @@
"react-icons": "^4.12.0",
"react-pdf": "^7.7.1",
"react-phone-number-input": "^3.3.9",
+ "react-use-measure": "^2.1.1",
"remix-flat-routes": "^0.6.4",
"remix-typedjson": "^0.4.1",
"resend": "^3.1.0",
diff --git a/package-lock.json b/package-lock.json
index c15d9b73ba..7bda02754d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -90,6 +90,7 @@
"react-icons": "^4.12.0",
"react-pdf": "^7.7.1",
"react-phone-number-input": "^3.3.9",
+ "react-use-measure": "^2.1.1",
"remix-flat-routes": "^0.6.4",
"remix-typedjson": "^0.4.1",
"resend": "^3.1.0",
@@ -14283,6 +14284,11 @@
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz",
"integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg=="
},
+ "node_modules/debounce": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz",
+ "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug=="
+ },
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -28463,6 +28469,18 @@
}
}
},
+ "node_modules/react-use-measure": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/react-use-measure/-/react-use-measure-2.1.1.tgz",
+ "integrity": "sha512-nocZhN26cproIiIduswYpV5y5lQpSQS1y/4KuvUCjSKmw7ZWIS/+g3aFnX3WdBkyuGUtTLif3UTqnLLhbDoQig==",
+ "dependencies": {
+ "debounce": "^1.2.1"
+ },
+ "peerDependencies": {
+ "react": ">=16.13",
+ "react-dom": ">=16.13"
+ }
+ },
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
diff --git a/packages/react/src/Form/FormError.tsx b/packages/react/src/Form/FormError.tsx
index d243892e15..e97cdce761 100644
--- a/packages/react/src/Form/FormError.tsx
+++ b/packages/react/src/Form/FormError.tsx
@@ -24,7 +24,7 @@ export const FormErrorMessage = forwardRef<
<div
{...field?.getErrorMessageProps(props, ref)}
className={cn(
- "text-destructive text-sm font-medium leading-none",
+ "text-destructive text-xs font-medium leading-none",
props.className
)}
/>
diff --git a/packages/react/src/Form/FormLabel.tsx b/packages/react/src/Form/FormLabel.tsx
index 1e0b87668b..e6c46c4d40 100644
--- a/packages/react/src/Form/FormLabel.tsx
+++ b/packages/react/src/Form/FormLabel.tsx
@@ -3,6 +3,7 @@ import { forwardRef } from "react";
import { useFormControlContext } from "./FormControl";
import * as ReactAria from "react-aria-components";
+import { cn } from "../utils/cn";
export const FormLabel = forwardRef<
ElementRef<typeof ReactAria.Label>,
@@ -14,7 +15,12 @@ export const FormLabel = forwardRef<
const labelProps = field?.getLabelProps(rest, ref) ?? { ref, ...rest };
return (
- <ReactAria.Label {...labelProps} ref={ref} className={className} {...props}>
+ <ReactAria.Label
+ {...labelProps}
+ ref={ref}
+ className={cn("text-xs text-muted-foreground", className)}
+ {...props}
+ >
{children}
{field?.isRequired && <span className="text-destructive"> *</span>}
</ReactAria.Label>