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: model uploads

Brad Barbinc365b6cb9222
diff --git a/apps/carbon/app/components/Search/Search/Search.tsx b/apps/carbon/app/components/Search/Search/Search.tsx
index 6c03ea50d9..48b4f441d1 100644
--- a/apps/carbon/app/components/Search/Search/Search.tsx
+++ b/apps/carbon/app/components/Search/Search/Search.tsx
@@ -162,7 +162,7 @@ const SearchModal = ({
if (!open) onClose();
}}
>
- <ModalContent className="rounded-lg translate-y-0 p-0">
+ <ModalContent className="rounded-lg translate-y-0 p-0 h-[343px]">
<Command className="rounded-lg border shadow-md">
<CommandInput
placeholder="Type a command or search..."
diff --git a/apps/carbon/app/components/TreeView/TreeView.tsx b/apps/carbon/app/components/TreeView/TreeView.tsx
index b283dda6c5..d68c3059f3 100644
--- a/apps/carbon/app/components/TreeView/TreeView.tsx
+++ b/apps/carbon/app/components/TreeView/TreeView.tsx
@@ -16,7 +16,7 @@ export type TreeViewProps<TData> = {
state: NodeState;
index: number;
virtualizer: Virtualizer<HTMLElement, Element>;
- virtualItem: VirtualItem;
+ virtualItem: VirtualItem<HTMLElement>;
}) => React.ReactNode;
nodes: UseTreeStateOutput["nodes"];
autoFocus?: boolean;
diff --git a/apps/carbon/app/jobs.server/autodesk-poll.server.ts b/apps/carbon/app/jobs.server/autodesk-poll.server.ts
index dc753cb243..60e9c72c3c 100644
--- a/apps/carbon/app/jobs.server/autodesk-poll.server.ts
+++ b/apps/carbon/app/jobs.server/autodesk-poll.server.ts
@@ -19,10 +19,11 @@ const job = triggerClient.defineJob({
name: z.string(),
size: z.number(),
autodeskUrn: z.string(),
+ companyId: z.string(),
}),
}),
run: async (payload, io, ctx) => {
- const { id, name, size, autodeskUrn } = payload;
+ const { companyId, id, name, size, autodeskUrn } = payload;
await io.runTask(
"autodesk-manifest-poll",
@@ -34,7 +35,11 @@ const job = triggerClient.defineJob({
);
}
- const manifest = await getManifest(autodeskUrn, token.data.token);
+ const manifest = await getManifest(
+ autodeskUrn,
+ token.data.token,
+ companyId
+ );
if (manifest.error) {
throw new Error("Failed to get manifest: " + manifest.error.message);
}
@@ -43,6 +48,7 @@ const job = triggerClient.defineJob({
id,
name,
size,
+ thumbnailPath: manifest.data.thumbnailPath,
autodeskUrn,
});
diff --git a/apps/carbon/app/jobs.server/autodesk-upload.server.ts b/apps/carbon/app/jobs.server/autodesk-upload.server.ts
index 922bc137a4..0a60737da9 100644
--- a/apps/carbon/app/jobs.server/autodesk-upload.server.ts
+++ b/apps/carbon/app/jobs.server/autodesk-upload.server.ts
@@ -23,10 +23,22 @@ const job = triggerClient.defineJob({
name: z.string(),
modelPath: z.string(),
fileId: z.string(),
+ companyId: z.string(),
+ itemId: z.union([z.string(), z.null()]),
+ salesRfqLineId: z.union([z.string(), z.null()]),
+ quoteLineId: z.union([z.string(), z.null()]),
}),
}),
run: async (payload, io, ctx) => {
- const { modelPath, fileId, name } = payload;
+ const {
+ companyId,
+ modelPath,
+ fileId,
+ name,
+ itemId,
+ salesRfqLineId,
+ quoteLineId,
+ } = payload;
const autodeskToken = await getAutodeskToken();
if (autodeskToken.error) {
@@ -73,6 +85,26 @@ const job = triggerClient.defineJob({
throw new Error("Failed to translate file: " + translation.error.message);
}
+ const client = getSupabaseServiceRole();
+ if (itemId) {
+ await client
+ .from("item")
+ .update({ modelUploadId: fileId })
+ .eq("id", itemId);
+ }
+ if (salesRfqLineId) {
+ await client
+ .from("salesRfqLine")
+ .update({ modelUploadId: fileId })
+ .eq("id", salesRfqLineId);
+ }
+ if (quoteLineId) {
+ await client
+ .from("quoteLine")
+ .update({ modelUploadId: fileId })
+ .eq("id", quoteLineId);
+ }
+
const event = await triggerClient.sendEvent({
name: "autodesk.poll",
payload: {
@@ -80,6 +112,7 @@ const job = triggerClient.defineJob({
size: file.size,
name,
autodeskUrn,
+ companyId,
},
});
diff --git a/apps/carbon/app/jobs.server/send-email-resend.server.ts b/apps/carbon/app/jobs.server/send-email-resend.server.ts
index 4747d21463..4b7e3e61b7 100644
--- a/apps/carbon/app/jobs.server/send-email-resend.server.ts
+++ b/apps/carbon/app/jobs.server/send-email-resend.server.ts
@@ -40,6 +40,7 @@ const job = triggerClient.defineJob({
.eq("id", "resend")
.maybeSingle();
+ // TODO: integration should include from email
const integrationMetadata = resendFormValidator.safeParse(
integration?.data?.metadata
);
diff --git a/apps/carbon/app/lib/autodesk/autodesk.server.ts b/apps/carbon/app/lib/autodesk/autodesk.server.ts
index ea56f6319a..fd1e659488 100644
--- a/apps/carbon/app/lib/autodesk/autodesk.server.ts
+++ b/apps/carbon/app/lib/autodesk/autodesk.server.ts
@@ -7,6 +7,8 @@ import {
AUTODESK_CLIENT_ID,
AUTODESK_CLIENT_SECRET,
} from "~/config/env";
+import logger from "../logger";
+import { getSupabaseServiceRole } from "../supabase";
import type { AutodeskTokenResponse } from "./types";
const SIGNED_URL_EXPIRATION = 15;
@@ -27,6 +29,11 @@ const autodeskAPI = {
`https://developer.api.autodesk.com/oss/v2/buckets/${bucketName}/objects/${filename}/signeds3upload?minutesExpiration=${SIGNED_URL_EXPIRATION}`,
method: "GET",
},
+ getThumbnail: {
+ url: (urn: string) =>
+ `https://developer.api.autodesk.com/modelderivative/v2/designdata/${urn}/thumbnail?width=400&height=400`,
+ method: "GET",
+ },
getToken: {
url: "https://developer.api.autodesk.com/authentication/v2/token",
method: "POST",
@@ -224,12 +231,17 @@ export async function getAutodeskToken(refresh = false, scope?: string) {
}
}
-export async function getManifest(urn: string, token: string) {
+export async function getManifest(
+ urn: string,
+ token: string,
+ companyId: string
+) {
// poll the manifest endpoint for 30s until we get a response with progress === "complete"
let response;
let progress = "inprogress";
let tries = 0;
+ let thumbnailPath = "";
while (progress !== "complete" && tries < 100) {
try {
@@ -242,8 +254,17 @@ export async function getManifest(urn: string, token: string) {
});
const data = await response.json();
- // TODO: there are thumbnails here that we want to return
+
progress = data.progress;
+ if (progress === "complete") {
+ const thumbnail = await getThumbnail(urn, token, companyId);
+
+ if (thumbnail.data) {
+ thumbnailPath = thumbnail.data;
+ } else {
+ logger.error("Failed to get thumbnail for model", { urn });
+ }
+ }
} catch (err) {
const message = (err as Error).message || "Something went wrong";
console.error(message, err);
@@ -269,11 +290,71 @@ export async function getManifest(urn: string, token: string) {
}
return {
- data: { urn },
+ data: { urn, thumbnailPath },
error: null,
};
}
+export async function getThumbnail(
+ urn: string,
+ token: string,
+ companyId: string
+) {
+ const supabase = getSupabaseServiceRole();
+ const url = autodeskAPI.getThumbnail.url(urn);
+
+ let response;
+ try {
+ response = await fetch(url, {
+ method: autodeskAPI.getThumbnail.method,
+ cache: "no-store",
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ if (response.ok && response.status === 200) {
+ // the response is a binary stream of the thumbnail
+ // of type image/png
+ // we convert it to an ArrayBuffer and then upload it
+ // to supabase storage
+ const data = await response.arrayBuffer();
+ const fileName = `${companyId}/models/${urn}.png`;
+
+ const fileUpload = await supabase.storage
+ .from("private")
+ .upload(fileName, data, {
+ cacheControl: `${365 * 24 * 60 * 60}`,
+ });
+
+ if (fileUpload.error) {
+ return {
+ data: null,
+ error: {
+ message: "Failed to upload thumbnail",
+ },
+ };
+ }
+
+ return {
+ data: fileName,
+ error: null,
+ };
+ }
+
+ return { data: null, error: { message: "Failed to fetch thumbnail" } };
+ } catch (err) {
+ const message = (err as Error).message || "Something went wrong.";
+
+ return {
+ data: null,
+ error: {
+ message,
+ },
+ };
+ }
+}
+
export async function getTranslationStatus(urn: string, token: string) {
const url = autodeskAPI.getTranslationStatus.url(urn);
@@ -313,6 +394,13 @@ export async function translateFile(urn: string, token: string) {
type: "svf2",
views: ["3d"],
},
+ {
+ type: "thumbnail",
+ advanced: {
+ height: 400,
+ width: 400,
+ },
+ },
],
},
};
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index a9dd55b541..5b88e7f72f 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -878,19 +878,6 @@ export async function getUnitOfMeasuresList(
.order("name");
}
-export async function getModelUploadByItemId(
- client: SupabaseClient<Database>,
- itemId: string,
- companyId: string
-) {
- return client
- .from("modelUpload")
- .select("*")
- .eq("itemId", itemId)
- .eq("companyId", companyId)
- .maybeSingle();
-}
-
export async function getModelUploadByUrn(
client: SupabaseClient<Database>,
urn: string,
@@ -898,7 +885,7 @@ export async function getModelUploadByUrn(
) {
return client
.from("modelUpload")
- .select("id")
+ .select("*")
.eq("companyId", companyId)
.eq("autodeskUrn", urn)
.single();
diff --git a/apps/carbon/app/modules/items/types.ts b/apps/carbon/app/modules/items/types.ts
index 6e8064a527..52fa5b0e8b 100644
--- a/apps/carbon/app/modules/items/types.ts
+++ b/apps/carbon/app/modules/items/types.ts
@@ -16,7 +16,6 @@ import type {
getMethodMaterials,
getMethodOperations,
getMethodTreeArray,
- getModelUploadByItemId,
getPart,
getParts,
getPickMethods,
@@ -98,9 +97,14 @@ export type MethodOperation = NonNullable<
export type MethodType = (typeof methodType)[number];
-export type ModelUpload = NonNullable<
- Awaited<ReturnType<typeof getModelUploadByItemId>>
->["data"];
+export type ModelUpload = {
+ modelId: string | null;
+ modelName: string | null;
+ modelPath: string | null;
+ modelSize: number | null;
+ thumbnailPath: string | null;
+ autodeskUrn: string | null;
+};
export type Part = NonNullable<
Awaited<ReturnType<typeof getParts>>["data"]
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
index 3536c48faa..0884bf7f2e 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
@@ -19,13 +19,7 @@ import {
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
-import type {
- BuyMethod,
- Fixture,
- ItemFile,
- ModelUpload,
- PickMethod,
-} from "../../types";
+import type { BuyMethod, Fixture, ItemFile, PickMethod } from "../../types";
import { FileBadge, MethodIcon, TrackingTypeIcon } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
@@ -39,7 +33,6 @@ const FixtureProperties = () => {
const routeData = useRouteData<{
fixtureSummary: Fixture;
files: ItemFile[];
- modelUpload?: ModelUpload;
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.fixture(itemId));
@@ -109,6 +102,13 @@ const FixtureProperties = () => {
</HStack>
</HStack>
<span className="text-sm">{routeData?.fixtureSummary?.name}</span>
+ {routeData?.fixtureSummary?.thumbnailPath && (
+ <img
+ alt="thumbnail"
+ src={`/file/preview/private/${routeData.fixtureSummary.thumbnailPath}`}
+ className="w-full h-auto bg-gradient-to-bl from-muted to-muted/40 rounded-lg border border-border"
+ />
+ )}
</VStack>
<VStack spacing={2}>
<h3 className="text-xs text-muted-foreground">Assignee</h3>
@@ -200,7 +200,7 @@ const FixtureProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Files</h3>
</HStack>
- {routeData?.modelUpload?.autodeskUrn && (
+ {routeData?.fixtureSummary?.autodeskUrn && (
<HStack className="group" spacing={1}>
<Badge variant="secondary">
<LuMove3D className="w-3 h-3 mr-1 text-green-500" />
@@ -208,7 +208,7 @@ const FixtureProperties = () => {
</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?.modelUpload.autodeskUrn!)}
+ to={path.to.file.cadModel(routeData?.fixtureSummary.autodeskUrn!)}
target="_blank"
>
<LuExternalLink />
diff --git a/apps/carbon/app/modules/items/ui/Item/CadModel.tsx b/apps/carbon/app/modules/items/ui/Item/CadModel.tsx
index e1219bd7e4..fcdb6fefa5 100644
--- a/apps/carbon/app/modules/items/ui/Item/CadModel.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/CadModel.tsx
@@ -14,6 +14,7 @@ type CadModelProps = {
metadata?: {
itemId?: string;
salesRfqLineId?: string;
+ quoteLineId?: string;
};
title?: string;
uploadClassName?: string;
@@ -28,6 +29,7 @@ const CadModel = ({
uploadClassName,
viewerClassName,
}: CadModelProps) => {
+ console.log({ modelPath });
useRealtime("modelUpload", `modelPath=eq.${modelPath ?? "unknown"}`);
const {
@@ -68,9 +70,15 @@ const CadModel = ({
formData.append("fileId", fileId);
formData.append("modelPath", modelUpload.data!.path);
if (metadata) {
- if (metadata.itemId) formData.append("itemId", metadata.itemId);
- if (metadata.salesRfqLineId)
+ if (metadata.itemId) {
+ formData.append("itemId", metadata.itemId);
+ }
+ if (metadata.salesRfqLineId) {
formData.append("salesRfqLineId", metadata.salesRfqLineId);
+ }
+ if (metadata.quoteLineId) {
+ formData.append("quoteLineId", metadata.quoteLineId);
+ }
}
fetcher.submit(formData, {
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx b/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx
index 5b71d05c97..c2becdf909 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx
@@ -65,7 +65,7 @@ const ItemDocuments = ({
</Tr>
</Thead>
<Tbody>
- {modelUpload && (
+ {modelUpload?.autodeskUrn && (
<Tr>
<Td>
<HStack>
@@ -75,15 +75,15 @@ const ItemDocuments = ({
onClick={() => viewModel(modelUpload)}
>
{modelUpload?.autodeskUrn
- ? modelUpload.name
+ ? modelUpload.modelName
: "Uploading..."}
</Hyperlink>
</HStack>
</Td>
<Td>
- {modelUpload.size
+ {modelUpload.modelSize
? convertKbToString(
- Math.floor((modelUpload.size ?? 0) / 1024)
+ Math.floor((modelUpload.modelSize ?? 0) / 1024)
)
: "--"}
</Td>
@@ -105,7 +105,7 @@ const ItemDocuments = ({
</DropdownMenuItem>
<DropdownMenuItem
disabled={!canDelete}
- onClick={() => deleteModel(modelUpload)}
+ onClick={() => deleteModel()}
>
Delete
</DropdownMenuItem>
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemDocuments/useItemDocuments.ts b/apps/carbon/app/modules/items/ui/Item/ItemDocuments/useItemDocuments.ts
index 0b0345d39d..4c0e975a8d 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemDocuments/useItemDocuments.ts
+++ b/apps/carbon/app/modules/items/ui/Item/ItemDocuments/useItemDocuments.ts
@@ -1,9 +1,10 @@
import { toast } from "@carbon/react";
import { useNavigate, useRevalidator } from "@remix-run/react";
+import type { FileObject } from "@supabase/storage-js";
import { useCallback } from "react";
import { usePermissions, useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
-import type { ItemFile, ModelUpload } from "~/modules/items";
+import type { ModelUpload } from "~/modules/items";
import { path } from "~/utils/path";
type Props = {
@@ -19,14 +20,14 @@ export const useItemDocuments = ({ itemId }: Props) => {
const canDelete = permissions.can("delete", "parts");
const getPath = useCallback(
- (file: ItemFile) => {
+ (file: FileObject) => {
return `${company.id}/parts/${itemId}/${file.name}`;
},
[company.id, itemId]
);
const deleteFile = useCallback(
- async (file: ItemFile) => {
+ async (file: FileObject) => {
const fileDelete = await supabase?.storage
.from("private")
.remove([getPath(file)]);
@@ -42,40 +43,23 @@ export const useItemDocuments = ({ itemId }: Props) => {
[getPath, supabase?.storage, revalidator]
);
- const deleteModel = useCallback(
- async (model: ModelUpload) => {
- if (!model || !supabase) return;
-
- // TODO: delete from Autodesk server
-
- if (model.modelPath) {
- const fileDelete = await supabase?.storage
- .from("private")
- .remove([model?.modelPath]);
-
- if (!fileDelete || fileDelete.error) {
- toast.error(fileDelete?.error?.message || "Error deleting file");
- return;
- }
- }
-
- const modelDelete = await supabase
- ?.from("modelUpload")
- .delete()
- .eq("id", model.id);
- if (modelDelete.error) {
- toast.error(modelDelete.error.message);
- return;
- }
-
- toast.success("File deleted successfully");
- revalidator.revalidate();
- },
- [supabase, revalidator]
- );
+ const deleteModel = useCallback(async () => {
+ if (!supabase) return;
+
+ const { error } = await supabase
+ .from("item")
+ .update({ modelUploadId: null })
+ .eq("id", itemId);
+ if (error) {
+ toast.error("Error removing model from item");
+ return;
+ }
+ toast.success("Model removed from item");
+ revalidator.revalidate();
+ }, [supabase, itemId, revalidator]);
const download = useCallback(
- async (file: ItemFile) => {
+ async (file: FileObject) => {
const result = await supabase?.storage
.from("private")
.download(getPath(file));
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
index ead965061e..c47508ae74 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
@@ -16,13 +16,7 @@ import Assignee from "~/components/Assignee";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
-import type {
- BuyMethod,
- ItemFile,
- ModelUpload,
- PartSummary,
- PickMethod,
-} from "../../types";
+import type { BuyMethod, ItemFile, PartSummary, PickMethod } from "../../types";
import { FileBadge } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
import { MethodIcon, TrackingTypeIcon } from "../Item/MethodIcon";
@@ -37,7 +31,6 @@ const PartProperties = () => {
const routeData = useRouteData<{
partSummary: PartSummary;
files: ItemFile[];
- modelUpload?: ModelUpload;
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.part(itemId));
@@ -107,6 +100,13 @@ const PartProperties = () => {
</HStack>
</HStack>
<span className="text-sm">{routeData?.partSummary?.name}</span>
+ {routeData?.partSummary?.thumbnailPath && (
+ <img
+ alt="thumbnail"
+ src={`/file/preview/private/${routeData.partSummary.thumbnailPath}`}
+ className="w-full h-auto bg-gradient-to-bl from-muted to-muted/40 rounded-lg border border-border"
+ />
+ )}
</VStack>
<VStack spacing={2}>
@@ -195,7 +195,7 @@ const PartProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Files</h3>
</HStack>
- {routeData?.modelUpload?.autodeskUrn && (
+ {routeData?.partSummary?.autodeskUrn && (
<HStack className="group" spacing={1}>
<Badge variant="secondary">
<LuMove3D className="w-3 h-3 mr-1 text-green-500" />
@@ -203,7 +203,7 @@ const PartProperties = () => {
</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?.modelUpload.autodeskUrn!)}
+ to={path.to.file.cadModel(routeData?.partSummary.autodeskUrn!)}
target="_blank"
>
<LuExternalLink />
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index 7fbfaa7ba4..06dbe7ad72 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -66,8 +66,7 @@ export const quoteLineStatusType = [
export const quoteStatusType = [
"Draft",
- "Open",
- "Replied",
+ "Sent",
"Ordered",
"Partial",
"Lost",
@@ -75,6 +74,22 @@ export const quoteStatusType = [
"Expired",
] as const;
+export const quoteValidator = z.object({
+ id: zfd.text(z.string().optional()),
+ quoteId: zfd.text(z.string().optional()),
+ salesPersonId: zfd.text(z.string().optional()),
+ estimatorId: zfd.text(z.string().optional()),
+ 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: z.any().optional(),
+ dueDate: zfd.text(z.string().optional()),
+ expirationDate: zfd.text(z.string().optional()),
+});
+
export const quotationValidator = z.object({
id: zfd.text(z.string().optional()),
quoteId: zfd.text(z.string().optional()),
@@ -331,4 +346,5 @@ export const salesRfqLineValidator = z.object({
.string()
.min(1, { message: "Unit of measure is required" }),
order: zfd.numeric(z.number().min(0)),
+ modelUploadId: zfd.text(z.string().optional()),
});
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 4842d1f093..ec0cbc38ac 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -54,7 +54,6 @@ export async function convertQuoteToOrder(
.from("quote")
.update({
status: "Ordered",
- quoteDate: today(getLocalTimeZone()).toString(),
updatedAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
@@ -119,11 +118,11 @@ export async function deleteQuote(
return client.from("quote").delete().eq("id", quoteId);
}
-export async function deleteQuoteAssembly(
+export async function deleteQuoteMakeMethod(
client: SupabaseClient<Database>,
- quoteAssemblyId: string
+ quoteMakeMethodId: string
) {
- return client.from("quoteAssembly").delete().eq("id", quoteAssemblyId);
+ return client.from("quoteMakeMethod").delete().eq("id", quoteMakeMethodId);
}
export async function deleteQuoteLine(
@@ -390,21 +389,10 @@ export async function getFilesByRfqId(
.from("private")
.list(`${companyId}/sales-rfq/${rfqId}/${lineId}`)
);
- const [modelUploads, ...files] = await Promise.all([
- client
- .from("modelUpload")
- .select("*")
- .in("salesRfqLineId", lineIds ?? []),
- ...fileQueries,
- ]);
-
- if (modelUploads.error) {
- return modelUploads;
- }
+ const files = await Promise.all([...fileQueries]);
return {
data: {
- modelUploads: modelUploads.data,
files: files.reduce<(FileObject & { salesRfqLineId: string | null })[]>(
(acc, file, index) => {
if (file.data) {
@@ -456,14 +444,14 @@ export async function getQuotes(
return query;
}
-export async function getQuoteAssembly(
+export async function getQuoteMakeMethod(
client: SupabaseClient<Database>,
- quoteAssemblyId: string
+ quoteMakeMethodId: string
) {
return client
- .from("quoteAssembly")
+ .from("quoteMakeMethod")
.select("*")
- .eq("id", quoteAssemblyId)
+ .eq("id", quoteMakeMethodId)
.single();
}
@@ -472,7 +460,7 @@ export async function getQuoteAssembliesByLine(
quoteLineId: string
) {
return client
- .from("quoteAssembly")
+ .from("quoteMakeMethod")
.select("*")
.eq("quoteLineId", quoteLineId);
}
@@ -481,7 +469,7 @@ export async function getQuoteAssemblies(
client: SupabaseClient<Database>,
quoteId: string
) {
- return client.from("quoteAssembly").select("*").eq("quoteId", quoteId);
+ return client.from("quoteMakeMethod").select("*").eq("quoteId", quoteId);
}
export async function getQuoteExternalDocuments(
@@ -761,7 +749,7 @@ export async function getSalesRFQLines(
salesRfqId: string
) {
return client
- .from("salesRfqLine")
+ .from("salesRfqLines")
.select("*")
.eq("salesRfqId", salesRfqId)
.order("order", { ascending: true });
@@ -913,8 +901,7 @@ export async function releaseQuote(
const quoteUpdate = await client
.from("quote")
.update({
- status: "Open",
- quoteDate: today(getLocalTimeZone()).toString(),
+ status: "Sent",
updatedAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
@@ -1192,7 +1179,7 @@ export async function upsertQuote(
}
}
-export async function upsertQuoteAssembly(
+export async function upsertQuoteMakeMethod(
client: SupabaseClient<Database>,
quotationAssembly:
| (Omit<z.infer<typeof quotationAssemblyValidator>, "id"> & {
@@ -1212,14 +1199,14 @@ export async function upsertQuoteAssembly(
) {
if ("id" in quotationAssembly) {
return client
- .from("quoteAssembly")
+ .from("quoteMakeMethod")
.update(sanitize(quotationAssembly))
.eq("id", quotationAssembly.id)
.select("id")
.single();
}
return client
- .from("quoteAssembly")
+ .from("quoteMakeMethod")
.insert([quotationAssembly])
.select("id")
.single();
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx
index 13e5983da5..85f17e8024 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationStatus.tsx
@@ -9,9 +9,7 @@ const QuotationStatus = ({ status }: QuotationStatusProps) => {
switch (status) {
case "Draft":
return <Status color="gray">{status}</Status>;
- case "Open":
- case "Replied":
- return <Status color="blue">{status}</Status>;
+ case "Sent":
case "Ordered":
case "Partial":
return <Status color="green">{status}</Status>;
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
new file mode 100644
index 0000000000..27dd6afbf6
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
@@ -0,0 +1,165 @@
+import { Badge, HStack, VStack, cn } from "@carbon/react";
+import { useRef } from "react";
+import { LuChevronDown, LuChevronUp } from "react-icons/lu";
+import type { FlatTreeItem } from "~/components/TreeView/TreeView";
+import { TreeView, useTree } from "~/components/TreeView/TreeView";
+import type { Method } from "~/modules/items/types";
+import {
+ MethodIcon,
+ MethodItemTypeIcon,
+} from "~/modules/items/ui/Item/MethodIcon";
+
+type QuoteBoMExplorerProps = {
+ methods: FlatTreeItem<Method>[];
+};
+
+const QuoteBoMExplorer = ({ methods }: QuoteBoMExplorerProps) => {
+ const parentRef = useRef<HTMLDivElement>(null);
+
+ const {
+ nodes,
+ getTreeProps,
+ getNodeProps,
+ // toggleNodeSelection,
+ toggleExpandNode,
+ expandAllBelowDepth,
+ // toggleExpandLevel,
+ collapseAllBelowDepth,
+ selectNode,
+ scrollToNode,
+ virtualizer,
+ } = useTree({
+ tree: methods,
+ // selectedId,
+ // collapsedIds,
+ onSelectedIdChanged: () => {},
+ estimatedRowHeight: () => 32,
+ parentRef,
+ isEager: true,
+ });
+
+ return (
+ <VStack className="p-2">
+ <TreeView
+ parentRef={parentRef}
+ virtualizer={virtualizer}
+ autoFocus
+ tree={methods}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ renderNode={({ node, state }) => (
+ <div
+ key={node.id}
+ className={cn(
+ "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
+ state.selected
+ ? "bg-muted hover:bg-muted/90"
+ : "bg-transparent hover:bg-muted/90"
+ )}
+ onClick={() => {
+ selectNode(node.id);
+ alert("navigating to " + node.id);
+ }}
+ >
+ <div className="flex h-8 items-center">
+ {Array.from({ length: node.level }).map((_, index) => (
+ <TaskLine key={index} isSelected={state.selected} />
+ ))}
+ <div
+ className={cn(
+ "flex h-8 w-4 items-center",
+ node.hasChildren && "hover:bg-accent"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (e.altKey) {
+ if (state.expanded) {
+ collapseAllBelowDepth(node.level);
+ } else {
+ expandAllBelowDepth(node.level);
+ }
+ } else {
+ toggleExpandNode(node.id);
+ }
+ scrollToNode(node.id);
+ }}
+ >
+ {node.hasChildren ? (
+ state.expanded ? (
+ <LuChevronDown className="h-4 w-4 text-gray-400" />
+ ) : (
+ <LuChevronUp className="h-4 w-4 text-gray-400" />
+ )
+ ) : (
+ <div className="h-8 w-4" />
+ )}
+ </div>
+ </div>
+
+ <div className="flex w-full items-center justify-between gap-2">
+ <div
+ className={cn(
+ "flex items-center gap-2 overflow-x-hidden",
+ node.level > 1 && "opacity-50"
+ )}
+ >
+ <MethodIcon
+ type={
+ // node.data.isRoot ? "Method" :
+ node.data.methodType
+ }
+ className="h-4 min-h-4 w-4 min-w-4 flex-shrink-0"
+ />
+ <NodeText node={node} />
+ </div>
+ <div className="flex items-center gap-1">
+ {node.data.isRoot ? (
+ <Badge variant="outline" className="text-xs">
+ Method
+ </Badge>
+ ) : (
+ <NodeData node={node} />
+ )}
+ </div>
+ </div>
+ </div>
+ )}
+ />
+ </VStack>
+ );
+};
+
+export default QuoteBoMExplorer;
+
+function NodeText({ node }: { node: FlatTreeItem<Method> }) {
+ return (
+ <div className="flex items-center gap-1">
+ <span className="text-sm font-mono">{node.data.itemReadableId}</span>
+ </div>
+ );
+}
+
+function NodeData({ node }: { node: FlatTreeItem<Method> }) {
+ return (
+ <HStack spacing={1}>
+ <Badge className="text-xs" variant="outline">
+ {node.data.quantity}
+ </Badge>
+ <Badge variant="secondary">
+ <MethodItemTypeIcon type={node.data.itemType} />
+ </Badge>
+ </HStack>
+ );
+}
+
+function TaskLine({ isSelected }: { isSelected: boolean }) {
+ return (
+ <div
+ className={cn(
+ "h-8 w-2 border-r border-border",
+ isSelected && "border-foreground/30"
+ )}
+ />
+ );
+}
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/QuoteDocumentForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/QuoteDocumentForm.tsx
new file mode 100644
index 0000000000..e49b3bcc9a
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/QuoteDocumentForm.tsx
@@ -0,0 +1,76 @@
+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 QuoteDocumentFormProps = {
+ id: string;
+ isExternal: boolean;
+};
+
+const QuoteDocumentForm = ({ id, isExternal }: QuoteDocumentFormProps) => {
+ 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 QuoteDocumentForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/QuoteDocuments.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/QuoteDocuments.tsx
new file mode 100644
index 0000000000..ed6699b6ab
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/QuoteDocuments.tsx
@@ -0,0 +1,144 @@
+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 QuoteDocumentForm from "./QuoteDocumentForm";
+import { useQuoteDocuments } from "./useQuoteDocuments";
+
+type QuoteDocumentsProps = {
+ attachments: QuotationAttachment[];
+ isExternal: boolean;
+ id: string;
+};
+
+const QuoteDocuments = ({
+ attachments,
+ isExternal,
+ id,
+}: QuoteDocumentsProps) => {
+ const { canDelete, download, deleteAttachment, getPath } = useQuoteDocuments({
+ isExternal,
+ id,
+ });
+
+ return (
+ <>
+ <Card>
+ <HStack className="justify-between items-start">
+ <CardHeader>
+ <CardTitle>Documents</CardTitle>
+ </CardHeader>
+ <CardAction>
+ <QuoteDocumentForm 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 QuoteDocuments;
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/index.ts b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/index.ts
new file mode 100644
index 0000000000..535d266182
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/index.ts
@@ -0,0 +1,3 @@
+import QuoteDocuments from "./QuoteDocuments";
+
+export default QuoteDocuments;
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/useQuoteDocuments.ts b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/useQuoteDocuments.ts
new file mode 100644
index 0000000000..b43c02986b
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteDocuments/useQuoteDocuments.ts
@@ -0,0 +1,84 @@
+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 useQuoteDocuments = ({ 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/Quotes/QuoteForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
new file mode 100644
index 0000000000..7f48be2f4d
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
@@ -0,0 +1,129 @@
+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,
+ DatePicker,
+ Employee,
+ Hidden,
+ Input,
+ Location,
+ Select,
+ Submit,
+} from "~/components/Form";
+import { usePermissions } from "~/hooks";
+import { quoteStatusType, quoteValidator } from "~/modules/sales";
+
+type QuoteFormValues = z.infer<typeof quoteValidator>;
+
+type QuoteFormProps = {
+ initialValues: QuoteFormValues;
+};
+
+const QuoteForm = ({ initialValues }: QuoteFormProps) => {
+ const permissions = usePermissions();
+ const [customer, setCustomer] = useState<string | undefined>(
+ initialValues.customerId
+ );
+ const isEditing = initialValues.id !== undefined;
+ const isCustomer = permissions.is("customer");
+
+ const statusOptions = quoteStatusType.map((status) => ({
+ label: status,
+ value: status,
+ }));
+
+ return (
+ <Card>
+ <ValidatedForm
+ method="post"
+ validator={quoteValidator}
+ defaultValues={initialValues}
+ >
+ <CardHeader>
+ <CardTitle>{isEditing ? "Quote" : "New Quote"}</CardTitle>
+ {!isEditing && (
+ <CardDescription>
+ A quote is a set of prices for specific parts and quantities.
+ </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={(newValue) =>
+ setCustomer(newValue?.value as string | undefined)
+ }
+ />
+ <CustomerContact
+ name="customerContactId"
+ label="Customer Contact"
+ customer={customer}
+ />
+ <Input name="customerReference" label="Customer Ref. Number" />
+ <Employee name="salesPersonId" label="Sales Person" />
+ <Employee name="estimatorId" label="Estimator" />
+ <Location name="locationId" label="Location" />
+
+ <DatePicker
+ name="dueDate"
+ label="Due Date"
+ isDisabled={isCustomer}
+ />
+ <DatePicker
+ name="expirationDate"
+ label="Expiration Date"
+ isDisabled={isCustomer}
+ />
+ {isEditing && permissions.can("delete", "sales") && (
+ <Select
+ name="status"
+ label="Status"
+ value={initialValues.status}
+ options={statusOptions}
+ isReadOnly={isCustomer}
+ />
+ )}
+ <CustomFormFields table="quote" />
+ </div>
+ </VStack>
+ </CardContent>
+ <CardFooter>
+ <Submit
+ isDisabled={
+ isEditing
+ ? !permissions.can("update", "sales")
+ : !permissions.can("create", "sales")
+ }
+ >
+ Save
+ </Submit>
+ </CardFooter>
+ </ValidatedForm>
+ </Card>
+ );
+};
+
+export default QuoteForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
index bb6ac2fc86..aca30b9b44 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
@@ -1,6 +1,16 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import {
+ Badge,
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ HStack,
+ Heading,
+} from "@carbon/react";
import { useParams } from "@remix-run/react";
+import { LuCheckCheck, LuChevronDown, LuEye } from "react-icons/lu";
import { RiProgress4Line } from "react-icons/ri";
import { useRouteData } from "~/hooks";
@@ -15,7 +25,7 @@ const QuoteHeader = () => {
return (
<div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
- <VStack spacing={0} className="flex-grow">
+ <HStack className="w-full justify-between">
<HStack>
<Heading size="h2">{routeData?.quote?.quoteId}</Heading>
<Badge variant="secondary">
@@ -24,7 +34,25 @@ const QuoteHeader = () => {
</Badge>
</Badge>
</HStack>
- </VStack>
+ <HStack>
+ <Button leftIcon={<LuEye />} variant="secondary">
+ Preview
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger>
+ <Button rightIcon={<LuChevronDown />} variant="secondary">
+ Actions
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem>Download</DropdownMenuItem>
+ <DropdownMenuItem>Print</DropdownMenuItem>
+ <DropdownMenuItem>Export</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <Button leftIcon={<LuCheckCheck />}>Send</Button>
+ </HStack>
+ </HStack>
</div>
);
};
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
index e421c1d070..2e148a7ae6 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
@@ -212,8 +212,8 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
},
},
{
- accessorKey: "quoteDate",
- header: "Quote Date",
+ accessorKey: "dueDate",
+ header: "Due Date",
cell: (item) => item.getValue(),
},
{
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/index.ts b/apps/carbon/app/modules/sales/ui/Quotes/index.ts
index 52783b29a8..09a7c8f559 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/index.ts
+++ b/apps/carbon/app/modules/sales/ui/Quotes/index.ts
@@ -1,4 +1,13 @@
+import QuoteBoMExplorer from "./QuoteBoMExplorer";
+import QuoteDocuments from "./QuoteDocuments";
+import QuoteForm from "./QuoteForm";
import QuoteHeader from "./QuoteHeader";
import QuotesTable from "./QuotesTable";
-export { QuoteHeader, QuotesTable };
+export {
+ QuoteBoMExplorer,
+ QuoteDocuments,
+ QuoteForm,
+ QuoteHeader,
+ QuotesTable,
+};
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
index 6e43ee4d7e..55f16b7da5 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
@@ -78,7 +78,7 @@ const SalesOrderForm = ({ initialValues }: SalesOrderFormProps) => {
setCustomer(newValue?.value as string | undefined)
}
/>
- <Input name="customerReference" label="Customer Order Number" />
+ <Input name="customerReference" label="Customer PO Number" />
{isEditing && permissions.can("delete", "sales") && (
<Select
name="status"
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx
index 0df8c0af1c..0d7869f2e5 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx
@@ -77,7 +77,7 @@ const SalesRFQForm = ({ initialValues }: SalesRFQFormProps) => {
setCustomer(newValue?.value as string | undefined)
}
/>
- <Input name="customerReference" label="Customer Order Number" />
+ <Input name="customerReference" label="Customer Ref. Number" />
{isEditing && permissions.can("delete", "sales") && (
<Select
name="status"
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx
index 310a66b7f5..150a856fd9 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx
@@ -69,32 +69,18 @@ const useSalesRFQLineDocuments = ({
);
const deleteModel = useCallback(
- async (model: ModelUpload) => {
- if (!model || !supabase) return;
-
- // TODO: delete from Autodesk server
-
- if (model.modelPath) {
- const fileDelete = await supabase?.storage
- .from("private")
- .remove([model?.modelPath]);
-
- if (!fileDelete || fileDelete.error) {
- toast.error(fileDelete?.error?.message || "Error deleting file");
- return;
- }
- }
-
- const modelDelete = await supabase
- ?.from("modelUpload")
- .delete()
- .eq("id", model.id);
- if (modelDelete.error) {
- toast.error(modelDelete.error.message);
+ async (salesRfqLineId: string) => {
+ if (!salesRfqLineId || !supabase) return;
+
+ const { error } = await supabase
+ .from("salesRfqLine")
+ .update({ modelUploadId: null })
+ .eq("id", salesRfqLineId);
+ if (error) {
+ toast.error("Error removing model from line");
return;
}
-
- toast.success("File deleted successfully");
+ toast.success("Model removed from line");
revalidator.revalidate();
},
[supabase, revalidator]
@@ -183,7 +169,7 @@ const SalesRFQLineDocuments = ({
</Tr>
</Thead>
<Tbody>
- {modelUpload && (
+ {modelUpload?.autodeskUrn && (
<Tr>
<Td>
<HStack>
@@ -193,15 +179,15 @@ const SalesRFQLineDocuments = ({
onClick={() => viewModel(modelUpload)}
>
{modelUpload?.autodeskUrn
- ? modelUpload.name
+ ? modelUpload.modelName
: "Uploading..."}
</Hyperlink>
</HStack>
</Td>
<Td>
- {modelUpload.size
+ {modelUpload.modelSize
? convertKbToString(
- Math.floor((modelUpload.size ?? 0) / 1024)
+ Math.floor((modelUpload.modelSize ?? 0) / 1024)
)
: "--"}
</Td>
@@ -221,7 +207,7 @@ const SalesRFQLineDocuments = ({
</DropdownMenuItem>
<DropdownMenuItem
disabled={!canDelete}
- onClick={() => deleteModel(modelUpload)}
+ onClick={() => deleteModel(salesRfqLineId)}
>
Delete
</DropdownMenuItem>
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx
index 881186b40e..0e7bd20e64 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx
@@ -52,29 +52,25 @@ import SalesRFQLineDocuments from "./SalesRFQLineDocuments";
type Line = z.infer<typeof salesRfqLineValidator> & {
internalNotes: JSONContent;
externalNotes: JSONContent;
-};
+} & ModelUpload;
type ItemWithData = SortableItem & {
data: Line;
- modelUpload?: ModelUpload;
files?: (FileObject & { salesRfqLineId: string | null })[];
};
type SalesRFQLinesProps = {
lines: Line[];
files: (FileObject & { salesRfqLineId: string | null })[];
- modelUploads: ModelUpload[];
};
function makeItems(
lines: Line[],
- modelUploads: ModelUpload[],
files: (FileObject & { salesRfqLineId: string | null })[]
): ItemWithData[] {
return lines.map((line) =>
makeItem(
line,
- modelUploads.find((m) => m?.salesRfqLineId === line.id),
files.filter((f) => {
return f.salesRfqLineId === line.id;
})
@@ -84,7 +80,6 @@ function makeItems(
function makeItem(
line: Line,
- modelUpload?: ModelUpload,
files?: (FileObject & { salesRfqLineId: string | null })[]
): ItemWithData {
return {
@@ -111,7 +106,7 @@ function makeItem(
{q}
</Badge>
))}
- {modelUpload && (
+ {line.autodeskUrn && (
<Badge variant="secondary">
<LuMove3D className="w-4 h-4 text-green-500" />
</Badge>
@@ -124,7 +119,6 @@ function makeItem(
</HStack>
),
data: line,
- modelUpload,
files,
};
}
@@ -136,11 +130,18 @@ const initialLine: Omit<Line, "id" | "salesRfqId" | "order"> = {
description: "",
quantity: [1],
unitOfMeasureCode: "EA",
+ modelUploadId: undefined,
+ autodeskUrn: null,
+ modelId: "",
+ modelName: "",
+ modelPath: null,
+ modelSize: 0,
+ thumbnailPath: null,
internalNotes: {} as JSONContent,
externalNotes: {} as JSONContent,
};
-const SalesRFQLines = ({ lines, files, modelUploads }: SalesRFQLinesProps) => {
+const SalesRFQLines = ({ lines, files }: SalesRFQLinesProps) => {
const { rfqId } = useParams();
if (!rfqId) throw new Error("rfqId not found");
@@ -152,14 +153,14 @@ const SalesRFQLines = ({ lines, files, modelUploads }: SalesRFQLinesProps) => {
} = useUser();
const [items, setItems] = useState<ItemWithData[]>(
- makeItems(lines ?? [], modelUploads, files)
+ makeItems(lines ?? [], files)
);
const [selectedLineId, setSelectedLineId] = useState<string | null>(null);
useEffect(() => {
- setItems(makeItems(lines, modelUploads, files));
+ setItems(makeItems(lines, files));
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [modelUploads, files]);
+ }, [files]);
const onToggleItem = (id: string) => {
setItems((prevItems) =>
@@ -380,11 +381,11 @@ const SalesRFQLines = ({ lines, files, modelUploads }: SalesRFQLinesProps) => {
}}
>
<CadModel
- autodeskUrn={item.modelUpload?.autodeskUrn ?? null}
+ autodeskUrn={item.data.autodeskUrn ?? null}
metadata={{
salesRfqLineId: item.id,
}}
- modelPath={item.modelUpload?.modelPath ?? null}
+ modelPath={item.data.modelPath ?? null}
uploadClassName="min-h-[300px]"
/>
</motion.div>
@@ -409,7 +410,7 @@ const SalesRFQLines = ({ lines, files, modelUploads }: SalesRFQLinesProps) => {
>
<SalesRFQLineDocuments
files={item.files ?? []}
- modelUpload={item.modelUpload}
+ modelUpload={item.data}
rfqId={rfqId}
salesRfqLineId={item.id}
/>
@@ -651,10 +652,12 @@ function SalesRFQLineForm({
itemId: string;
description: string;
unitOfMeasureCode: string;
+ modelUploadId: string | null;
}>({
itemId: item.data.itemId ?? "",
description: item.data.description ?? "",
unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
+ modelUploadId: item.data.modelUploadId ?? null,
});
const onItemChange = async (itemId: string) => {
@@ -662,7 +665,7 @@ function SalesRFQLineForm({
const item = await supabase
.from("item")
- .select("name, unitOfMeasureCode")
+ .select("name, unitOfMeasureCode, modelUploadId")
.eq("id", itemId)
.eq("companyId", company.id)
.single();
@@ -677,6 +680,7 @@ function SalesRFQLineForm({
itemId,
description: item.data?.name ?? "",
unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",
+ modelUploadId: item.data?.modelUploadId ?? null,
}));
};
@@ -698,10 +702,8 @@ function SalesRFQLineForm({
i.id === item.id
? {
...makeItem({
+ ...item.data,
...values,
- description: itemData.description,
- internalNotes: item.data.internalNotes,
- externalNotes: item.data.externalNotes,
}),
isTemporary: false,
id: item.id,
@@ -714,6 +716,10 @@ function SalesRFQLineForm({
<Hidden name="id" />
<Hidden name="salesRfqId" />
<Hidden name="order" />
+ <Hidden
+ name="modelUploadId"
+ value={itemData.modelUploadId ?? undefined}
+ />
<VStack className="pt-4">
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3">
<Input
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
index 1a3fb2849e..9032dc6d1b 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
@@ -16,7 +16,6 @@ import {
useOptimisticAssignment,
} from "~/components";
import { useRouteData } from "~/hooks";
-import type { ModelUpload } from "~/modules/items";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
import type { SalesRFQ } from "../../types";
@@ -36,7 +35,6 @@ const SalesRFQProperties = () => {
);
const routeData = useRouteData<{
rfqSummary: SalesRFQ;
- modelUploads?: ModelUpload[];
}>(path.to.salesRfq(rfqId));
const locations = sharedData?.locations ?? [];
diff --git a/apps/carbon/app/modules/shared/shared.service.ts b/apps/carbon/app/modules/shared/shared.service.ts
index d5094c53d7..d0400b88ba 100644
--- a/apps/carbon/app/modules/shared/shared.service.ts
+++ b/apps/carbon/app/modules/shared/shared.service.ts
@@ -40,14 +40,20 @@ export async function updateNote(
return client.from("note").update({ note }).eq("id", id);
}
+export async function updateModelThumbnail(
+ client: SupabaseClient<Database>,
+ modelId: string,
+ thumbnailPath: string
+) {
+ return client.from("modelUpload").update({ thumbnailPath }).eq("id", modelId);
+}
+
export async function upsertModelUpload(
client: SupabaseClient<Database>,
upload:
| {
id: string;
modelPath: string;
- itemId?: string;
- salesRfqLineId?: string;
companyId: string;
createdBy: string;
}
@@ -56,6 +62,7 @@ export async function upsertModelUpload(
name: string;
size: number;
autodeskUrn: string;
+ thumbnailPath: string;
}
) {
if ("createdBy" in upload) {
diff --git a/apps/carbon/app/routes/api+/autodesk.upload.ts b/apps/carbon/app/routes/api+/autodesk.upload.ts
index 31820d92f6..63be3d8d86 100644
--- a/apps/carbon/app/routes/api+/autodesk.upload.ts
+++ b/apps/carbon/app/routes/api+/autodesk.upload.ts
@@ -14,16 +14,24 @@ export async function action({ request }: ActionFunctionArgs) {
const fileId = formData.get("fileId") as string;
const name = formData.get("name") as string;
const modelPath = formData.get("modelPath") as string;
- const itemId = (formData.get("itemId") ?? undefined) as string | undefined;
- const salesRfqLineId = (formData.get("salesRfqLineId") ?? undefined) as
- | string
- | undefined;
+
+ const itemId = formData.get("itemId") as string | null;
+ const salesRfqLineId = formData.get("salesRfqLineId") as string | null;
+ const quoteLineId = formData.get("quoteLineId") as string | null;
+
+ if (!fileId) {
+ throw new Error("File ID is required");
+ }
+ if (!name) {
+ throw new Error("Name is required");
+ }
+ if (!modelPath) {
+ throw new Error("Model path is required");
+ }
const modelRecord = await upsertModelUpload(client, {
id: fileId,
modelPath,
- itemId,
- salesRfqLineId,
companyId,
createdBy: userId,
});
@@ -40,8 +48,10 @@ export async function action({ request }: ActionFunctionArgs) {
modelPath,
companyId,
fileId,
- itemId,
userId,
+ itemId,
+ salesRfqLineId,
+ quoteLineId,
},
});
} catch (err) {
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
index c51b5f84e8..d4cedea082 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
@@ -4,7 +4,7 @@ import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
import { usePermissions, useRouteData } from "~/hooks";
-import type { Fixture, ItemFile, ModelUpload } from "~/modules/items";
+import type { Fixture, ItemFile } from "~/modules/items";
import {
CadModel,
FixtureForm,
@@ -65,7 +65,6 @@ export default function FixtureDetailsRoute() {
const fixtureData = useRouteData<{
fixtureSummary: Fixture;
- modelUpload?: ModelUpload;
files: ItemFile[];
}>(path.to.fixture(itemId));
if (!fixtureData) throw new Error("Could not find fixture data");
@@ -95,17 +94,17 @@ export default function FixtureDetailsRoute() {
{permissions.is("employee") && (
<div className="grid grid-cols-1 md:grid-cols-2 w-full flex-grow gap-2">
<CadModel
- autodeskUrn={fixtureData?.modelUpload?.autodeskUrn ?? null}
+ autodeskUrn={fixtureData?.fixtureSummary?.autodeskUrn ?? null}
metadata={{
itemId,
}}
- modelPath={fixtureData?.modelUpload?.modelPath ?? null}
+ modelPath={fixtureData?.fixtureSummary?.modelPath ?? null}
title="CAD Model"
/>
<ItemDocuments
files={fixtureData?.files ?? []}
itemId={itemId}
- modelUpload={fixtureData.modelUpload}
+ modelUpload={fixtureData.fixtureSummary}
type="Fixture"
/>
</div>
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
index 8675b4aaa4..a009b4352b 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
@@ -7,7 +7,6 @@ import {
getBuyMethods,
getFixture,
getItemFiles,
- getModelUploadByItemId,
getPickMethods,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
@@ -29,14 +28,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [fixtureSummary, files, modelUpload, buyMethods, pickMethods] =
- await Promise.all([
- getFixture(client, itemId, companyId),
- getItemFiles(client, itemId, companyId),
- getModelUploadByItemId(client, itemId, companyId),
- getBuyMethods(client, itemId, companyId),
- getPickMethods(client, itemId, companyId),
- ]);
+ const [fixtureSummary, files, buyMethods, pickMethods] = await Promise.all([
+ getFixture(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ ]);
if (fixtureSummary.error) {
throw redirect(
@@ -51,7 +48,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
fixtureSummary: fixtureSummary.data,
files: files.data ?? [],
- modelUpload: modelUpload.data,
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
index fd74eb6bef..483b83c64a 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
@@ -4,7 +4,7 @@ import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
import { usePermissions, useRouteData } from "~/hooks";
-import type { ItemFile, ModelUpload, PartSummary } from "~/modules/items";
+import type { ItemFile, PartSummary } from "~/modules/items";
import {
CadModel,
ItemDocuments,
@@ -60,7 +60,6 @@ export default function PartDetailsRoute() {
const partData = useRouteData<{
partSummary: PartSummary;
- modelUpload?: ModelUpload;
files: ItemFile[];
}>(path.to.part(itemId));
@@ -86,15 +85,15 @@ export default function PartDetailsRoute() {
{permissions.is("employee") && (
<div className="grid grid-cols-1 md:grid-cols-2 w-full flex-grow gap-2">
<CadModel
- autodeskUrn={partData?.modelUpload?.autodeskUrn ?? null}
+ autodeskUrn={partData?.partSummary?.autodeskUrn ?? null}
metadata={{ itemId }}
- modelPath={partData?.modelUpload?.modelPath ?? null}
+ modelPath={partData?.partSummary?.modelPath ?? null}
title="CAD Model"
/>
<ItemDocuments
files={partData?.files ?? []}
itemId={itemId}
- modelUpload={partData.modelUpload}
+ modelUpload={partData.partSummary ?? undefined}
type="Part"
/>
</div>
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.tsx
index 79f2d15d5e..7b163d91a4 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.tsx
@@ -6,7 +6,6 @@ import {
PartProperties,
getBuyMethods,
getItemFiles,
- getModelUploadByItemId,
getPart,
getPickMethods,
} from "~/modules/items";
@@ -30,14 +29,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [partSummary, files, modelUpload, buyMethods, pickMethods] =
- await Promise.all([
- getPart(client, itemId, companyId),
- getItemFiles(client, itemId, companyId),
- getModelUploadByItemId(client, itemId, companyId),
- getBuyMethods(client, itemId, companyId),
- getPickMethods(client, itemId, companyId),
- ]);
+ const [partSummary, files, buyMethods, pickMethods] = await Promise.all([
+ getPart(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ ]);
if (partSummary.error) {
throw redirect(
@@ -52,7 +49,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
partSummary: partSummary.data,
files: files.data ?? [],
- modelUpload: modelUpload.data,
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
new file mode 100644
index 0000000000..8b85368f5f
--- /dev/null
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
@@ -0,0 +1,18 @@
+import { VStack } from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { QuoteDocuments, QuoteForm } from "~/modules/sales";
+
+export default function QuoteDetailsRoute() {
+ const { quoteId } = useParams();
+ if (!quoteId) throw new Error("Could not find quoteId");
+ const initialValues = {
+ id: "1",
+ };
+
+ return (
+ <VStack spacing={2} className="p-2">
+ <QuoteForm key={initialValues.id} initialValues={initialValues} />
+ <QuoteDocuments id={quoteId} attachments={[]} isExternal={false} />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.tsx
index 41af0cf1fa..59d9676136 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.tsx
@@ -1,14 +1,23 @@
import {
+ Button,
ClientOnly,
+ cn,
+ HStack,
+ IconButton,
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
ScrollArea,
+ useDisclosure,
+ VStack,
} from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet, useParams } from "@remix-run/react";
-import { getQuote, QuoteHeader } from "~/modules/sales";
+import { LuGhost, LuPlus } from "react-icons/lu";
+import { MdMoreVert } from "react-icons/md";
+import type { FlatTree } from "~/components/TreeView/TreeView";
+import { getQuote, QuoteBoMExplorer, QuoteHeader } from "~/modules/sales";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import type { Handle } from "~/utils/handle";
@@ -61,21 +70,16 @@ export default function QuoteRoute() {
order={1}
minSize={10}
defaultSize={20}
- className="bg-card"
+ className="bg-card h-full"
>
<ScrollArea className="h-[calc(100vh-99px)]">
- <div className="grid h-full overflow-hidden p-2">
+ <div className="grid w-full h-full overflow-hidden">
<QuoteExplorer />
</div>
</ScrollArea>
</ResizablePanel>
<ResizableHandle withHandle />
- <ResizablePanel
- order={2}
- minSize={40}
- defaultSize={60}
- className="border-t border-border"
- >
+ <ResizablePanel order={2} className="border-t border-border">
<ScrollArea className="h-[calc(100vh-99px)]">
<Outlet key={JSON.stringify(params)} />
</ScrollArea>
@@ -91,5 +95,172 @@ export default function QuoteRoute() {
}
function QuoteExplorer() {
- return null;
+ return (
+ <VStack className="w-full h-[calc(100vh-99px)] justify-between">
+ <VStack className="flex-1 overflow-y-auto" spacing={0}>
+ <QuoteLineItem />
+ <QuoteLineItem />
+ <QuoteLineItem />
+ {/* <EmptyQuote /> */}
+ </VStack>
+ <div className="w-full flex flex-0 sm:flex-row border-t border-border p-4 sm:justify-start sm:space-x-2">
+ <Button leftIcon={<LuPlus />}>Add Line Item</Button>
+ </div>
+ </VStack>
+ );
+}
+
+function EmptyQuote() {
+ return (
+ <VStack className="w-full h-full justify-center items-center">
+ <LuGhost className="w-12 h-12" />
+ <h3 className="font-semibold text-lg">Pretty empty around here</h3>
+ <Button leftIcon={<LuPlus />}>Add Line Item</Button>
+ </VStack>
+ );
+}
+
+const methods: FlatTree<{
+ itemId: string;
+ makeMethodId: string | null;
+ methodType: string;
+ materialMakeMethodId: string | null;
+ itemType: string;
+ quantity: number;
+ itemReadableId: string;
+ order: number;
+ methodMaterialId: string;
+ parentMaterialId: string | null;
+ isRoot: boolean;
+}> = [
+ {
+ id: "node-d9210a4deb583",
+ children: ["node-b1633fd85ebf", "node-889f33c1ba64b"],
+ hasChildren: true,
+ level: 0,
+ parentId: undefined,
+ data: {
+ itemId: "cqc7ms9r80lmbqsrdnbg",
+ makeMethodId: null,
+ methodType: "Make",
+ materialMakeMethodId: "cqc7ms9r80lmbqkrdnc0",
+ itemType: "Part",
+ quantity: 1,
+ itemReadableId: "P2392303",
+ order: 1,
+ methodMaterialId: "cqc7ms9r80lmbqkrdnc0",
+ parentMaterialId: null,
+ isRoot: true,
+ },
+ },
+ {
+ id: "node-b1633fd85ebf",
+ children: [],
+ hasChildren: false,
+ level: 1,
+ data: {
+ itemId: "cqc7nq1r80lmchkrdnf0",
+ makeMethodId: "cqc7ms9r80lmbqkrdnc0",
+ methodType: "Pick",
+ materialMakeMethodId: null,
+ itemType: "Tool",
+ quantity: 1,
+ itemReadableId: "T932023",
+ order: 1,
+ methodMaterialId: "cqc7nrpr80lmbusrdnfg",
+ parentMaterialId: "cqc7ms9r80lmbqkrdnc0",
+ isRoot: false,
+ },
+ parentId: "node-d9210a4deb583",
+ },
+ {
+ id: "node-889f33c1ba64b",
+ children: ["node-324eaa176575a"],
+ hasChildren: true,
+ level: 1,
+ data: {
+ itemId: "cqc7n1pr80lmbv4rdncg",
+ makeMethodId: "cqc7ms9r80lmbqkrdnc0",
+ methodType: "Make",
+ materialMakeMethodId: "cqc7n1pr80lmbqkrdnd0",
+ itemType: "Part",
+ quantity: 2,
+ itemReadableId: "P2392304",
+ order: 1,
+ methodMaterialId: "cqc7n3pr80lmbukrdndg",
+ parentMaterialId: "cqc7ms9r80lmbqkrdnc0",
+ isRoot: false,
+ },
+ parentId: "node-d9210a4deb583",
+ },
+ {
+ id: "node-324eaa176575a",
+ children: [],
+ hasChildren: false,
+ level: 2,
+ data: {
+ itemId: "cqc7njpr80lmbv4rdne0",
+ makeMethodId: "cqc7n1pr80lmbqkrdnd0",
+ methodType: "Buy",
+ materialMakeMethodId: null,
+ itemType: "Material",
+ quantity: 3.8,
+ itemReadableId: "RAW3290393",
+ order: 1,
+ methodMaterialId: "cqc7nlhr80lmbv4rdneg",
+ parentMaterialId: "cqc7n3pr80lmbukrdndg",
+ isRoot: false,
+ },
+ parentId: "node-889f33c1ba64b",
+ },
+];
+
+function QuoteLineItem() {
+ const isSelected = false;
+ const disclosure = useDisclosure();
+ const onParentClick = () => {
+ disclosure.onToggle();
+ };
+ return (
+ <VStack spacing={0}>
+ <HStack
+ className={cn(
+ "w-full p-2 items-center justify-between hover:bg-accent cursor-pointer",
+ !disclosure.isOpen && "border-b border-border",
+ isSelected && "bg-accent"
+ )}
+ onClick={onParentClick}
+ >
+ <HStack spacing={2}>
+ <img
+ alt="P2392303"
+ className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border border-border"
+ src="/file/preview/private/cqbjc69r80lg2msrdjkg/models/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Y2FyYm9uLW9zLWRldi93U1dpb3lHMndybGdhekdHNVNwSDkuc3RlcA==.png"
+ />
+ {/* <div className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border border-border p-2">
+ <LuImage className="w-6 h-6 text-muted-foreground" />
+ </div> */}
+ <VStack spacing={0}>
+ <span className="font-mono font-semibold">A932023</span>
+ <span className="font-mono text-muted-foreground text-xs">
+ Rev 0
+ </span>
+ </VStack>
+ </HStack>
+ {/* <HStack spacing={1}>
+ {false ? (
+ <EmployeeAvatar employeeId={null} className="flex-shrink-0" />
+ ) : (
+ <Avatar className="flex-shrink-0" size="xs" />
+ )} */}
+ <IconButton aria-label="More" icon={<MdMoreVert />} variant="ghost" />
+ {/* </HStack> */}
+ </HStack>
+ {disclosure.isOpen && (
+ <VStack className="border-b border-border">
+ <QuoteBoMExplorer methods={methods} />
+ </VStack>
+ )}
+ </VStack>
+ );
}
diff --git a/apps/carbon/app/routes/x+/quote-deprecated+/$id.details.tsx b/apps/carbon/app/routes/x+/quote-deprecated+/$id.details.tsx
index eff37c2ba3..a3242a539c 100644
--- a/apps/carbon/app/routes/x+/quote-deprecated+/$id.details.tsx
+++ b/apps/carbon/app/routes/x+/quote-deprecated+/$id.details.tsx
@@ -71,13 +71,13 @@ export default function QuotationBasicRoute() {
const initialValues = {
id: quoteData?.quotation?.id ?? "",
quoteId: quoteData?.quotation?.quoteId ?? "",
- name: quoteData?.quotation?.name ?? "",
+
customerId: quoteData?.quotation?.customerId ?? "",
customerContactId: quoteData?.quotation?.customerContactId ?? "",
customerLocationId: quoteData?.quotation?.customerLocationId ?? "",
customerReference: quoteData?.quotation?.customerReference ?? "",
locationId: quoteData?.quotation?.locationId ?? "",
- quoteDate: quoteData?.quotation?.quoteDate ?? "",
+ quoteDate: quoteData?.quotation?.dueDate ?? "",
expirationDate: quoteData?.quotation.expirationDate ?? undefined,
status: quoteData?.quotation?.status ?? ("Draft" as "Draft"),
notes: quoteData?.quotation?.notes ?? "",
diff --git a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
index a1da8f6078..1d98c0e3f7 100644
--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
@@ -7,7 +7,6 @@ import { json, redirect } from "@remix-run/node";
import { useLoaderData, useParams } from "@remix-run/react";
import type { FileObject } from "@supabase/storage-js";
import { useRouteData } from "~/hooks";
-import type { ModelUpload } from "~/modules/items";
import type { SalesRFQ, SalesRFQStatus } from "~/modules/sales";
import {
SalesRFQForm,
@@ -42,6 +41,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
lines: lines.data.map((line) => ({
...line,
+ id: line.id ?? "",
+ order: line.order ?? 0,
+ unitOfMeasureCode: line.unitOfMeasureCode ?? "",
customerRevisionId: line.customerRevisionId ?? "",
description: line.description ?? "",
externalNotes: (line.externalNotes ?? {}) as JSONContent,
@@ -100,7 +102,6 @@ export default function SalesRFQDetailsRoute() {
const rfqData = useRouteData<{
rfqSummary: SalesRFQ;
files: (FileObject & { salesRfqLineId: string | null })[];
- modelUploads?: ModelUpload[];
}>(path.to.salesRfq(rfqId));
if (!rfqData) throw new Error("Could not find rfq data");
@@ -126,9 +127,9 @@ export default function SalesRFQDetailsRoute() {
<VStack spacing={2} className="p-2">
<SalesRFQForm key={initialValues.id} initialValues={initialValues} />
<SalesRFQLines
+ // @ts-ignore
lines={lines}
files={rfqData?.files ?? []}
- modelUploads={rfqData?.modelUploads ?? []}
/>
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx
index f42aa7b308..5fea4f4db5 100644
--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx
+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx
@@ -44,7 +44,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
rfqSummary: rfqSummary.data,
files: files.data?.files ?? [],
- modelUploads: files.data?.modelUploads ?? [],
});
}
diff --git a/package-lock.json b/package-lock.json
index 70668cfb5a..45fbb9a791 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4846,6 +4846,50 @@
"resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.0.tgz",
"integrity": "sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA=="
},
+ "node_modules/@radix-ui/react-accordion": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.2.0.tgz",
+ "integrity": "sha512-HJOzSX8dQqtsp/3jVxCU3CXEONF7/2jlGAB28oX8TTw1Dz8JYbEI1UcL8355PuLBE41/IRRMvCw7VkiK/jcUOQ==",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.0",
+ "@radix-ui/react-collapsible": "1.1.0",
+ "@radix-ui/react-collection": "1.1.0",
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-context": "1.1.0",
+ "@radix-ui/react-direction": "1.1.0",
+ "@radix-ui/react-id": "1.1.0",
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-use-controllable-state": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-compose-refs": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.0.tgz",
+ "integrity": "sha512-b4inOtiaOnYf9KWyO3jAeeCG6FeyfY6ldiEPanbUjWd+xIk5wZeHa8yVwmrJ2vderhu/BQvzCrJI0lHd+wIiqw==",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-arrow": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
@@ -4936,6 +4980,49 @@
}
}
},
+ "node_modules/@radix-ui/react-collapsible": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.0.tgz",
+ "integrity": "sha512-zQY7Epa8sTL0mq4ajSJpjgn2YmCgyrG7RsQgLp3C0LQVkG7+Tf6Pv1CeNWZLyqMjhdPkBa5Lx7wYBeSu7uCSTA==",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.0",
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-context": "1.1.0",
+ "@radix-ui/react-id": "1.1.0",
+ "@radix-ui/react-presence": "1.1.0",
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-use-controllable-state": "1.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-collapsible/node_modules/@radix-ui/react-compose-refs": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.0.tgz",
+ "integrity": "sha512-b4inOtiaOnYf9KWyO3jAeeCG6FeyfY6ldiEPanbUjWd+xIk5wZeHa8yVwmrJ2vderhu/BQvzCrJI0lHd+wIiqw==",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-collection": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.0.tgz",
@@ -35539,6 +35626,7 @@
"name": "@carbon/react",
"version": "*",
"dependencies": {
+ "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-context-menu": "^2.1.4",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index f6072b8d45..2cfe7f963d 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6029,11 +6029,10 @@ export type Database = {
description: string | null
id: string
itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
+ modelUploadId: string | null
name: string
readableId: string
replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
- thumbnailPath: string | null
- thumbnailUrl: string | null
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -6049,11 +6048,10 @@ export type Database = {
description?: string | null
id?: string
itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
+ modelUploadId?: string | null
name: string
readableId: string
replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
- thumbnailPath?: string | null
- thumbnailUrl?: string | null
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -6069,11 +6067,10 @@ export type Database = {
description?: string | null
id?: string
itemTrackingType?: Database["public"]["Enums"]["itemTrackingType"]
+ modelUploadId?: string | null
name?: string
readableId?: string
replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
- thumbnailPath?: string | null
- thumbnailUrl?: string | null
type?: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -8670,11 +8667,10 @@ export type Database = {
createdAt: string | null
createdBy: string
id: string
- itemId: string | null
modelPath: string
name: string | null
- salesRfqLineId: string | null
size: number | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
}
@@ -8684,11 +8680,10 @@ export type Database = {
createdAt?: string | null
createdBy: string
id?: string
- itemId?: string | null
modelPath: string
name?: string | null
- salesRfqLineId?: string | null
size?: number | null
+ thumbnailPath?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
@@ -8698,11 +8693,10 @@ export type Database = {
createdAt?: string | null
createdBy?: string
id?: string
- itemId?: string | null
modelPath?: string
name?: string | null
- salesRfqLineId?: string | null
size?: number | null
+ thumbnailPath?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
@@ -8770,27 +8764,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "modelUpload_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "item"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "modelUpload_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["itemId"]
- },
- {
- foreignKeyName: "modelUpload_salesRfqLineId_fkey"
- columns: ["salesRfqLineId"]
- isOneToOne: false
- referencedRelation: "salesRfqLine"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "modelUpload_updatedBy_fkey"
columns: ["updatedBy"]
@@ -12424,12 +12397,12 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ dueDate: string | null
estimatorId: string | null
expirationDate: string | null
id: string
locationId: string | null
notes: Json | null
- quoteDate: string | null
quoteId: string
revisionId: number
salesPersonId: string | null
@@ -12448,12 +12421,12 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ dueDate?: string | null
estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
notes?: Json | null
- quoteDate?: string | null
quoteId: string
revisionId?: number
salesPersonId?: string | null
@@ -12472,12 +12445,12 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ dueDate?: string | null
estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
notes?: Json | null
- quoteDate?: string | null
quoteId?: string
revisionId?: number
salesPersonId?: string | null
@@ -12853,6 +12826,7 @@ export type Database = {
id: string
itemId: string
itemReadableId: string | null
+ modelUploadId: string | null
quoteId: string
quoteRevisionId: number
replenishmentSystem: string | null
@@ -12872,6 +12846,7 @@ export type Database = {
id?: string
itemId: string
itemReadableId?: string | null
+ modelUploadId?: string | null
quoteId: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -12891,6 +12866,7 @@ export type Database = {
id?: string
itemId?: string
itemReadableId?: string | null
+ modelUploadId?: string | null
quoteId?: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -15831,6 +15807,7 @@ export type Database = {
id: string
internalNotes: Json | null
itemId: string | null
+ modelUploadId: string | null
order: number
quantity: number[] | null
salesRfqId: string
@@ -15850,6 +15827,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
itemId?: string | null
+ modelUploadId?: string | null
order?: number
quantity?: number[] | null
salesRfqId: string
@@ -15869,6 +15847,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
itemId?: string | null
+ modelUploadId?: string | null
order?: number
quantity?: number[] | null
salesRfqId?: string
@@ -21017,6 +20996,7 @@ export type Database = {
approved: boolean | null
approvedBy: string | null
assignee: string | null
+ autodeskUrn: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -21030,11 +21010,16 @@ export type Database = {
itemTrackingType:
| Database["public"]["Enums"]["itemTrackingType"]
| null
+ modelId: string | null
+ modelName: string | null
+ modelPath: string | null
+ modelSize: number | null
name: string | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
supplierIds: string[] | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
}
@@ -21849,6 +21834,7 @@ export type Database = {
approved: boolean | null
approvedBy: string | null
assignee: string | null
+ autodeskUrn: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -21861,11 +21847,16 @@ export type Database = {
itemTrackingType:
| Database["public"]["Enums"]["itemTrackingType"]
| null
+ modelId: string | null
+ modelName: string | null
+ modelPath: string | null
+ modelSize: number | null
name: string | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
supplierIds: string[] | null
+ thumbnailPath: string | null
toDate: string | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -23090,6 +23081,7 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ dueDate: string | null
estimatorId: string | null
expirationDate: string | null
favorite: boolean | null
@@ -23098,7 +23090,6 @@ export type Database = {
locationId: string | null
locationName: string | null
notes: Json | null
- quoteDate: string | null
quoteId: string | null
revisionId: number | null
salesPersonId: string | null
@@ -24087,6 +24078,170 @@ export type Database = {
},
]
}
+ salesRfqLines: {
+ Row: {
+ autodeskUrn: string | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customerPartNumber: string | null
+ customerRevisionId: string | null
+ customFields: Json | null
+ description: string | null
+ externalNotes: Json | null
+ id: string | null
+ internalNotes: Json | null
+ itemId: string | null
+ itemName: string | null
+ modelId: string | null
+ modelName: string | null
+ modelPath: string | null
+ modelSize: number | null
+ modelUploadId: string | null
+ order: number | null
+ quantity: number[] | null
+ salesRfqId: string | null
+ thumbnailPath: string | null
+ unitOfMeasureCode: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfq"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfqs"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
salesRfqs: {
Row: {
assignee: string | null
@@ -25567,8 +25722,7 @@ export type Database = {
quoteLineStatus: "Draft" | "In Progress" | "Complete"
quoteStatus:
| "Draft"
- | "Open"
- | "Replied"
+ | "Sent"
| "Ordered"
| "Partial"
| "Lost"
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index f6072b8d45..2cfe7f963d 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -6029,11 +6029,10 @@ export type Database = {
description: string | null
id: string
itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
+ modelUploadId: string | null
name: string
readableId: string
replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
- thumbnailPath: string | null
- thumbnailUrl: string | null
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -6049,11 +6048,10 @@ export type Database = {
description?: string | null
id?: string
itemTrackingType: Database["public"]["Enums"]["itemTrackingType"]
+ modelUploadId?: string | null
name: string
readableId: string
replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
- thumbnailPath?: string | null
- thumbnailUrl?: string | null
type: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -6069,11 +6067,10 @@ export type Database = {
description?: string | null
id?: string
itemTrackingType?: Database["public"]["Enums"]["itemTrackingType"]
+ modelUploadId?: string | null
name?: string
readableId?: string
replenishmentSystem?: Database["public"]["Enums"]["itemReplenishmentSystem"]
- thumbnailPath?: string | null
- thumbnailUrl?: string | null
type?: Database["public"]["Enums"]["itemType"]
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -8670,11 +8667,10 @@ export type Database = {
createdAt: string | null
createdBy: string
id: string
- itemId: string | null
modelPath: string
name: string | null
- salesRfqLineId: string | null
size: number | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
}
@@ -8684,11 +8680,10 @@ export type Database = {
createdAt?: string | null
createdBy: string
id?: string
- itemId?: string | null
modelPath: string
name?: string | null
- salesRfqLineId?: string | null
size?: number | null
+ thumbnailPath?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
@@ -8698,11 +8693,10 @@ export type Database = {
createdAt?: string | null
createdBy?: string
id?: string
- itemId?: string | null
modelPath?: string
name?: string | null
- salesRfqLineId?: string | null
size?: number | null
+ thumbnailPath?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
@@ -8770,27 +8764,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "modelUpload_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "item"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "modelUpload_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["itemId"]
- },
- {
- foreignKeyName: "modelUpload_salesRfqLineId_fkey"
- columns: ["salesRfqLineId"]
- isOneToOne: false
- referencedRelation: "salesRfqLine"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "modelUpload_updatedBy_fkey"
columns: ["updatedBy"]
@@ -12424,12 +12397,12 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ dueDate: string | null
estimatorId: string | null
expirationDate: string | null
id: string
locationId: string | null
notes: Json | null
- quoteDate: string | null
quoteId: string
revisionId: number
salesPersonId: string | null
@@ -12448,12 +12421,12 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ dueDate?: string | null
estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
notes?: Json | null
- quoteDate?: string | null
quoteId: string
revisionId?: number
salesPersonId?: string | null
@@ -12472,12 +12445,12 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ dueDate?: string | null
estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
notes?: Json | null
- quoteDate?: string | null
quoteId?: string
revisionId?: number
salesPersonId?: string | null
@@ -12853,6 +12826,7 @@ export type Database = {
id: string
itemId: string
itemReadableId: string | null
+ modelUploadId: string | null
quoteId: string
quoteRevisionId: number
replenishmentSystem: string | null
@@ -12872,6 +12846,7 @@ export type Database = {
id?: string
itemId: string
itemReadableId?: string | null
+ modelUploadId?: string | null
quoteId: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -12891,6 +12866,7 @@ export type Database = {
id?: string
itemId?: string
itemReadableId?: string | null
+ modelUploadId?: string | null
quoteId?: string
quoteRevisionId?: number
replenishmentSystem?: string | null
@@ -15831,6 +15807,7 @@ export type Database = {
id: string
internalNotes: Json | null
itemId: string | null
+ modelUploadId: string | null
order: number
quantity: number[] | null
salesRfqId: string
@@ -15850,6 +15827,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
itemId?: string | null
+ modelUploadId?: string | null
order?: number
quantity?: number[] | null
salesRfqId: string
@@ -15869,6 +15847,7 @@ export type Database = {
id?: string
internalNotes?: Json | null
itemId?: string | null
+ modelUploadId?: string | null
order?: number
quantity?: number[] | null
salesRfqId?: string
@@ -21017,6 +20996,7 @@ export type Database = {
approved: boolean | null
approvedBy: string | null
assignee: string | null
+ autodeskUrn: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -21030,11 +21010,16 @@ export type Database = {
itemTrackingType:
| Database["public"]["Enums"]["itemTrackingType"]
| null
+ modelId: string | null
+ modelName: string | null
+ modelPath: string | null
+ modelSize: number | null
name: string | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
supplierIds: string[] | null
+ thumbnailPath: string | null
updatedAt: string | null
updatedBy: string | null
}
@@ -21849,6 +21834,7 @@ export type Database = {
approved: boolean | null
approvedBy: string | null
assignee: string | null
+ autodeskUrn: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -21861,11 +21847,16 @@ export type Database = {
itemTrackingType:
| Database["public"]["Enums"]["itemTrackingType"]
| null
+ modelId: string | null
+ modelName: string | null
+ modelPath: string | null
+ modelSize: number | null
name: string | null
replenishmentSystem:
| Database["public"]["Enums"]["itemReplenishmentSystem"]
| null
supplierIds: string[] | null
+ thumbnailPath: string | null
toDate: string | null
unitOfMeasure: string | null
unitOfMeasureCode: string | null
@@ -23090,6 +23081,7 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ dueDate: string | null
estimatorId: string | null
expirationDate: string | null
favorite: boolean | null
@@ -23098,7 +23090,6 @@ export type Database = {
locationId: string | null
locationName: string | null
notes: Json | null
- quoteDate: string | null
quoteId: string | null
revisionId: number | null
salesPersonId: string | null
@@ -24087,6 +24078,170 @@ export type Database = {
},
]
}
+ salesRfqLines: {
+ Row: {
+ autodeskUrn: string | null
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customerPartNumber: string | null
+ customerRevisionId: string | null
+ customFields: Json | null
+ description: string | null
+ externalNotes: Json | null
+ id: string | null
+ internalNotes: Json | null
+ itemId: string | null
+ itemName: string | null
+ modelId: string | null
+ modelName: string | null
+ modelPath: string | null
+ modelSize: number | null
+ modelUploadId: string | null
+ order: number | null
+ quantity: number[] | null
+ salesRfqId: string | null
+ thumbnailPath: string | null
+ unitOfMeasureCode: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfq"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfqs"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "salesRfqLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
salesRfqs: {
Row: {
assignee: string | null
@@ -25567,8 +25722,7 @@ export type Database = {
quoteLineStatus: "Draft" | "In Progress" | "Complete"
quoteStatus:
| "Draft"
- | "Open"
- | "Replied"
+ | "Sent"
| "Ordered"
| "Partial"
| "Lost"
diff --git a/packages/database/supabase/migrations/20240715024405_quotes.sql b/packages/database/supabase/migrations/20240715024405_quotes.sql
index 2bcac5c12b..974e2ec568 100644
--- a/packages/database/supabase/migrations/20240715024405_quotes.sql
+++ b/packages/database/supabase/migrations/20240715024405_quotes.sql
@@ -2,8 +2,7 @@
CREATE TYPE "quoteStatus" AS ENUM (
'Draft',
- 'Open',
- 'Replied',
+ 'Sent',
'Ordered',
'Partial',
'Lost',
@@ -16,7 +15,7 @@ CREATE TABLE "quote" (
"quoteId" TEXT NOT NULL,
"revisionId" INTEGER NOT NULL DEFAULT 0,
"salesRfqId" TEXT,
- "quoteDate" DATE,
+ "dueDate" DATE,
"expirationDate" DATE,
"status" "quoteStatus" NOT NULL DEFAULT 'Draft',
"notes" JSON DEFAULT '{}'::json,
diff --git a/packages/database/supabase/migrations/20240719014956_model-uploads-thumbnail.sql b/packages/database/supabase/migrations/20240719014956_model-uploads-thumbnail.sql
new file mode 100644
index 0000000000..bb948daada
--- /dev/null
+++ b/packages/database/supabase/migrations/20240719014956_model-uploads-thumbnail.sql
@@ -0,0 +1,93 @@
+ALTER TABLE "modelUpload"
+ ADD COLUMN "thumbnailPath" TEXT,
+ DROP COLUMN "itemId",
+ DROP COLUMN "salesRfqLineId";
+
+ALTER TABLE "item"
+ ADD COLUMN "modelUploadId" TEXT,
+ DROP COLUMN "thumbnailPath",
+ DROP COLUMN "thumbnailUrl";
+
+ALTER TABLE "salesRfqLine"
+ ADD COLUMN "modelUploadId" TEXT;
+
+ALTER TABLE "quoteLine"
+ ADD COLUMN "modelUploadId" TEXT;
+
+DROP VIEW "fixtures";
+CREATE OR REPLACE VIEW "fixtures" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ i.name,
+ i.description,
+ i."itemTrackingType",
+ i.active,
+ i."replenishmentSystem",
+ i."defaultMethodType",
+ i.assignee,
+ f.*,
+ mu.id as "modelId",
+ mu."autodeskUrn",
+ mu."modelPath",
+ mu."thumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ s."supplierIds",
+ c.name as "customer"
+ FROM "fixture" f
+ INNER JOIN "item" i ON i.id = f."itemId"
+ LEFT JOIN (
+ SELECT
+ "itemId",
+ array_agg(s."supplierId") AS "supplierIds"
+ FROM "buyMethod" s
+ GROUP BY "itemId"
+ ) s ON s."itemId" = f."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "customer" c ON c.id = f."customerId";
+
+DROP VIEW "parts";
+CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ i.name,
+ i.description,
+ i."itemTrackingType",
+ i."unitOfMeasureCode",
+ i.active,
+ i."replenishmentSystem",
+ i."defaultMethodType",
+ i.assignee,
+ mu.id as "modelId",
+ mu."autodeskUrn",
+ mu."modelPath",
+ mu."thumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ p.*,
+ ps."supplierIds",
+ uom.name as "unitOfMeasure"
+ FROM "part" p
+ INNER JOIN "item" i ON i.id = p."itemId"
+ LEFT JOIN (
+ SELECT
+ "itemId",
+ array_agg(ps."supplierId") AS "supplierIds"
+ FROM "buyMethod" ps
+ GROUP BY "itemId"
+ ) ps ON ps."itemId" = p."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";
+
+
+CREATE OR REPLACE VIEW "salesRfqLines" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ srl.*,
+ mu.id as "modelId",
+ mu."autodeskUrn",
+ mu."modelPath",
+ mu."thumbnailPath",
+ mu."name" as "modelName",
+ mu."size" as "modelSize",
+ i.name as "itemName"
+ FROM "salesRfqLine" srl
+ LEFT JOIN "item" i ON i.id = srl."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = srl."modelUploadId";
\ No newline at end of file
diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsx
index 2a63bb8ba7..75a5f41899 100644
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@ -58,8 +58,8 @@ const QuotePDF = ({
company={company}
items={[
{
- label: "Date",
- value: quote?.quoteDate ?? today(getLocalTimeZone()).toString(),
+ label: "Quote Date",
+ value: today(getLocalTimeZone()).toString(),
},
{
label: "Expires",
diff --git a/packages/react/package.json b/packages/react/package.json
index 6d295f76d5..28f9efbc4c 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -1,6 +1,7 @@
{
"name": "@carbon/react",
"dependencies": {
+ "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-context-menu": "^2.1.4",
diff --git a/packages/react/src/Accordion.tsx b/packages/react/src/Accordion.tsx
new file mode 100644
index 0000000000..9e6eb0d155
--- /dev/null
+++ b/packages/react/src/Accordion.tsx
@@ -0,0 +1,59 @@
+"use client";
+
+import * as AccordionPrimitive from "@radix-ui/react-accordion";
+import type { ComponentPropsWithoutRef, ElementRef } from "react";
+import { forwardRef } from "react";
+import { LuChevronDown } from "react-icons/lu";
+
+import { cn } from "./utils/cn";
+
+const Accordion = AccordionPrimitive.Root;
+
+const AccordionItem = forwardRef<
+ ElementRef<typeof AccordionPrimitive.Item>,
+ ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
+>(({ className, ...props }, ref) => (
+ <AccordionPrimitive.Item
+ ref={ref}
+ className={cn("border-b", className)}
+ {...props}
+ />
+));
+AccordionItem.displayName = "AccordionItem";
+
+const AccordionTrigger = forwardRef<
+ ElementRef<typeof AccordionPrimitive.Trigger>,
+ ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <AccordionPrimitive.Header className="flex">
+ <AccordionPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <LuChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
+ </AccordionPrimitive.Trigger>
+ </AccordionPrimitive.Header>
+));
+AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
+
+const AccordionContent = forwardRef<
+ ElementRef<typeof AccordionPrimitive.Content>,
+ ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <AccordionPrimitive.Content
+ ref={ref}
+ className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
+ {...props}
+ >
+ <div className={cn("pb-4 pt-0", className)}>{children}</div>
+ </AccordionPrimitive.Content>
+));
+
+AccordionContent.displayName = AccordionPrimitive.Content.displayName;
+
+export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
diff --git a/packages/react/src/Avatar.tsx b/packages/react/src/Avatar.tsx
index 27e62f0c03..543c01ec3d 100644
--- a/packages/react/src/Avatar.tsx
+++ b/packages/react/src/Avatar.tsx
@@ -20,7 +20,7 @@ import {
import { cn } from "./utils/cn";
export const avatarVariants = cva(
- "inline-flex overflow-hidden rounded-full items-center justify-center text-white font-semibold",
+ "flex flex-shrink-0 overflow-hidden rounded-full items-center justify-center text-white font-semibold",
{
variants: {
size: {
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index a69a72578e..780fce6ccf 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -1,4 +1,10 @@
import type { JSONContent } from "novel";
+import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+} from "./Accordion";
import { ActionMenu } from "./ActionMenu";
import { Alert, AlertDescription, AlertTitle } from "./Alert";
import { AutodeskViewer } from "./AutodeskViewer";
@@ -238,6 +244,10 @@ import { cn } from "./utils/cn";
import { getValidChildren, reactNodeToString } from "./utils/react";
export * from "./hooks";
export {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
ActionMenu,
Alert,
AlertDescription,