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: persist column ordering in local storage

Brad Barbin8e4fb2b1de88
diff --git a/apps/carbon/app/modules/production/ui/Schedule/Kanban/Kanban.tsx b/apps/carbon/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
index e9d16b8910..218f1ca314 100644
--- a/apps/carbon/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
+++ b/apps/carbon/app/modules/production/ui/Schedule/Kanban/Kanban.tsx
@@ -17,7 +17,7 @@ import {
} from "@dnd-kit/core";
import { SortableContext, arrayMove } from "@dnd-kit/sortable";
import { useFetchers, useSubmit } from "@remix-run/react";
-import { useRef, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { path } from "~/utils/path";
import { BoardContainer, ColumnCard } from "./components/ColumnCard";
@@ -30,15 +30,35 @@ type KanbanProps = {
items: Item[];
} & DisplaySettings;
+const COLUMN_ORDER_KEY = "kanban-column-order";
+
const Kanban = ({
columns,
items: initialItems,
...displaySettings
}: KanbanProps) => {
const submit = useSubmit();
- const [columnOrder, setColumnOrder] = useState<string[]>(
- columns.map((col) => col.id)
- );
+ const [columnOrder, setColumnOrder] = useState<string[]>(() => {
+ // Get stored column order from localStorage
+ const storedOrder = localStorage.getItem(COLUMN_ORDER_KEY);
+ if (storedOrder) {
+ const parsedOrder = JSON.parse(storedOrder) as string[];
+ // Add any new columns that aren't in stored order
+ const newOrder = [...parsedOrder];
+ columns.forEach((col) => {
+ if (!newOrder.includes(col.id)) {
+ newOrder.push(col.id);
+ }
+ });
+ return newOrder;
+ }
+ return columns.map((col) => col.id);
+ });
+
+ // Update localStorage when column order changes
+ useEffect(() => {
+ localStorage.setItem(COLUMN_ORDER_KEY, JSON.stringify(columnOrder));
+ }, [columnOrder]);
const itemsById = new Map<string, Item>(
initialItems.map((item) => [item.id, item])
diff --git a/apps/carbon/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx b/apps/carbon/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
index 08b6c095b4..e80554227a 100644
--- a/apps/carbon/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
+++ b/apps/carbon/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
@@ -150,9 +150,12 @@ export function ItemCard({
{item.subtitle}
</span>
)}
- <span className="mr-auto font-semibold line-clamp-1">
+ <Link
+ to={`${item.link}?selectedOperation=${item.id}`}
+ className="mr-auto font-semibold line-clamp-1"
+ >
{item.title}
- </span>
+ </Link>
</div>
<HStack spacing={0} className="-mr-4">
<IconButton
diff --git a/apps/carbon/app/routes/x+/schedule+/index.tsx b/apps/carbon/app/routes/x+/schedule+/index.tsx
index baa64baf9c..2bf274f805 100644
--- a/apps/carbon/app/routes/x+/schedule+/index.tsx
+++ b/apps/carbon/app/routes/x+/schedule+/index.tsx
@@ -4,7 +4,7 @@ import { path } from "~/utils/path";
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { Button, HStack } from "@carbon/react";
+import { Button, ClientOnly, HStack, Spinner } from "@carbon/react";
import { Link, useLoaderData } from "@remix-run/react";
import { json, redirect, type LoaderFunctionArgs } from "@vercel/remix";
import { useMemo } from "react";
@@ -233,17 +233,27 @@ export default function ScheduleRoute() {
<div className="flex flex-grow h-full items-stretch overflow-hidden relative">
<div className="flex flex-1 min-h-0 w-full relative">
{columns.length > 0 ? (
- <Kanban
- columns={columns}
- items={items}
- showCustomer
- showDescription
- showDueDate
- showDuration
- showEmployee
- showProgress={false}
- showStatus
- />
+ <ClientOnly
+ fallback={
+ <div className="flex h-full w-full items-center justify-center">
+ <Spinner className="h-8 w-8" />
+ </div>
+ }
+ >
+ {() => (
+ <Kanban
+ columns={columns}
+ items={items}
+ showCustomer
+ showDescription
+ showDueDate
+ showDuration
+ showEmployee
+ showProgress={false}
+ showStatus
+ />
+ )}
+ </ClientOnly>
) : hasFilters ? (
<div className="flex flex-col w-full h-full items-center justify-center gap-4">
<div className="flex justify-center items-center h-12 w-12 rounded-full bg-foreground text-background">
diff --git a/launcher.sh b/launcher.sh
deleted file mode 100644
index 559450cf03..0000000000
--- a/launcher.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-
-# ______________Node___________________
-# export NVM_DIR="$HOME/.nvm"
-# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
-# nvm use 20
-
-npm install
-npm run db:start
-
-cp ./.env.example ./.env
-
-read -p "Enter SUPABASE_SERVICE_ROLE key: " supabase_service_role
-read -p "Enter SUPABASE_ANON_PUBLIC key: " supabase_anon_public
-read -p "Enter UPSTASH_REDIS_REST_URL: " upstash_redis_rest_url
-read -p "Enter UPSTASH_REDIS_REST_TOKEN: " upstash_redis_rest_token
-read -p "Enter TRIGGER_PUBLIC_API_KEY: " trigger_public_api_key
-read -p "Enter TRIGGER_API_KEY: " trigger_api_key
-read -p "Enter POSTHOG_API_HOST: " posthog_api_host
-read -p "Enter POSTHOG_PROJECT_PUBLIC_KEY: " posthog_project_public_key
-
-sed -i '' "s/SUPABASE_SERVICE_ROLE=.*$/SUPABASE_SERVICE_ROLE=$supabase_service_role/" ./.env
-sed -i '' "s/SUPABASE_ANON_PUBLIC=.*$/SUPABASE_ANON_PUBLIC=$supabase_anon_public/" ./.env
-sed -i '' "s/UPSTASH_REDIS_REST_URL=.*$/UPSTASH_REDIS_REST_URL=$upstash_redis_rest_url/" ./.env
-sed -i '' "s/UPSTASH_REDIS_REST_TOKEN=.*$/UPSTASH_REDIS_REST_TOKEN=$upstash_redis_rest_token/" ./.env
-sed -i '' "s/TRIGGER_PUBLIC_API_KEY=.*$/TRIGGER_PUBLIC_API_KEY=$trigger_public_api_key/" ./.env
-sed -i '' "s/TRIGGER_API_KEY=.*$/TRIGGER_API_KEY=$trigger_api_key/" ./.env
-sed -i '' "s/POSTHOG_API_HOST=.*$/POSTHOG_API_HOST=$posthog_api_host/" ./.env
-sed -i '' "s/POSTHOG_PROJECT_PUBLIC_KEY=.*$/POSTHOG_PROJECT_PUBLIC_KEY=$posthog_project_public_key/" ./.env
-
-npm run db:build
-npm run build:app
-npm run dev
-
-# npm run db:kill #This will kill the DB
-# npm run db:build
-
-echo "Setup complete. You can now sign in with the default credentials."
\ No newline at end of file