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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: kanban item card details
Brad Barbine52b205c49e5
diff --git a/apps/carbon/app/components/EmployeeAvatarGroup.tsx b/apps/carbon/app/components/EmployeeAvatarGroup.tsxnew file mode 100644index 0000000000..87d43bb44f--- /dev/null+++ b/apps/carbon/app/components/EmployeeAvatarGroup.tsx@@ -0,0 +1,44 @@+import {+ AvatarGroup,+ AvatarGroupList,+ AvatarOverflowIndicator,+ type AvatarProps,+} from "@carbon/react";+import { usePeople } from "~/stores";+import Avatar from "./Avatar";++type EmployeeAvatarProps = AvatarProps & {+ employeeIds: string[];+};++const EmployeeAvatarGroup = ({+ employeeIds,+ size,+ ...props+}: EmployeeAvatarProps) => {+ const [people] = usePeople();++ const employees = people.filter((p) => employeeIds.includes(p.id));++ if (employees.length === 0) {+ return null;+ }++ return (+ <AvatarGroup size={size ?? "xs"} limit={5}>+ <AvatarGroupList>+ {employees.map((employee, index: number) => (+ <Avatar+ key={index}+ name={employee.name ?? undefined}+ title={employee.name ?? undefined}+ path={employee.avatarUrl}+ />+ ))}+ </AvatarGroupList>+ <AvatarOverflowIndicator />+ </AvatarGroup>+ );+};++export default EmployeeAvatarGroup;diff --git a/apps/carbon/app/components/Gantt/Gantt.tsx b/apps/carbon/app/components/Gantt/Gantt.tsxindex 1234da9df4..2397a457ab 100644--- a/apps/carbon/app/components/Gantt/Gantt.tsx+++ b/apps/carbon/app/components/Gantt/Gantt.tsx@@ -685,9 +685,9 @@ function PulsingDot() {return (<span className="relative flex h-2 w-2"><span- className={`absolute h-full w-full animate-ping rounded-full border border-primary opacity-100 duration-1000`}+ className={`absolute h-full w-full animate-ping rounded-full border border-emerald-500 opacity-100 duration-1000`}/>- <span className={`h-2 w-2 rounded-full bg-primary`} />+ <span className={`h-2 w-2 rounded-full bg-emerald-500`} /></span>);}diff --git a/apps/carbon/app/components/Kanban/Kanban.tsx b/apps/carbon/app/components/Kanban/Kanban.tsxindex 378c3f8955..2d5d8e2a44 100644--- a/apps/carbon/app/components/Kanban/Kanban.tsx+++ b/apps/carbon/app/components/Kanban/Kanban.tsx@@ -76,11 +76,9 @@ const Kanban = ({active.id,pickedUpItemColumn.current);- return `Picked up Item ${- active.data.current.item.content- } at position: ${itemPosition + 1} of ${- itemsInColumn.length- } in column ${column?.title}`;+ return `Picked up Item ${active.data.current.item.title} at position: ${+ itemPosition + 1+ } of ${itemsInColumn.length} in column ${column?.title}`;}},onDragOver({ active, over }) {@@ -104,7 +102,7 @@ const Kanban = ({);if (over.data.current.item.columnId !== pickedUpItemColumn.current) {return `Item ${- active.data.current.item.content+ active.data.current.item.title} was moved over column ${column?.title} in position ${itemPosition + 1} of ${itemsInColumn.length}`;diff --git a/apps/carbon/app/components/Kanban/components/ColumnCard.tsx b/apps/carbon/app/components/Kanban/components/ColumnCard.tsxindex 7e8609eb9b..44b3ca1932 100644--- a/apps/carbon/app/components/Kanban/components/ColumnCard.tsx+++ b/apps/carbon/app/components/Kanban/components/ColumnCard.tsx@@ -70,8 +70,11 @@ export function ColumnCard({ column, items, isOverlay }: ColumnCardProps) {dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,})}>- <CardHeader className="p-4 font-semibold border-b-2 text-left flex flex-row space-between items-center">- <span className="mr-auto truncate"> {column.title}</span>+ <CardHeader className="p-4 w-full font-semibold border-b-2 text-left flex flex-row space-between items-center">+ <div className="flex flex-grow items-center space-x-2">+ {column.active && <PulsingDot />}+ <span className="mr-auto truncate"> {column.title}</span>+ </div><Buttonvariant={"ghost"}{...attributes}@@ -120,3 +123,14 @@ export function BoardContainer({ children }: { children: React.ReactNode }) {</ScrollArea>);}++function PulsingDot() {+ return (+ <span className="relative flex h-2 w-2">+ <span+ className={`absolute h-full w-full animate-ping rounded-full border border-emerald-500 opacity-100 duration-1000`}+ />+ <span className={`h-2 w-2 rounded-full bg-emerald-500`} />+ </span>+ );+}diff --git a/apps/carbon/app/components/Kanban/components/ItemCard.tsx b/apps/carbon/app/components/Kanban/components/ItemCard.tsxindex 80844850d7..4ad3ea5588 100644--- a/apps/carbon/app/components/Kanban/components/ItemCard.tsx+++ b/apps/carbon/app/components/Kanban/components/ItemCard.tsx@@ -1,10 +1,31 @@-import { Badge, Button, Card, CardContent, CardHeader } from "@carbon/react";+import {+ Button,+ Card,+ CardContent,+ CardHeader,+ HStack,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ cn,+} from "@carbon/react";+import { formatDate } from "@carbon/utils";import { useSortable } from "@dnd-kit/sortable";import { CSS } from "@dnd-kit/utilities";import { cva } from "class-variance-authority";-import { LuGripVertical } from "react-icons/lu";+import { BsExclamationSquareFill } from "react-icons/bs";+import {+ LuCalendarCheck,+ LuFactory,+ LuGripVertical,+ LuRocket,+ LuUsers,+} from "react-icons/lu";+import CustomerAvatar from "~/components/CustomerAvatar";+import EmployeeAvatarGroup from "~/components/EmployeeAvatarGroup";import type { Item, ItemDragData } from "../types";+import KanbanStatus from "./KanbanStatus";type ItemCardProps = {item: Item;@@ -48,14 +69,15 @@ export function ItemCard({ item, isOverlay }: ItemCardProps) {<Cardref={setNodeRef}style={style}- className={variants({- dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,- })}+ className={cn(+ "max-w-[330px]",+ variants({+ dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,+ })+ )}>- <CardHeader className="px-3 py-3 space-between flex flex-row border-b-2 border-secondary relative">- <Badge variant={"outline"} className="mr-auto font-semibold truncate">- Item- </Badge>+ <CardHeader className="max-w-full px-3 py-3 space-y-0 flex-row border-b-2 border-secondary relative">+ <span className="mr-auto font-semibold truncate">{item.title}</span><Buttonvariant={"ghost"}{...attributes}@@ -66,9 +88,71 @@ export function ItemCard({ item, isOverlay }: ItemCardProps) {<LuGripVertical /></Button></CardHeader>- <CardContent className="px-3 pt-3 pb-6 text-left whitespace-pre-wrap">- {item.content}+ <CardContent className="p-3 space-y-2 text-left whitespace-pre-wrap">+ {item.status && (+ <HStack className="justify-start space-x-2">+ <LuRocket className="text-muted-foreground" />+ <KanbanStatus {...item.status} />+ </HStack>+ )}+ {item.deadlineType && (+ <HStack className="justify-start space-x-2">+ {getDeadlineIcon(item.deadlineType)}+ <Tooltip>+ <TooltipTrigger>+ <span className="text-sm">+ {["ASAP", "NO_DEADLINE"].includes(item.deadlineType)+ ? getDeadlineText(item.deadlineType)+ : formatDate(item.dueDate)}+ </span>+ </TooltipTrigger>+ <TooltipContent>+ {getDeadlineText(item.deadlineType)}+ </TooltipContent>+ </Tooltip>+ </HStack>+ )}++ {item.customerId && (+ <HStack className="justify-start space-x-2">+ <LuFactory className="text-muted-foreground" />+ <CustomerAvatar customerId={item.customerId} />+ </HStack>+ )}++ {item.employeeIds && (+ <HStack className="justify-start space-x-2">+ <LuUsers className="text-muted-foreground" />+ <EmployeeAvatarGroup employeeIds={item.employeeIds} />+ </HStack>+ )}</CardContent></Card>);}++function getDeadlineIcon(deadlineType: Item["deadlineType"]) {+ switch (deadlineType) {+ case "ASAP":+ return <BsExclamationSquareFill className="text-red-500" />;+ case "HARD_DEADLINE":+ return <LuCalendarCheck className="text-orange-500" />;+ case "SOFT_DEADLINE":+ return <LuCalendarCheck className="text-yellow-500" />;+ case "NO_DEADLINE":+ return <LuCalendarCheck className="text-muted-foreground" />;+ }+}++function getDeadlineText(deadlineType: Item["deadlineType"]) {+ switch (deadlineType) {+ case "ASAP":+ return "ASAP";+ case "HARD_DEADLINE":+ return "Hard deadline";+ case "SOFT_DEADLINE":+ return "Soft deadline";+ case "NO_DEADLINE":+ return "No deadline";+ }+}diff --git a/apps/carbon/app/components/Kanban/components/KanbanStatus.tsx b/apps/carbon/app/components/Kanban/components/KanbanStatus.tsxnew file mode 100644index 0000000000..cba9e3f04a--- /dev/null+++ b/apps/carbon/app/components/Kanban/components/KanbanStatus.tsx@@ -0,0 +1,42 @@+import { Status } from "@carbon/react";+import { ItemStatus, type Item } from "../types";++type KanbanStatusProps = NonNullable<Item["status"]>;++const KanbanStatus = ({ status, message }: KanbanStatusProps) => {+ switch (status) {+ case ItemStatus.Warning:+ return (+ <Status className="w-fit" color="orange">+ {message}+ </Status>+ );+ case ItemStatus.Success:+ return (+ <Status className="w-fit" color="green">+ {message}+ </Status>+ );+ case ItemStatus.Error:+ return (+ <Status className="w-fit" color="red">+ {message}+ </Status>+ );+ case ItemStatus.Info:+ return (+ <Status className="w-fit" color="blue">+ {message}+ </Status>+ );+ case ItemStatus.Default:+ default:+ return (+ <Status className="w-fit" color="gray">+ {message}+ </Status>+ );+ }+};++export default KanbanStatus;diff --git a/apps/carbon/app/components/Kanban/types.ts b/apps/carbon/app/components/Kanban/types.tsindex 3eff42214e..cd7d095ac6 100644--- a/apps/carbon/app/components/Kanban/types.ts+++ b/apps/carbon/app/components/Kanban/types.ts@@ -1,7 +1,12 @@-export interface Column {- id: string;- title: string;-}+import { z } from "zod";++export const columnValidator = z.object({+ id: z.string(),+ title: z.string(),+ active: z.boolean().optional(),+});++export type Column = z.infer<typeof columnValidator>;export interface ColumnDragData {type: "column";@@ -10,13 +15,51 @@ export interface ColumnDragData {export type DraggableData = ColumnDragData | ItemDragData;-export interface Item {- id: string;- columnId: string;- content: string;-}+const itemValidator = z.object({+ id: z.string(),+ columnId: z.string(),+ title: z.string(),+ customerId: z.string().optional(),+ employeeIds: z.array(z.string()).optional(),+ dueDate: z.string().optional(),+ deadlineType: z+ .enum(["ASAP", "HARD_DEADLINE", "SOFT_DEADLINE", "NO_DEADLINE"])+ .optional(),+ status: z+ .object({+ status: z+ .enum(["INFO", "WARNING", "ERROR", "SUCCESS", "DEFAULT"])+ .optional(),+ message: z.string(),+ })+ .optional(),+});++export type Item = z.infer<typeof itemValidator>;export interface ItemDragData {type: "item";item: Item;}++export enum ItemStatus {+ Info = "INFO",+ Warning = "WARNING",+ Error = "ERROR",+ Success = "SUCCESS",+ Default = "DEFAULT",+}++export enum ItemDeadline {+ ASAP = "ASAP",+ HardDeadline = "HARD_DEADLINE",+ SoftDeadline = "SOFT_DEADLINE",+ NoDeadline = "NO_DEADLINE",+}++export enum ItemPriority {+ ASAP = "ASAP",+ High = "HIGH",+ Average = "AVERAGE",+ Low = "LOW",+}diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.tsindex 445cd9a9c8..ce6434295d 100644--- a/apps/carbon/app/components/index.ts+++ b/apps/carbon/app/components/index.ts@@ -8,6 +8,7 @@ import CreatableCombobox from "./CreateableCombobox";import CustomerAvatar from "./CustomerAvatar";import DocumentPreview from "./DocumentPreview";import EmployeeAvatar from "./EmployeeAvatar";+import EmployeeAvatarGroup from "./EmployeeAvatarGroup";import Hyperlink from "./Hyperlink";import MultiSelect from "./MultiSelect";import New from "./New";@@ -29,6 +30,7 @@ export {CustomerAvatar,DocumentPreview,EmployeeAvatar,+ EmployeeAvatarGroup,Hyperlink,MultiSelect,New,diff --git a/apps/carbon/app/routes/x+/_layout.tsx b/apps/carbon/app/routes/x+/_layout.tsxindex 4a8bb197b4..7b6f4e141e 100644--- a/apps/carbon/app/routes/x+/_layout.tsx+++ b/apps/carbon/app/routes/x+/_layout.tsx@@ -122,7 +122,7 @@ export default function AuthenticatedRoute() {<div className="w-full h-full flex-1 overflow-hidden"><main className="h-full flex flex-col flex-1 w-full overflow-x-hidden bg-muted"><Topbar />- <main className="flex-1 overflow-y-auto max-h-[calc(100vh-49px)]">+ <main className="flex-1 overflow-y-auto max-h-[calc(100vh-49px)] max-w-[calc(100vw-39px)]"><Outlet /></main></main>diff --git a/apps/carbon/app/routes/x+/scheduling+/index.tsx b/apps/carbon/app/routes/x+/scheduling+/index.tsxindex 3476e774c5..841dc88e1f 100644--- a/apps/carbon/app/routes/x+/scheduling+/index.tsx+++ b/apps/carbon/app/routes/x+/scheduling+/index.tsx@@ -12,6 +12,7 @@ export async function loader({ request }: LoaderFunctionArgs) {{id: "1",title: "Assembly Station 1",+ active: true,},{id: "2",@@ -31,70 +32,132 @@ export async function loader({ request }: LoaderFunctionArgs) {},] satisfies Column[],items: [+ {+ id: "item0",+ columnId: "4",+ title: "1503",+ customerId: "6bd344cd-5ea8-406e-9253-2d3672a56533",+ dueDate: "2024-05-20",+ deadlineType: "HARD_DEADLINE",+ status: {+ status: "WARNING",+ message: "Paused",+ },+ },{id: "item1",columnId: "3",- content: "Project initiation and planning",+ title: "1032",+ dueDate: "2024-05-20",+ deadlineType: "SOFT_DEADLINE",+ status: {+ status: "WARNING",+ message: "Paused",+ },},{id: "item2",columnId: "3",- content: "Gather requirements from stakeholders",+ title: "1023",+ dueDate: "2024-05-20",+ deadlineType: "ASAP",+ customerId: "6bd344cd-5ea8-406e-9253-2d3672a56533",+ status: {+ status: "INFO",+ message: "Ready",+ },},{id: "item3",columnId: "3",- content: "Create wireframes and mockups",+ title: "1022",+ deadlineType: "NO_DEADLINE",+ status: {+ status: "INFO",+ message: "Ready",+ },},{id: "item4",columnId: "2",- content: "Develop homepage layout",+ title: "1492",+ deadlineType: "NO_DEADLINE",+ status: {+ status: "ERROR",+ message: "Waiting",+ },},{id: "item5",columnId: "2",- content: "Design color scheme and typography",+ title: "1109",+ dueDate: "2024-05-20",+ deadlineType: "SOFT_DEADLINE",+ status: {+ status: "ERROR",+ message: "Waiting",+ },},{id: "item6",columnId: "1",- content: "Implement user authentication",+ title: "1013",+ deadlineType: "NO_DEADLINE",+ employeeIds: [+ "1ab986d3-362b-4d7f-849e-bc57697c4aff",+ "98bc4b87-37a9-4032-9f8e-97849e8dd8d4",+ ],+ status: {+ status: "SUCCESS",+ message: "In Progress",+ },},{id: "item7",columnId: "1",- content: "Build contact us page",+ title: "1014",+ dueDate: "2024-05-20",+ deadlineType: "HARD_DEADLINE",+ customerId: "1af341c6-d71c-4e4e-8382-e3850e4808cc",+ status: {+ status: "DEFAULT",+ message: "Pending",+ },},{id: "item8",columnId: "1",- content: "Create product catalog",+ title: "1032",+ dueDate: "2024-05-20",+ deadlineType: "SOFT_DEADLINE",+ customerId: "6bd344cd-5ea8-406e-9253-2d3672a56533",+ status: {+ status: "DEFAULT",+ message: "Pending",+ },},{id: "item9",columnId: "1",- content: "Develop about us page",+ title: "1010",+ dueDate: "2024-05-20",+ deadlineType: "ASAP",+ status: {+ status: "DEFAULT",+ message: "Pending",+ },},{id: "item10",columnId: "1",- content: "Optimize website for mobile devices",- },- {- id: "item11",- columnId: "1",- content: "Integrate payment gateway",- },- {- id: "item12",- columnId: "1",- content: "Perform testing and bug fixing",- },- {- id: "item13",- columnId: "1",- content: "Launch website and deploy to server",+ title: "1403",+ dueDate: "2024-05-20",+ deadlineType: "NO_DEADLINE",+ customerId: "1af341c6-d71c-4e4e-8382-e3850e4808cc",+ status: {+ status: "DEFAULT",+ message: "Pending",+ },},] satisfies Item[],});@@ -103,8 +166,8 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function KanbanView() {const { columns, items } = useTypedLoaderData<typeof loader>();return (- <div className={cn("grid grid-cols-1 h-full max-h-full overflow-hidden")}>- <HStack className="px-4 py-2 justify-between bg-card border-b border-border w-full">+ <div className={cn("flex flex-col h-full max-h-full overflow-hidden")}>+ <HStack className="px-4 py-2 justify-between bg-card border-b border-border"><HStack><DebouncedInput param="search" size="sm" placeholder="Search" />{/* <Filter filters={filters} /> */}