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.

style: add icons and progress bars to kanban view

Brad Barbin2c567503496c
diff --git a/apps/carbon/app/assets/icons/AlmostDoneIcon.tsx b/apps/carbon/app/assets/icons/AlmostDoneIcon.tsx
new file mode 100644
index 0000000000..f03b54160f
--- /dev/null
+++ b/apps/carbon/app/assets/icons/AlmostDoneIcon.tsx
@@ -0,0 +1,34 @@
+export function AlmostDoneIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ width="14"
+ height="14"
+ viewBox="0 0 14 14"
+ fill="none"
+ color="currentColor"
+ className={className}
+ >
+ <circle
+ cx="7"
+ cy="7"
+ r="6"
+ fill="none"
+ stroke="#26a544"
+ stroke-width="2"
+ stroke-dasharray="3.14 0"
+ stroke-dashoffset="-0.7"
+ ></circle>
+ <circle
+ cx="7"
+ cy="7"
+ r="2"
+ fill="none"
+ stroke="#26a544"
+ stroke-width="4"
+ stroke-dasharray="9.377654070965532 100"
+ stroke-dashoffset="0"
+ transform="rotate(-90 7 7)"
+ ></circle>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/assets/icons/HighPriorityIcon.tsx b/apps/carbon/app/assets/icons/HighPriorityIcon.tsx
new file mode 100644
index 0000000000..e138e67e38
--- /dev/null
+++ b/apps/carbon/app/assets/icons/HighPriorityIcon.tsx
@@ -0,0 +1,18 @@
+export function HighPriorityIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ aria-label="High Priority"
+ className={className}
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ role="img"
+ focusable="false"
+ >
+ <rect x="1.5" y="8" width="3" height="6" rx="1"></rect>
+ <rect x="6.5" y="5" width="3" height="9" rx="1"></rect>
+ <rect x="11.5" y="2" width="3" height="12" rx="1"></rect>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/assets/icons/InProgressStatusIcon.tsx b/apps/carbon/app/assets/icons/InProgressStatusIcon.tsx
new file mode 100644
index 0000000000..3063a28852
--- /dev/null
+++ b/apps/carbon/app/assets/icons/InProgressStatusIcon.tsx
@@ -0,0 +1,35 @@
+export function InProgressStatusIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ width="14"
+ height="14"
+ viewBox="0 0 14 14"
+ fill="none"
+ color="currentColor"
+ className={className}
+ >
+ <circle
+ cx="7"
+ cy="7"
+ r="6"
+ fill="none"
+ stroke="#f2be00"
+ stroke-width="2"
+ stroke-dasharray="3.14 0"
+ stroke-dashoffset="-0.7"
+ ></circle>
+ <circle
+ className="progress"
+ cx="7"
+ cy="7"
+ r="2"
+ fill="none"
+ stroke="#f2be00"
+ stroke-width="4"
+ stroke-dasharray="6.2517693806436885 100"
+ stroke-dashoffset="0"
+ transform="rotate(-90 7 7)"
+ ></circle>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/assets/icons/LowPriorityIcon.tsx b/apps/carbon/app/assets/icons/LowPriorityIcon.tsx
new file mode 100644
index 0000000000..d91e4698c9
--- /dev/null
+++ b/apps/carbon/app/assets/icons/LowPriorityIcon.tsx
@@ -0,0 +1,25 @@
+export function LowPriorityIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ aria-label="Low Priority"
+ className={className}
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ role="img"
+ focusable="false"
+ >
+ <rect x="1.5" y="8" width="3" height="6" rx="1"></rect>
+ <rect x="6.5" y="5" width="3" height="9" rx="1" fill-opacity="0.4"></rect>
+ <rect
+ x="11.5"
+ y="2"
+ width="3"
+ height="12"
+ rx="1"
+ fill-opacity="0.4"
+ ></rect>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/assets/icons/MediumPriorityIcon.tsx b/apps/carbon/app/assets/icons/MediumPriorityIcon.tsx
new file mode 100644
index 0000000000..2af03b2975
--- /dev/null
+++ b/apps/carbon/app/assets/icons/MediumPriorityIcon.tsx
@@ -0,0 +1,25 @@
+export function MediumPriorityIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ aria-label="Medium Priority"
+ className={className}
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ fill="currentColor"
+ role="img"
+ focusable="false"
+ >
+ <rect x="1.5" y="8" width="3" height="6" rx="1"></rect>
+ <rect x="6.5" y="5" width="3" height="9" rx="1"></rect>
+ <rect
+ x="11.5"
+ y="2"
+ width="3"
+ height="12"
+ rx="1"
+ fill-opacity="0.4"
+ ></rect>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/assets/icons/TodoStatusIcon.tsx b/apps/carbon/app/assets/icons/TodoStatusIcon.tsx
new file mode 100644
index 0000000000..1b83430342
--- /dev/null
+++ b/apps/carbon/app/assets/icons/TodoStatusIcon.tsx
@@ -0,0 +1,35 @@
+export function TodoStatusIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ width="14"
+ height="14"
+ viewBox="0 0 14 14"
+ fill="none"
+ color="currentColor"
+ className="className"
+ >
+ <circle
+ cx="7"
+ cy="7"
+ r="6"
+ fill="none"
+ stroke="#e2e2e2"
+ stroke-width="2"
+ stroke-dasharray="3.14 0"
+ stroke-dashoffset="-0.7"
+ ></circle>
+ <circle
+ className="progress"
+ cx="7"
+ cy="7"
+ r="2"
+ fill="none"
+ stroke="#e2e2e2"
+ stroke-width="4"
+ stroke-dasharray="0 100"
+ stroke-dashoffset="0"
+ transform="rotate(-90 7 7)"
+ ></circle>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/components/EmployeeAvatarGroup.tsx b/apps/carbon/app/components/EmployeeAvatarGroup.tsx
index 87d43bb44f..625b3c2f01 100644
--- a/apps/carbon/app/components/EmployeeAvatarGroup.tsx
+++ b/apps/carbon/app/components/EmployeeAvatarGroup.tsx
@@ -30,6 +30,7 @@ const EmployeeAvatarGroup = ({
{employees.map((employee, index: number) => (
<Avatar
key={index}
+ size={size ?? "xs"}
name={employee.name ?? undefined}
title={employee.name ?? undefined}
path={employee.avatarUrl}
diff --git a/apps/carbon/app/components/Kanban/components/ColumnCard.tsx b/apps/carbon/app/components/Kanban/components/ColumnCard.tsx
index 44b3ca1932..e926b5f761 100644
--- a/apps/carbon/app/components/Kanban/components/ColumnCard.tsx
+++ b/apps/carbon/app/components/Kanban/components/ColumnCard.tsx
@@ -70,7 +70,7 @@ export function ColumnCard({ column, items, isOverlay }: ColumnCardProps) {
dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,
})}
>
- <CardHeader className="p-4 w-full font-semibold border-b-2 text-left flex flex-row space-between items-center">
+ <CardHeader className="p-4 w-full font-semibold 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>
@@ -116,7 +116,7 @@ export function BoardContainer({ children }: { children: React.ReactNode }) {
dragging: dndContext.active ? "active" : "default",
})}
>
- <div className="flex gap-4 items-start flex-row justify-start p-4">
+ <div className="flex gap-0.5 items-start flex-row justify-start p-0.5">
{children}
</div>
<ScrollBar orientation="horizontal" />
diff --git a/apps/carbon/app/components/Kanban/components/ItemCard.tsx b/apps/carbon/app/components/Kanban/components/ItemCard.tsx
index 4ad3ea5588..ecf1e8c9cf 100644
--- a/apps/carbon/app/components/Kanban/components/ItemCard.tsx
+++ b/apps/carbon/app/components/Kanban/components/ItemCard.tsx
@@ -4,34 +4,86 @@ import {
CardContent,
CardHeader,
HStack,
+ Progress,
Tooltip,
TooltipContent,
TooltipTrigger,
cn,
} from "@carbon/react";
-import { formatDate } from "@carbon/utils";
+import {
+ convertDateStringToIsoString,
+ formatDurationMilliseconds,
+ formatRelativeTime,
+} from "@carbon/utils";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { cva } from "class-variance-authority";
import { BsExclamationSquareFill } from "react-icons/bs";
import {
- LuCalendarCheck,
+ LuCheckCircle,
LuFactory,
LuGripVertical,
- LuRocket,
+ LuTimer,
LuUsers,
+ LuXCircle,
} from "react-icons/lu";
+import { AlmostDoneIcon } from "~/assets/icons/AlmostDoneIcon";
+import { HighPriorityIcon } from "~/assets/icons/HighPriorityIcon";
+import { InProgressStatusIcon } from "~/assets/icons/InProgressStatusIcon";
+import { LowPriorityIcon } from "~/assets/icons/LowPriorityIcon";
+import { MediumPriorityIcon } from "~/assets/icons/MediumPriorityIcon";
+import { TodoStatusIcon } from "~/assets/icons/TodoStatusIcon";
import CustomerAvatar from "~/components/CustomerAvatar";
import EmployeeAvatarGroup from "~/components/EmployeeAvatarGroup";
-import type { Item, ItemDragData } from "../types";
-import KanbanStatus from "./KanbanStatus";
+import { type Item, type ItemDragData } from "../types";
type ItemCardProps = {
item: Item;
isOverlay?: boolean;
};
+const cardVariants = cva(
+ "bg-gradient-to-tl via-card to-card hover:from-muted/30 hover:to-muted/30 hover:via-muted/30",
+ {
+ variants: {
+ dragging: {
+ over: "ring-2 opacity-30",
+ overlay: "ring-2 ring-primary",
+ },
+ status: {
+ IN_PROGRESS: "border-green-600/30 from-green-600/10",
+ READY: "",
+ DONE: "",
+ PAUSED: "",
+ CANCELED: "",
+ WAITING: "border-red-500/30 from-red-500/10",
+ TODO: "border-border",
+ },
+ },
+ defaultVariants: {
+ status: "TODO",
+ },
+ }
+);
+
+const cardHeaderVariants = cva("border-b", {
+ variants: {
+ status: {
+ IN_PROGRESS: "border-green-600/30",
+ READY: "",
+ DONE: "",
+ PAUSED: "",
+ CANCELED: "",
+ WAITING: "border-red-500/30",
+ TODO: "border-border",
+ },
+ },
+ defaultVariants: {
+ status: "TODO",
+ },
+});
+
export function ItemCard({ item, isOverlay }: ItemCardProps) {
const {
setNodeRef,
@@ -56,14 +108,10 @@ export function ItemCard({ item, isOverlay }: ItemCardProps) {
transform: CSS.Translate.toString(transform),
};
- const variants = cva("", {
- variants: {
- dragging: {
- over: "ring-2 opacity-30",
- overlay: "ring-2 ring-primary",
- },
- },
- });
+ const isOverdue =
+ item.deadlineType !== "NO_DEADLINE" && item.dueDate
+ ? new Date(item.dueDate) < new Date()
+ : false;
return (
<Card
@@ -71,42 +119,87 @@ export function ItemCard({ item, isOverlay }: ItemCardProps) {
style={style}
className={cn(
"max-w-[330px]",
- variants({
+ cardVariants({
dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,
+ status: item.status,
})
)}
>
- <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>
- <Button
- variant={"ghost"}
- {...attributes}
- {...listeners}
- className="p-1 text-secondary-foreground/50 -ml-2 h-auto cursor-grab"
- >
- <span className="sr-only">Move item</span>
- <LuGripVertical />
- </Button>
+ <CardHeader
+ className={cn(
+ "max-w-full p-3 border-b relative",
+ cardHeaderVariants({
+ status: item.status,
+ })
+ )}
+ >
+ <div className="flex w-full max-w-full justify-between">
+ <div className="flex flex-col space-y-0">
+ <span className="text-xs text-muted-foreground truncate">
+ F01234
+ </span>
+ <span className="mr-auto font-semibold truncate">{item.title}</span>
+ </div>
+ <Button
+ variant={"ghost"}
+ {...attributes}
+ {...listeners}
+ className="p-1 text-secondary-foreground/50 -ml-2 h-auto cursor-grab"
+ >
+ <span className="sr-only">Move item</span>
+ <LuGripVertical />
+ </Button>
+ </div>
+ {["PAUSED", "DONE", "IN_PROGRESS"].includes(item.status!) && (
+ <Progress
+ indicatorClassName={item.status === "PAUSED" ? "bg-yellow-500" : ""}
+ leftLabel={
+ item.progress ? formatDurationMilliseconds(item.progress) : ""
+ }
+ rightLabel={
+ item.duration ? formatDurationMilliseconds(item.duration) : ""
+ }
+ value={
+ item.progress && item.duration
+ ? (item.progress / item.duration) * 100
+ : 0
+ }
+ />
+ )}
</CardHeader>
<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} />
+ {getStatusIcon(item.status)}
+ <span className="text-sm">{getStatusText(item.status)}</span>
+ </HStack>
+ )}
+ {item.duration && (
+ <HStack className="justify-start space-x-2">
+ <LuTimer className="text-muted-foreground" />
+ <span className="text-sm">
+ {formatDurationMilliseconds(item.duration)}
+ </span>
</HStack>
)}
{item.deadlineType && (
<HStack className="justify-start space-x-2">
- {getDeadlineIcon(item.deadlineType)}
+ {getDeadlineIcon(item.deadlineType, isOverdue)}
<Tooltip>
<TooltipTrigger>
- <span className="text-sm">
+ <span
+ className={cn("text-sm", isOverdue ? "text-red-500" : "")}
+ >
{["ASAP", "NO_DEADLINE"].includes(item.deadlineType)
? getDeadlineText(item.deadlineType)
- : formatDate(item.dueDate)}
+ : item.dueDate
+ ? `Due ${formatRelativeTime(
+ convertDateStringToIsoString(item.dueDate)
+ )}`
+ : "–"}
</span>
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent side="right">
{getDeadlineText(item.deadlineType)}
</TooltipContent>
</Tooltip>
@@ -131,16 +224,56 @@ export function ItemCard({ item, isOverlay }: ItemCardProps) {
);
}
-function getDeadlineIcon(deadlineType: Item["deadlineType"]) {
+function getStatusIcon(status: Item["status"]) {
+ switch (status) {
+ case "READY":
+ case "TODO":
+ return <TodoStatusIcon className="text-foreground" />;
+ case "WAITING":
+ case "CANCELED":
+ return <LuXCircle className="text-muted-foreground" />;
+ case "DONE":
+ return <LuCheckCircle className="text-blue-600" />;
+ case "IN_PROGRESS":
+ return <AlmostDoneIcon />;
+ case "PAUSED":
+ return <InProgressStatusIcon />;
+ default:
+ return null;
+ }
+}
+
+function getStatusText(status: Item["status"], overdue: boolean = false) {
+ switch (status) {
+ case "READY":
+ return "Ready";
+ case "TODO":
+ return "Todo";
+ case "WAITING":
+ return "Waiting";
+ case "CANCELED":
+ return "Canceled";
+ case "DONE":
+ return "Done";
+ case "IN_PROGRESS":
+ return "In progress";
+ case "PAUSED":
+ return "Paused";
+ }
+}
+
+function getDeadlineIcon(deadlineType: Item["deadlineType"], overdue: boolean) {
switch (deadlineType) {
case "ASAP":
return <BsExclamationSquareFill className="text-red-500" />;
case "HARD_DEADLINE":
- return <LuCalendarCheck className="text-orange-500" />;
+ return <HighPriorityIcon className={cn(overdue ? "text-red-500" : "")} />;
case "SOFT_DEADLINE":
- return <LuCalendarCheck className="text-yellow-500" />;
+ return (
+ <MediumPriorityIcon className={cn(overdue ? "text-red-500" : "")} />
+ );
case "NO_DEADLINE":
- return <LuCalendarCheck className="text-muted-foreground" />;
+ return <LowPriorityIcon />;
}
}
diff --git a/apps/carbon/app/components/Kanban/components/KanbanStatus.tsx b/apps/carbon/app/components/Kanban/components/KanbanStatus.tsx
deleted file mode 100644
index cba9e3f04a..0000000000
--- a/apps/carbon/app/components/Kanban/components/KanbanStatus.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-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.ts
index cd7d095ac6..fda742c829 100644
--- a/apps/carbon/app/components/Kanban/types.ts
+++ b/apps/carbon/app/components/Kanban/types.ts
@@ -22,16 +22,21 @@ const itemValidator = z.object({
customerId: z.string().optional(),
employeeIds: z.array(z.string()).optional(),
dueDate: z.string().optional(),
+ duration: z.number().optional(),
deadlineType: z
.enum(["ASAP", "HARD_DEADLINE", "SOFT_DEADLINE", "NO_DEADLINE"])
.optional(),
+ progress: z.number().optional(),
status: z
- .object({
- status: z
- .enum(["INFO", "WARNING", "ERROR", "SUCCESS", "DEFAULT"])
- .optional(),
- message: z.string(),
- })
+ .enum([
+ "CANCELED",
+ "DONE",
+ "IN_PROGRESS",
+ "PAUSED",
+ "READY",
+ "TODO",
+ "WAITING",
+ ])
.optional(),
});
@@ -43,11 +48,13 @@ export interface ItemDragData {
}
export enum ItemStatus {
- Info = "INFO",
- Warning = "WARNING",
- Error = "ERROR",
- Success = "SUCCESS",
- Default = "DEFAULT",
+ Canceled = "CANCELED",
+ Done = "DONE",
+ InProgress = "IN_PROGRESS",
+ Paused = "PAUSED",
+ Ready = "READY",
+ Todo = "TODO",
+ Waiting = "WAITING",
}
export enum ItemDeadline {
diff --git a/apps/carbon/app/components/Layout/Navigation/useModules.tsx b/apps/carbon/app/components/Layout/Navigation/useModules.tsx
index e96e9c81c9..6f9f51cab7 100644
--- a/apps/carbon/app/components/Layout/Navigation/useModules.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/useModules.tsx
@@ -1,4 +1,5 @@
import {
+ LuCalendarRange,
LuComponent,
LuCreditCard,
LuFiles,
@@ -35,12 +36,12 @@ export function useModules() {
// to: path.to.receipts,
// icon: LuBox,
// },
- // {
- // permission: "scheduling",
- // name: "Scheduling",
- // to: path.to.scheduling,
- // icon: LuCalendarRange,
- // },
+ {
+ permission: "scheduling",
+ name: "Scheduling",
+ to: path.to.scheduling,
+ icon: LuCalendarRange,
+ },
// {
// permission: "timecards",
// name: "Timecards",
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesStatus.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
index c4aad7299e..ef43dceac3 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
@@ -10,12 +10,13 @@ const SalesStatus = ({ status }: SalesOrderStatusProps) => {
case "Draft":
return <Status color="gray">{status}</Status>;
case "Cancelled":
- return <Status color="yellow">{status}</Status>;
+ return <Status color="red">{status}</Status>;
case "Confirmed":
+ return <Status color="blue">{status}</Status>;
case "In Progress":
- case "Invoiced":
case "Needs Approval":
return <Status color="orange">{status}</Status>;
+ case "Invoiced":
case "Completed":
return <Status color="green">{status}</Status>;
default:
diff --git a/apps/carbon/app/routes/x+/_layout.tsx b/apps/carbon/app/routes/x+/_layout.tsx
index 7b6f4e141e..8aa3aedd77 100644
--- a/apps/carbon/app/routes/x+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/_layout.tsx
@@ -120,9 +120,9 @@ export default function AuthenticatedRoute() {
<IconSidebar />
<div className="flex w-full h-full">
<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">
+ <main className="h-full flex flex-col flex-1 max-w-[calc(100vw-56px)] overflow-x-hidden bg-muted">
<Topbar />
- <main className="flex-1 overflow-y-auto max-h-[calc(100vh-49px)] max-w-[calc(100vw-39px)]">
+ <main className="flex-1 overflow-y-auto max-h-[calc(100vh-49px)]">
<Outlet />
</main>
</main>
diff --git a/apps/carbon/app/routes/x+/scheduling+/index.tsx b/apps/carbon/app/routes/x+/scheduling+/index.tsx
index 841dc88e1f..4a2dc88ca6 100644
--- a/apps/carbon/app/routes/x+/scheduling+/index.tsx
+++ b/apps/carbon/app/routes/x+/scheduling+/index.tsx
@@ -1,6 +1,6 @@
-import { Button, HStack, cn } from "@carbon/react";
+import { Button, HStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
-import { LuListFilter } from "react-icons/lu";
+import { LuListFilter, LuRefreshCcw } from "react-icons/lu";
import { typedjson, useTypedLoaderData } from "remix-typedjson";
import type { Column, Item } from "~/components/Kanban";
import { Kanban } from "~/components/Kanban";
@@ -25,6 +25,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
{
id: "4",
title: "Bench Grinder",
+ active: true,
},
{
id: "5",
@@ -36,128 +37,106 @@ export async function loader({ request }: LoaderFunctionArgs) {
id: "item0",
columnId: "4",
title: "1503",
- customerId: "6bd344cd-5ea8-406e-9253-2d3672a56533",
- dueDate: "2024-05-20",
+ customerId: "ca2f11f8-1464-4753-9690-00107f141f3a",
+ dueDate: "2024-05-28",
+ duration: 30 * 60 * 1000,
deadlineType: "HARD_DEADLINE",
- status: {
- status: "WARNING",
- message: "Paused",
- },
+ progress: 5 * 60 * 1000,
+ status: "IN_PROGRESS",
},
{
id: "item1",
columnId: "3",
title: "1032",
- dueDate: "2024-05-20",
+ dueDate: "2024-05-30",
+ duration: 2 * 60 * 60 * 1000,
deadlineType: "SOFT_DEADLINE",
- status: {
- status: "WARNING",
- message: "Paused",
- },
+ status: "PAUSED",
+ progress: 1.3 * 60 * 60 * 1000,
},
{
id: "item2",
columnId: "3",
title: "1023",
dueDate: "2024-05-20",
+ duration: 2 * 60 * 60 * 1000,
deadlineType: "ASAP",
- customerId: "6bd344cd-5ea8-406e-9253-2d3672a56533",
- status: {
- status: "INFO",
- message: "Ready",
- },
+ customerId: "ca2f11f8-1464-4753-9690-00107f141f3a",
+ status: "READY",
},
{
id: "item3",
columnId: "3",
title: "1022",
+ duration: 10 * 60 * 1000,
deadlineType: "NO_DEADLINE",
- status: {
- status: "INFO",
- message: "Ready",
- },
+ status: "READY",
},
{
id: "item4",
columnId: "2",
title: "1492",
+ duration: 4 * 60 * 60 * 1000,
deadlineType: "NO_DEADLINE",
- status: {
- status: "ERROR",
- message: "Waiting",
- },
+ status: "WAITING",
},
{
id: "item5",
columnId: "2",
title: "1109",
dueDate: "2024-05-20",
+ duration: 4 * 60 * 60 * 1000,
deadlineType: "SOFT_DEADLINE",
- status: {
- status: "ERROR",
- message: "Waiting",
- },
+ status: "WAITING",
},
{
id: "item6",
columnId: "1",
title: "1013",
deadlineType: "NO_DEADLINE",
- employeeIds: [
- "1ab986d3-362b-4d7f-849e-bc57697c4aff",
- "98bc4b87-37a9-4032-9f8e-97849e8dd8d4",
- ],
- status: {
- status: "SUCCESS",
- message: "In Progress",
- },
+ duration: 2 * 60 * 60 * 1000,
+ employeeIds: ["52cdefed-f4b7-45b1-9ec8-701473671fb7"],
+ status: "IN_PROGRESS",
+ progress: 35 * 60 * 1000,
},
{
id: "item7",
columnId: "1",
title: "1014",
- dueDate: "2024-05-20",
+ dueDate: "2024-06-20",
+ duration: 20 * 60 * 1000,
deadlineType: "HARD_DEADLINE",
- customerId: "1af341c6-d71c-4e4e-8382-e3850e4808cc",
- status: {
- status: "DEFAULT",
- message: "Pending",
- },
+ customerId: "bcbe0bca-6516-4a6c-bb8a-b3942f1a9a33",
+ status: "TODO",
},
{
id: "item8",
columnId: "1",
title: "1032",
- dueDate: "2024-05-20",
+ dueDate: "2024-05-24",
+ duration: 2 * 60 * 60 * 1000,
deadlineType: "SOFT_DEADLINE",
- customerId: "6bd344cd-5ea8-406e-9253-2d3672a56533",
- status: {
- status: "DEFAULT",
- message: "Pending",
- },
+ customerId: "ca2f11f8-1464-4753-9690-00107f141f3a",
+ status: "TODO",
},
{
id: "item9",
columnId: "1",
title: "1010",
dueDate: "2024-05-20",
+ duration: 32 * 1000,
deadlineType: "ASAP",
- status: {
- status: "DEFAULT",
- message: "Pending",
- },
+ status: "TODO",
},
{
id: "item10",
columnId: "1",
title: "1403",
dueDate: "2024-05-20",
+ duration: 6 * 60 * 60 * 1000,
deadlineType: "NO_DEADLINE",
- customerId: "1af341c6-d71c-4e4e-8382-e3850e4808cc",
- status: {
- status: "DEFAULT",
- message: "Pending",
- },
+ customerId: "bcbe0bca-6516-4a6c-bb8a-b3942f1a9a33",
+ status: "TODO",
},
] satisfies Item[],
});
@@ -166,7 +145,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function KanbanView() {
const { columns, items } = useTypedLoaderData<typeof loader>();
return (
- <div className={cn("flex flex-col h-full max-h-full overflow-hidden")}>
+ <div className="flex flex-col h-full max-h-full overflow-auto relative">
<HStack className="px-4 py-2 justify-between bg-card border-b border-border">
<HStack>
<DebouncedInput param="search" size="sm" placeholder="Search" />
@@ -180,9 +159,15 @@ export default function KanbanView() {
Filter
</Button>
</HStack>
+ <Button leftIcon={<LuRefreshCcw />}>Reschedule</Button>
</HStack>
-
- <Kanban columns={columns} items={items} />
+ <div className="flex flex-grow h-full items-stretch overflow-hidden relative">
+ <div className="flex flex-grow h-full items-stretch overflow-hidden relative">
+ <div className="flex flex-1 min-h-0 w-full relative">
+ <Kanban columns={columns} items={items} />
+ </div>
+ </div>
+ </div>
</div>
);
}
diff --git a/packages/react/src/Progress.tsx b/packages/react/src/Progress.tsx
index b90bdc279f..0f446e3852 100644
--- a/packages/react/src/Progress.tsx
+++ b/packages/react/src/Progress.tsx
@@ -6,24 +6,48 @@ import { forwardRef } from "react";
import { cn } from "./utils/cn";
+type ProgressProps = ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {
+ indicatorClassName?: string;
+ leftLabel?: string;
+ rightLabel?: string;
+};
+
const Progress = forwardRef<
ElementRef<typeof ProgressPrimitive.Root>,
- ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
->(({ className, value, ...props }, ref) => (
- <ProgressPrimitive.Root
- ref={ref}
- className={cn(
- "relative h-4 w-full overflow-hidden rounded-full bg-secondary",
- className
- )}
- {...props}
- >
- <ProgressPrimitive.Indicator
- className="h-full w-full flex-1 bg-green-500 transition-all"
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
- />
- </ProgressPrimitive.Root>
-));
+ ProgressProps
+>(
+ (
+ { className, indicatorClassName, leftLabel, rightLabel, value, ...props },
+ ref
+ ) => (
+ <ProgressPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative h-4 w-full overflow-hidden rounded-full bg-secondary",
+ className
+ )}
+ {...props}
+ >
+ <ProgressPrimitive.Indicator
+ className={cn(
+ "h-full w-full flex-1 bg-green-500 transition-all",
+ indicatorClassName
+ )}
+ style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
+ />
+ {leftLabel && (
+ <div className="absolute left-1 z-10 inset-0 text-xs text-secondary-foreground">
+ {leftLabel}
+ </div>
+ )}
+ {rightLabel && (
+ <div className="absolute right-1 top-0 z-10 text-xs text-secondary-foreground">
+ {rightLabel}
+ </div>
+ )}
+ </ProgressPrimitive.Root>
+ )
+);
Progress.displayName = ProgressPrimitive.Root.displayName;
export { Progress };
diff --git a/packages/utils/src/date.ts b/packages/utils/src/date.ts
index d25289c5dc..d3737e414b 100644
--- a/packages/utils/src/date.ts
+++ b/packages/utils/src/date.ts
@@ -18,6 +18,10 @@ const defaultFormatOptions: Intl.DateTimeFormatOptions = {
timeZone: getLocalTimeZone(),
};
+export function convertDateStringToIsoString(dateString: string) {
+ return new Date(dateString).toISOString();
+}
+
export function formatDate(
dateString?: string | null,
options?: Intl.DateTimeFormatOptions
@@ -31,6 +35,14 @@ export function formatDate(
).format(date.toDate(getLocalTimeZone()));
}
+export function formatRelativeTime(isoString: string) {
+ if (new Date(isoString).getTime() > new Date().getTime()) {
+ return formatTimeFromNow(isoString);
+ } else {
+ return formatTimeAgo(isoString);
+ }
+}
+
export function formatTimeAgo(isoString: string) {
let duration = (new Date(isoString).getTime() - new Date().getTime()) / 1000;
@@ -43,6 +55,21 @@ export function formatTimeAgo(isoString: string) {
}
}
+export function formatTimeFromNow(isoString: string) {
+ let duration = (new Date().getTime() - new Date(isoString).getTime()) / 1000;
+
+ for (let i = 0; i <= DIVISIONS.length; i++) {
+ const division = DIVISIONS[i];
+ if (Math.abs(duration) < division!.amount) {
+ return relativeFormatter.format(
+ Math.round(-1 * duration),
+ division!.name
+ );
+ }
+ duration /= division!.amount;
+ }
+}
+
export function getDateNYearsAgo(n: number) {
const date = new Date();
date.setFullYear(date.getFullYear() - n);