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: remove fixtures

Brad Barbin578ce1ff05d9
diff --git a/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx b/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx
index b9123d578d..e8d38bd785 100644
--- a/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx
+++ b/apps/carbon/app/components/Editable/EditablePurchaseInvoiceLineNumber.tsx
@@ -85,7 +85,6 @@ const EditablePurchaseInvoiceLineNumber =
case "Material":
case "Part":
case "Tool":
- case "Fixture":
case "Consumable":
const [item, buyMethod, inventory] = await Promise.all([
client
@@ -211,14 +210,9 @@ const EditablePurchaseInvoiceLineNumber =
if (!newValue) return;
if (
- [
- "Part",
- "Service",
- "Material",
- "Tool",
- "Fixture",
- "Consumable",
- ].includes(row.invoiceLineType)
+ ["Part", "Service", "Material", "Tool", "Consumable"].includes(
+ row.invoiceLineType
+ )
) {
onItemChange(newValue);
} else if (row.invoiceLineType === "G/L Account") {
diff --git a/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx b/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx
index d01debd501..f88105c16e 100644
--- a/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx
+++ b/apps/carbon/app/components/Editable/EditablePurchaseOrderLineNumber.tsx
@@ -90,7 +90,6 @@ const EditablePurchaseOrderLineNumber =
case "Material":
case "Part":
case "Tool":
- case "Fixture":
case "Consumable":
const [item, buyMethod, inventory] = await Promise.all([
client
@@ -218,14 +217,9 @@ const EditablePurchaseOrderLineNumber =
if (!row.purchaseOrderLineType) return;
if (
- [
- "Part",
- "Service",
- "Material",
- "Tool",
- "Fixture",
- "Consumable",
- ].includes(row.purchaseOrderLineType)
+ ["Part", "Service", "Material", "Tool", "Consumable"].includes(
+ row.purchaseOrderLineType
+ )
) {
onItemChange(newValue);
} else if (row.purchaseOrderLineType === "G/L Account") {
@@ -253,10 +247,9 @@ export default EditablePurchaseOrderLineNumber;
function getValue(row: PurchaseOrderLine) {
switch (row.purchaseOrderLineType) {
case "Part":
- case "Service":
+ // case "Service":
case "Material":
case "Tool":
- case "Fixture":
case "Consumable":
return row.itemId;
diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsx
index 4dd1e575f9..84d3963420 100644
--- a/apps/carbon/app/components/Form/Item.tsx
+++ b/apps/carbon/app/components/Form/Item.tsx
@@ -21,7 +21,6 @@ import {
import { useEffect, useMemo, useRef, useState } from "react";
import {
ConsumableForm,
- FixtureForm,
MaterialForm,
PartForm,
ToolForm,
@@ -240,6 +239,7 @@ const Item = ({
defaultMethodType: "Make",
active: props?.includeInactive === undefined,
unitCost: 0,
+ tags: [],
}}
/>
)}
@@ -261,30 +261,11 @@ const Item = ({
defaultMethodType: "Buy",
active: props?.includeInactive === undefined,
unitCost: 0,
+ tags: [],
}}
/>
)}
- {type === "Fixture" && newItemsModal.isOpen && (
- <FixtureForm
- type="modal"
- onClose={() => {
- setCreated("");
- newItemsModal.onClose();
- triggerRef.current?.click();
- }}
- initialValues={{
- id: "",
- name: created,
- description: "",
- itemTrackingType: "Inventory",
- unitOfMeasureCode: "EA",
- replenishmentSystem: "Make",
- defaultMethodType: "Buy",
- active: props?.includeInactive === undefined,
- unitCost: 0,
- }}
- />
- )}
+
{type === "Material" && newItemsModal.isOpen && (
<MaterialForm
type="modal"
@@ -327,6 +308,7 @@ const Item = ({
defaultMethodType: "Buy",
active: props?.includeInactive === undefined,
unitCost: 0,
+ tags: [],
}}
/>
)}
diff --git a/apps/carbon/app/components/Icons.tsx b/apps/carbon/app/components/Icons.tsx
index d32b4528cf..76dbb238d2 100644
--- a/apps/carbon/app/components/Icons.tsx
+++ b/apps/carbon/app/components/Icons.tsx
@@ -6,7 +6,6 @@ import {
LuAtom,
LuCheckCircle,
LuExternalLink,
- LuGrip,
LuHammer,
LuHardHat,
LuHeadphones,
@@ -70,8 +69,6 @@ export const MethodItemTypeIcon = ({
return <LuAtom className={className} />;
case "Tool":
return <LuHammer className={className} />;
- case "Fixture":
- return <LuGrip className={className} />;
case "Consumable":
return <LuPizza className={className} />;
case "Service":
diff --git a/apps/carbon/app/components/Layout/Topbar/Search.tsx b/apps/carbon/app/components/Layout/Topbar/Search.tsx
index 5d39fd6653..02ee8b78b9 100644
--- a/apps/carbon/app/components/Layout/Topbar/Search.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/Search.tsx
@@ -264,7 +264,6 @@ function ResultIcon({ entity }: { entity: SearchResult["entity"] | "Module" }) {
case "Part":
case "Material":
case "Tool":
- case "Fixture":
case "Consumable":
return (
<MethodItemTypeIcon
diff --git a/apps/carbon/app/hooks/useNextItemId.tsx b/apps/carbon/app/hooks/useNextItemId.tsx
index 3ed33cd510..47c626e395 100644
--- a/apps/carbon/app/hooks/useNextItemId.tsx
+++ b/apps/carbon/app/hooks/useNextItemId.tsx
@@ -3,7 +3,7 @@ import { useState } from "react";
import { useUser } from "./useUser";
export function useNextItemId(
- table: "Part" | "Service" | "Tool" | "Material" | "Consumable" | "Fixture"
+ table: "Part" | "Service" | "Tool" | "Material" | "Consumable"
) {
const { company } = useUser();
const { carbon } = useCarbon();
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
index c20e6e9e8e..fc3bce9b7b 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
@@ -610,8 +610,6 @@ function getDocumentLocation(
return path.to.material(sourceDocumentId);
case "Tool":
return path.to.tool(sourceDocumentId);
- case "Fixture":
- return path.to.fixture(sourceDocumentId);
case "Consumable":
return path.to.consumable(sourceDocumentId);
// case "Service":
diff --git a/apps/carbon/app/modules/inventory/inventory.models.ts b/apps/carbon/app/modules/inventory/inventory.models.ts
index f520adb33a..ab7a7c07ef 100644
--- a/apps/carbon/app/modules/inventory/inventory.models.ts
+++ b/apps/carbon/app/modules/inventory/inventory.models.ts
@@ -5,7 +5,6 @@ export const itemTypes = [
"Part",
"Material",
"Tool",
- "Fixture",
"Consumable",
// "Service",
] as const;
diff --git a/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx b/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
index 2e285eb41b..301ca5a45a 100644
--- a/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
+++ b/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
@@ -31,12 +31,6 @@ const inventoryRoutes: AuthenticatedRouteGroup[] = [
"type:eq:Tool"
)}`,
},
- {
- name: "Fixtures",
- to: `${path.to.inventory}?filter=${encodeURIComponent(
- "type:eq:Fixture"
- )}`,
- },
{
name: "Consumables",
to: `${path.to.inventory}?filter=${encodeURIComponent(
diff --git a/apps/carbon/app/modules/invoicing/invoicing.models.ts b/apps/carbon/app/modules/invoicing/invoicing.models.ts
index 56a9a28ad6..d8c49d2573 100644
--- a/apps/carbon/app/modules/invoicing/invoicing.models.ts
+++ b/apps/carbon/app/modules/invoicing/invoicing.models.ts
@@ -6,7 +6,6 @@ export const purchaseInvoiceLineType = [
// "Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"Fixed Asset",
"G/L Account",
@@ -68,7 +67,7 @@ export const purchaseInvoiceLineValidator = z
})
.refine(
(data) =>
- ["Part", "Service", "Material", "Tool", "Fixture", "Consumable"].includes(
+ ["Part", "Service", "Material", "Tool", "Consumable"].includes(
data.invoiceLineType
)
? data.itemId
@@ -80,9 +79,7 @@ export const purchaseInvoiceLineValidator = z
)
.refine(
(data) =>
- ["Part", "Material", "Tool", "Fixture", "Consumable"].includes(
- data.invoiceLineType
- )
+ ["Part", "Material", "Tool", "Consumable"].includes(data.invoiceLineType)
? data.locationId
: true,
{
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
index cb9fd69199..56b39ab88c 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
@@ -59,13 +59,7 @@ const PurchaseInvoiceHeader = () => {
.from("purchaseInvoiceLine")
.select("itemId, itemReadableId, quantity, conversionFactor")
.eq("invoiceId", invoiceId)
- .in("invoiceLineType", [
- "Part",
- "Material",
- "Tool",
- "Fixture",
- "Consumable",
- ])
+ .in("invoiceLineType", ["Part", "Material", "Tool", "Consumable"])
.is("purchaseOrderLineId", null);
if (error) throw new Error(error.message);
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
index 26c42b6ec6..b5e9063bbc 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
@@ -140,7 +140,6 @@ const PurchaseInvoiceLineForm = ({
case "Material":
case "Part":
case "Tool":
- case "Fixture":
const [item, buyMethod, inventory] = await Promise.all([
carbon
.from("item")
@@ -281,10 +280,9 @@ const PurchaseInvoiceLineForm = ({
/>
{[
"Part",
- "Service",
+ // "Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
].includes(type) && (
<Item
@@ -395,7 +393,6 @@ const PurchaseInvoiceLineForm = ({
"Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"Fixed Asset",
].includes(type) && (
@@ -412,7 +409,6 @@ const PurchaseInvoiceLineForm = ({
"Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"Fixed Asset",
].includes(type) && (
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
index 87d1c40710..e18b40ec51 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLines/PurchaseInvoiceLines.tsx
@@ -119,7 +119,6 @@ const PurchaseInvoiceLines = () => {
case "Service":
case "Material":
case "Tool":
- case "Fixture":
case "Consumable":
return <span>{row.original.itemReadableId}</span>;
case "G/L Account":
@@ -190,7 +189,7 @@ const PurchaseInvoiceLines = () => {
case "Part":
case "Material":
case "Tool":
- case "Fixture":
+ // case "Fixture":
case "Consumable":
return (
<span>
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index 36255b830a..ebef54cfec 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -100,13 +100,6 @@ export const customerPartValidator = z.object({
customerPartRevision: zfd.text(z.string().optional()),
});
-export const fixtureValidator = itemValidator.merge(
- z.object({
- id: z.string().min(1, { message: "Fixture ID is required" }).max(255),
- customerId: z.string().optional(),
- })
-);
-
export const materialValidator = itemValidator.merge(
z.object({
id: z.string().min(1, { message: "Material ID is required" }).max(255),
@@ -168,18 +161,18 @@ export const methodMaterialValidator = z
path: ["itemId"],
}
)
- .refine(
- (data) => {
- if (data.itemType === "Fixture") {
- return !!data.itemReadableId;
- }
- return true;
- },
- {
- message: "Fixture ID is required",
- path: ["itemId"],
- }
- )
+ // .refine(
+ // (data) => {
+ // if (data.itemType === "Fixture") {
+ // return !!data.itemReadableId;
+ // }
+ // return true;
+ // },
+ // {
+ // message: "Fixture ID is required",
+ // path: ["itemId"],
+ // }
+ // )
.refine(
(data) => {
if (data.itemType === "Tool") {
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index f8f9857ef1..ddf95b729d 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -10,7 +10,6 @@ import type {
buyMethodValidator,
consumableValidator,
customerPartValidator,
- fixtureValidator,
getMethodValidator,
itemCostValidator,
itemPlanningValidator,
@@ -196,75 +195,6 @@ export async function getConsumablesList(
return query.order("name");
}
-
-export async function getFixture(
- client: SupabaseClient<Database>,
- itemId: string,
- companyId: string
-) {
- return client
- .from("fixtures")
- .select("*")
- .eq("itemId", itemId)
- .eq("companyId", companyId)
- .single();
-}
-
-export async function getFixtures(
- client: SupabaseClient<Database>,
- companyId: string,
- args: GenericQueryFilters & {
- search: string | null;
- supplierId: string | null;
- }
-) {
- let query = client
- .from("fixtures")
- .select("*", {
- count: "exact",
- })
- .eq("companyId", companyId);
-
- const includeInactive = args?.filters?.some(
- (filter) =>
- (filter.column === "active" && filter.value === "false") ||
- (filter.column === "active" && filter.operator === "in")
- );
-
- if (!includeInactive) {
- query = query.eq("active", true);
- }
-
- if (args.search) {
- query = query.or(
- `id.ilike.%${args.search}%,name.ilike.%${args.search}%,description.ilike.%${args.search}%,supplierIds.ilike.%${args.search}%`
- );
- }
-
- if (args.supplierId) {
- query = query.contains("supplierIds", [args.supplierId]);
- }
-
- query = setGenericQueryFilters(query, args, [
- { column: "id", ascending: true },
- ]);
- return query;
-}
-
-export async function getFixturesList(
- client: SupabaseClient<Database>,
- companyId: string
-) {
- let query = client
- .from("item")
- .select("id, name, readableId")
- .eq("type", "Fixture")
- .eq("companyId", companyId)
- .eq("active", true);
-
- return query.order("name");
-}
-
export async function getItem(client: SupabaseClient<Database>, id: string) {
return client.from("item").select("*").eq("id", id).single();
}
@@ -1189,105 +1119,6 @@ export async function upsertConsumable(
if (updateItem.error) return updateItem;
return updateConsumable;
}
-
-export async function upsertFixture(
- client: SupabaseClient<Database>,
- fixture:
- | (z.infer<typeof fixtureValidator> & {
- companyId: string;
- createdBy: string;
- customFields?: Json;
- })
- | (z.infer<typeof fixtureValidator> & {
- updatedBy: string;
- customFields?: Json;
- })
-) {
- if ("createdBy" in fixture) {
- const itemInsert = await client
- .from("item")
- .insert({
- readableId: fixture.id,
- name: fixture.name,
- type: "Fixture",
- replenishmentSystem: fixture.replenishmentSystem,
- defaultMethodType: fixture.defaultMethodType,
- itemTrackingType: fixture.itemTrackingType,
- unitOfMeasureCode: "EA",
- active: fixture.active,
- companyId: fixture.companyId,
- createdBy: fixture.createdBy,
- })
- .select("id")
- .single();
-
- if (itemInsert.error) return itemInsert;
- const itemId = itemInsert.data?.id;
-
- const fixtureInsert = await client
- .from("fixture")
- .insert({
- id: fixture.id,
- itemId: itemId,
- companyId: fixture.companyId,
- customerId: fixture.customerId || null,
- createdBy: fixture.createdBy,
- customFields: fixture.customFields,
- })
- .select("*")
- .single();
-
- if (fixtureInsert.error) return fixtureInsert;
-
- const costUpdate = await client
- .from("itemCost")
- .update({ unitCost: fixture.unitCost })
- .eq("itemId", itemId)
- .select("*")
- .single();
-
- if (costUpdate.error) return costUpdate;
-
- return fixtureInsert;
- }
-
- const itemUpdate = {
- id: fixture.id,
- name: fixture.name,
- description: fixture.description,
- replenishmentSystem: fixture.replenishmentSystem,
- defaultMethodType: fixture.defaultMethodType,
- itemTrackingType: fixture.itemTrackingType,
- unitOfMeasureCode: "EA",
- active: fixture.active,
- };
-
- const fixtureUpdate = {
- customerId: fixture.customerId ? fixture.customerId : undefined,
- customFields: fixture.customFields,
- };
-
- const [updateItem, updateFixture] = await Promise.all([
- client
- .from("item")
- .update({
- ...sanitize(itemUpdate),
- updatedAt: today(getLocalTimeZone()).toString(),
- })
- .eq("id", fixture.id),
- client
- .from("fixture")
- .update({
- ...sanitize(fixtureUpdate),
- updatedAt: today(getLocalTimeZone()).toString(),
- })
- .eq("itemId", fixture.id),
- ]);
-
- if (updateItem.error) return updateItem;
- return updateFixture;
-}
-
export async function upsertPart(
client: SupabaseClient<Database>,
part:
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
deleted file mode 100644
index 3b4a653c91..0000000000
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
+++ /dev/null
@@ -1,213 +0,0 @@
-import { ValidatedForm } from "@carbon/form";
-import {
- ModalCard,
- ModalCardBody,
- ModalCardContent,
- ModalCardDescription,
- ModalCardFooter,
- ModalCardHeader,
- ModalCardProvider,
- ModalCardTitle,
- cn,
- toast,
-} from "@carbon/react";
-import { useFetcher } from "@remix-run/react";
-import type { PostgrestResponse } from "@supabase/supabase-js";
-import { useEffect, useState } from "react";
-import type { z } from "zod";
-import {
- Boolean,
- CustomFormFields,
- Customer,
- DefaultMethodType,
- Hidden,
- Input,
- InputControlled,
- Number,
- Select,
- Submit,
- TextArea,
-} from "~/components/Form";
-import { useNextItemId, usePermissions, useUser } from "~/hooks";
-import {
- fixtureValidator,
- itemReplenishmentSystems,
- itemTrackingTypes,
-} from "~/modules/items";
-import { path } from "~/utils/path";
-
-type FixtureFormProps = {
- initialValues: z.infer<typeof fixtureValidator> & { tags: string[] };
- type?: "card" | "modal";
- onClose?: () => void;
-};
-
-function startsWithLetter(value: string) {
- return /^[A-Za-z]/.test(value);
-}
-
-const FixtureForm = ({
- initialValues,
- type = "card",
- onClose,
-}: FixtureFormProps) => {
- const { company } = useUser();
- const baseCurrency = company?.baseCurrencyCode ?? "USD";
-
- const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();
-
- useEffect(() => {
- if (type !== "modal") return;
-
- if (fetcher.state === "loading" && fetcher.data?.data) {
- onClose?.();
- toast.success(`Created fixture`);
- } else if (fetcher.state === "idle" && fetcher.data?.error) {
- toast.error(`Failed to create fixture: ${fetcher.data.error.message}`);
- }
- }, [fetcher.data, fetcher.state, onClose, type]);
-
- const { id, onIdChange, loading } = useNextItemId("Fixture");
- const permissions = usePermissions();
- const isEditing = !!initialValues.id;
-
- const itemTrackingTypeOptions =
- itemTrackingTypes.map((itemTrackingType) => ({
- label: itemTrackingType,
- value: itemTrackingType,
- })) ?? [];
-
- const [replenishmentSystem, setReplenishmentSystem] = useState<string>(
- initialValues.replenishmentSystem ?? "Buy"
- );
- const [defaultMethodType, setDefaultMethodType] = useState<string>(
- initialValues.defaultMethodType ?? "Buy"
- );
- const itemReplenishmentSystemOptions =
- itemReplenishmentSystems.map((itemReplenishmentSystem) => ({
- label: itemReplenishmentSystem,
- value: itemReplenishmentSystem,
- })) ?? [];
-
- return (
- <ModalCardProvider type={type}>
- <ModalCard onClose={onClose}>
- <ModalCardContent>
- <ValidatedForm
- action={isEditing ? undefined : path.to.newFixture}
- method="post"
- validator={fixtureValidator}
- defaultValues={initialValues}
- fetcher={fetcher}
- >
- <ModalCardHeader>
- <ModalCardTitle>
- {isEditing ? "Fixture Details" : "New Fixture"}
- </ModalCardTitle>
- {!isEditing && (
- <ModalCardDescription>
- A fixture is a physical item used to make a part that can be
- used across multiple jobs
- </ModalCardDescription>
- )}
- </ModalCardHeader>
- <ModalCardBody>
- <Hidden name="type" value={type} />
- <Hidden name="unitOfMeasureCode" value="EA" />
-
- <div
- className={cn(
- "grid w-full gap-x-8 gap-y-4",
- isEditing
- ? "grid-cols-1 md:grid-cols-3"
- : "grid-cols-1 md:grid-cols-2"
- )}
- >
- {isEditing ? (
- <Input name="id" label="Fixture ID" isReadOnly />
- ) : (
- <InputControlled
- name="id"
- label="Fixture ID"
- helperText={
- startsWithLetter(id)
- ? "Use ... to get the next fixture ID"
- : undefined
- }
- value={id}
- onChange={onIdChange}
- isDisabled={loading}
- isUppercase
- autoFocus
- />
- )}
-
- <Input name="name" label="Short Description" />
- <Select
- name="itemTrackingType"
- label="Tracking Type"
- options={itemTrackingTypeOptions}
- />
- {isEditing && (
- <TextArea name="description" label="Long Description" />
- )}
- <Select
- name="replenishmentSystem"
- label="Replenishment System"
- options={itemReplenishmentSystemOptions}
- onChange={(newValue) => {
- setReplenishmentSystem(newValue?.value ?? "Buy");
- if (newValue?.value === "Buy") {
- setDefaultMethodType("Buy");
- } else {
- setDefaultMethodType("Make");
- }
- }}
- />
- <DefaultMethodType
- name="defaultMethodType"
- label="Default Method Type"
- replenishmentSystem={replenishmentSystem}
- value={defaultMethodType}
- onChange={(newValue) =>
- setDefaultMethodType(newValue?.value ?? "Buy")
- }
- />
-
- <Customer name="customerId" label="Customer" />
- {!isEditing && (
- <Number
- name="unitCost"
- label="Unit Cost"
- formatOptions={{
- style: "currency",
- currency: baseCurrency,
- maximumFractionDigits: 4,
- }}
- minValue={0}
- />
- )}
- <Boolean name="active" label="Active" />
-
- <CustomFormFields table="fixture" tags={initialValues.tags} />
- </div>
- </ModalCardBody>
- <ModalCardFooter>
- <Submit
- isDisabled={
- isEditing
- ? !permissions.can("update", "parts")
- : !permissions.can("create", "parts")
- }
- >
- Save
- </Submit>
- </ModalCardFooter>
- </ValidatedForm>
- </ModalCardContent>
- </ModalCard>
- </ModalCardProvider>
- );
-};
-
-export default FixtureForm;
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
deleted file mode 100644
index 1ac847fe1d..0000000000
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { HStack, Heading, VStack } from "@carbon/react";
-
-import { Link, useParams } from "@remix-run/react";
-import { Copy } from "~/components";
-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 links = useFixtureNavigation();
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const routeData = useRouteData<{ fixtureSummary: Fixture }>(
- path.to.fixture(itemId)
- );
-
- return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border h-[50px]">
- <VStack spacing={0} className="flex-grow">
- <HStack>
- <Link to={path.to.fixtureDetails(itemId)}>
- <Heading size="h3" className="flex items-center gap-2">
- {/* <ModuleIcon icon={<MethodItemTypeIcon type="Fixture" />} /> */}
- <span>{routeData?.fixtureSummary?.id}</span>
- </Heading>
- </Link>
- <Copy text={routeData?.fixtureSummary?.id ?? ""} />
- </HStack>
- </VStack>
- <VStack spacing={0} className="flex-shrink justify-center items-end">
- <DetailsTopbar links={links} />
- </VStack>
- </div>
- );
-};
-
-export default FixtureHeader;
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
deleted file mode 100644
index 37d8284d49..0000000000
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
+++ /dev/null
@@ -1,402 +0,0 @@
-import type { Json } from "@carbon/database";
-import { ValidatedForm } from "@carbon/form";
-import {
- Badge,
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuIcon,
- DropdownMenuItem,
- DropdownMenuTrigger,
- HStack,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- VStack,
- cn,
- toast,
-} from "@carbon/react";
-import { Await, Link, useFetcher, useParams } from "@remix-run/react";
-import { Suspense, useCallback, useEffect } from "react";
-import { LuCopy, LuExternalLink, LuLink, LuMove3D } from "react-icons/lu";
-import { z } from "zod";
-import { zfd } from "zod-form-data";
-import {
- CustomerAvatar,
- MethodBadge,
- MethodIcon,
- TrackingTypeIcon,
-} from "~/components";
-import { Enumerable } from "~/components/Enumerable";
-import { Boolean, Tags } from "~/components/Form";
-import CustomFormInlineFields from "~/components/Form/CustomFormInlineFields";
-import { ItemThumbnailUpload } from "~/components/ItemThumnailUpload";
-import { useRouteData } from "~/hooks";
-import { methodType } from "~/modules/shared";
-import type { action } from "~/routes/x+/items+/update";
-import type { ListItem } from "~/types";
-import { path } from "~/utils/path";
-import { copyToClipboard } from "~/utils/string";
-import {
- itemReplenishmentSystems,
- itemTrackingTypes,
-} from "../../items.models";
-import type { BuyMethod, Fixture, ItemFile, PickMethod } from "../../types";
-import { FileBadge } from "../Item";
-
-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;
- files: Promise<ItemFile[]>;
- buyMethods: BuyMethod[];
- pickMethods: PickMethod[];
- tags: { name: string }[];
- }>(path.to.fixture(itemId));
-
- const locations = sharedFixturesData?.locations ?? [];
- const buyMethods = routeData?.buyMethods ?? [];
- const pickMethods = routeData?.pickMethods ?? [];
-
- const fetcher = useFetcher<typeof action>();
- useEffect(() => {
- if (fetcher.data?.error) {
- toast.error(fetcher.data.error.message);
- }
- }, [fetcher.data]);
-
- const onUpdate = useCallback(
- (
- field:
- | "replenishmentSystem"
- | "defaultMethodType"
- | "itemTrackingType"
- | "active",
- value: string
- ) => {
- const formData = new FormData();
-
- formData.append("items", itemId);
- formData.append("field", field);
- formData.append("value", value?.toString() ?? "");
- fetcher.submit(formData, {
- method: "post",
- action: path.to.bulkUpdateItems,
- });
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [itemId]
- );
-
- const onUpdateTags = useCallback(
- (value: string[]) => {
- const formData = new FormData();
-
- formData.append("ids", itemId);
- formData.append("table", "fixture");
- value.forEach((v) => {
- formData.append("value", v);
- });
-
- fetcher.submit(formData, {
- method: "post",
- action: path.to.tags,
- });
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [itemId]
- );
-
- const onUpdateCustomFields = useCallback(
- (value: string) => {
- const formData = new FormData();
-
- formData.append("ids", itemId);
- formData.append("table", "fixture");
- formData.append("value", value);
-
- fetcher.submit(formData, {
- method: "post",
- action: path.to.customFields,
- });
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [itemId]
- );
-
- return (
- <VStack
- spacing={4}
- className="w-96 bg-background h-full overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent border-l border-border px-4 py-2 text-sm"
- >
- <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={() =>
- copyToClipboard(
- 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={() =>
- copyToClipboard(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>
- <ItemThumbnailUpload
- path={routeData?.fixtureSummary?.thumbnailPath}
- itemId={itemId}
- modelId={routeData?.fixtureSummary?.modelId}
- />
- </VStack>
- {/* <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Assignee</h3>
- <Assignee
- id={itemId}
- table="item"
- value={assignee ?? ""}
- isReadOnly={!permissions.can("update", "parts")}
- />
- </VStack> */}
-
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Tracking Type</h3>
- <DropdownMenu>
- <DropdownMenuTrigger>
- <Badge variant="secondary">
- <TrackingTypeIcon
- type={routeData?.fixtureSummary?.itemTrackingType!}
- className={cn(
- "mr-2",
- routeData?.fixtureSummary?.active === false && "opacity-50"
- )}
- />
- <span>{routeData?.fixtureSummary?.itemTrackingType!}</span>
- </Badge>
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- {itemTrackingTypes.map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() => onUpdate("itemTrackingType", type)}
- >
- <DropdownMenuIcon icon={<TrackingTypeIcon type={type} />} />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- </VStack>
-
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Default Method Type</h3>
- <DropdownMenu>
- <DropdownMenuTrigger>
- <Badge variant="secondary">
- <MethodIcon
- type={routeData?.fixtureSummary?.defaultMethodType!}
- className={cn(
- "mr-2",
- routeData?.fixtureSummary?.active === false && "opacity-50"
- )}
- />
- <span>{routeData?.fixtureSummary?.defaultMethodType!}</span>
- </Badge>
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- {methodType.map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() => onUpdate("defaultMethodType", type)}
- >
- <DropdownMenuIcon icon={<MethodIcon type={type} />} />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- </VStack>
-
- <VStack spacing={2}>
- <h3 className="text-xs text-muted-foreground">Replenishment</h3>
- <DropdownMenu>
- <DropdownMenuTrigger>
- <Enumerable
- value={routeData?.fixtureSummary?.replenishmentSystem ?? null}
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- {itemReplenishmentSystems.map((system) => (
- <DropdownMenuItem
- key={system}
- onClick={() => onUpdate("replenishmentSystem", system)}
- >
- <Enumerable value={system} />
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- </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>
- {routeData?.fixtureSummary?.replenishmentSystem?.includes("Make") && (
- <MethodBadge
- type="Make"
- text={routeData?.fixtureSummary?.id ?? ""}
- to={path.to.fixtureManufacturing(itemId)}
- />
- )}
- {routeData?.fixtureSummary?.replenishmentSystem?.includes("Buy") &&
- 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={locations.find((l) => l.id === method.locationId)?.name ?? ""}
- to={path.to.fixtureInventoryLocation(itemId, method.locationId)}
- />
- ))}
- </VStack>
- <ValidatedForm
- defaultValues={{
- active: routeData?.fixtureSummary?.active ?? undefined,
- }}
- validator={z.object({
- active: zfd.checkbox(),
- })}
- className="w-full"
- >
- <Boolean
- label="Active"
- name="active"
- variant="small"
- onChange={(value) => {
- onUpdate("active", value ? "on" : "off");
- }}
- />
- </ValidatedForm>
- <ValidatedForm
- defaultValues={{
- tags: routeData?.fixtureSummary?.tags ?? [],
- }}
- validator={z.object({
- tags: z.array(z.string()).optional(),
- })}
- className="w-full"
- >
- <Tags
- label="Tags"
- name="tags"
- availableTags={routeData?.tags ?? []}
- table="fixture"
- inline
- onChange={onUpdateTags}
- />
- </ValidatedForm>
-
- <CustomFormInlineFields
- customFields={
- (routeData?.fixtureSummary?.customFields ?? {}) as Record<
- string,
- Json
- >
- }
- table="fixture"
- tags={routeData?.fixtureSummary?.tags ?? []}
- onUpdate={onUpdateCustomFields}
- />
-
- <VStack spacing={2}>
- <HStack className="w-full justify-between">
- <h3 className="text-xs text-muted-foreground">Files</h3>
- </HStack>
- {routeData?.fixtureSummary?.modelId && (
- <HStack className="group" spacing={1}>
- <Badge variant="secondary">
- <LuMove3D className="w-3 h-3 mr-1 text-emerald-500" />
- 3D Model
- </Badge>
- <Link
- className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
- to={path.to.file.cadModel(routeData?.fixtureSummary.modelId)}
- target="_blank"
- >
- <LuExternalLink />
- </Link>
- </HStack>
- )}
- <Suspense fallback={null}>
- <Await resolve={routeData?.files}>
- {(files) =>
- files?.map((file) => (
- <FileBadge
- key={file.id}
- file={file}
- itemId={itemId}
- itemType="Fixture"
- />
- ))
- }
- </Await>
- </Suspense>
- </VStack>
- </VStack>
- );
-};
-
-export default FixtureProperties;
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
deleted file mode 100644
index 52e948129b..0000000000
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
+++ /dev/null
@@ -1,480 +0,0 @@
-import {
- Badge,
- Checkbox,
- DropdownMenuContent,
- DropdownMenuGroup,
- DropdownMenuIcon,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuPortal,
- DropdownMenuSeparator,
- DropdownMenuSub,
- DropdownMenuSubContent,
- DropdownMenuSubTrigger,
- HStack,
- MenuIcon,
- MenuItem,
- toast,
- useDisclosure,
- VStack,
-} from "@carbon/react";
-import { formatDate } from "@carbon/utils";
-import { useFetcher, useNavigate } from "@remix-run/react";
-import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useCallback, useEffect, useMemo, useState } from "react";
-import {
- LuAlignJustify,
- LuAlignLeft,
- LuBookMarked,
- LuCalendar,
- LuCheck,
- LuPencil,
- LuRefreshCw,
- LuTag,
- LuTrash,
- LuUser,
-} from "react-icons/lu";
-import { RxCodesandboxLogo } from "react-icons/rx";
-import { TbTargetArrow } from "react-icons/tb";
-import {
- CustomerAvatar,
- EmployeeAvatar,
- Hyperlink,
- ItemThumbnail,
- MethodIcon,
- New,
- Table,
- TrackingTypeIcon,
-} from "~/components";
-import { Enumerable } from "~/components/Enumerable";
-import { ConfirmDelete } from "~/components/Modals";
-import { usePermissions } from "~/hooks";
-import { useCustomColumns } from "~/hooks/useCustomColumns";
-import type { Fixture } from "~/modules/items";
-import { itemReplenishmentSystems, itemTrackingTypes } from "~/modules/items";
-import { methodType } from "~/modules/shared";
-import type { action } from "~/routes/x+/items+/update";
-import { useCustomers, usePeople } from "~/stores";
-import { path } from "~/utils/path";
-
-type FixturesTableProps = {
- data: Fixture[];
- tags: { name: string }[];
- count: number;
-};
-
-const FixturesTable = memo(({ data, count, tags }: FixturesTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
-
- const deleteItemModal = useDisclosure();
- const [selectedItem, setSelectedItem] = useState<Fixture | null>(null);
-
- const [customers] = useCustomers();
- const [people] = usePeople();
- const customColumns = useCustomColumns<Fixture>("fixture");
-
- const columns = useMemo<ColumnDef<Fixture>[]>(() => {
- const defaultColumns: ColumnDef<Fixture>[] = [
- {
- accessorKey: "id",
- header: "Fixture ID",
- cell: ({ row }) => (
- <HStack className="py-1 min-w-[200px] truncate">
- <ItemThumbnail
- size="sm"
- thumbnailPath={row.original.thumbnailPath}
- type="Fixture"
- />
- <VStack spacing={0}>
- <Hyperlink to={path.to.fixtureDetails(row.original.itemId!)}>
- {row.original.id}
- </Hyperlink>
- <div className="w-full truncate text-muted-foreground text-xs">
- {row.original.name}
- </div>
- </VStack>
- </HStack>
- ),
- meta: {
- icon: <LuBookMarked />,
- },
- },
- {
- accessorKey: "name",
- header: "Short Description",
- cell: (item) => (
- <div className="max-w-[320px] truncate">
- {item.getValue<string>()}
- </div>
- ),
- meta: {
- icon: <LuAlignLeft />,
- },
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => (
- <div className="max-w-[320px] truncate">
- {item.getValue<string>()}
- </div>
- ),
- meta: {
- icon: <LuAlignJustify />,
- },
- },
- {
- accessorKey: "itemTrackingType",
- header: "Tracking",
- cell: (item) => (
- <Badge variant="secondary">
- <TrackingTypeIcon type={item.getValue<string>()} className="mr-2" />
- <span>{item.getValue<string>()}</span>
- </Badge>
- ),
- meta: {
- filter: {
- type: "static",
- options: itemTrackingTypes.map((type) => ({
- value: type,
- label: (
- <Badge variant="secondary">
- <TrackingTypeIcon type={type} className="mr-2" />
- <span>{type}</span>
- </Badge>
- ),
- })),
- },
- icon: <TbTargetArrow />,
- },
- },
-
- {
- accessorKey: "defaultMethodType",
- header: "Default Method",
- cell: (item) => (
- <Badge variant="secondary">
- <MethodIcon type={item.getValue<string>()} className="mr-2" />
- <span>{item.getValue<string>()}</span>
- </Badge>
- ),
- meta: {
- filter: {
- type: "static",
- options: methodType.map((value) => ({
- value,
- label: (
- <Badge variant="secondary">
- <MethodIcon type={value} className="mr-2" />
- <span>{value}</span>
- </Badge>
- ),
- })),
- },
- icon: <RxCodesandboxLogo />,
- },
- },
- {
- accessorKey: "replenishmentSystem",
- header: "Replenishment",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: itemReplenishmentSystems.map((type) => ({
- value: type,
- label: <Enumerable value={type} />,
- })),
- },
- icon: <LuRefreshCw />,
- },
- },
- {
- accessorKey: "customerId",
- header: "Customer",
- cell: (item) => <CustomerAvatar customerId={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "static",
- options: customers.map((customer) => ({
- value: customer.id,
- label: customer.name,
- })),
- },
- icon: <LuUser />,
- },
- },
- {
- accessorKey: "tags",
- header: "Tags",
- cell: ({ row }) => (
- <HStack spacing={0} className="gap-1">
- {row.original.tags?.map((tag) => (
- <Badge key={tag} variant="secondary">
- {tag}
- </Badge>
- ))}
- </HStack>
- ),
- meta: {
- filter: {
- type: "static",
- options: tags?.map((tag) => ({
- value: tag.name,
- label: <Badge variant="secondary">{tag.name}</Badge>,
- })),
- isArray: true,
- },
- icon: <LuTag />,
- },
- },
- {
- accessorKey: "active",
- header: "Active",
- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
- meta: {
- filter: {
- type: "static",
- options: [
- { value: "true", label: "Active" },
- { value: "false", label: "Inactive" },
- ],
- },
- pluralHeader: "Active Statuses",
- icon: <LuCheck />,
- },
- },
- {
- id: "createdBy",
- header: "Created By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.createdBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
- icon: <LuUser />,
- },
- },
- {
- accessorKey: "createdAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- meta: {
- icon: <LuCalendar />,
- },
- },
- {
- id: "updatedBy",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.updatedBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
- icon: <LuUser />,
- },
- },
- {
- accessorKey: "updatedAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- meta: {
- icon: <LuCalendar />,
- },
- },
- ];
- return [...defaultColumns, ...customColumns];
- }, [customers, tags, people, customColumns]);
-
- const fetcher = useFetcher<typeof action>();
- useEffect(() => {
- if (fetcher.data?.error) {
- toast.error(fetcher.data.error.message);
- }
- }, [fetcher.data]);
- const onBulkUpdate = useCallback(
- (
- selectedRows: typeof data,
- field: "replenishmentSystem" | "defaultMethodType" | "itemTrackingType",
- value: string
- ) => {
- const formData = new FormData();
- selectedRows.forEach((row) => {
- if (row.itemId) formData.append("items", row.itemId);
- });
- formData.append("field", field);
- formData.append("value", value);
- fetcher.submit(formData, {
- method: "post",
- action: path.to.bulkUpdateItems,
- });
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps
- []
- );
-
- const renderActions = useCallback(
- (selectedRows: typeof data) => {
- return (
- <DropdownMenuContent align="end" className="min-w-[200px]">
- <DropdownMenuLabel>Bulk Update</DropdownMenuLabel>
- <DropdownMenuSeparator />
- <DropdownMenuGroup>
- <DropdownMenuSub>
- <DropdownMenuSubTrigger>Replenishment</DropdownMenuSubTrigger>
- <DropdownMenuPortal>
- <DropdownMenuSubContent>
- {itemReplenishmentSystems.map((system) => (
- <DropdownMenuItem
- key={system}
- onClick={() =>
- onBulkUpdate(
- selectedRows,
- "replenishmentSystem",
- system
- )
- }
- >
- <Enumerable value={system} />
- </DropdownMenuItem>
- ))}
- </DropdownMenuSubContent>
- </DropdownMenuPortal>
- </DropdownMenuSub>
- <DropdownMenuSub>
- <DropdownMenuSubTrigger>
- Default Method Type
- </DropdownMenuSubTrigger>
- <DropdownMenuPortal>
- <DropdownMenuSubContent>
- {methodType.map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() =>
- onBulkUpdate(selectedRows, "defaultMethodType", type)
- }
- >
- <DropdownMenuIcon icon={<MethodIcon type={type} />} />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
- </DropdownMenuSubContent>
- </DropdownMenuPortal>
- </DropdownMenuSub>
- <DropdownMenuSub>
- <DropdownMenuSubTrigger>Inventory</DropdownMenuSubTrigger>
- <DropdownMenuPortal>
- <DropdownMenuSubContent>
- {itemTrackingTypes.map((type) => (
- <DropdownMenuItem
- key={type}
- onClick={() =>
- onBulkUpdate(selectedRows, "itemTrackingType", type)
- }
- >
- <DropdownMenuIcon
- icon={<TrackingTypeIcon type={type} />}
- />
- <span>{type}</span>
- </DropdownMenuItem>
- ))}
- </DropdownMenuSubContent>
- </DropdownMenuPortal>
- </DropdownMenuSub>
- </DropdownMenuGroup>
- </DropdownMenuContent>
- );
- },
- [onBulkUpdate]
- );
-
- const renderContextMenu = useMemo(() => {
- // eslint-disable-next-line react/display-name
- return (row: Fixture) => (
- <>
- <MenuItem onClick={() => navigate(path.to.fixture(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Fixture
- </MenuItem>
- <MenuItem
- disabled={!permissions.can("delete", "parts")}
- onClick={() => {
- setSelectedItem(row);
- deleteItemModal.onOpen();
- }}
- >
- <MenuIcon icon={<LuTrash />} />
- Delete Fixture
- </MenuItem>
- </>
- );
- }, [deleteItemModal, navigate, permissions]);
-
- return (
- <>
- <Table<Fixture>
- count={count}
- columns={columns}
- data={data}
- defaultColumnPinning={{
- left: ["id"],
- }}
- defaultColumnVisibility={{
- description: false,
- active: false,
- createdBy: false,
- createdAt: false,
- updatedBy: false,
- updatedAt: false,
- }}
- importCSV={[
- {
- table: "fixture",
- label: "Fixtures",
- },
- ]}
- primaryAction={
- permissions.can("create", "parts") && (
- <New label="Fixture" to={path.to.newFixture} />
- )
- }
- renderActions={renderActions}
- renderContextMenu={renderContextMenu}
- withSelectableRows
- />
- {selectedItem && selectedItem.id && (
- <ConfirmDelete
- action={path.to.deleteItem(selectedItem.itemId!)}
- isOpen={deleteItemModal.isOpen}
- name={selectedItem.id!}
- text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
- onCancel={() => {
- deleteItemModal.onClose();
- setSelectedItem(null);
- }}
- onSubmit={() => {
- deleteItemModal.onClose();
- setSelectedItem(null);
- }}
- />
- )}
- </>
- );
-});
-
-FixturesTable.displayName = "FixtureTable";
-
-export default FixturesTable;
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/index.ts b/apps/carbon/app/modules/items/ui/Fixtures/index.ts
deleted file mode 100644
index 625fcd7fb4..0000000000
--- a/apps/carbon/app/modules/items/ui/Fixtures/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import FixtureForm from "./FixtureForm";
-import FixtureHeader from "./FixtureHeader";
-import FixtureProperties from "./FixtureProperties";
-import FixturesTable from "./FixturesTable";
-
-export { FixtureForm, FixtureHeader, FixtureProperties, FixturesTable };
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx b/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
deleted file mode 100644
index 2ddecf3b67..0000000000
--- a/apps/carbon/app/modules/items/ui/Fixtures/useFixtureNavigation.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { useParams } from "@remix-run/react";
-
-import { BiListCheck } from "react-icons/bi";
-import { LuBox, LuFileText, LuShoppingCart, LuTags } from "react-icons/lu";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { Role } from "~/types";
-import { path } from "~/utils/path";
-import type { Fixture } from "../../types";
-
-export function useFixtureNavigation() {
- const permissions = usePermissions();
- const { itemId } = useParams();
- if (!itemId) throw new Error("itemId not found");
-
- const routeData = useRouteData<{
- fixtureSummary: Fixture;
- }>(path.to.fixture(itemId));
- if (!routeData?.fixtureSummary?.replenishmentSystem)
- throw new Error("Could not find replenishmentSystem in routeData");
- if (!routeData?.fixtureSummary?.itemTrackingType)
- throw new Error("Could not find itemTrackingType in routeData");
-
- const replenishment = routeData.fixtureSummary.replenishmentSystem;
- const itemTrackingType = routeData.fixtureSummary.itemTrackingType;
-
- return [
- {
- name: "Details",
- to: path.to.fixtureDetails(itemId),
- icon: LuFileText,
- shortcut: "Command+Shift+d",
- },
- {
- name: "Purchasing",
- to: path.to.fixturePurchasing(itemId),
- isDisabled: replenishment === "Make",
- role: ["employee", "supplier"],
- icon: LuShoppingCart,
- shortcut: "Command+Shift+p",
- },
- {
- name: "Manufacturing",
- to: path.to.fixtureManufacturing(itemId),
- isDisabled: replenishment === "Buy",
- role: ["employee"],
- icon: BiListCheck,
- shortcut: "Command+Shift+m",
- },
- {
- name: "Costing",
- to: path.to.fixtureCosting(itemId),
- role: ["employee"],
- icon: LuTags,
- shortcut: "Command+Shift+c",
- },
- {
- name: "Inventory",
- to: path.to.fixtureInventory(itemId),
- isDisabled: itemTrackingType === "Non-Inventory",
- role: ["employee", "supplier"],
- icon: LuBox,
- shortcut: "Command+Shift+i",
- },
- ].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/Item/BillOfMaterial.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
index 7d35d2aab0..6e03fb671a 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -521,6 +521,7 @@ function MaterialForm({
label={itemType}
includeInactive
type={itemType}
+ validItemTypes={["Consumable", "Material", "Part"]}
onChange={(value) => {
onItemChange(value?.value as string);
}}
diff --git a/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx b/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx
index 3ca922dd4b..caf035696d 100644
--- a/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx
@@ -220,8 +220,6 @@ function getRootLink(itemType: MethodItemType, itemId: string) {
switch (itemType) {
case "Part":
return path.to.partMakeMethod(itemId);
- case "Fixture":
- return path.to.fixtureMakeMethod(itemId);
case "Tool":
return path.to.toolMakeMethod(itemId);
default:
@@ -242,12 +240,12 @@ function getMaterialLink(
makeMethodId,
materialId
);
- case "Fixture":
- return path.to.fixtureManufacturingMaterial(
- itemId,
- makeMethodId,
- materialId
- );
+ // case "Fixture":
+ // return path.to.fixtureManufacturingMaterial(
+ // itemId,
+ // makeMethodId,
+ // materialId
+ // );
case "Tool":
return path.to.toolManufacturingMaterial(
itemId,
diff --git a/apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsx b/apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsx
index 2081196316..0ddf14494a 100644
--- a/apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BuyMethodForm.tsx
@@ -30,7 +30,7 @@ import { path } from "~/utils/path";
type BuyMethodFormProps = {
initialValues: z.infer<typeof buyMethodValidator>;
- type: "Part" | "Service" | "Tool" | "Consumable" | "Material" | "Fixture";
+ type: "Part" | "Service" | "Tool" | "Consumable" | "Material";
};
const BuyMethodForm = ({ initialValues, type }: BuyMethodFormProps) => {
@@ -135,7 +135,7 @@ export default BuyMethodForm;
function getAction(
isEditing: boolean,
- type: "Part" | "Service" | "Tool" | "Consumable" | "Material" | "Fixture",
+ type: "Part" | "Service" | "Tool" | "Consumable" | "Material",
itemId: string,
id?: string
) {
@@ -178,13 +178,5 @@ function getAction(
}
}
- if (type === "Fixture") {
- if (isEditing) {
- return path.to.fixtureSupplier(itemId, id!);
- } else {
- return path.to.newFixtureSupplier(itemId);
- }
- }
-
throw new Error("Invalid type");
}
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
index 4d1cfb5cad..eec45c2b3d 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
@@ -159,8 +159,6 @@ export function getLinkToItemDetails(type: MethodItemType, id: string) {
return path.to.consumableDetails(id);
// case "Service":
// return path.to.serviceDetails(id);
- case "Fixture":
- return path.to.fixtureDetails(id);
default:
throw new Error("Invalid type");
}
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx
index 500bd009b2..83ccdabfdc 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemPlanningForm.tsx
@@ -28,7 +28,7 @@ import { path } from "~/utils/path";
type ItemPlanningFormProps = {
initialValues: z.infer<typeof itemPlanningValidator>;
locations: ListItem[];
- type: "Part" | "Material" | "Tool" | "Fixture" | "Consumable";
+ type: "Part" | "Material" | "Tool" | "Consumable";
};
const ItemPlanningForm = ({
@@ -163,7 +163,7 @@ export default ItemPlanningForm;
function getLocationPath(
itemId: string,
locationId: string,
- type: "Part" | "Material" | "Tool" | "Fixture" | "Consumable"
+ type: "Part" | "Material" | "Tool" | "Consumable"
) {
switch (type) {
case "Part":
@@ -173,8 +173,6 @@ function getLocationPath(
case "Tool":
return `${path.to.toolPlanning(itemId)}?location=${locationId}`;
- case "Fixture":
- return `${path.to.fixturePlanning(itemId)}?location=${locationId}`;
case "Consumable":
return `${path.to.consumablePlanning(itemId)}?location=${locationId}`;
default:
diff --git a/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx b/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx
index 8fe40f4879..b3981be1ff 100644
--- a/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/PickMethodForm.tsx
@@ -25,7 +25,7 @@ type PickMethodFormProps = {
initialValues: z.infer<typeof pickMethodValidator>;
locations: ListItem[];
shelves: ListItem[];
- type: "Part" | "Material" | "Tool" | "Fixture" | "Consumable";
+ type: "Part" | "Material" | "Tool" | "Consumable";
};
const PickMethodForm = ({
@@ -101,7 +101,7 @@ export default PickMethodForm;
function getLocationPath(
itemId: string,
locationId: string,
- type: "Part" | "Material" | "Tool" | "Fixture" | "Consumable"
+ type: "Part" | "Material" | "Tool" | "Consumable"
) {
switch (type) {
case "Part":
@@ -111,8 +111,6 @@ function getLocationPath(
case "Tool":
return `${path.to.toolInventory(itemId)}?location=${locationId}`;
- case "Fixture":
- return `${path.to.fixtureInventory(itemId)}?location=${locationId}`;
case "Consumable":
return `${path.to.consumableInventory(itemId)}?location=${locationId}`;
default:
diff --git a/apps/carbon/app/modules/items/ui/Methods/MethodMaterialsTable.tsx b/apps/carbon/app/modules/items/ui/Methods/MethodMaterialsTable.tsx
index 3f3c612922..203e2411d4 100644
--- a/apps/carbon/app/modules/items/ui/Methods/MethodMaterialsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Methods/MethodMaterialsTable.tsx
@@ -3,7 +3,7 @@ import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo } from "react";
import { Hyperlink, MethodIcon, MethodItemTypeIcon, Table } from "~/components";
import { methodItemType, methodType } from "~/modules/shared";
-import { useFixtures, useParts } from "~/stores";
+import { useParts, useTools } from "~/stores";
import type { MethodMaterial } from "../../types";
import { getPathToMakeMethod } from "./utils";
@@ -15,9 +15,9 @@ type MethodMaterialsTableProps = {
const MethodMaterialsTable = memo(
({ data, count }: MethodMaterialsTableProps) => {
const parts = useParts();
- const fixtures = useFixtures();
+ const tools = useTools();
- const items = useMemo(() => [...parts, ...fixtures], [parts, fixtures]);
+ const items = useMemo(() => [...parts, ...tools], [parts, tools]);
const columns = useMemo<ColumnDef<MethodMaterial>[]>(() => {
return [
diff --git a/apps/carbon/app/modules/items/ui/Methods/MethodOperationsTable.tsx b/apps/carbon/app/modules/items/ui/Methods/MethodOperationsTable.tsx
index 1307c99baa..7dd37e6daa 100644
--- a/apps/carbon/app/modules/items/ui/Methods/MethodOperationsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Methods/MethodOperationsTable.tsx
@@ -3,7 +3,7 @@ import { memo, useMemo } from "react";
import { Hyperlink, Table } from "~/components";
import { Enumerable } from "~/components/Enumerable";
import { operationTypes } from "~/modules/shared";
-import { useFixtures, useParts } from "~/stores";
+import { useParts, useTools } from "~/stores";
import type { MethodOperation } from "../../types";
import { getPathToMakeMethod } from "./utils";
@@ -15,9 +15,9 @@ type MethodOperationsTableProps = {
const MethodOperationsTable = memo(
({ data, count }: MethodOperationsTableProps) => {
const parts = useParts();
- const fixtures = useFixtures();
+ const tools = useTools();
- const items = useMemo(() => [...parts, ...fixtures], [parts, fixtures]);
+ const items = useMemo(() => [...parts, ...tools], [parts, tools]);
const columns = useMemo<ColumnDef<MethodOperation>[]>(() => {
return [
diff --git a/apps/carbon/app/modules/items/ui/Methods/utils.ts b/apps/carbon/app/modules/items/ui/Methods/utils.ts
index de3da9e986..6c30792651 100644
--- a/apps/carbon/app/modules/items/ui/Methods/utils.ts
+++ b/apps/carbon/app/modules/items/ui/Methods/utils.ts
@@ -4,8 +4,6 @@ export function getPathToMakeMethod(type: string, id: string) {
switch (type) {
case "Part":
return path.to.partMakeMethod(id);
- case "Fixture":
- return path.to.fixtureMakeMethod(id);
case "Tool":
return path.to.toolMakeMethod(id);
default:
diff --git a/apps/carbon/app/modules/items/ui/index.ts b/apps/carbon/app/modules/items/ui/index.ts
index 50f33ac389..cbde2c1a6b 100644
--- a/apps/carbon/app/modules/items/ui/index.ts
+++ b/apps/carbon/app/modules/items/ui/index.ts
@@ -1,7 +1,6 @@
import useItemsSubmodules from "./useItemsSubmodules";
export * from "./Consumables";
-export * from "./Fixtures";
export * from "./Item";
export * from "./ItemPostingGroups";
export * from "./MaterialForms";
diff --git a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
index eb3ff4d221..328aceddd2 100644
--- a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
+++ b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
@@ -2,7 +2,6 @@ import { AiOutlinePartition } from "react-icons/ai";
import {
LuAtom,
LuGlassWater,
- LuGrip,
LuHammer,
LuPizza,
LuRuler,
@@ -31,11 +30,6 @@ const itemsRoutes: AuthenticatedRouteGroup[] = [
to: path.to.tools,
icon: <LuHammer />,
},
- {
- name: "Fixtures",
- to: path.to.fixtures,
- icon: <LuGrip />,
- },
{
name: "Consumables",
to: path.to.consumables,
diff --git a/apps/carbon/app/modules/production/production.models.ts b/apps/carbon/app/modules/production/production.models.ts
index b2d80b0de8..a97705b946 100644
--- a/apps/carbon/app/modules/production/production.models.ts
+++ b/apps/carbon/app/modules/production/production.models.ts
@@ -332,18 +332,6 @@ export const jobMaterialValidator = z
path: ["itemId"],
}
)
- .refine(
- (data) => {
- if (data.itemType === "Fixture") {
- return !!data.itemReadableId;
- }
- return true;
- },
- {
- message: "Fixture ID is required",
- path: ["itemId"],
- }
- )
.refine(
(data) => {
if (data.itemType === "Tool") {
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 560a019942..4a5782357a 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -548,6 +548,7 @@ function MaterialForm({
name="itemId"
label={itemType}
includeInactive
+ validItemTypes={["Consumable", "Material", "Part"]}
type={itemType}
onChange={(value) => {
onItemChange(value?.value as string);
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobForm.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobForm.tsx
index 79798ed589..2e80ef6678 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobForm.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobForm.tsx
@@ -168,7 +168,7 @@ const JobForm = ({ initialValues }: JobFormProps) => {
label={type}
type={type}
value={itemData.itemId}
- validItemTypes={["Part", "Fixture"]}
+ validItemTypes={["Part", "Tool"]}
onChange={(value) => {
onItemChange(value?.value as string);
}}
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx
index 1875f4326c..d22e75925c 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx
@@ -197,7 +197,7 @@ const JobProperties = () => {
inline
isReadOnly={isDisabled}
type={type}
- validItemTypes={["Part", "Fixture"]}
+ validItemTypes={["Part", "Tool"]}
onChange={(value) => {
onUpdate("itemId", value?.value ?? null);
}}
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx
index 6c2e673a09..8983c9e313 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx
@@ -40,7 +40,7 @@ import {
jobStatus,
JobStatus,
} from "~/modules/production";
-import { useCustomers, useFixtures, useParts, usePeople } from "~/stores";
+import { useCustomers, useParts, usePeople, useTools } from "~/stores";
import { path } from "~/utils/path";
type JobsTableProps = {
@@ -68,9 +68,9 @@ const JobsTable = memo(({ data, count, tags }: JobsTableProps) => {
const navigate = useNavigate();
const [params] = useUrlParams();
const parts = useParts();
- const fixtures = useFixtures();
+ const tools = useTools();
- const items = useMemo(() => [...parts, ...fixtures], [parts, fixtures]);
+ const items = useMemo(() => [...parts, ...tools], [parts, tools]);
const [people] = usePeople();
const [customers] = useCustomers();
diff --git a/apps/carbon/app/modules/purchasing/purchasing.models.ts b/apps/carbon/app/modules/purchasing/purchasing.models.ts
index 7eb4437282..27a1a2bb82 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.models.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.models.ts
@@ -7,7 +7,6 @@ export const purchaseOrderLineType = [
// "Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"G/L Account",
"Fixed Asset",
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
index 994a9457a4..05bf66e813 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
@@ -138,7 +138,6 @@ const PurchaseOrderLineForm = ({
case "Material":
case "Part":
case "Tool":
- case "Fixture":
const [item, buyMethod, inventory] = await Promise.all([
carbon
.from("item")
@@ -386,7 +385,6 @@ const PurchaseOrderLineForm = ({
"Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"Fixed Asset",
].includes(type) && (
@@ -403,7 +401,6 @@ const PurchaseOrderLineForm = ({
"Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"Fixed Asset",
].includes(type) && (
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
index 0ce2da9b0a..62ffe539cd 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
@@ -122,7 +122,6 @@ const PurchaseOrderLines = () => {
case "Service":
case "Material":
case "Tool":
- case "Fixture":
case "Consumable":
return <span>{row.original.itemReadableId}</span>;
case "G/L Account":
@@ -207,7 +206,7 @@ const PurchaseOrderLines = () => {
case "Part":
case "Material":
case "Tool":
- case "Fixture":
+ // case "Fixture":
case "Consumable":
return (
<span>
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index e1fc238c43..25ee660a7d 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -219,18 +219,6 @@ export const quoteMaterialValidator = z
path: ["itemId"],
}
)
- .refine(
- (data) => {
- if (data.itemType === "Fixture") {
- return !!data.itemReadableId;
- }
- return true;
- },
- {
- message: "Fixture ID is required",
- path: ["itemId"],
- }
- )
.refine(
(data) => {
if (data.itemType === "Tool") {
@@ -494,7 +482,6 @@ export const salesOrderLineType = [
// "Service",
"Material",
"Tool",
- "Fixture",
"Consumable",
"Comment",
"Fixed Asset",
diff --git a/apps/carbon/app/modules/sales/types.ts b/apps/carbon/app/modules/sales/types.ts
index 2ab2c63bee..f7ca9e835f 100644
--- a/apps/carbon/app/modules/sales/types.ts
+++ b/apps/carbon/app/modules/sales/types.ts
@@ -25,7 +25,6 @@ import type {
export type Costs = {
consumableCost: number;
- fixtureCost: number;
laborCost: number;
laborHours: number;
machineHours: number;
@@ -41,7 +40,6 @@ export type Costs = {
export type CostEffects = {
consumableCost: QuantityEffect[];
- fixtureCost: QuantityEffect[];
laborCost: QuantityEffect[];
laborHours: QuantityEffect[];
machineHours: QuantityEffect[];
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index a15bcfaf87..0a54912ea7 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -548,6 +548,7 @@ function MaterialForm({
name="itemId"
label={itemType}
includeInactive
+ validItemTypes={["Consumable", "Material", "Part"]}
type={itemType}
onChange={(value) => {
onItemChange(value?.value as string);
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx
index 42bd1d120a..17ebcaa776 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx
@@ -92,7 +92,6 @@ const QuoteLineCosting = ({
costs.materialCost +
costs.partCost +
costs.toolCost +
- costs.fixtureCost +
costs.consumableCost +
costs.serviceCost;
@@ -210,34 +209,6 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10 ">
- <HStack className="w-full justify-between ">
- <span className="whitespace-nowrap">Fixture Cost</span>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Fixture" />
- </Badge>
- </HStack>
- </Td>
- {quantityCosts.map(({ quantity, costs }) => {
- return (
- <Td key={quantity.toString()}>
- <VStack spacing={0}>
- <span>
- {costs.fixtureCost
- ? formatter.format(costs.fixtureCost)
- : formatter.format(0)}
- </span>
- <span className="text-muted-foreground text-xs">
- {costs.fixtureCost && quantity > 0
- ? formatter.format(costs.fixtureCost / quantity)
- : formatter.format(0)}
- </span>
- </VStack>
- </Td>
- );
- })}
- </Tr>
<Tr>
<Td className="border-r border-border pl-10 ">
<HStack className="w-full justify-between ">
@@ -500,7 +471,6 @@ const QuoteLineCosting = ({
{quantityCosts.map(({ quantity, costs }) => {
const totalCost =
costs.consumableCost +
- costs.fixtureCost +
costs.laborCost +
costs.machineCost +
costs.materialCost +
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
index 0774c7ff29..f3c508e90b 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
@@ -179,7 +179,6 @@ const QuoteLinePricing = ({
const costs = getLineCosts(quantity);
const totalCost =
(costs.consumableCost +
- costs.fixtureCost +
costs.laborCost +
costs.machineCost +
costs.materialCost +
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx b/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx
index 107f03ebf6..ac95c3131f 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/useLineCosts.tsx
@@ -10,7 +10,6 @@ import type {
const defaultEffects: CostEffects = {
consumableCost: [],
- fixtureCost: [],
laborCost: [],
laborHours: [],
machineCost: [],
@@ -91,11 +90,6 @@ export function useLineCosts({
(quantity) => data.unitCost * data.quantity * quantity
);
break;
- case "Fixture":
- effects.fixtureCost.push(
- (quantity) => data.unitCost * data.quantity * quantity
- );
- break;
case "Consumable":
effects.consumableCost.push(
(quantity) => data.unitCost * data.quantity * quantity
@@ -362,11 +356,6 @@ export function useLineCosts({
0
);
- const fixtureCost = costEffects.fixtureCost.reduce(
- (acc, effect) => acc + effect(quantity),
- 0
- );
-
const consumableCost = costEffects.consumableCost.reduce(
(acc, effect) => acc + effect(quantity),
0
@@ -414,7 +403,6 @@ export function useLineCosts({
return {
consumableCost,
- fixtureCost,
laborCost,
laborHours,
machineCost,
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
index ea87b0a3a7..35c4da4f08 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderLineForm.tsx
@@ -365,7 +365,6 @@ const SalesOrderLineForm = ({
"Material",
"Service",
"Tool",
- "Fixture",
"Consumable",
].includes(lineType) && (
<Location
diff --git a/apps/carbon/app/modules/shared/shared.models.ts b/apps/carbon/app/modules/shared/shared.models.ts
index 9c329068d3..bef41bed9a 100644
--- a/apps/carbon/app/modules/shared/shared.models.ts
+++ b/apps/carbon/app/modules/shared/shared.models.ts
@@ -14,7 +14,6 @@ export const methodItemType = [
"Part",
"Material",
"Tool",
- "Fixture",
"Consumable",
// "Service",
] as const;
diff --git a/apps/carbon/app/routes/api+/item.$type.ts b/apps/carbon/app/routes/api+/item.$type.ts
index 619cf9a3e8..9645cd5486 100644
--- a/apps/carbon/app/routes/api+/item.$type.ts
+++ b/apps/carbon/app/routes/api+/item.$type.ts
@@ -14,11 +14,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { type } = params;
if (!type) throw new Error("Could not find type");
- if (
- !["Part", "Material", "Tool", "Service", "Consumable", "Fixture"].includes(
- type
- )
- ) {
+ if (!["Part", "Material", "Tool", "Service", "Consumable"].includes(type)) {
throw new Error("Invalid type");
}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId._index.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId._index.tsx
deleted file mode 100644
index 27d2f6e004..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId._index.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import type { LoaderFunctionArgs } from "@vercel/remix";
-import { redirect } from "@vercel/remix";
-import { path } from "~/utils/path";
-
-export async function loader({ params }: LoaderFunctionArgs) {
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- throw redirect(path.to.fixtureDetails(itemId));
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx
deleted file mode 100644
index f25231f8bc..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.costing.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { VStack } from "@carbon/react";
-import { useLoaderData } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import { getAccountsList } from "~/modules/accounting";
-import {
- ItemCostingForm,
- getItemCost,
- itemCostValidator,
- upsertItemCost,
-} from "~/modules/items";
-import { getCustomFields, setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-
-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 [itemCost, accounts] = await Promise.all([
- getItemCost(client, itemId, companyId),
- getAccountsList(client, companyId),
- ]);
-
- if (itemCost.error) {
- throw redirect(
- path.to.items,
- await flash(
- request,
- error(itemCost.error, "Failed to load fixture costing")
- )
- );
- }
- if (accounts.error) {
- throw redirect(
- path.to.items,
- await flash(request, error(accounts.error, "Failed to load accounts"))
- );
- }
-
- return json({
- itemCost: itemCost.data,
- accounts: accounts.data,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const formData = await request.formData();
- const validation = await validator(itemCostValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const updateItemCost = await upsertItemCost(client, {
- ...validation.data,
- itemId,
- updatedBy: userId,
- customFields: setCustomFields(formData),
- });
- if (updateItemCost.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(updateItemCost.error, "Failed to update fixture costing")
- )
- );
- }
-
- throw redirect(
- path.to.fixtureCosting(itemId),
- await flash(request, success("Updated fixture costing"))
- );
-}
-
-export default function FixtureCostingRoute() {
- const { itemCost } = useLoaderData<typeof loader>();
- return (
- <VStack spacing={2} className="p-2">
- <ItemCostingForm
- key={itemCost.itemId}
- initialValues={{
- ...itemCost,
- // itemPostingGroupId: itemCost?.itemPostingGroupId ?? undefined,
- ...getCustomFields(itemCost.customFields),
- }}
- />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
deleted file mode 100644
index cb520eed25..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { Spinner, VStack } from "@carbon/react";
-import { Await, useParams } from "@remix-run/react";
-import type { ActionFunctionArgs } from "@vercel/remix";
-import { redirect } from "@vercel/remix";
-import { Suspense } from "react";
-import { CadModel } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { Fixture, ItemFile } from "~/modules/items";
-import {
- FixtureForm,
- ItemDocuments,
- fixtureValidator,
- upsertFixture,
-} from "~/modules/items";
-import { getCustomFields, setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const formData = await request.formData();
- const validation = await validator(fixtureValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const updateFixture = await upsertFixture(client, {
- ...validation.data,
- id: itemId,
- customFields: setCustomFields(formData),
- updatedBy: userId,
- });
- if (updateFixture.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(updateFixture.error, "Failed to update fixture")
- )
- );
- }
-
- throw redirect(
- path.to.fixture(itemId),
- await flash(request, success("Updated fixture"))
- );
-}
-
-export default function FixtureDetailsRoute() {
- const permissions = usePermissions();
-
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const fixtureData = useRouteData<{
- fixtureSummary: Fixture;
- files: Promise<ItemFile[]>;
- }>(path.to.fixture(itemId));
- if (!fixtureData) throw new Error("Could not find fixture data");
-
- const fixtureInitialValues = {
- id: fixtureData.fixtureSummary?.id ?? "",
- itemId: fixtureData.fixtureSummary?.itemId ?? "",
- name: fixtureData.fixtureSummary?.name ?? "",
- description: fixtureData.fixtureSummary?.description ?? "",
- replenishmentSystem:
- fixtureData.fixtureSummary?.replenishmentSystem ?? "Buy",
- defaultMethodType: fixtureData.fixtureSummary?.defaultMethodType ?? "Buy",
- itemTrackingType:
- fixtureData.fixtureSummary?.itemTrackingType ?? "Inventory",
- active: fixtureData.fixtureSummary?.active ?? true,
- customerId: fixtureData.fixtureSummary?.customerId ?? "",
- unitOfMeasureCode: "EA",
- tags: fixtureData.fixtureSummary?.tags ?? [],
- ...getCustomFields(fixtureData.fixtureSummary?.customFields ?? {}),
- };
-
- return (
- <VStack spacing={2} className="p-2">
- <FixtureForm
- key={JSON.stringify(fixtureInitialValues)}
- initialValues={fixtureInitialValues}
- />
- {permissions.is("employee") && (
- <div className="grid grid-cols-1 2xl:grid-cols-2 w-full flex-grow gap-2">
- <Suspense
- fallback={
- <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
- <Spinner className="h-10 w-10" />
- </div>
- }
- >
- <Await resolve={fixtureData?.files ?? []}>
- {(resolvedFiles) => (
- <ItemDocuments
- files={resolvedFiles}
- itemId={itemId}
- modelUpload={fixtureData.fixtureSummary}
- type="Fixture"
- />
- )}
- </Await>
- </Suspense>
- <CadModel
- isReadOnly={!permissions.can("update", "parts")}
- metadata={{
- itemId,
- }}
- modelPath={fixtureData?.fixtureSummary?.modelPath ?? null}
- title="CAD Model"
- />
- </div>
- )}
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsx
deleted file mode 100644
index e15c689252..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.inventory.tsx
+++ /dev/null
@@ -1,229 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { VStack } from "@carbon/react";
-import { useLoaderData } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import { useRouteData } from "~/hooks";
-import { InventoryDetails } from "~/modules/inventory";
-import type { Fixture, UnitOfMeasureListItem } from "~/modules/items";
-import {
- PickMethodForm,
- getItemQuantities,
- getItemShelfQuantities,
- getPickMethod,
- pickMethodValidator,
- upsertPickMethod,
-} from "~/modules/items";
-import { getLocationsList } from "~/modules/resources";
-import { getUserDefaults } from "~/modules/users/users.server";
-import type { ListItem } from "~/types";
-import { getCustomFields, setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId, userId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const url = new URL(request.url);
- const searchParams = new URLSearchParams(url.search);
- let locationId = searchParams.get("location");
-
- if (!locationId) {
- const userDefaults = await getUserDefaults(client, userId, companyId);
- if (userDefaults.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(userDefaults.error, "Failed to load default location")
- )
- );
- }
-
- locationId = userDefaults.data?.locationId ?? null;
- }
-
- if (!locationId) {
- const locations = await getLocationsList(client, companyId);
- if (locations.error || !locations.data?.length) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(locations.error, "Failed to load any locations")
- )
- );
- }
- locationId = locations.data?.[0].id as string;
- }
-
- let [fixtureInventory] = await Promise.all([
- getPickMethod(client, itemId, companyId, locationId),
- ]);
-
- if (fixtureInventory.error || !fixtureInventory.data) {
- const insertPickMethod = await upsertPickMethod(client, {
- itemId,
- companyId,
- locationId,
- customFields: {},
- createdBy: userId,
- });
-
- if (insertPickMethod.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(insertPickMethod.error, "Failed to insert fixture inventory")
- )
- );
- }
-
- fixtureInventory = await getPickMethod(
- client,
- itemId,
- companyId,
- locationId
- );
- if (fixtureInventory.error || !fixtureInventory.data) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(fixtureInventory.error, "Failed to load fixture inventory")
- )
- );
- }
- }
-
- const quantities = await getItemQuantities(
- client,
- itemId,
- companyId,
- locationId
- );
- if (quantities.error) {
- throw redirect(
- path.to.items,
- await flash(
- request,
- error(quantities, "Failed to load fixture quantities")
- )
- );
- }
-
- const itemShelfQuantities = await getItemShelfQuantities(
- client,
- itemId,
- companyId,
- locationId
- );
- if (itemShelfQuantities.error || !itemShelfQuantities.data) {
- throw redirect(
- path.to.items,
- await flash(
- request,
- error(quantities, "Failed to load fixture quantities")
- )
- );
- }
-
- return json({
- fixtureInventory: fixtureInventory.data,
- itemShelfQuantities: itemShelfQuantities.data,
- quantities: quantities.data,
- itemId,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const formData = await request.formData();
- // validate with fixturesValidator
- const validation = await validator(pickMethodValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { ...update } = validation.data;
-
- const updatePickMethod = await upsertPickMethod(client, {
- ...update,
- itemId,
- customFields: setCustomFields(formData),
- updatedBy: userId,
- });
- if (updatePickMethod.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(updatePickMethod.error, "Failed to update fixture inventory")
- )
- );
- }
-
- throw redirect(
- path.to.fixtureInventoryLocation(itemId, update.locationId),
- await flash(request, success("Updated fixture inventory"))
- );
-}
-
-export default function FixtureInventoryRoute() {
- const sharedFixturesData = useRouteData<{
- locations: ListItem[];
- shelves: ListItem[];
- unitOfMeasures: UnitOfMeasureListItem[];
- }>(path.to.fixtureRoot);
-
- const { fixtureInventory, itemShelfQuantities, quantities, itemId } =
- useLoaderData<typeof loader>();
-
- const fixtureData = useRouteData<{
- fixtureSummary: Fixture;
- }>(path.to.fixture(itemId));
- if (!fixtureData) throw new Error("Could not find fixture data");
- const itemUnitOfMeasureCode = fixtureData?.fixtureSummary?.unitOfMeasureCode;
-
- const initialValues = {
- ...fixtureInventory,
- defaultShelfId: fixtureInventory.defaultShelfId ?? undefined,
- ...getCustomFields(fixtureInventory.customFields ?? {}),
- };
- return (
- <VStack spacing={2} className="p-2">
- <PickMethodForm
- key={initialValues.itemId}
- initialValues={initialValues}
- locations={sharedFixturesData?.locations ?? []}
- shelves={sharedFixturesData?.shelves ?? []}
- type="Fixture"
- />
- <InventoryDetails
- itemShelfQuantities={itemShelfQuantities}
- itemUnitOfMeasureCode={itemUnitOfMeasureCode ?? "EA"}
- locations={sharedFixturesData?.locations ?? []}
- pickMethod={initialValues}
- quantities={quantities}
- shelves={sharedFixturesData?.shelves ?? []}
- unitOfMeasures={sharedFixturesData?.unitOfMeasures ?? []}
- />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
deleted file mode 100644
index 6db0dda3f6..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ /dev/null
@@ -1,128 +0,0 @@
-import type { JSONContent } from "@carbon/react";
-import { VStack } from "@carbon/react";
-import { json, redirect, useLoaderData, useParams } from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import {
- BillOfMaterial,
- BillOfProcess,
- ItemForm,
- MakeMethodTools,
- getItem,
- getMethodMaterial,
- getMethodMaterialsByMakeMethod,
- getMethodOperationsByMakeMethodId,
-} from "~/modules/items";
-import type { MethodItemType, MethodType } from "~/modules/shared";
-import { path } from "~/utils/path";
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId, materialId, makeMethodId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!materialId) throw new Error("Could not find materialId");
- if (!makeMethodId) throw new Error("Could not find makeMethodId");
-
- const [material, methodMaterials, methodOperations] = await Promise.all([
- getMethodMaterial(client, materialId),
- getMethodMaterialsByMakeMethod(client, makeMethodId),
- getMethodOperationsByMakeMethodId(client, makeMethodId),
- ]);
-
- if (material.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(request, error(material.error, "Failed to load material"))
- );
- }
-
- if (methodOperations.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(
- request,
- error(methodOperations.error, "Failed to load method operations")
- )
- );
- }
- if (methodMaterials.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(
- request,
- error(methodMaterials.error, "Failed to load method materials")
- )
- );
- }
-
- const item = await getItem(client, material.data.itemId);
- if (item.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(request, error(item.error, "Failed to load item"))
- );
- }
-
- return json({
- item: {
- ...item.data,
- defaultMethodType: item.data.defaultMethodType ?? "Buy",
- unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
- description: item.data.description ?? "",
- },
- material: material.data,
- methodMaterials:
- methodMaterials.data?.map((m) => ({
- ...m,
- description: m.item?.name ?? "",
- methodType: m.methodType as MethodType,
- itemType: m.itemType as MethodItemType,
- methodOperationId: m.methodOperationId ?? undefined,
- })) ?? [],
- methodOperations:
- methodOperations.data?.map((operation) => ({
- ...operation,
- workCenterId: operation.workCenterId ?? undefined,
- operationSupplierProcessId:
- operation.operationSupplierProcessId ?? undefined,
- workInstruction: operation.workInstruction as JSONContent | null,
- })) ?? [],
- });
-}
-
-export default function MethodMaterialMakePage() {
- const loaderData = useLoaderData<typeof loader>();
- const { item, methodMaterials, methodOperations } = loaderData;
-
- const { itemId, makeMethodId, materialId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
- if (!makeMethodId) throw new Error("Could not find makeMethodId");
- if (!materialId) throw new Error("Could not find materialId");
-
- return (
- <VStack spacing={2} className="p-2">
- <MakeMethodTools itemId={item.id} type="Fixture" />
- <ItemForm
- key={`item:${itemId}:${makeMethodId}:${materialId}`}
- type={item.type}
- initialValues={item}
- />
- <BillOfProcess
- key={`bop:${itemId}:${methodOperations.length}`}
- makeMethodId={makeMethodId}
- operations={methodOperations}
- />
- <BillOfMaterial
- key={`bom:${itemId}:${methodMaterials.length}`}
- makeMethodId={makeMethodId}
- materials={methodMaterials}
- operations={methodOperations}
- />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing._index.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing._index.tsx
deleted file mode 100644
index 084eb8fd88..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing._index.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import type { LoaderFunctionArgs } from "@vercel/remix";
-import { redirect } from "@vercel/remix";
-import { path } from "~/utils/path";
-
-export async function loader({ params }: LoaderFunctionArgs) {
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- throw redirect(path.to.fixtureMakeMethod(itemId));
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.buy.$materialId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.buy.$materialId.tsx
deleted file mode 100644
index d1de153e0c..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.buy.$materialId.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { VStack } from "@carbon/react";
-import { json, redirect, useLoaderData, useParams } from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { ItemForm, getItem, getMethodMaterial } from "~/modules/items";
-import { path } from "~/utils/path";
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId, materialId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!materialId) throw new Error("Could not find materialId");
-
- const [material] = await Promise.all([getMethodMaterial(client, materialId)]);
-
- if (material.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(request, error(material.error, "Failed to load material"))
- );
- }
-
- const item = await getItem(client, material.data.itemId);
- if (item.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(request, error(item.error, "Failed to load item"))
- );
- }
-
- return json({
- item: {
- ...item.data,
- defaultMethodType: item.data.defaultMethodType ?? "Buy",
- unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
- description: item.data.description ?? "",
- },
- material: material.data,
- });
-}
-
-export default function MethodMaterialBuyPage() {
- const { item } = useLoaderData<typeof loader>();
- const { itemId, materialId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
- if (!materialId) throw new Error("Could not find materialId");
-
- return (
- <VStack spacing={2} className="p-2">
- <ItemForm
- key={`item:${itemId}:${materialId}`}
- type={item.type}
- initialValues={item}
- />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx
deleted file mode 100644
index b8b0d2eb95..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { VStack } from "@carbon/react";
-import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-
-import type { MakeMethod, Material, MethodOperation } from "~/modules/items";
-import {
- BillOfMaterial,
- BillOfProcess,
- MakeMethodTools,
-} from "~/modules/items";
-import { path } from "~/utils/path";
-
-export default function MakeMethodRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const manufacturingRouteData = useRouteData<{
- makeMethod: MakeMethod;
- methodMaterials: Material[];
- methodOperations: MethodOperation[];
- }>(path.to.fixtureManufacturing(itemId));
-
- const makeMethodId = manufacturingRouteData?.makeMethod?.id;
- if (!makeMethodId) throw new Error("Could not find makeMethodId");
-
- return (
- <VStack spacing={2} className="p-2">
- <MakeMethodTools itemId={itemId} type="Fixture" />
- <BillOfProcess
- key={`bop:${itemId}:${manufacturingRouteData?.methodOperations?.length}`}
- makeMethodId={makeMethodId}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations ?? []}
- />
- <BillOfMaterial
- key={`bom:${itemId}:${manufacturingRouteData?.methodMaterials?.length}`}
- makeMethodId={makeMethodId}
- // @ts-ignore
- materials={manufacturingRouteData?.methodMaterials ?? []}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations}
- />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.pick.$materialId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.pick.$materialId.tsx
deleted file mode 100644
index 0ace1afe37..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.pick.$materialId.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { VStack } from "@carbon/react";
-import { json, redirect, useLoaderData, useParams } from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { ItemForm, getItem, getMethodMaterial } from "~/modules/items";
-import { path } from "~/utils/path";
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
- view: "parts",
- });
-
- const { itemId, materialId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!materialId) throw new Error("Could not find materialId");
-
- const [material] = await Promise.all([getMethodMaterial(client, materialId)]);
-
- if (material.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(request, error(material.error, "Failed to load material"))
- );
- }
-
- const item = await getItem(client, material.data.itemId);
- if (item.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(request, error(item.error, "Failed to load item"))
- );
- }
-
- return json({
- item: {
- ...item.data,
- defaultMethodType: item.data.defaultMethodType ?? "Buy",
- unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
- description: item.data.description ?? "",
- },
- material: material.data,
- });
-}
-
-export default function MethodMaterialPickPage() {
- const { item } = useLoaderData<typeof loader>();
- const { itemId, materialId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
- if (!materialId) throw new Error("Could not find materialId");
-
- return (
- <VStack spacing={2} className="p-2">
- <ItemForm
- key={`item:${itemId}:${materialId}`}
- type={item.type}
- initialValues={item}
- />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx
deleted file mode 100644
index 75c0b759b7..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx
+++ /dev/null
@@ -1,153 +0,0 @@
-import type { JSONContent } from "@carbon/react";
-import {
- ClientOnly,
- ResizableHandle,
- ResizablePanel,
- ResizablePanelGroup,
- ScrollArea,
-} from "@carbon/react";
-import {
- Outlet,
- json,
- redirect,
- useLoaderData,
- useParams,
-} from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import type { FlatTreeItem } from "~/components/TreeView";
-import { flattenTree } from "~/components/TreeView";
-import type { Method } from "~/modules/items";
-import {
- BoMExplorer,
- getMakeMethod,
- getMethodMaterialsByMakeMethod,
- getMethodOperationsByMakeMethodId,
- getMethodTree,
-} from "~/modules/items";
-import type { MethodItemType, MethodType } from "~/modules/shared";
-import { path } from "~/utils/path";
-
-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 makeMethod = await getMakeMethod(client, itemId, companyId);
-
- if (makeMethod.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(
- request,
- error(makeMethod.error, "Failed to load make method")
- )
- );
- }
-
- const [methodTree, methodMaterials, methodOperations] = await Promise.all([
- getMethodTree(client, makeMethod.data.id),
- getMethodMaterialsByMakeMethod(client, makeMethod.data.id),
- getMethodOperationsByMakeMethodId(client, makeMethod.data.id),
- ]);
- if (methodTree?.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(
- request,
- error(methodTree.error, "Failed to load method tree")
- )
- );
- }
-
- if (methodOperations.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(
- request,
- error(methodOperations.error, "Failed to load method operations")
- )
- );
- }
- if (methodMaterials.error) {
- throw redirect(
- path.to.fixtureDetails(itemId),
- await flash(
- request,
- error(methodMaterials.error, "Failed to load method materials")
- )
- );
- }
-
- return json({
- makeMethod: makeMethod.data,
- methodMaterials:
- methodMaterials.data?.map((m) => ({
- ...m,
- description: m.item?.name ?? "",
- methodType: m.methodType as MethodType,
- itemType: m.itemType as MethodItemType,
- })) ?? [],
- methodOperations:
- methodOperations.data?.map((operation) => ({
- ...operation,
- workCenterId: operation.workCenterId ?? undefined,
- workInstruction: operation.workInstruction as JSONContent,
- })) ?? [],
- methods: (methodTree.data.length > 0
- ? flattenTree(methodTree.data[0])
- : []) satisfies FlatTreeItem<Method>[],
- });
-}
-
-export default function FixtureManufacturing() {
- const { methods } = useLoaderData<typeof loader>();
-
- const params = useParams();
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return (
- <div className="flex flex-grow overflow-hidden">
- <ClientOnly fallback={null}>
- {() => (
- <ResizablePanelGroup direction="horizontal">
- <ResizablePanel
- order={1}
- minSize={10}
- defaultSize={20}
- className="bg-card"
- >
- <ScrollArea className="h-[calc(100dvh-99px)]">
- <div className="grid h-full overflow-hidden p-2">
- <BoMExplorer
- itemType="Fixture"
- // @ts-ignore
- methods={methods}
- />
- </div>
- </ScrollArea>
- </ResizablePanel>
- <ResizableHandle withHandle />
- <ResizablePanel
- order={2}
- minSize={40}
- defaultSize={60}
- className="border-t border-border"
- >
- <ScrollArea className="h-[calc(100dvh-99px)]">
- <Outlet key={JSON.stringify(params)} />
- </ScrollArea>
- </ResizablePanel>
- </ResizablePanelGroup>
- )}
- </ClientOnly>
- </div>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.new.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.new.tsx
deleted file mode 100644
index 566ce8e99a..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.new.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { assertIsPost, error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { useParams } from "@remix-run/react";
-import type { ActionFunctionArgs } from "@vercel/remix";
-import { redirect } from "@vercel/remix";
-import {
- BuyMethodForm,
- buyMethodValidator,
- upsertBuyMethod,
-} from "~/modules/items";
-import { setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- create: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const formData = await request.formData();
- const validation = await validator(buyMethodValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { id, ...data } = validation.data;
-
- const createFixtureSupplier = await upsertBuyMethod(client, {
- ...data,
- companyId,
- createdBy: userId,
- customFields: setCustomFields(formData),
- });
-
- if (createFixtureSupplier.error) {
- throw redirect(
- path.to.fixturePurchasing(itemId),
- await flash(
- request,
- error(createFixtureSupplier.error, "Failed to create fixture supplier")
- )
- );
- }
-
- throw redirect(path.to.fixturePurchasing(itemId));
-}
-
-export default function NewFixtureSupplierRoute() {
- const { itemId } = useParams();
-
- if (!itemId) throw new Error("itemId not found");
-
- const initialValues = {
- itemId: itemId,
- supplierId: "",
- supplierFixtureId: "",
- unitPrice: 0,
- supplierUnitOfMeasureCode: "EA",
- minimumOrderQuantity: 1,
- conversionFactor: 1,
- };
-
- return <BuyMethodForm type="Fixture" initialValues={initialValues} />;
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx
deleted file mode 100644
index 4421dbfd5d..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.purchasing.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { VStack } from "@carbon/react";
-import { useLoaderData, useParams } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import { useRouteData } from "~/hooks";
-import type { BuyMethod } from "~/modules/items";
-import {
- BuyMethods,
- ItemPurchasingForm,
- getItemReplenishment,
- itemPurchasingValidator,
- upsertItemPurchasing,
-} from "~/modules/items";
-import { path } from "~/utils/path";
-
-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 [fixturePurchasing] = await Promise.all([
- getItemReplenishment(client, itemId, companyId),
- ]);
-
- if (fixturePurchasing.error) {
- throw redirect(
- path.to.items,
- await flash(
- request,
- error(fixturePurchasing.error, "Failed to load fixture purchasing")
- )
- );
- }
-
- return json({
- fixturePurchasing: fixturePurchasing.data,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts",
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- // validate with fixturesValidator
- const validation = await validator(itemPurchasingValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const updateFixturePurchasing = await upsertItemPurchasing(client, {
- ...validation.data,
- itemId,
- updatedBy: userId,
- });
- if (updateFixturePurchasing.error) {
- throw redirect(
- path.to.fixture(itemId),
- await flash(
- request,
- error(
- updateFixturePurchasing.error,
- "Failed to update fixture purchasing"
- )
- )
- );
- }
-
- throw redirect(
- path.to.fixturePurchasing(itemId),
- await flash(request, success("Updated fixture purchasing"))
- );
-}
-
-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,
- purchasingLeadTime: fixturePurchasing?.purchasingLeadTime ?? "",
- purchasingBlocked: fixturePurchasing?.purchasingBlocked ?? false,
- purchasingUnitOfMeasureCode:
- fixturePurchasing?.purchasingUnitOfMeasureCode ?? "",
- conversionFactor: fixturePurchasing?.conversionFactor ?? 1,
- };
-
- return (
- <VStack spacing={2} className="p-2">
- <ItemPurchasingForm
- key={initialValues.itemId}
- initialValues={initialValues}
- allowedSuppliers={
- buyMethods.map((s) => s.supplier?.id).filter(Boolean) as string[]
- }
- />
- <BuyMethods buyMethods={buyMethods} />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
deleted file mode 100644
index dd2f930f7e..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { error, getCarbonServiceRole } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { Outlet, useLoaderData } from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-import { defer, redirect } from "@vercel/remix";
-import { useRealtime } from "~/hooks";
-import {
- FixtureHeader,
- FixtureProperties,
- getBuyMethods,
- getFixture,
- getItemFiles,
- getPickMethods,
-} from "~/modules/items";
-import { getTagsList } from "~/modules/shared";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-
-export const handle: Handle = {
- breadcrumb: "Fixtures",
- to: path.to.fixtures,
-};
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const serviceRole = await getCarbonServiceRole();
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const [fixtureSummary, buyMethods, pickMethods, tags] = await Promise.all([
- getFixture(serviceRole, itemId, companyId),
- getBuyMethods(serviceRole, itemId, companyId),
- getPickMethods(serviceRole, itemId, companyId),
- getTagsList(serviceRole, companyId, "fixture"),
- ]);
-
- if (fixtureSummary.error) {
- throw redirect(
- path.to.items,
- await flash(
- request,
- error(fixtureSummary.error, "Failed to load fixture summary")
- )
- );
- }
-
- return defer({
- fixtureSummary: fixtureSummary.data,
- files: getItemFiles(serviceRole, itemId, companyId),
- buyMethods: buyMethods.data ?? [],
- pickMethods: pickMethods.data ?? [],
- tags: tags.data ?? [],
- });
-}
-
-export default function FixtureRoute() {
- const { fixtureSummary } = useLoaderData<typeof loader>();
-
- useRealtime("modelUpload", `modelPath=eq.${fixtureSummary.modelPath}`);
-
- return (
- <div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
- <FixtureHeader />
- <div className="flex h-[calc(100dvh-99px)] w-full overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent">
- <Outlet />
- <FixtureProperties />
- </div>
- </div>
- );
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/_layout.tsx b/apps/carbon/app/routes/x+/fixture+/_layout.tsx
deleted file mode 100644
index ea2c096b72..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/_layout.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { Outlet } from "@remix-run/react";
-import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";
-import { getShelvesList } from "~/modules/inventory";
-import { getUnitOfMeasuresList } from "~/modules/items";
-import { getLocationsList } from "~/modules/resources";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-
-export const meta: MetaFunction = () => {
- return [{ title: "Carbon | Fixtures" }];
-};
-
-export const handle: Handle = {
- breadcrumb: "Items",
- to: path.to.items,
- module: "items",
-};
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const [unitOfMeasures, locations, shelves] = await Promise.all([
- getUnitOfMeasuresList(client, companyId),
- getLocationsList(client, companyId),
- getShelvesList(client, companyId),
- ]);
-
- return {
- locations: locations?.data ?? [],
- unitOfMeasures: unitOfMeasures?.data ?? [],
- shelves: shelves?.data ?? [],
- };
-}
-
-export default function FixtureRoute() {
- return <Outlet />;
-}
diff --git a/apps/carbon/app/routes/x+/fixture+/new.tsx b/apps/carbon/app/routes/x+/fixture+/new.tsx
deleted file mode 100644
index e6c1855bcf..0000000000
--- a/apps/carbon/app/routes/x+/fixture+/new.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { assertIsPost, error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import type { ActionFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import { FixtureForm, fixtureValidator, upsertFixture } from "~/modules/items";
-import { setCustomFields } from "~/utils/form";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-
-export const handle: Handle = {
- breadcrumb: "Fixtures",
- to: path.to.fixtures,
-};
-
-export async function action({ request }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- create: "parts",
- });
-
- const formData = await request.formData();
- const modal = formData.get("type") === "modal";
-
- const validation = await validator(fixtureValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const createFixture = await upsertFixture(client, {
- ...validation.data,
- companyId,
- customFields: setCustomFields(formData),
- createdBy: userId,
- });
- if (createFixture.error) {
- return modal
- ? json(
- createFixture,
- await flash(
- request,
- error(createFixture.error, "Failed to insert fixture")
- )
- )
- : redirect(
- path.to.fixtures,
- await flash(
- request,
- error(createFixture.error, "Failed to insert fixture")
- )
- );
- }
-
- const itemId = createFixture.data?.itemId;
- if (!itemId) throw new Error("Fixture ID not found");
-
- return modal
- ? json(createFixture, { status: 201 })
- : redirect(path.to.fixture(itemId));
-}
-
-export default function FixturesNewRoute() {
- const initialValues = {
- id: "",
- name: "",
- description: "",
- replenishmentSystem: "Make" as const,
- defaultMethodType: "Make" as const,
- itemTrackingType: "Inventory" as "Inventory",
- unitOfMeasureCode: "EA",
- unitCost: 0,
- active: true,
- };
-
- return (
- <div className="max-w-[50rem] w-full p-2 sm:p-0 mx-auto mt-0 md:mt-8">
- <FixtureForm initialValues={initialValues} />
- </div>
- );
-}
diff --git a/apps/carbon/app/routes/x+/items+/fixtures.tsx b/apps/carbon/app/routes/x+/items+/fixtures.tsx
deleted file mode 100644
index cd9495260c..0000000000
--- a/apps/carbon/app/routes/x+/items+/fixtures.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { VStack } from "@carbon/react";
-import { Outlet, useLoaderData } from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import { FixturesTable, getFixtures } from "~/modules/items";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-import { getGenericQueryFilters } from "~/utils/query";
-
-import { getTagsList } from "~/modules/shared";
-export const handle: Handle = {
- breadcrumb: "Fixtures",
- to: path.to.fixtures,
-};
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- });
-
- const url = new URL(request.url);
- const searchParams = new URLSearchParams(url.search);
- const search = searchParams.get("search");
- const supplierId = searchParams.get("supplierId");
-
- const { limit, offset, sorts, filters } =
- getGenericQueryFilters(searchParams);
-
- const [fixtures, tags] = await Promise.all([
- getFixtures(client, companyId, {
- search,
- supplierId,
- limit,
- offset,
- sorts,
- filters,
- }),
- getTagsList(client, companyId, "fixture"),
- ]);
-
- if (fixtures.error) {
- redirect(
- path.to.authenticatedRoot,
- await flash(request, error(fixtures.error, "Failed to fetch fixtures"))
- );
- }
-
- return json({
- count: fixtures.count ?? 0,
- fixtures: fixtures.data ?? [],
- tags: tags.data ?? [],
- });
-}
-
-export default function FixturesSearchRoute() {
- const { count, fixtures, tags } = useLoaderData<typeof loader>();
-
- return (
- <VStack spacing={0} className="h-full">
- <FixturesTable data={fixtures} count={count} tags={tags} />
- <Outlet />
- </VStack>
- );
-}
diff --git a/apps/carbon/app/routes/x+/tool+/new.tsx b/apps/carbon/app/routes/x+/tool+/new.tsx
index b1bf5a714a..f8a99c9096 100644
--- a/apps/carbon/app/routes/x+/tool+/new.tsx
+++ b/apps/carbon/app/routes/x+/tool+/new.tsx
@@ -67,6 +67,7 @@ export default function ToolsNewRoute() {
unitOfMeasureCode: "EA",
unitCost: 0,
active: true,
+ tags: [],
};
return (
diff --git a/apps/carbon/app/stores/items.ts b/apps/carbon/app/stores/items.ts
index 59e34fd56c..9ee714a54b 100644
--- a/apps/carbon/app/stores/items.ts
+++ b/apps/carbon/app/stores/items.ts
@@ -17,8 +17,8 @@ const $partsStore = computed($itemsStore, (item) =>
item.filter((i) => i.type === "Part")
);
-const $fixturesStore = computed($itemsStore, (item) =>
- item.filter((i) => i.type === "Fixture")
+const $toolsStore = computed($itemsStore, (item) =>
+ item.filter((i) => i.type === "Tool")
);
const $serivceStore = computed($itemsStore, (item) =>
@@ -31,6 +31,6 @@ const $materialsStore = computed($itemsStore, (item) =>
export const useItems = () => useNanoStore<Item[]>($itemsStore, "items");
export const useParts = () => useValue($partsStore);
-export const useFixtures = () => useValue($fixturesStore);
+export const useTools = () => useValue($toolsStore);
export const useServices = () => useValue($serivceStore);
export const useMaterials = () => useValue($materialsStore);
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index e88b72c02b..123a4dd66e 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -337,37 +337,6 @@ export const path = {
externalQuote: (id: string) => generatePath(`/share/quote/${id}`),
feedback: `${x}/feedback`,
fiscalYears: `${x}/accounting/years`,
- fixture: (id: string) => generatePath(`${x}/fixture/${id}`),
- fixtures: `${x}/items/fixtures`,
- fixtureCosting: (id: string) => generatePath(`${x}/fixture/${id}/costing`),
- fixtureDetails: (id: string) => generatePath(`${x}/fixture/${id}/details`),
- fixtureInventory: (id: string) =>
- generatePath(`${x}/fixture/${id}/inventory`),
- fixtureInventoryLocation: (id: string, locationId: string) =>
- generatePath(`${x}/fixture/${id}/inventory?location=${locationId}`),
- fixtureMakeMethod: (id: string) =>
- generatePath(`${x}/fixture/${id}/manufacturing/method`),
- fixtureManufacturing: (id: string) =>
- generatePath(`${x}/fixture/${id}/manufacturing`),
- fixtureManufacturingMaterial: (
- itemId: string,
- makeMethodId: string,
- methodMaterialId: string
- ) =>
- generatePath(
- `${x}/fixture/${itemId}/manufacturing/${makeMethodId}/${methodMaterialId}`
- ),
- fixturePlanning: (id: string) =>
- generatePath(`${x}/fixture/${id}/planning`),
- fixturePlanningLocation: (id: string, locationId: string) =>
- generatePath(`${x}/fixture/${id}/planning?location=${locationId}`),
- fixturePurchasing: (id: string) =>
- generatePath(`${x}/fixture/${id}/purchasing`),
- fixtureRoot: `${x}/fixture`,
- fixtureSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/fixture/${itemId}/suppliers/${id}`),
- fixtureSuppliers: (id: string) =>
- generatePath(`${x}/fixture/${id}/suppliers`),
forgotPassword: "/forgot-password",
group: (id: string) => generatePath(`${x}/users/groups/${id}`),
groups: `${x}/users/groups`,
diff --git a/apps/mes/app/components/Icons.tsx b/apps/mes/app/components/Icons.tsx
index e428074d4a..7b8a2c70ca 100644
--- a/apps/mes/app/components/Icons.tsx
+++ b/apps/mes/app/components/Icons.tsx
@@ -5,7 +5,6 @@ import { HiSquares2X2 } from "react-icons/hi2";
import {
LuAtom,
LuCheckCircle,
- LuGrip,
LuHammer,
LuHeadphones,
LuPizza,
@@ -138,8 +137,6 @@ export const MethodItemTypeIcon = ({
return <LuAtom className={className} />;
case "Tool":
return <LuHammer className={className} />;
- case "Fixture":
- return <LuGrip className={className} />;
case "Consumable":
return <LuPizza className={className} />;
case "Service":