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.

refactor: remove more deprecated quote files

Brad Barbin72820e8b179b
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index 210a447083..8b3fed970c 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -112,44 +112,6 @@ export const quoteLineValidator = z.object({
modelUploadId: zfd.text(z.string().optional()),
});
-export const quotationValidator = z.object({
- id: zfd.text(z.string().optional()),
- quoteId: zfd.text(z.string().optional()),
- name: z.string(),
- customerId: z.string().min(36, { message: "Customer is required" }),
- customerLocationId: zfd.text(z.string().optional()),
- customerContactId: zfd.text(z.string().optional()),
- customerReference: zfd.text(z.string().optional()),
- locationId: zfd.text(z.string().optional()),
- status: z.enum(quoteStatusType).optional(),
- notes: zfd.text(z.string().optional()),
- expirationDate: zfd.text(z.string().optional()),
-});
-
-export const quotationAssemblyValidator = z.object({
- id: zfd.text(z.string().optional()),
- parentAssemblyId: zfd.text(z.string().optional()),
- itemId: z.string().min(1, { message: "Part is required" }),
- itemReadableId: zfd.text(z.string().optional()),
- description: z.string().min(1, { message: "Description is required" }),
- unitOfMeasureCode: zfd.text(z.string().optional()),
- quantityPerParent: zfd.numeric(
- z.number().min(1, { message: "Quantity is required" })
- ),
-});
-
-export const quotationMaterialValidator = z.object({
- id: zfd.text(z.string().optional()),
- itemId: z.string().min(1, { message: "Part is required" }),
- itemReadableId: zfd.text(z.string().optional()),
- quantity: zfd.numeric(
- z.number().min(0.00001, { message: "Quantity is required" })
- ),
- description: z.string().min(1, { message: "Description is required" }),
- unitCost: zfd.numeric(z.number().min(0)),
- unitOfMeasureCode: zfd.text(z.string().optional()),
-});
-
export const quoteMaterialValidator = z
.object({
id: zfd.text(z.string().optional()),
@@ -249,24 +211,6 @@ export const quoteMaterialValidator = z
}
);
-export const quotationOperationValidator = z.object({
- id: zfd.text(z.string().optional()),
- quoteAssemblyId: zfd.text(z.string().optional()),
- workCellTypeId: z.string().min(20, { message: "Work cell is required" }),
- equipmentTypeId: zfd.text(z.string().optional()),
- description: zfd.text(
- z.string().min(0, { message: "Description is required" })
- ),
- setupHours: zfd.numeric(z.number().min(0)),
- standardFactor: z.enum(standardFactorType, {
- errorMap: () => ({ message: "Standard factor is required" }),
- }),
- productionStandard: zfd.numeric(z.number().min(0)),
- quotingRate: zfd.numeric(z.number().min(0)),
- laborRate: zfd.numeric(z.number().min(0)),
- overheadRate: zfd.numeric(z.number().min(0)),
-});
-
export const quoteOperationValidator = z.object({
id: zfd.text(z.string().optional()),
quoteMakeMethodId: z
@@ -300,23 +244,6 @@ export const quotationPricingValidator = z.object({
extendedPrice: zfd.numeric(z.number()),
});
-export const quotationLineValidator = z.object({
- id: zfd.text(z.string().optional()),
- quoteId: z.string(),
- itemId: z.string().min(1, { message: "Part is required" }),
- itemReadableId: zfd.text(z.string().optional()),
- status: z.enum(quoteLineStatusType, {
- errorMap: () => ({ message: "Status is required" }),
- }),
- description: z.string().min(1, { message: "Description is required" }),
- replenishmentSystem: z.enum(["Buy", "Make"]),
- customerPartId: zfd.text(z.string().optional()),
- customerPartRevision: zfd.text(z.string().optional()),
- unitOfMeasureCode: zfd.text(
- z.string().min(1, { message: "Unit of measure is required" })
- ),
-});
-
export const quotationReleaseValidator = z
.object({
notification: z.enum(["Email", "None"]).optional(),
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index b13ef5d19a..7ec1bfa4d9 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -14,11 +14,10 @@ import type {
customerStatusValidator,
customerTypeValidator,
customerValidator,
- quotationAssemblyValidator,
- quotationOperationValidator,
quotationPricingValidator,
quoteLineValidator,
quoteMaterialValidator,
+ quoteOperationValidator,
quoteValidator,
salesOrderLineValidator,
salesOrderPaymentValidator,
@@ -1315,39 +1314,6 @@ export async function upsertQuote(
}
}
-export async function upsertQuoteMakeMethod(
- client: SupabaseClient<Database>,
- quotationAssembly:
- | (Omit<z.infer<typeof quotationAssemblyValidator>, "id"> & {
- quoteId: string;
- quoteLineId: string;
- companyId: string;
- createdBy: string;
- customFields?: Json;
- })
- | (Omit<z.infer<typeof quotationAssemblyValidator>, "id"> & {
- id: string;
- quoteId: string;
- quoteLineId: string;
- updatedBy: string;
- customFields?: Json;
- })
-) {
- if ("id" in quotationAssembly) {
- return client
- .from("quoteMakeMethod")
- .update(sanitize(quotationAssembly))
- .eq("id", quotationAssembly.id)
- .select("id")
- .single();
- }
- return client
- .from("quoteMakeMethod")
- .insert([quotationAssembly])
- .select("id")
- .single();
-}
-
export async function upsertQuoteLine(
client: SupabaseClient<Database>,
quotationLine:
@@ -1424,15 +1390,15 @@ export async function upsertQuoteMaterial(
export async function upsertQuoteOperation(
client: SupabaseClient<Database>,
- quotationOperation:
- | (Omit<z.infer<typeof quotationOperationValidator>, "id"> & {
+ operation:
+ | (Omit<z.infer<typeof quoteOperationValidator>, "id"> & {
quoteId: string;
quoteLineId: string;
companyId: string;
createdBy: string;
customFields?: Json;
})
- | (Omit<z.infer<typeof quotationOperationValidator>, "id"> & {
+ | (Omit<z.infer<typeof quoteOperationValidator>, "id"> & {
id: string;
quoteId: string;
quoteLineId: string;
@@ -1440,17 +1406,17 @@ export async function upsertQuoteOperation(
customFields?: Json;
})
) {
- if ("id" in quotationOperation) {
+ if ("id" in operation) {
return client
.from("quoteOperation")
- .update(sanitize(quotationOperation))
- .eq("id", quotationOperation.id)
+ .update(sanitize(operation))
+ .eq("id", operation.id)
.select("id")
.single();
}
return client
.from("quoteOperation")
- .insert([quotationOperation])
+ .insert([operation])
.select("id")
.single();
}
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/ConvertToSalesOrderModal.tsx b/apps/carbon/app/modules/sales/ui/Quotation/ConvertToSalesOrderModal.tsx
deleted file mode 100644
index 5c1b9c7433..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/ConvertToSalesOrderModal.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import {
- Button,
- Modal,
- ModalBody,
- ModalContent,
- ModalDescription,
- ModalFooter,
- ModalHeader,
- ModalTitle,
- VStack,
-} from "@carbon/react";
-import { Form } from "@remix-run/react";
-import { useParams } from "@remix-run/react";
-import { path } from "~/utils/path";
-import type { Quotation } from "../../types";
-
-type ConvertToSalesOrderModalProps = {
- onClose: () => void;
- quotation?: Quotation;
-};
-
-const ConvertToSalesOrderModal = ({
- quotation,
- onClose,
-}: ConvertToSalesOrderModalProps) => {
- const { id } = useParams();
- if (!id) throw new Error("id not found");
-
- return (
- <Modal
- open
- onOpenChange={(open) => {
- if (!open) {
- onClose();
- }
- }}
- >
- <ModalContent>
- <Form
- method="post"
- action={path.to.convertQuoteToOrder(id)}
- onSubmit={onClose}
- >
- <ModalHeader>
- <ModalTitle>{`Convert to Sales Order - ${quotation?.quoteId}`}</ModalTitle>
- <ModalDescription>
- Are you sure you want to convert this quote to a sales order?
- </ModalDescription>
- </ModalHeader>
- <ModalBody>
- <VStack spacing={4}>
- </VStack>
- </ModalBody>
- <ModalFooter>
- <Button variant="secondary" onClick={onClose}>
- Cancel
- </Button>
- <Button type="submit">Convert to sales order</Button>
- </ModalFooter>
- </Form>
- </ModalContent>
- </Modal>
- );
-};
-
-export default ConvertToSalesOrderModal;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
deleted file mode 100644
index 00a56e751c..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
+++ /dev/null
@@ -1,203 +0,0 @@
-import {
- Card,
- CardAction,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuIcon,
- DropdownMenuItem,
- DropdownMenuTrigger,
- HStack,
- IconButton,
- VStack,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useNavigate, useParams } from "@remix-run/react";
-import { useState } from "react";
-import { BsDownload, BsThreeDotsVertical, BsUpload } from "react-icons/bs";
-import { LuTrash } from "react-icons/lu";
-import type { z } from "zod";
-import {
- CustomFormFields,
- Hidden,
- InputControlled,
- Number,
- Part,
- Submit,
-} from "~/components/Form";
-import { usePermissions, useRouteData, useUrlParams, useUser } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import type { Quotation } from "~/modules/sales";
-import { quotationAssemblyValidator } from "~/modules/sales";
-import { path } from "~/utils/path";
-
-type QuotationAssemblyFormValues = z.infer<typeof quotationAssemblyValidator>;
-
-type QuotationAssemblyFormProps = {
- initialValues: QuotationAssemblyFormValues;
-};
-
-const QuotationAssemblyForm = ({
- initialValues,
-}: QuotationAssemblyFormProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
- const { company } = useUser();
- const { supabase } = useSupabase();
-
- const { id: quoteId, lineId } = useParams();
- if (!quoteId) throw new Error("quoteId not found");
- if (!lineId) throw new Error("lineId not found");
-
- const [params] = useUrlParams();
- const parentAssemblyId = params.get("parentAssemblyId");
-
- const isEditing = initialValues.id !== undefined;
-
- const [partData, setPartData] = useState<{
- itemId: string;
- description: string;
- uom: string;
- }>({
- itemId: initialValues.itemId ?? "",
- description: initialValues.description ?? "",
- uom: initialValues.unitOfMeasureCode ?? "",
- });
-
- const onPartChange = async (itemId: string) => {
- if (!supabase || !company.id) return;
- const [item, part] = await Promise.all([
- supabase
- .from("item")
- .select("name")
- .eq("id", itemId)
- .eq("companyId", company.id)
- .single(),
- supabase
- .from("part")
- .select("replenishmentSystem, unitOfMeasureCode")
- .eq("id", itemId)
- .eq("companyId", company.id)
- .single(),
- ]);
-
- setPartData({
- itemId,
- description: item.data?.name ?? "",
- uom: part.data?.unitOfMeasureCode ?? "",
- });
- };
-
- const routeData = useRouteData<{
- quotation: Quotation;
- }>(path.to.quote(quoteId));
- const isEditable = ["Draft"].includes(routeData?.quotation?.status ?? "");
-
- return (
- <ValidatedForm
- method="post"
- validator={quotationAssemblyValidator}
- defaultValues={initialValues}
- className="w-full"
- action={
- isEditing
- ? path.to.quoteAssembly(quoteId, lineId, initialValues.id!)
- : path.to.newQuoteAssembly(quoteId, lineId)
- }
- >
- <Card>
- <HStack className="w-full justify-between items-start">
- <CardHeader>
- <CardTitle>{isEditing ? "Assembly" : "New Assembly"}</CardTitle>
- <CardDescription>
- {isEditing
- ? partData?.itemId
- : "A quote assembly is a collection of operations, materials, and subassemblies that are used to build a product."}
- </CardDescription>
- </CardHeader>
- <CardAction>
- {isEditing && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- icon={<BsThreeDotsVertical />}
- aria-label="More"
- variant="secondary"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={() => navigate("delete")}>
- <DropdownMenuIcon icon={<LuTrash />} />
- Delete Assembly
- </DropdownMenuItem>
- <DropdownMenuItem disabled>
- <DropdownMenuIcon icon={<BsDownload />} />
- Get Part
- </DropdownMenuItem>
- <DropdownMenuItem disabled>
- <DropdownMenuIcon icon={<BsUpload />} />
- Save Part
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </CardAction>
- </HStack>
- <CardContent>
- <Hidden name="id" />
- <Hidden
- name="parentAssemblyId"
- value={parentAssemblyId ?? undefined}
- />
- <Hidden name="unitOfMeasureCode" value={partData?.uom} />
- <VStack>
- <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <Part
- name="itemId"
- label="Manufactured Part"
- itemReplenishmentSystem="Make"
- onChange={(value) => {
- onPartChange(value?.value as string);
- }}
- />
-
- <InputControlled
- name="description"
- label="Description"
- value={partData.description}
- onChange={(newValue) =>
- setPartData((d) => ({ ...d, description: newValue }))
- }
- />
-
- <Number
- name="quantityPerParent"
- label="Quantity per Parent"
- minValue={0}
- />
- <CustomFormFields table="quoteAssembly" />
- </div>
- </VStack>
- </CardContent>
- <CardFooter>
- <Submit
- isDisabled={
- !isEditable ||
- (isEditing
- ? !permissions.can("update", "sales")
- : !permissions.can("create", "sales"))
- }
- >
- Save
- </Submit>
- </CardFooter>
- </Card>
- </ValidatedForm>
- );
-};
-
-export default QuotationAssemblyForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/QuotationDocumentForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/QuotationDocumentForm.tsx
deleted file mode 100644
index 447172a584..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/QuotationDocumentForm.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { File, toast } from "@carbon/react";
-import { useSubmit } from "@remix-run/react";
-import type { ChangeEvent } from "react";
-import { LuUpload } from "react-icons/lu";
-import { useUser } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import { path } from "~/utils/path";
-
-type QuotationDocumentFormProps = {
- id: string;
- isExternal: boolean;
-};
-
-const QuotationDocumentForm = ({
- id,
- isExternal,
-}: QuotationDocumentFormProps) => {
- const submit = useSubmit();
- const { company } = useUser();
- const { supabase } = useSupabase();
-
- const uploadFile = async (e: ChangeEvent<HTMLInputElement>) => {
- if (e.target.files && supabase && company) {
- const file = e.target.files[0];
- const fileName = `${company.id}/quote/${
- isExternal ? "external" : "internal"
- }/${id}/${file.name}`;
-
- const fileUpload = await supabase.storage
- .from("private")
- .upload(fileName, file, {
- cacheControl: `${12 * 60 * 60}`,
- });
-
- if (fileUpload.error) {
- toast.error("Failed to upload file");
- }
-
- if (fileUpload.data?.path) {
- toast.success("File uploaded");
- submitFileData({
- path: fileUpload.data.path,
- name: file.name,
- size: file.size,
- });
- }
- }
- };
-
- const submitFileData = ({
- path: filePath,
- name,
- size,
- }: {
- path: string;
- name: string;
- size: number;
- }) => {
- const formData = new FormData();
- formData.append("path", filePath);
- formData.append("name", name);
- formData.append("size", Math.round(size / 1024).toString());
- formData.append("sourceDocument", "Quote");
- formData.append("sourceDocumentId", id);
-
- submit(formData, {
- method: "post",
- action: path.to.newDocument,
- });
- };
-
- return (
- <File leftIcon={<LuUpload />} onChange={uploadFile}>
- New
- </File>
- );
-};
-
-export default QuotationDocumentForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/QuotationDocuments.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/QuotationDocuments.tsx
deleted file mode 100644
index d236d542ba..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/QuotationDocuments.tsx
+++ /dev/null
@@ -1,145 +0,0 @@
-import {
- Card,
- CardAction,
- CardContent,
- CardHeader,
- CardTitle,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- HStack,
- IconButton,
- Table,
- Tbody,
- Td,
- Th,
- Thead,
- Tr,
-} from "@carbon/react";
-import { convertKbToString } from "@carbon/utils";
-import { Outlet } from "@remix-run/react";
-import { MdMoreVert } from "react-icons/md";
-import { DocumentPreview, Hyperlink } from "~/components";
-import { DocumentIcon, getDocumentType } from "~/modules/documents";
-import type { QuotationAttachment } from "~/modules/sales";
-import QuotationDocumentForm from "./QuotationDocumentForm";
-import { useQuotationDocuments } from "./useQuotationDocuments";
-
-type QuotationDocumentsProps = {
- attachments: QuotationAttachment[];
- isExternal: boolean;
- id: string;
-};
-
-const QuotationDocuments = ({
- attachments,
- isExternal,
- id,
-}: QuotationDocumentsProps) => {
- const { canDelete, download, deleteAttachment, getPath } =
- useQuotationDocuments({
- isExternal,
- id,
- });
-
- return (
- <>
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>Documents</CardTitle>
- </CardHeader>
- <CardAction>
- <QuotationDocumentForm isExternal={false} id={id} />
- </CardAction>
- </HStack>
- <CardContent>
- <Table>
- <Thead>
- <Tr>
- <Th>Name</Th>
- <Th>Size</Th>
-
- <Th></Th>
- </Tr>
- </Thead>
- <Tbody>
- {attachments.length ? (
- attachments.map((attachment) => {
- const type = getDocumentType(attachment.name);
- return (
- <Tr key={attachment.id}>
- <Td>
- <HStack>
- <DocumentIcon type={type} />
- <Hyperlink onClick={() => download(attachment)}>
- {["PDF", "Image"].includes(type) ? (
- <DocumentPreview
- bucket="private"
- pathToFile={getPath(attachment)}
- // @ts-ignore
- type={type}
- >
- {attachment.name}
- </DocumentPreview>
- ) : (
- attachment.name
- )}
- </Hyperlink>
- </HStack>
- </Td>
- <Td>
- {convertKbToString(
- Math.floor((attachment.metadata?.size ?? 0) / 1024)
- )}
- </Td>
- <Td>
- <div className="flex justify-end w-full">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- aria-label="More"
- icon={<MdMoreVert />}
- variant="secondary"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- <DropdownMenuItem
- onClick={() => download(attachment)}
- >
- Download
- </DropdownMenuItem>
- <DropdownMenuItem
- disabled={!canDelete}
- onClick={() => deleteAttachment(attachment)}
- >
- Delete
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </Td>
- </Tr>
- );
- })
- ) : (
- <Tr>
- <Td
- colSpan={24}
- className="py-8 text-muted-foreground text-center"
- >
- No {isExternal ? "external" : "internal"} attachments
- </Td>
- </Tr>
- )}
- </Tbody>
- </Table>
- </CardContent>
- </Card>
- <Outlet />
- </>
- );
-};
-
-export default QuotationDocuments;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/index.ts b/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/index.ts
deleted file mode 100644
index 7c9f485ae4..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import QuotationDocuments from "./QuotationDocuments";
-
-export default QuotationDocuments;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/useQuotationDocuments.ts b/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/useQuotationDocuments.ts
deleted file mode 100644
index 6a46f581ca..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationDocuments/useQuotationDocuments.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { toast } from "@carbon/react";
-import { useFetcher } from "@remix-run/react";
-import { useCallback } from "react";
-import { usePermissions, useUser } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import type { QuotationAttachment } from "~/modules/sales/types";
-
-type Props = {
- isExternal: boolean;
- id: string;
-};
-
-export const useQuotationDocuments = ({ isExternal, id }: Props) => {
- const fetcher = useFetcher<{}>();
- const permissions = usePermissions();
- const { company } = useUser();
- const { supabase } = useSupabase();
-
- const canDelete = permissions.can("delete", "sales"); // TODO: or is document owner
-
- const refresh = useCallback(
- () => fetcher.submit(null, { method: "post" }),
- [fetcher]
- );
-
- const getPath = useCallback(
- (attachment: QuotationAttachment) => {
- return `${company.id}/quote/${
- isExternal ? "external" : "internal"
- }/${id}/${attachment.name}`;
- },
- [company.id, isExternal, id]
- );
-
- const deleteAttachment = useCallback(
- async (attachment: QuotationAttachment) => {
- const result = await supabase?.storage
- .from("private")
- .remove([getPath(attachment)]);
-
- if (!result || result.error) {
- toast.error(result?.error?.message || "Error deleting file");
- return;
- }
-
- toast.success("File deleted successfully");
- refresh();
- },
- [supabase?.storage, getPath, refresh]
- );
-
- const download = useCallback(
- async (attachment: QuotationAttachment) => {
- const result = await supabase?.storage
- .from("private")
- .download(getPath(attachment));
-
- if (!result || result.error) {
- toast.error(result?.error?.message || "Error downloading file");
- return;
- }
-
- const a = document.createElement("a");
- document.body.appendChild(a);
- const url = window.URL.createObjectURL(result.data);
- a.href = url;
- a.download = attachment.name;
- a.click();
-
- setTimeout(() => {
- window.URL.revokeObjectURL(url);
- document.body.removeChild(a);
- }, 0);
- },
- [supabase?.storage, getPath]
- );
-
- return {
- canDelete,
- deleteAttachment,
- download,
- getPath,
- };
-};
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
deleted file mode 100644
index a202478450..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
+++ /dev/null
@@ -1,804 +0,0 @@
-import {
- Button,
- cn,
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandTrigger,
- HStack,
- IconButton,
- Kbd,
- Popover,
- PopoverContent,
- PopoverTrigger,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- useKeyboardShortcuts,
- VStack,
-} from "@carbon/react";
-import type { Params } from "@remix-run/react";
-import { Link, useLocation, useNavigate, useParams } from "@remix-run/react";
-import { arrayToTree } from "performant-array-to-tree";
-import { useMemo, useRef, useState } from "react";
-import { AiOutlinePartition } from "react-icons/ai";
-import { HiOutlineCube } from "react-icons/hi";
-import { IoMdAdd } from "react-icons/io";
-import { LuClock } from "react-icons/lu";
-import { RxCheck, RxChevronDown } from "react-icons/rx";
-import { useOptimisticLocation } from "~/hooks";
-import type { BillOfMaterialNode } from "~/modules/shared";
-import { path } from "~/utils/path";
-import type {
- QuotationAssembly,
- QuotationLine,
- QuotationMaterial,
- QuotationOperation,
-} from "../..";
-import { useQuotation } from "./useQuotation";
-
-const QuotationExplorerItem = (
- node: Omit<BillOfMaterialNode, "children"> & {
- params: Params<string>;
- pathname: string;
- onClick: () => void;
- }
-) => {
- const { type, id, parentId, label, meta, params, pathname, onClick } = node;
- let isActive = false;
- switch (type) {
- case "assembly":
- isActive =
- pathname ===
- path.to.quoteAssembly(params.id!, meta.quoteLineId, meta.id);
- return (
- <Button
- leftIcon={<AiOutlinePartition />}
- variant={isActive ? "active" : "ghost"}
- className="flex-1 justify-start"
- asChild
- >
- <Link
- to={path.to.quoteAssembly(params.id!, meta.quoteLineId, meta.id)}
- prefetch="intent"
- onClick={onClick}
- >
- {label}
- </Link>
- </Button>
- );
- case "assemblies":
- isActive =
- pathname ===
- path.to.newQuoteAssembly(meta.quoteId, meta.quoteLineId, parentId);
- return (
- <Button
- variant={isActive ? "active" : "ghost"}
- className={cn(
- "font-mono w-full justify-between",
- !isActive && "text-muted-foreground"
- )}
- asChild
- >
- <Link
- to={path.to.newQuoteAssembly(
- meta.quoteId,
- meta.quoteLineId,
- parentId
- )}
- onClick={onClick}
- >
- <span>{label}</span>
- <IoMdAdd />
- </Link>
- </Button>
- );
- case "line":
- isActive = pathname === path.to.quoteLine(params.id!, id);
-
- return (
- <Button
- variant={isActive ? "active" : "ghost"}
- className="flex-1 justify-between"
- asChild
- >
- <Link
- to={path.to.quoteLine(params.id!, id)}
- prefetch="intent"
- onClick={onClick}
- >
- <span className="flex items-center justify-start">
- {meta.replenishmentSystem === "Buy" ? (
- <HiOutlineCube className="w-4 h-4 mr-2" />
- ) : (
- <AiOutlinePartition className="w-4 h-4 mr-2" />
- )}
- {label}
- </span>
- <span
- className={cn(
- "rounded-full h-2 w-2 inline-block ml-2",
- meta?.status === "Complete" && "bg-green-500",
- meta?.status === "In Progress" && "bg-orange-500",
- meta?.status === "Draft" && "bg-zinc-500"
- )}
- />
- </Link>
- </Button>
- );
-
- case "material":
- return (
- <Button
- leftIcon={<HiOutlineCube />}
- variant="ghost"
- className="flex-1 justify-start"
- asChild
- >
- <Link
- to={path.to.quoteOperation(params.id!, meta.quoteLineId, parentId!)}
- >
- {label}
- </Link>
- </Button>
- );
-
- case "materials":
- return (
- <Button
- variant="ghost"
- className="font-mono w-full justify-between text-muted-foreground"
- asChild
- >
- <Link
- to={path.to.newQuoteMaterial(params.id!, meta.quoteLineId, meta.id)}
- onClick={onClick}
- >
- <span>{label}</span>
- <IoMdAdd />
- </Link>
- </Button>
- );
- case "operations":
- isActive =
- pathname ===
- path.to.newQuoteOperation(meta.quoteId, meta.quoteLineId, parentId);
- return (
- <Button
- variant={isActive ? "active" : "ghost"}
- className={cn(
- "font-mono w-full justify-between",
- !isActive && "text-muted-foreground"
- )}
- asChild
- >
- <Link
- to={path.to.newQuoteOperation(
- meta.quoteId,
- meta.quoteLineId,
- parentId
- )}
- onClick={onClick}
- >
- <span>{label}</span>
- <IoMdAdd />
- </Link>
- </Button>
- );
-
- case "operation":
- isActive = [
- path.to.quoteOperation(params.id!, meta.quoteLineId, meta.id),
- path.to.newQuoteMaterial(params.id!, meta.quoteLineId, meta.id),
- ].includes(pathname);
- return (
- <Button
- leftIcon={<LuClock />}
- variant={isActive ? "active" : "ghost"}
- className="flex-1 justify-start"
- asChild
- >
- <Link
- to={path.to.quoteOperation(params.id!, meta.quoteLineId, meta.id)}
- prefetch="intent"
- onClick={onClick}
- >
- {label}
- </Link>
- </Button>
- );
- case "parent":
- isActive = pathname === path.to.quoteDetails(id);
- return (
- <Button
- variant={isActive ? "active" : "ghost"}
- className="flex-1 justify-start"
- asChild
- >
- <Link
- to={path.to.quote(params.id!)}
- prefetch="intent"
- onClick={onClick}
- >
- {label}
- </Link>
- </Button>
- );
- default:
- throw new Error(
- `unknown type: ${type} for node: ${JSON.stringify(node, null, 2)}`
- );
- }
-};
-
-const QuotationExplorer = () => {
- const { pathname, search } = useOptimisticLocation();
-
- const params = useParams();
- if (!params.id) throw new Error("id not found");
-
- const [quote] = useQuotation();
-
- const tree = useMemo(() => {
- if (!quote.quote) return [];
-
- let materialsByOperationId = quote.materials?.reduce<
- Record<string, QuotationMaterial[]>
- >((acc, material) => {
- if (!acc[material.quoteOperationId]) {
- acc[material.quoteOperationId] = [];
- }
- acc[material.quoteOperationId].push(material);
- return acc;
- }, {});
-
- let operationsByAssemblyId = quote.operations?.reduce<
- Record<string, BillOfMaterialNode[]>
- >((acc, operation) => {
- if (!operation?.quoteAssemblyId) return acc;
- if (!acc[operation.quoteAssemblyId]) {
- acc[operation.quoteAssemblyId] = [];
- }
-
- acc[operation.quoteAssemblyId].push({
- id: operation.id,
- parentId: operation.quoteAssemblyId ?? undefined,
- label: operation.description ?? "Operation",
- type: "operation",
- meta: operation,
- children: [
- {
- id: `${operation.id}-materials`,
- label: "Materials",
- type: "materials",
- meta: operation,
- children: materialsByOperationId[operation.id]?.map((material) => ({
- id: material.id,
- parentId: operation.id,
- label: material.description,
- type: "material",
- meta: material,
- })),
- },
- ],
- });
- return acc;
- }, {});
-
- const assembliesByLineId = quote.assemblies?.reduce<
- Record<string, BillOfMaterialNode[]>
- >((acc, assembly) => {
- if (!acc[assembly.quoteLineId]) {
- acc[assembly.quoteLineId] = [];
- }
- acc[assembly.quoteLineId].push({
- id: assembly.id,
- parentId: assembly.parentAssemblyId ?? undefined,
- label: assembly.description ?? assembly.itemId,
- type: "assembly",
- meta: assembly,
- });
- return acc;
- }, {});
-
- const operationsByLineId = quote.operations?.reduce<
- Record<string, BillOfMaterialNode[]>
- >((acc, operation) => {
- if (!acc[operation.quoteLineId]) {
- acc[operation.quoteLineId] = [];
- }
- acc[operation.quoteLineId].push({
- id: operation.id,
- parentId: operation.quoteAssemblyId ?? undefined,
- label: operation.description ?? "Operation",
- type: "operation",
- meta: operation,
- children: [
- {
- id: `${operation.id}-materials`,
- label: "Materials",
- type: "materials",
- meta: operation,
- children: materialsByOperationId[operation.id]?.map((material) => ({
- id: material.id,
- parentId: operation.id,
- label: material.description,
- type: "material",
- meta: material,
- })),
- },
- ],
- });
- return acc;
- }, {});
-
- let tree: BillOfMaterialNode[] = [
- {
- id: quote.quote.id!,
- label: quote.quote.quoteId!,
- type: "parent",
- children: quote.lines?.map<BillOfMaterialNode>((line) => ({
- id: line.id!,
- label: line.description!,
- type: "line",
- meta: line,
- children:
- line.replenishmentSystem === "Make"
- ? [
- {
- id: `${line.id}-assemblies`,
- label: "Assemblies",
- type: "assemblies",
- children: assembliesByLineId[line.id!]
- ? [
- ...(arrayToTree([...assembliesByLineId[line.id!]], {
- id: "id",
- dataField: null,
- }) as BillOfMaterialNode[]),
- ]
- : [],
- meta: {
- quoteId: line.quoteId,
- quoteLineId: line.id,
- },
- },
- {
- id: `${line.id}-operations`,
- label: "Operations",
- type: "operations",
- children: operationsByLineId[line.id!]
- ? [...operationsByLineId[line.id!]]?.filter(
- (operation) => operation.parentId === undefined
- )
- : ([] as BillOfMaterialNode[]),
- meta: {
- quoteId: line.quoteId,
- quoteLineId: line.id,
- },
- },
- ]
- : undefined,
- })),
- },
- ];
-
- traverseTree(tree, (node) => {
- if (node.type === "assembly") {
- let currentChildren = node.children ? [...node.children] : [];
- node.children = [
- {
- id: `${node.id}-assemblies`,
- parentId: node.id,
- label: "Assemblies",
- type: "assemblies",
- children: currentChildren,
- meta: {
- quoteId: node.meta.quoteId,
- quoteLineId: node.meta.quoteLineId,
- },
- },
- {
- id: `${node.id}-operations`,
- parentId: node.id,
- label: "Operations",
- type: "operations",
- children: operationsByAssemblyId[node.id]
- ? [...operationsByAssemblyId[node.id]]
- : [],
- meta: {
- quoteId: node.meta.quoteId,
- quoteLineId: node.meta.quoteLineId,
- },
- },
- ];
- }
- });
-
- return tree;
- }, [quote]);
-
- const nodeParentById = useMemo(() => {
- let result: Record<string, string> = {};
- traverseTree(tree, (node) => {
- if (node.children) {
- node.children.forEach((child) => {
- // better to lose functionality than to have an infinite loop
- if (child.id !== node.id) {
- result[child.id] = node.id;
- }
- });
- }
- });
- return result;
- }, [tree]);
-
- const [collapsedNodes, setCollapsedNodes] = useState<Record<string, boolean>>(
- {}
- );
-
- const openNode = (id: string) => {
- const collapsed = { [id]: false };
- let currentId = id;
- while (nodeParentById[currentId]) {
- collapsed[nodeParentById[currentId]] = false;
- currentId = nodeParentById[currentId];
- }
-
- setCollapsedNodes((prev) => ({
- ...prev,
- ...collapsed,
- }));
- };
-
- const toggleNode = (id: string) => {
- setCollapsedNodes((prev) => ({
- ...prev,
- [id]: !prev[id],
- }));
- };
-
- const renderBillOfMaterial = (
- tree: BillOfMaterialNode[],
- level: number = 0
- ) => {
- return tree.map((node) => {
- return (
- <div className="w-full" role="group" key={`${node.id}:${node.type}`}>
- <HStack
- className="items-stretch w-full"
- spacing={0}
- style={{
- paddingLeft: `calc(${0.75 * level}rem)`,
- }}
- >
- <IconButton
- aria-label={collapsedNodes[node.id] ? "Expand" : "Collapse"}
- onClick={() => toggleNode(node.id)}
- isDisabled={!node.children}
- icon={<RxChevronDown />}
- style={{
- transition: "transform .25s ease",
- transform:
- collapsedNodes[node.id] === undefined ||
- collapsedNodes[node.id] === false ||
- !node.children ||
- node.children?.length === 0
- ? undefined
- : "rotate(-0.25turn)",
- }}
- variant="ghost"
- />
- <QuotationExplorerItem
- type={node.type}
- id={node.id}
- label={node.label}
- parentId={node.parentId}
- params={params}
- pathname={pathname + search}
- meta={node.meta}
- onClick={() => openNode(node.id)}
- />
- </HStack>
- {node.children &&
- !collapsedNodes[node.id] &&
- renderBillOfMaterial(node.children, level + 1)}
- </div>
- );
- });
- };
-
- const newButtonRef = useRef<HTMLButtonElement>(null);
- useKeyboardShortcuts({
- l: () => {
- if (newButtonRef.current) {
- newButtonRef.current.click();
- }
- },
- });
-
- const navigate = useNavigate();
- const { id } = useParams();
- if (!id) throw new Error("id not found");
-
- return (
- <>
- <VStack className="border-b border-border p-2" spacing={0}>
- <HStack className="w-full justify-between">
- <QuotationSearch onSelect={openNode} />
- <Tooltip>
- <TooltipTrigger>
- <IconButton
- aria-label="Add Quote Line"
- icon={<IoMdAdd />}
- ref={newButtonRef}
- onClick={() => navigate(path.to.newQuoteLine(id))}
- />
- </TooltipTrigger>
- <TooltipContent>
- Add Quote Line <Kbd>l</Kbd>
- </TooltipContent>
- </Tooltip>
- </HStack>
- </VStack>
- <VStack className="h-full w-full p-2">
- <div className="w-full h-full overflow-auto" role="tree">
- {renderBillOfMaterial(tree)}
- {quote && Array.isArray(quote.lines) && quote.lines.length === 0 && (
- <div className="flex flex-col space-y-2 py-16 text-muted-foreground items-center justify-center text-center">
- <span className="text-sm">No quote lines</span>
- <Button onClick={() => navigate(path.to.newQuoteLine(id))}>
- Add Quote Line
- </Button>
- </div>
- )}
- </div>
- </VStack>
- </>
- );
-};
-
-export default QuotationExplorer;
-
-function traverseTree(
- tree: BillOfMaterialNode[],
- callback: (node: BillOfMaterialNode) => void
-) {
- tree.forEach((node) => {
- callback(node);
- if (node.children) {
- traverseTree(node.children, callback);
- }
- });
-}
-
-type QuotationSearchProps = {
- onSelect: (id: string) => void;
-};
-
-const QuotationSearch = ({ onSelect }: QuotationSearchProps) => {
- const navigate = useNavigate();
- const { pathname, search } = useLocation();
- const [open, setOpen] = useState(false);
- const [quote] = useQuotation();
- const assembliesById = useMemo(
- () =>
- quote?.assemblies.reduce<Record<string, QuotationAssembly>>(
- (acc, assembly) => {
- acc[assembly.id] = assembly;
- return acc;
- },
- {}
- ),
- [quote?.assemblies]
- );
-
- const linesById = useMemo(
- () =>
- quote?.lines.reduce<Record<string, QuotationLine>>((acc, line) => {
- acc[line.id!] = line;
- return acc;
- }, {}),
- [quote?.lines]
- );
-
- const operationsById = useMemo(
- () =>
- quote?.operations.reduce<Record<string, QuotationOperation>>(
- (acc, operation) => {
- acc[operation.id] = operation;
- return acc;
- },
- {}
- ),
- [quote?.operations]
- );
-
- const commandTriggerRef = useRef<HTMLButtonElement>(null);
-
- useKeyboardShortcuts({
- s: () => {
- if (commandTriggerRef.current) {
- commandTriggerRef.current.click();
- }
- },
- });
-
- return (
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <CommandTrigger
- ref={commandTriggerRef}
- size="sm"
- role="combobox"
- onClick={() => setOpen(true)}
- >
- Search Quote
- </CommandTrigger>
- </PopoverTrigger>
- <PopoverContent className="w-[250px] p-0" align="start">
- <Command>
- <CommandInput placeholder="Search..." className="h-9" />
- <CommandEmpty>No option found.</CommandEmpty>
- {quote?.lines.length > 0 && (
- <CommandGroup heading="Lines">
- {quote?.lines.map((line) => (
- <CommandItem
- value={`lines ${line.itemId} ${line.description}`}
- key={line.id}
- onSelect={() => {
- onSelect(line.id!);
- navigate(path.to.quoteLine(line.quoteId!, line.id!));
- setOpen(false);
- }}
- >
- <div className="flex flex-col">
- <p>{line.description}</p>
- <p className="text-xs text-muted-foreground">
- {line.itemId}
- </p>
- </div>
-
- <RxCheck
- className={cn(
- "ml-auto h-4 w-4",
- `${pathname}${search}` ===
- path.to.quoteLine(line.quoteId!, line.id!)
- ? "opacity-100"
- : "opacity-0"
- )}
- />
- </CommandItem>
- ))}
- </CommandGroup>
- )}
- {quote?.assemblies.length > 0 && (
- <CommandGroup heading="Assemblies">
- {quote?.assemblies.map((assembly) => (
- <CommandItem
- value={`assemblies ${assembly.itemId} ${assembly.description}`}
- key={assembly.id}
- onSelect={() => {
- onSelect(assembly.id);
- navigate(
- path.to.quoteAssembly(
- assembly.quoteId,
- assembly.quoteLineId,
- assembly.id
- )
- );
- setOpen(false);
- }}
- >
- <div className="flex flex-col">
- <p>{assembly.description}</p>
- <p className="text-xs text-muted-foreground">
- {assembly.itemId}
- </p>
- </div>
-
- <RxCheck
- className={cn(
- "ml-auto h-4 w-4",
- `${pathname}${search}` ===
- path.to.quoteAssembly(
- assembly.quoteId,
- assembly.quoteLineId,
- assembly.id
- )
- ? "opacity-100"
- : "opacity-0"
- )}
- />
- </CommandItem>
- ))}
- </CommandGroup>
- )}
- {quote?.operations.length > 0 && (
- <CommandGroup heading="Operations">
- {quote?.operations.map((operation) => {
- const parent = operation.quoteAssemblyId
- ? assembliesById[operation.quoteAssemblyId]
- : linesById[operation.quoteLineId];
- const to = path.to.quoteOperation(
- operation.quoteId,
- operation.quoteLineId,
- operation.id
- );
- return (
- <CommandItem
- value={`operations ${operation.description} ${parent.description} ${operation.id}`}
- key={operation.id}
- onSelect={() => {
- onSelect(operation.id);
- navigate(to);
- setOpen(false);
- }}
- >
- <div className="flex flex-col">
- <p>{operation.description}</p>
-
- <p className="text-xs text-muted-foreground">
- {parent.description}
- </p>
- </div>
-
- <RxCheck
- className={cn(
- "ml-auto h-4 w-4",
- `${pathname}${search}` === to
- ? "opacity-100"
- : "opacity-0"
- )}
- />
- </CommandItem>
- );
- })}
- </CommandGroup>
- )}
- {quote?.materials.length > 0 && (
- <CommandGroup heading="Operations">
- {quote?.materials.map((material) => {
- const parent = operationsById[material.quoteOperationId];
- const to = path.to.quoteOperation(
- material.quoteId,
- material.quoteLineId,
- material.quoteOperationId
- );
- return (
- <CommandItem
- value={`materials ${material.description} ${material.itemId} ${parent.description}`}
- key={material.id}
- onSelect={() => {
- onSelect(material.id);
- navigate(to);
- setOpen(false);
- }}
- >
- <div className="flex flex-col">
- <p>{material.description}</p>
-
- <p className="text-xs text-muted-foreground">
- {parent.description}
- </p>
- </div>
-
- <RxCheck
- className={cn(
- "ml-auto h-4 w-4",
- `${pathname}${search}` === to
- ? "opacity-100"
- : "opacity-0"
- )}
- />
- </CommandItem>
- );
- })}
- </CommandGroup>
- )}
- </Command>
- </PopoverContent>
- </Popover>
- );
-};
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
deleted file mode 100644
index b57a6c057f..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-import {
- Card,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
- VStack,
- cn,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useState } from "react";
-import type { z } from "zod";
-import {
- CustomFormFields,
- Customer,
- CustomerContact,
- CustomerLocation,
- DatePicker,
- Hidden,
- Input,
- Location,
- Select,
- Submit,
- TextArea,
-} from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import { quotationValidator, quoteStatusType } from "~/modules/sales";
-
-type QuotationFormValues = z.infer<typeof quotationValidator>;
-
-type QuotationFormProps = {
- initialValues: QuotationFormValues;
-};
-
-const QuotationForm = ({ initialValues }: QuotationFormProps) => {
- const permissions = usePermissions();
- const [customer, setCustomer] = useState<string | undefined>(
- initialValues.customerId
- );
-
- const isEditing = initialValues.id !== undefined;
-
- const statusOptions = quoteStatusType.map((status) => ({
- label: status,
- value: status,
- }));
-
- return (
- <ValidatedForm
- method="post"
- validator={quotationValidator}
- defaultValues={initialValues}
- className="w-full"
- >
- <Card>
- <CardHeader>
- <CardTitle>{isEditing ? "Quote" : "New Quote"}</CardTitle>
- {!isEditing && (
- <CardDescription>
- A quote is a document that provides a potential customer with a
- price for a product or service.
- </CardDescription>
- )}
- </CardHeader>
- <CardContent>
- <Hidden name="quoteId" />
- <VStack>
- <div
- className={cn(
- "grid w-full gap-x-8 gap-y-4",
- isEditing ? "grid-cols-1 lg:grid-cols-3" : "grid-cols-2"
- )}
- >
- <Customer
- autoFocus={!isEditing}
- name="customerId"
- label="Customer"
- onChange={(value) => setCustomer(value?.value as string)}
- />
- <Input name="name" label="Customer Reference" />
-
- <Location name="locationId" label="Location" />
- <CustomerLocation
- name="customerLocationId"
- label="Customer Location"
- customer={customer}
- />
- <CustomerContact
- name="customerContactId"
- label="Customer Contact"
- customer={customer}
- />
-
- {isEditing && (
- <>
- <DatePicker name="expirationDate" label="Expiration Date" />
- <TextArea name="notes" label="Notes" />
- {permissions.can("delete", "sales") && (
- <Select
- name="status"
- label="Status"
- value={initialValues.status}
- options={statusOptions}
- isReadOnly={permissions.is("customer")}
- />
- )}
- </>
- )}
- <CustomFormFields table="quote" />
- </div>
- </VStack>
- </CardContent>
- <CardFooter>
- <Submit
- isDisabled={
- isEditing
- ? !permissions.can("update", "sales")
- : !permissions.can("create", "sales")
- }
- >
- Save
- </Submit>
- </CardFooter>
- </Card>
- </ValidatedForm>
- );
-};
-
-export default QuotationForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
deleted file mode 100644
index 184b1dee2d..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
+++ /dev/null
@@ -1,246 +0,0 @@
-import {
- Card,
- CardAction,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuIcon,
- DropdownMenuItem,
- DropdownMenuTrigger,
- HStack,
- IconButton,
- VStack,
- cn,
-} from "@carbon/react";
-
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useNavigate, useParams } from "@remix-run/react";
-import { useState } from "react";
-import { BsDownload, BsThreeDotsVertical, BsUpload } from "react-icons/bs";
-import { LuTrash } from "react-icons/lu";
-import type { z } from "zod";
-import {
- CustomFormFields,
- Hidden,
- Input,
- InputControlled,
- Item,
- Select,
- SelectControlled,
- Submit,
-} from "~/components/Form";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import type { Quotation } from "~/modules/sales";
-import { quotationLineValidator, quoteLineStatusType } from "~/modules/sales";
-import { path } from "~/utils/path";
-
-type QuotationLineFormProps = {
- initialValues: z.infer<typeof quotationLineValidator>;
-};
-
-const QuotationLineForm = ({ initialValues }: QuotationLineFormProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
- const { company } = useUser();
- const { supabase } = useSupabase();
-
- const { id } = useParams();
-
- if (!id) throw new Error("id not found");
-
- const routeData = useRouteData<{
- quotation: Quotation;
- }>(path.to.quote(id));
-
- const isEditable = ["Draft", "To Review"].includes(
- routeData?.quotation?.status ?? ""
- );
-
- const isEditing = initialValues.id !== undefined;
- const isDisabled = !isEditable
- ? true
- : isEditing
- ? !permissions.can("update", "sales")
- : !permissions.can("create", "sales");
-
- const [itemData, setItemData] = useState<{
- itemId: string;
- itemReadableId: string;
- description: string;
- replenishmentSystem: string;
- uom: string;
- }>({
- itemId: initialValues.itemId ?? "",
- itemReadableId: initialValues.itemReadableId ?? "",
- description: initialValues.description ?? "",
- replenishmentSystem: initialValues.replenishmentSystem ?? "",
- uom: initialValues.unitOfMeasureCode ?? "",
- });
-
- const onItemChange = async (itemId: string) => {
- if (!supabase || !company.id) return;
- const [item, part] = await Promise.all([
- supabase
- .from("item")
- .select("name, readableId")
- .eq("id", itemId)
- .single(),
- supabase
- .from("part")
- .select("replenishmentSystem, unitOfMeasureCode")
- .eq("itemId", itemId)
- .eq("companyId", company.id)
- .single(),
- ]);
-
- setItemData({
- itemId,
- itemReadableId: item.data?.readableId ?? "",
- description: item.data?.name ?? "",
- replenishmentSystem:
- part.data?.replenishmentSystem === "Buy and Make"
- ? ""
- : part.data?.replenishmentSystem ?? "",
- uom: part.data?.unitOfMeasureCode ?? "",
- });
- };
-
- return (
- <ValidatedForm
- defaultValues={initialValues}
- validator={quotationLineValidator}
- method="post"
- action={
- isEditing
- ? path.to.quoteLine(id, initialValues.id!)
- : path.to.newQuoteLine(id)
- }
- className="w-full"
- >
- <Card>
- <HStack className="w-full justify-between items-start">
- <CardHeader>
- <CardTitle>{isEditing ? "Quote Line" : "New Quote Line"}</CardTitle>
- <CardDescription>
- {isEditing
- ? itemData?.description
- : "A quote line contains pricing and lead times for a particular part"}
- </CardDescription>
- </CardHeader>
- <CardAction>
- {isEditing && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- icon={<BsThreeDotsVertical />}
- aria-label="More"
- variant="secondary"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={() => navigate("delete")}>
- <DropdownMenuIcon icon={<LuTrash />} />
- Delete Line
- </DropdownMenuItem>
- <DropdownMenuItem disabled>
- <DropdownMenuIcon icon={<BsDownload />} />
- Get Part
- </DropdownMenuItem>
- <DropdownMenuItem disabled>
- <DropdownMenuIcon icon={<BsUpload />} />
- Save Part
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </CardAction>
- </HStack>
- <CardContent>
- <Hidden name="intent" value="line" />
- <Hidden name="id" />
- <Hidden name="quoteId" />
- <Hidden name="itemReadableId" value={itemData?.itemReadableId} />
- <Hidden name="unitOfMeasureCode" value={itemData?.uom} />
- <VStack>
- <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <Item
- name="itemId"
- type="Part"
- label="Part"
- onChange={(value) => {
- onItemChange(value?.value as string);
- }}
- />
-
- <InputControlled
- name="description"
- label="Description"
- value={itemData.description}
- onChange={(newValue) =>
- setItemData((d) => ({ ...d, description: newValue }))
- }
- />
-
- <SelectControlled
- name="replenishmentSystem"
- label="Replenishment System"
- options={
- itemData.replenishmentSystem === "Buy"
- ? [{ label: "Buy", value: "Buy" }]
- : itemData.replenishmentSystem === "Make"
- ? [{ label: "Make", value: "Make" }]
- : [
- {
- label: "Buy",
- value: "Buy",
- },
- {
- label: "Make",
- value: "Make",
- },
- ]
- }
- value={itemData.replenishmentSystem}
- onChange={(newValue) => {
- if (newValue)
- setItemData((d) => ({
- ...d,
- replenishmentSystem: newValue?.value,
- }));
- }}
- />
-
- <Input name="customerPartId" label="Customer Part ID" />
- <Input
- name="customerPartRevision"
- label="Customer Part Revision"
- />
-
- <Select
- name="status"
- label="Line Status"
- options={quoteLineStatusType.map((s) => ({
- label: s,
- value: s,
- }))}
- className={cn(!isEditing && "sr-only")}
- />
-
- <CustomFormFields table="quoteLine" />
- </div>
- </VStack>
- </CardContent>
- <CardFooter>
- <Submit isDisabled={isDisabled}>Save</Submit>
- </CardFooter>
- </Card>
- </ValidatedForm>
- );
-};
-
-export default QuotationLineForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
deleted file mode 100644
index 750fcda404..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
+++ /dev/null
@@ -1,187 +0,0 @@
-import {
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- HStack,
- VStack,
-} from "@carbon/react";
-
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useNavigate, useParams } from "@remix-run/react";
-import { useState } from "react";
-import type { z } from "zod";
-import {
- CustomFormFields,
- Hidden,
- InputControlled,
- Number,
- NumberControlled,
- Part,
- Submit,
-} from "~/components/Form";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import type { Quotation } from "~/modules/sales";
-import { quotationMaterialValidator } from "~/modules/sales";
-import { path } from "~/utils/path";
-
-type QuotationMaterialFormProps = {
- initialValues: z.infer<typeof quotationMaterialValidator>;
-};
-
-const QuotationMaterialForm = ({
- initialValues,
-}: QuotationMaterialFormProps) => {
- const permissions = usePermissions();
- const { supabase } = useSupabase();
- const { company } = useUser();
- const navigate = useNavigate();
-
- const { id, lineId, operationId } = useParams();
- if (!id) throw new Error("id not found");
- if (!lineId) throw new Error("lineId not found");
- if (!operationId) throw new Error("operationId not found");
-
- const routeData = useRouteData<{
- quotation: Quotation;
- }>(path.to.quote(id));
- const isEditable = ["Draft"].includes(routeData?.quotation?.status ?? "");
-
- const [partData, setPartData] = useState<{
- itemId: string;
- description: string;
- unitCost: number;
- uom: string;
- }>({
- itemId: initialValues.itemId ?? "",
- description: initialValues.description ?? "",
- unitCost: initialValues.unitCost ?? 0,
- uom: initialValues.unitOfMeasureCode ?? "",
- });
-
- const isEditing = initialValues.id !== undefined;
- const isDisabled = !isEditable
- ? true
- : isEditing
- ? !permissions.can("update", "sales")
- : !permissions.can("create", "sales");
-
- const onClose = () => navigate(-1);
-
- const onPartChange = async (itemId: string) => {
- if (!supabase || !company.id) return;
- const [item, part, cost] = await Promise.all([
- supabase
- .from("item")
- .select("name")
- .eq("id", itemId)
- .eq("companyId", company.id)
- .single(),
- supabase
- .from("part")
- .select("unitOfMeasureCode")
- .eq("id", itemId)
- .eq("companyId", company.id)
- .single(),
- supabase
- .from("itemCost")
- .select("unitCost")
- .eq("itemId", itemId)
- .eq("companyId", company.id)
- .single(),
- ]);
-
- setPartData({
- itemId,
- description: item.data?.name ?? "",
- unitCost: cost.data?.unitCost ?? 0,
- uom: part.data?.unitOfMeasureCode ?? "EA",
- });
- };
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <ValidatedForm
- defaultValues={initialValues}
- validator={quotationMaterialValidator}
- method="post"
- action={
- isEditing
- ? path.to.quoteMaterial(
- id,
- lineId,
- operationId,
- initialValues.id!
- )
- : path.to.newQuoteMaterial(id, lineId, operationId)
- }
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>{isEditing ? "Edit" : "New"} Material</DrawerTitle>
- </DrawerHeader>
- <DrawerBody>
- <Hidden name="id" />
-
- <VStack spacing={4}>
- <Part
- name="itemId"
- label="Part"
- itemReplenishmentSystem="Buy"
- onChange={(value) => {
- onPartChange(value?.value as string);
- }}
- />
-
- <InputControlled
- name="description"
- label="Description"
- value={partData.description}
- onChange={(newValue) =>
- setPartData((d) => ({ ...d, description: newValue }))
- }
- />
-
- <Number name="quantity" label="Quantity" />
- {/*
- // TODO: implement this and replace the UoM in PartForm */}
- {/* <UnitOfMeasure name="unitOfMeasureCode" label="Unit of Measure" value={uom} /> */}
- <NumberControlled
- name="unitCost"
- label="Unit Cost"
- value={partData.unitCost}
- onChange={(value) =>
- setPartData((d) => ({
- ...d,
- unitCost: value,
- }))
- }
- />
- <CustomFormFields table="quoteMaterial" />
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-};
-
-export default QuotationMaterialForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx
deleted file mode 100644
index a17803bffa..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialLines.tsx
+++ /dev/null
@@ -1,158 +0,0 @@
-import {
- Card,
- CardAction,
- CardContent,
- CardHeader,
- CardTitle,
- HStack,
-} from "@carbon/react";
-import { Outlet, useNavigate, useParams } from "@remix-run/react";
-import type { ColumnDef } from "@tanstack/react-table";
-import { useCallback, useMemo } from "react";
-import { New } from "~/components";
-import { EditableNumber, EditableText } from "~/components/Editable";
-import Grid from "~/components/Grid";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import {
- useQuotation,
- type Quotation,
- type QuotationMaterial,
-} from "~/modules/sales";
-import { useItems } from "~/stores";
-import { path } from "~/utils/path";
-
-type QuotationMaterialLinesProps = {
- quotationMaterials: QuotationMaterial[];
-};
-
-const QuotationMaterialLines = ({
- quotationMaterials,
-}: QuotationMaterialLinesProps) => {
- const { id, lineId, operationId } = useParams();
- if (!id) throw new Error("id not found");
- if (!lineId) throw new Error("lineId not found");
- if (!operationId) throw new Error("operationId not found");
-
- const [, setQuote] = useQuotation();
-
- const { id: userId } = useUser();
- const { supabase } = useSupabase();
- const permissions = usePermissions();
-
- const canEdit = permissions.can("update", "sales");
- const canDelete = permissions.can("delete", "sales");
-
- const onCellEdit = useCallback(
- async (id: string, value: unknown, row: QuotationMaterial) => {
- if (!supabase) throw new Error("Supabase client not found");
- return await supabase
- .from("quoteMaterial")
- .update({
- [id]: value,
- updatedBy: userId,
- })
- .eq("id", row.id!);
- },
- [supabase, userId]
- );
-
- const navigate = useNavigate();
-
- const routeData = useRouteData<{
- quotation: Quotation;
- }>(path.to.quote(id));
- const isEditable = ["Draft"].includes(routeData?.quotation?.status ?? "");
-
- // TODO: use the currency of the quote
- const formatter = new Intl.NumberFormat("en-US", {
- style: "currency",
- currency: "USD",
- });
-
- const [items] = useItems();
-
- const columns = useMemo<ColumnDef<QuotationMaterial>[]>(() => {
- return [
- {
- accessorKey: "itemId",
- header: "Part",
- cell: ({ row }) =>
- items.find((item) => item.id === row.original.itemId)?.readableId ??
- null,
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "quantity",
- header: "Quantity",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "unitCost",
- header: "Unit Cost",
- cell: (item) => formatter.format(item.getValue<number>()),
- },
- // {
- // accessorKey: "unitOfMeasureCode",
- // header: "Unit of Measure",
- // cell: (item) => item.getValue(),
- // },
- ];
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [navigate, isEditable, canDelete]);
-
- const editableComponents = useMemo(
- () => ({
- quantity: EditableNumber(onCellEdit),
- description: EditableText(onCellEdit),
- unitCost: EditableNumber(onCellEdit, { minValue: 0 }),
- }),
- [onCellEdit]
- );
-
- return (
- <>
- <Card
- className="w-full"
- style={{ height: 196 + quotationMaterials.length * 44 }}
- >
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>Materials</CardTitle>
- </CardHeader>
- <CardAction>
- {canEdit && isEditable && (
- <New label="Material" to="material/new" />
- )}
- </CardAction>
- </HStack>
-
- <CardContent>
- <Grid<QuotationMaterial>
- data={quotationMaterials}
- canEdit={canEdit && isEditable}
- columns={columns}
- contained={false}
- editableComponents={editableComponents}
- onNewRow={() => navigate("material/new")}
- onDataChange={(data) =>
- setQuote((prev) => ({
- ...prev,
- materials: prev.materials
- .filter((m) => m.quoteOperationId !== operationId)
- .concat(data),
- }))
- }
- />
- </CardContent>
- </Card>
- <Outlet />
- </>
- );
-};
-
-export default QuotationMaterialLines;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
deleted file mode 100644
index 42f3ff71bb..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
+++ /dev/null
@@ -1,259 +0,0 @@
-import {
- Card,
- CardAction,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuIcon,
- DropdownMenuItem,
- DropdownMenuTrigger,
- HStack,
- IconButton,
- VStack,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useNavigate, useParams } from "@remix-run/react";
-import { useState } from "react";
-import { BsThreeDotsVertical } from "react-icons/bs";
-import { LuTrash } from "react-icons/lu";
-import type { z } from "zod";
-import {
- CustomFormFields,
- EquipmentType,
- Hidden,
- InputControlled,
- Number,
- NumberControlled,
- StandardFactor,
- Submit,
- WorkCellType,
-} from "~/components/Form";
-import { usePermissions, useRouteData, useUrlParams } from "~/hooks";
-import { useSupabase } from "~/lib/supabase";
-import type { Quotation } from "~/modules/sales";
-import { quotationOperationValidator } from "~/modules/sales";
-import { path } from "~/utils/path";
-
-type QuotationOperationFormValues = z.infer<typeof quotationOperationValidator>;
-
-type QuotationOperationFormProps = {
- initialValues: QuotationOperationFormValues;
-};
-
-const QuotationOperationForm = ({
- initialValues,
-}: QuotationOperationFormProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
- const { supabase } = useSupabase();
-
- const { id: quoteId, lineId } = useParams();
- if (!quoteId) throw new Error("quoteId not found");
- if (!lineId) throw new Error("lineId not found");
-
- const [params] = useUrlParams();
- const quoteAssemblyId = params.get("quoteAssemblyId");
-
- const isEditing = initialValues.id !== undefined;
-
- const routeData = useRouteData<{
- quotation: Quotation;
- }>(path.to.quote(quoteId));
- const isEditable = ["Draft"].includes(routeData?.quotation?.status ?? "");
-
- const [workCellData, setWorkCellData] = useState<{
- workCellTypeId: string;
- description: string;
- quotingRate: number;
- laborRate: number;
- overheadRate: number;
- }>({
- workCellTypeId: initialValues.workCellTypeId ?? "",
- description: initialValues.description ?? "",
- quotingRate: initialValues.quotingRate ?? 0,
- laborRate: initialValues.laborRate ?? 0,
- overheadRate: initialValues.overheadRate ?? 0,
- });
-
- const onWorkCellChange = async (workCellTypeId: string) => {
- if (!supabase || !workCellTypeId) return;
- const { data, error } = await supabase
- .from("workCellType")
- .select("*")
- .eq("id", workCellTypeId)
- .single();
-
- if (error) throw new Error(error.message);
-
- setWorkCellData({
- workCellTypeId,
- description: data?.name ?? "",
- quotingRate: data?.quotingRate ?? 0,
- laborRate: data?.laborRate ?? 0,
- overheadRate: data?.overheadRate ?? 0,
- });
- };
-
- const [equipmentData, setEquipmentData] = useState<{
- equipmentTypeId: string;
- setupHours: number;
- }>({
- equipmentTypeId: initialValues.equipmentTypeId ?? "",
- setupHours: initialValues.setupHours ?? 0,
- });
-
- const onEquipmentChange = async (equipmentTypeId: string) => {
- if (!supabase || !equipmentTypeId) return;
- const { data, error } = await supabase
- .from("equipmentType")
- .select("*")
- .eq("id", equipmentTypeId)
- .single();
-
- if (error) throw new Error(error.message);
-
- setEquipmentData({
- equipmentTypeId,
- setupHours: data?.setupHours ?? 0,
- });
- };
-
- return (
- <ValidatedForm
- method="post"
- validator={quotationOperationValidator}
- defaultValues={initialValues}
- className="w-full"
- action={
- isEditing
- ? path.to.quoteOperation(quoteId, lineId, initialValues.id!)
- : path.to.newQuoteOperation(quoteId, lineId)
- }
- >
- <Card>
- <HStack className="w-full justify-between items-start">
- <CardHeader>
- <CardTitle>{isEditing ? "Operation" : "New Operation"}</CardTitle>
- <CardDescription>
- {isEditing
- ? workCellData.description
- : "A quote operation is a distinct step in the production of a part. It can consume material"}
- </CardDescription>
- </CardHeader>
- <CardAction>
- {isEditing && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- icon={<BsThreeDotsVertical />}
- aria-label="More"
- variant="secondary"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={() => navigate("delete")}>
- <DropdownMenuIcon icon={<LuTrash />} />
- Delete Operation
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </CardAction>
- </HStack>
- <CardContent>
- <Hidden name="id" />
- <Hidden name="quoteAssemblyId" value={quoteAssemblyId ?? undefined} />
-
- <VStack>
- <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <WorkCellType
- name="workCellTypeId"
- label="Work Cell"
- onChange={(value) => {
- onWorkCellChange(value?.value as string);
- }}
- />
- <InputControlled
- name="description"
- label="Description"
- value={workCellData.description}
- onChange={(newValue) => {
- setWorkCellData((d) => ({ ...d, description: newValue }));
- }}
- />
- <EquipmentType
- name="equipmentTypeId"
- label="Equipment"
- onChange={(value) => onEquipmentChange(value?.value as string)}
- />
-
- <NumberControlled
- name="setupHours"
- label="Setup Time (hours)"
- minValue={0}
- value={equipmentData.setupHours}
- onChange={(newValue) => {
- setEquipmentData((d) => ({ ...d, setupHours: newValue }));
- }}
- />
- <Number
- name="productionStandard"
- label="Production Standard"
- minValue={0}
- />
- {/* TODO: this should be controlled when the work center changes */}
- <StandardFactor name="standardFactor" label="Standard Factor" />
-
- <NumberControlled
- name="quotingRate"
- label="Quoting Rate"
- minValue={0}
- value={workCellData.quotingRate}
- onChange={(newValue) => {
- setWorkCellData((d) => ({ ...d, quotingRate: newValue }));
- }}
- />
- <NumberControlled
- name="laborRate"
- label="Labor Rate"
- minValue={0}
- value={workCellData.laborRate}
- onChange={(newValue) => {
- setWorkCellData((d) => ({ ...d, laborRate: newValue }));
- }}
- />
- <NumberControlled
- name="overheadRate"
- label="Overhead Rate"
- minValue={0}
- value={workCellData.overheadRate}
- onChange={(newValue) => {
- setWorkCellData((d) => ({ ...d, overheadRate: newValue }));
- }}
- />
- <CustomFormFields table="quoteOperation" />
- </div>
- </VStack>
- </CardContent>
- <CardFooter>
- <Submit
- isDisabled={
- !isEditable ||
- (isEditing
- ? !permissions.can("update", "sales")
- : !permissions.can("create", "sales"))
- }
- >
- Save
- </Submit>
- </CardFooter>
- </Card>
- </ValidatedForm>
- );
-};
-
-export default QuotationOperationForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx
deleted file mode 100644
index 76fc82d052..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationPricing.tsx
+++ /dev/null
@@ -1,365 +0,0 @@
-import {
- Button,
- Card,
- CardContent,
- CardFooter,
- CardHeader,
- CardTitle,
- Enumerable,
- HStack,
- Table,
- Tbody,
- Td,
- Tfoot,
- Th,
- Thead,
- Tr,
- VStack,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useParams } from "@remix-run/react";
-import { useMemo, useState } from "react";
-import type { z } from "zod";
-import { Hidden, Number, NumberControlled, Submit } from "~/components/Form";
-import {
- getLinePriceUpdate,
- quotationPricingValidator,
- useQuotationLinePriceEffects,
-} from "~/modules/sales";
-import { path } from "~/utils/path";
-
-type QuotationPricingProps = {
- initialValues: z.infer<typeof quotationPricingValidator>;
- isMade: boolean;
-};
-
-export default function QuotationPricing({
- initialValues,
- isMade,
-}: QuotationPricingProps) {
- const linePriceEffects = useQuotationLinePriceEffects();
-
- const { id, lineId } = useParams();
- if (!id) throw new Error("id not found");
- if (!lineId) throw new Error("lineId not found");
-
- const [quantities] = useState([1, 25, 50, 100]);
- const [state, setState] = useState({
- quantity: initialValues.quantity ?? 1,
- unitCost: initialValues.unitCost ?? 0,
- discountPercent: initialValues.discountPercent ?? 0,
- markupPercent: initialValues.markupPercent ?? 0,
- extendedPrice: initialValues.extendedPrice ?? 0,
- });
-
- const quantityPriceEffects = useMemo(
- () =>
- quantities.map((quantity) => {
- const effects = linePriceEffects.effects[lineId];
- return {
- quantity,
- effects: getLinePriceUpdate(quantity, effects),
- };
- }),
- [lineId, linePriceEffects.effects, quantities]
- );
-
- const onAdd = ({
- quantity,
- effects,
- }: (typeof quantityPriceEffects)[number]) => {
- const totalCost =
- effects.materialCost +
- effects.laborCost +
- effects.overheadCost +
- effects.outsideCost;
- const unitCost = totalCost / quantity;
-
- setState((prevState) => ({
- ...prevState,
- quantity,
- unitCost,
- extendedPrice:
- totalCost +
- totalCost * (prevState.markupPercent / 100) -
- totalCost * (prevState.discountPercent / 100),
- }));
- };
-
- // TODO: factor in default currency, po currency and exchange rate
- const formatter = useMemo(
- () =>
- new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }),
- []
- );
-
- return (
- <>
- {isMade && (
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>Costing</CardTitle>
- </CardHeader>
- {/* <CardAction>
- <IconButton
- variant="secondary"
- icon={<BsThreeDotsVertical />}
- aria-label="Options"
- />
- </CardAction> */}
- </HStack>
- <CardContent>
- <Table>
- <Thead>
- <Tr>
- <Th />
- {quantities.map((quantity) => (
- <Th key={quantity.toString()} className="font-mono">
- {quantity}
- </Th>
- ))}
- </Tr>
- </Thead>
- <Tbody>
- <Tr>
- <Td className="border-r border-border">
- <HStack className="w-full justify-between ">
- <span>Total Raw Material</span>
- <Enumerable value="Material" />
- </HStack>
- </Td>
- {quantityPriceEffects.map(({ quantity, effects }) => {
- return (
- <Td key={quantity.toString()} className="font-mono">
- <VStack spacing={0}>
- <span>
- {effects.materialCost
- ? formatter.format(effects.materialCost)
- : formatter.format(0)}
- </span>
- <span className="text-muted-foreground text-xs">
- {effects.materialCost && quantity > 0
- ? formatter.format(
- effects.materialCost / quantity
- )
- : formatter.format(0)}
- </span>
- </VStack>
- </Td>
- );
- })}
- </Tr>
- <Tr>
- <Td className="border-r border-border">
- <HStack className="w-full justify-between ">
- <span>Total Labor &amp; Overhead</span>
- <Enumerable value="Labor" />
- </HStack>
- </Td>
- {quantityPriceEffects.map(({ quantity, effects }) => {
- return (
- <Td key={quantity.toString()} className="font-mono">
- <VStack spacing={0}>
- <span>
- {effects.overheadCost
- ? formatter.format(
- effects.overheadCost + effects.laborCost
- )
- : formatter.format(0)}
- </span>
- <span className="text-muted-foreground text-xs">
- {effects.overheadCost && quantity > 0
- ? formatter.format(
- (effects.overheadCost + effects.laborCost) /
- quantity
- )
- : formatter.format(0)}
- </span>
- </VStack>
- </Td>
- );
- })}
- </Tr>
- <Tr>
- <Td className="border-r border-border">
- <HStack className="w-full justify-between ">
- <span>Total Outside Processing</span>
- <Enumerable value="Subcontract" />
- </HStack>
- </Td>
- {quantityPriceEffects.map(({ quantity, effects }) => {
- return (
- <Td key={quantity.toString()} className="font-mono">
- <VStack spacing={0}>
- <span>
- {effects.outsideCost
- ? formatter.format(effects.outsideCost)
- : formatter.format(0)}
- </span>
- <span className="text-muted-foreground text-xs">
- {effects.outsideCost && quantity > 0
- ? formatter.format(effects.outsideCost / quantity)
- : formatter.format(0)}
- </span>
- </VStack>
- </Td>
- );
- })}
- </Tr>
- <Tr className="font-bold">
- <Td className="border-r border-border">
- <HStack className="w-full justify-between ">
- <span>Total Cost</span>
- </HStack>
- </Td>
- {quantityPriceEffects.map(({ quantity, effects }) => {
- const totalCost =
- effects.materialCost +
- effects.laborCost +
- effects.overheadCost +
- effects.outsideCost;
- return (
- <Td key={quantity.toString()} className="font-mono">
- <VStack spacing={0}>
- <span>
- {totalCost
- ? formatter.format(totalCost)
- : formatter.format(0)}
- </span>
- <span className="text-muted-foreground text-xs">
- {totalCost && quantity > 0
- ? formatter.format(totalCost / quantity)
- : formatter.format(0)}
- </span>
- </VStack>
- </Td>
- );
- })}
- </Tr>
- </Tbody>
- <Tfoot>
- <Tr className="font-bold">
- <Td className="border-r border-border" />
- {quantityPriceEffects.map((quantityEffect) => (
- <Td key={quantityEffect.quantity} className="font-mono">
- <Button
- variant="secondary"
- onClick={() => onAdd(quantityEffect)}
- >
- Add
- </Button>
- </Td>
- ))}
- </Tr>
- </Tfoot>
- </Table>
- </CardContent>
- </Card>
- )}
-
- <ValidatedForm
- validator={quotationPricingValidator}
- defaultValues={initialValues}
- method="post"
- action={path.to.quoteLine(id, lineId)}
- className="w-full"
- >
- <Card>
- <CardHeader>
- <CardTitle>Pricing</CardTitle>
- </CardHeader>
- <CardContent>
- <Hidden name="intent" value="pricing" />
- <div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
- <NumberControlled
- name="quantity"
- label="Quantity"
- value={state.quantity}
- onChange={(quantity) =>
- setState((prevState) => ({
- ...prevState,
- quantity,
- extendedPrice:
- prevState.unitCost *
- quantity *
- (1 + prevState.markupPercent / 100) -
- prevState.unitCost *
- quantity *
- (prevState.discountPercent / 100),
- }))
- }
- />
- <NumberControlled
- name="unitCost"
- label="Unit Cost"
- value={state.unitCost}
- onChange={(unitCost) =>
- setState((prevState) => ({
- ...prevState,
- unitCost,
- extendedPrice:
- unitCost *
- prevState.quantity *
- (1 + prevState.markupPercent / 100) -
- unitCost *
- prevState.quantity *
- (prevState.discountPercent / 100),
- }))
- }
- formatOptions={{ style: "currency", currency: "USD" }}
- />
- <Number name="leadTime" label="Lead Time (Days)" />
- <NumberControlled
- name="discountPercent"
- label="Discount %"
- value={state.discountPercent}
- onChange={(discountPercent) =>
- setState((prevState) => ({
- ...prevState,
- discountPercent,
- extendedPrice:
- prevState.unitCost *
- prevState.quantity *
- (1 + prevState.markupPercent / 100) -
- prevState.unitCost *
- prevState.quantity *
- (discountPercent / 100),
- }))
- }
- />
- <NumberControlled
- name="markupPercent"
- label="Markup %"
- value={state.markupPercent}
- onChange={(markupPercent) =>
- setState((prevState) => ({
- ...prevState,
- markupPercent,
- extendedPrice:
- prevState.unitCost *
- prevState.quantity *
- (1 + markupPercent / 100) -
- prevState.unitCost *
- prevState.quantity *
- (prevState.discountPercent / 100),
- }))
- }
- />
- <NumberControlled
- name="extendedPrice"
- label="Extended Price"
- value={state.extendedPrice}
- isReadOnly
- formatOptions={{ style: "currency", currency: "USD" }}
- />
- </div>
- </CardContent>
- <CardFooter>
- <Submit>Save</Submit>
- </CardFooter>
- </Card>
- </ValidatedForm>
- </>
- );
-}
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationReleaseModal.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationReleaseModal.tsx
deleted file mode 100644
index eeca3c21b3..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationReleaseModal.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import {
- Button,
- Modal,
- ModalBody,
- ModalContent,
- ModalDescription,
- ModalFooter,
- ModalHeader,
- ModalTitle,
- VStack,
-} from "@carbon/react";
-import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useParams } from "@remix-run/react";
-import { useState } from "react";
-import { CustomerContact, SelectControlled } from "~/components/Form";
-import { useIntegrations } from "~/hooks/useIntegrations";
-import { path } from "~/utils/path";
-import { quotationReleaseValidator } from "../../sales.models";
-import type { Quotation } from "../../types";
-
-type QuotationReleaseModalProps = {
- onClose: () => void;
- quotation?: Quotation;
-};
-
-const QuotationReleaseModal = ({
- quotation,
- onClose,
-}: QuotationReleaseModalProps) => {
- const { id } = useParams();
- if (!id) throw new Error("id not found");
-
- const integrations = useIntegrations();
- const canEmail = integrations.has("resend");
-
- const [notificationType, setNotificationType] = useState(
- canEmail ? "Email" : "Download"
- );
-
- return (
- <Modal
- open
- onOpenChange={(open) => {
- if (!open) {
- onClose();
- }
- }}
- >
- <ModalContent>
- <ValidatedForm
- method="post"
- validator={quotationReleaseValidator}
- action={path.to.quoteRelease(id)}
- onSubmit={onClose}
- defaultValues={{
- notification: notificationType as "Email" | "None",
- customerContact: quotation?.customerContactId ?? undefined,
- }}
- >
- <ModalHeader>
- <ModalTitle>{`Release ${quotation?.quoteId}`}</ModalTitle>
- <ModalDescription>
- Are you sure you want to release the quote?
- </ModalDescription>
- </ModalHeader>
- <ModalBody>
- <VStack spacing={4}>
- {canEmail && (
- <SelectControlled
- label="Send Via"
- name="notification"
- options={[
- {
- label: "None",
- value: "None",
- },
- {
- label: "Email",
- value: "Email",
- },
- ]}
- value={notificationType}
- onChange={(t) => {
- if (t) setNotificationType(t.value);
- }}
- />
- )}
- {notificationType === "Email" && (
- <CustomerContact
- name="customerContact"
- customer={quotation?.customerId ?? undefined}
- />
- )}
- </VStack>
- </ModalBody>
- <ModalFooter>
- <Button variant="secondary" onClick={onClose}>
- Cancel
- </Button>
- <Button type="submit">Release</Button>
- </ModalFooter>
- </ValidatedForm>
- </ModalContent>
- </Modal>
- );
-};
-
-export default QuotationReleaseModal;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/index.ts b/apps/carbon/app/modules/sales/ui/Quotation/index.ts
deleted file mode 100644
index 8241ba39ba..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/index.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import QuotationAssemblyForm from "./QuotationAssemblyForm";
-import QuotationDocuments from "./QuotationDocuments";
-import QuotationExplorer from "./QuotationExplorer";
-import QuotationForm from "./QuotationForm";
-import QuotationLineForm from "./QuotationLineForm";
-import QuotationMaterialForm from "./QuotationMaterialForm";
-import QuotationMaterialLines from "./QuotationMaterialLines";
-import QuotationOperationForm from "./QuotationOperationForm";
-import QuotationPricing from "./QuotationPricing";
-import QuotationStatus from "./QuotationStatus";
-import {
- getLinePriceUpdate,
- useQuotation,
- useQuotationLinePriceEffects,
-} from "./useQuotation";
-export {
- QuotationAssemblyForm,
- QuotationDocuments,
- QuotationExplorer,
- QuotationForm,
- QuotationLineForm,
- QuotationMaterialForm,
- QuotationMaterialLines,
- QuotationOperationForm,
- QuotationPricing,
- QuotationStatus,
- getLinePriceUpdate,
- useQuotation,
- useQuotationLinePriceEffects,
-};
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsx b/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsx
deleted file mode 100644
index 4cf2db2199..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsx
+++ /dev/null
@@ -1,269 +0,0 @@
-import { useStore as useValue } from "@nanostores/react";
-import { atom, computed } from "nanostores";
-import { useNanoStore } from "~/hooks";
-import type {
- Quotation,
- QuotationAssembly,
- QuotationLine,
- QuotationMaterial,
- QuotationOperation,
-} from "~/modules/sales";
-
-type QuoteStore = {
- quote?: Quotation;
- lines: QuotationLine[];
- assemblies: QuotationAssembly[];
- operations: QuotationOperation[];
- materials: QuotationMaterial[];
-};
-
-type Effect = (quantity: number) => number;
-
-export type LinePriceEffects = {
- materialCost: Effect[];
- laborCost: Effect[];
- overheadCost: Effect[];
- setupHours: Effect[];
- productionHours: Effect[];
-};
-
-const $quotationStore = atom<QuoteStore>({
- quote: undefined,
- lines: [],
- assemblies: [],
- operations: [],
- materials: [],
-});
-
-const $quotationLinePriceEffects = computed($quotationStore, (store) => {
- const assembliesByLineId = store.assemblies?.reduce<
- Record<string, QuotationAssembly[]>
- >((acc, assembly) => {
- if (!acc[assembly.quoteLineId]) {
- acc[assembly.quoteLineId] = [];
- }
- acc[assembly.quoteLineId].push(assembly);
- return acc;
- }, {});
-
- const operationsByLineId = store.operations?.reduce<
- Record<string, QuotationOperation[]>
- >((acc, operation) => {
- if (!acc[operation.quoteLineId]) {
- acc[operation.quoteLineId] = [];
- }
- acc[operation.quoteLineId].push(operation);
- return acc;
- }, {});
-
- let materialsByOperationId = store.materials?.reduce<
- Record<string, QuotationMaterial[]>
- >((acc, material) => {
- if (!acc[material.quoteOperationId]) {
- acc[material.quoteOperationId] = [];
- }
- acc[material.quoteOperationId].push(material);
- return acc;
- }, {});
-
- const linePriceEffects = store?.lines
- ?.filter((line) => line.replenishmentSystem === "Make")
- .reduce<Record<string, LinePriceEffects>>((effects, line) => {
- if (!line.id) return effects;
- effects[line.id] = {
- materialCost: [],
- laborCost: [],
- overheadCost: [],
- setupHours: [],
- productionHours: [],
- };
-
- let assembliesById = assembliesByLineId[line.id]?.reduce<
- Record<string, QuotationAssembly>
- >((acc, assembly) => {
- acc[assembly.id] = assembly;
- return acc;
- }, {});
-
- const extendedQuantitiesPerAssembly = assembliesByLineId[line.id]?.reduce<
- Record<string, number>
- >((acc, assembly: QuotationAssembly) => {
- let quantity = assembly.quantityPerParent ?? 1;
- let asm = assembliesById[assembly.id];
- while (asm.parentAssemblyId) {
- // memoize the results
- if (acc[asm.parentAssemblyId]) {
- quantity *= acc[asm.parentAssemblyId];
- break;
- }
-
- let parent = assembliesById[asm.parentAssemblyId];
- quantity *= parent.quantityPerParent ?? 1;
- asm = parent;
- }
-
- acc[assembly.id] = quantity;
- return acc;
- }, {});
-
- operationsByLineId[line.id]?.forEach((operation: QuotationOperation) => {
- let materials = materialsByOperationId[operation.id] ?? [];
- let extendedQuantityPerAssembly = operation.quoteAssemblyId
- ? extendedQuantitiesPerAssembly[operation.quoteAssemblyId] ?? 1
- : 1;
-
- let materialCost = materials.reduce(
- (acc, material: QuotationMaterial) => {
- return acc + (material.quantity ?? 0) * (material.unitCost ?? 0);
- },
- 0
- );
-
- effects[line.id!].materialCost.push((quantity) => {
- return materialCost * quantity * extendedQuantityPerAssembly;
- });
-
- if (operation.setupHours) {
- effects[line.id!].setupHours.push((_quantity) => {
- return operation.setupHours;
- });
- if (operation.quotingRate) {
- effects[line.id!].overheadCost.push((_quantity) => {
- return operation.setupHours * (operation.quotingRate ?? 0);
- });
- } else {
- effects[line.id!].laborCost.push((_quantity) => {
- return operation.setupHours * (operation.laborRate ?? 0);
- });
- effects[line.id!].overheadCost.push((_quantity) => {
- return operation.setupHours * (operation.overheadRate ?? 0);
- });
- }
- }
-
- if (operation.productionStandard) {
- let hoursPerProductionStandard = 0;
- switch (operation.standardFactor) {
- case "Total Hours":
- case "Hours/Piece":
- hoursPerProductionStandard = operation.productionStandard;
- break;
- case "Hours/100 Pieces":
- hoursPerProductionStandard = operation.productionStandard / 100;
- break;
- case "Hours/1000 Pieces":
- hoursPerProductionStandard = operation.productionStandard / 1000;
- break;
- case "Total Minutes":
- case "Minutes/Piece":
- hoursPerProductionStandard = operation.productionStandard / 60;
- break;
- case "Minutes/100 Pieces":
- hoursPerProductionStandard =
- operation.productionStandard / 100 / 60;
- break;
- case "Minutes/1000 Pieces":
- hoursPerProductionStandard =
- operation.productionStandard / 1000 / 60;
- break;
- case "Pieces/Hour":
- hoursPerProductionStandard = 1 / operation.productionStandard;
- break;
- case "Pieces/Minute":
- hoursPerProductionStandard =
- 1 / (operation.productionStandard / 60);
- break;
- case "Seconds/Piece":
- hoursPerProductionStandard = operation.productionStandard / 3600;
- break;
- default:
- break;
- }
-
- effects[line.id!].productionHours.push((quantity) => {
- return (
- hoursPerProductionStandard *
- quantity *
- extendedQuantityPerAssembly
- );
- });
- if (operation.quotingRate) {
- effects[line.id!].overheadCost.push((quantity) => {
- return (
- hoursPerProductionStandard *
- quantity *
- extendedQuantityPerAssembly *
- (operation.quotingRate ?? 0)
- );
- });
- } else {
- effects[line.id!].laborCost.push((quantity) => {
- return (
- hoursPerProductionStandard *
- quantity *
- extendedQuantityPerAssembly *
- (operation.laborRate ?? 0)
- );
- });
- effects[line.id!].overheadCost.push((quantity) => {
- return (
- hoursPerProductionStandard *
- quantity *
- extendedQuantityPerAssembly *
- (operation.overheadRate ?? 0)
- );
- });
- }
- }
- });
- return effects;
- }, {});
-
- return {
- quoteId: store.quote?.id ?? "",
- effects: linePriceEffects,
- };
-});
-
-export function getLinePriceUpdate(
- quantity: number,
- effects: LinePriceEffects
-) {
- const materialCost = effects?.materialCost.reduce(
- (acc, effect) => acc + effect(quantity),
- 0
- );
-
- const laborCost = effects?.laborCost.reduce(
- (acc, effect) => acc + effect(quantity),
- 0
- );
-
- const overheadCost = effects?.overheadCost.reduce(
- (acc, effect) => acc + effect(quantity),
- 0
- );
-
- const setupHours = effects?.setupHours.reduce(
- (acc, effect) => acc + effect(quantity),
- 0
- );
-
- const productionHours = effects?.productionHours.reduce(
- (acc, effect) => acc + effect(quantity),
- 0
- );
-
- return {
- materialCost,
- laborCost,
- overheadCost,
- outsideCost: 0,
- setupHours,
- productionHours,
- };
-}
-
-export const useQuotation = () => useNanoStore<QuoteStore>($quotationStore);
-export const useQuotationLinePriceEffects = () =>
- useValue($quotationLinePriceEffects);
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteStatus.tsx
similarity index 80%
rename from apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx
rename to apps/carbon/app/modules/sales/ui/Quotes/QuoteStatus.tsx
index 85f17e8024..0d5e4089be 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteStatus.tsx
@@ -1,11 +1,11 @@
import { Status } from "@carbon/react";
import type { quoteStatusType } from "~/modules/sales";
-type QuotationStatusProps = {
+type QuoteStatusProps = {
status?: (typeof quoteStatusType)[number] | null;
};
-const QuotationStatus = ({ status }: QuotationStatusProps) => {
+const QuoteStatus = ({ status }: QuoteStatusProps) => {
switch (status) {
case "Draft":
return <Status color="gray">{status}</Status>;
@@ -22,4 +22,4 @@ const QuotationStatus = ({ status }: QuotationStatusProps) => {
}
};
-export default QuotationStatus;
+export default QuoteStatus;
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
index 7662550014..d81f1b7d8f 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
@@ -23,10 +23,10 @@ import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Quotation } from "~/modules/sales";
import { quoteStatusType } from "~/modules/sales";
-import { useCustomers, useItems, usePeople } from "~/stores";
+import { useCustomers, usePeople } from "~/stores";
import { favoriteSchema } from "~/types/validators";
import { path } from "~/utils/path";
-import { QuotationStatus } from "../Quotation";
+import QuoteStatus from "./QuoteStatus";
type QuotesTableProps = {
data: Quotation[];
@@ -43,7 +43,6 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
const deleteQuotationModal = useDisclosure();
const [customers] = useCustomers();
- const [items] = useItems();
const [people] = usePeople();
const fetcher = useFetcher<{}>();
@@ -148,14 +147,14 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
header: "Status",
cell: (item) => {
const status = item.getValue<(typeof quoteStatusType)[number]>();
- return <QuotationStatus status={status} />;
+ return <QuoteStatus status={status} />;
},
meta: {
filter: {
type: "static",
options: quoteStatusType.map((status) => ({
value: status,
- label: <QuotationStatus status={status} />,
+ label: <QuoteStatus status={status} />,
})),
},
pluralHeader: "Statuses",
diff --git a/apps/carbon/app/modules/sales/ui/index.ts b/apps/carbon/app/modules/sales/ui/index.ts
index 520433841c..04f82d5932 100644
--- a/apps/carbon/app/modules/sales/ui/index.ts
+++ b/apps/carbon/app/modules/sales/ui/index.ts
@@ -3,7 +3,6 @@ export * from "./Customer";
export * from "./Customers";
export * from "./CustomerStatuses";
export * from "./CustomerTypes";
-export * from "./Quotation";
export * from "./Quotes";
export * from "./SalesOrder";
export * from "./SalesOrders";
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index d14c55459b..9eae21ee01 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -231,14 +231,6 @@ export const path = {
deletePurchaseOrderLine: (orderId: string, lineId: string) =>
generatePath(`${x}/purchase-order/${orderId}/lines/delete/${lineId}`),
deleteQuote: (id: string) => generatePath(`${x}/quote/delete/${id}`),
- deleteQuoteAssemblyDeprecated: (
- quoteId: string,
- lineId: string,
- assemblyId: string
- ) =>
- generatePath(
- `${x}/quote/${quoteId}/lines/${lineId}/assembly/${assemblyId}/delete`
- ),
deleteQuoteLine: (id: string, lineId: string) =>
generatePath(`${x}/quote/${id}/${lineId}/delete`),
deleteQuoteMaterial: (quoteId: string, lineId: string, id: string) =>
@@ -443,25 +435,11 @@ export const path = {
newPurchaseOrderLine: (id: string) =>
generatePath(`${x}/purchase-order/${id}/lines/new`),
newQuote: `${x}/quote/new`,
- newQuoteAssembly: (quoteId: string, lineId: string, parentId?: string) =>
- generatePath(
- `${x}/quote/${quoteId}/lines/${lineId}/assembly/new${
- parentId ? `?parentAssemblyId=${parentId}` : ""
- }`
- ),
newQuoteLine: (id: string) => generatePath(`${x}/quote/${id}/new`),
newQuoteLineQuantity: (id: string, lineId: string) =>
generatePath(`${x}/quote/${id}/lines/${lineId}/new`),
newQuoteOperation: (quoteId: string, lineId: string) =>
generatePath(`${x}/quote/methods/${quoteId}/${lineId}/operation/new`),
- newQuoteMaterialDeprecated: (
- quoteId: string,
- lineId: string,
- operationId: string
- ) =>
- generatePath(
- `${x}/quote/${quoteId}/lines/${lineId}/operation/${operationId}/material/new`
- ),
newQuoteMaterial: (quoteId: string, lineId: string) =>
generatePath(`${x}/quote/methods/${quoteId}/${lineId}/material/new`),
newReceipt: `${x}/receipt/new`,
@@ -576,24 +554,6 @@ export const path = {
generatePath(`${x}/quote/${id}/internal`),
quoteLine: (quoteId: string, id: string) =>
generatePath(`${x}/quote/${quoteId}/${id}/details`),
- quoteMaterialDeprecated: (
- quoteId: string,
- lineId: string,
- operationId: string,
- materialId: string
- ) =>
- generatePath(
- `${x}/quote/${quoteId}/lines/${lineId}/operation/${operationId}/material/${materialId}`
- ),
- quoteLineMaterialDeprecated: (
- quoteId: string,
- lineId: string,
- makeMethodId: string,
- methodMaterialId: string
- ) =>
- generatePath(
- `${x}/quote/${quoteId}/${lineId}/${makeMethodId}/${methodMaterialId}`
- ),
quoteLineMaterial: (
quoteId: string,
lineId: string,