Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: sales rfq files

Brad Barbin1e05367ca727
diff --git a/apps/carbon/app/components/Assign.tsx b/apps/carbon/app/components/Assign.tsx
index f894a75ced..6fa699c269 100644
--- a/apps/carbon/app/components/Assign.tsx
+++ b/apps/carbon/app/components/Assign.tsx
@@ -1,126 +1,6 @@
-import {
- Button,
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- Popover,
- PopoverContent,
- PopoverTrigger,
- cn,
-} from "@carbon/react";
-import { useFetcher, useFetchers } from "@remix-run/react";
-import type { ComponentPropsWithoutRef } from "react";
-import { forwardRef, useMemo, useState } from "react";
-import { RxCheck } from "react-icons/rx";
-import { useUser } from "~/hooks";
-import { usePeople } from "~/stores";
+import { useFetchers } from "@remix-run/react";
import { path } from "~/utils/path";
-export type ComboboxProps = Omit<
- ComponentPropsWithoutRef<"button">,
- "onChange"
-> & {
- id: string;
- table: string;
- size?: "sm" | "md" | "lg";
- value?: string;
- isReadOnly?: boolean;
- placeholder?: string;
- onChange?: (selected: string) => void;
-};
-
-const Assign = forwardRef<HTMLButtonElement, ComboboxProps>(
- (
- { id, table, size, value, isReadOnly, placeholder, onChange, ...props },
- ref
- ) => {
- const [open, setOpen] = useState(false);
- const [people] = usePeople();
- const fetcher = useFetcher();
- const user = useUser();
-
- const handleChange = (value: string) => {
- const formData = new FormData();
- formData.append("id", id);
- formData.append("assignee", value);
- formData.append("table", table);
-
- fetcher.submit(formData, {
- method: "post",
- action: path.to.api.assign,
- });
- };
-
- const options = useMemo(() => {
- const base =
- people
- .filter((person) => person.id !== user.id)
- .map((person) => ({
- value: person.id,
- label: person.name,
- })) ?? [];
-
- return [
- { value: "", label: "Unassigned" },
- { value: user.id, label: `${user.firstName} ${user.lastName}` },
- ...base,
- ];
- }, [people, user]);
-
- return (
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <Button
- size={size}
- role="combobox"
- variant="ghost"
- ref={ref}
- onClick={() => setOpen(true)}
- {...props}
- >
- Assign
- </Button>
- </PopoverTrigger>
- <PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">
- <Command>
- <CommandInput placeholder="Search..." className="h-9" />
- <CommandEmpty>No option found.</CommandEmpty>
- <CommandGroup>
- {options.map((option) => (
- <CommandItem
- value={
- typeof option.label === "string" ? option.label : undefined
- }
- key={option.value}
- onSelect={() => {
- handleChange(option.value);
- onChange?.(option.value);
- setOpen(false);
- }}
- >
- {option.label}
-
- <RxCheck
- className={cn(
- "ml-auto h-4 w-4",
- option.value === value ? "opacity-100" : "opacity-0"
- )}
- />
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- );
- }
-);
-Assign.displayName = "Assign";
-
-export default Assign;
-
export function useOptimisticAssignment({
id,
table,
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
index ce6434295d..925f7973a4 100644
--- a/apps/carbon/app/components/index.ts
+++ b/apps/carbon/app/components/index.ts
@@ -1,5 +1,5 @@
import Address from "./Address";
-import Assign, { useOptimisticAssignment } from "./Assign";
+import Assignee, { useOptimisticAssignment } from "./Assignee";
import Avatar from "./Avatar";
import { BreadcrumbItem, BreadcrumbLink, Breadcrumbs } from "./Breadcrumb";
import Combobox from "./Combobox";
@@ -19,7 +19,7 @@ import Table from "./Table";
export {
Address,
- Assign,
+ Assignee,
Avatar,
BreadcrumbItem,
BreadcrumbLink,
diff --git a/apps/carbon/app/modules/documents/documents.models.ts b/apps/carbon/app/modules/documents/documents.models.ts
index c6fadb0482..70d7618a62 100644
--- a/apps/carbon/app/modules/documents/documents.models.ts
+++ b/apps/carbon/app/modules/documents/documents.models.ts
@@ -17,6 +17,7 @@ export const documentTypes = [
export const documentSourceTypes = [
"Purchase Order",
"Quote",
+ "Request for Quote",
...methodItemType,
] as const;
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
index ffbbc5a5b9..5803ac3f73 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
@@ -617,6 +617,8 @@ function getDocumentLocation(
return path.to.purchaseOrder(sourceDocumentId);
case "Quote":
return path.to.quote(sourceDocumentId);
+ case "Request for Quote":
+ return path.to.salesRfq(sourceDocumentId);
default:
return "#";
}
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx
index 5ab842e198..698766e78a 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptHeader.tsx
@@ -19,7 +19,7 @@ import {
import { formatDate } from "@carbon/utils";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { Receipt, ReceiptLine } from "~/modules/inventory";
import { ReceiptPostModal, ReceiptStatus } from "~/modules/inventory";
@@ -59,11 +59,6 @@ const ReceiptHeader = () => {
<VStack>
{permissions.is("employee") && (
<Menubar>
- <Assign
- id={receiptId}
- table="receipt"
- value={routeData?.receipt?.assignee ?? ""}
- />
<MenubarItem
isDisabled={!canPost || isPosted}
onClick={postingModal.onOpen}
@@ -95,11 +90,11 @@ const ReceiptHeader = () => {
<CardAttribute>
<CardAttributeLabel>Assignee</CardAttributeLabel>
<CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
+ <Assignee
+ id={receiptId}
+ table="receipt"
+ value={assignee ?? ""}
+ />
</CardAttributeValue>
</CardAttribute>
<CardAttribute>
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
index f5fbe22218..9f4e357846 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceHeader.tsx
@@ -16,7 +16,7 @@ import {
import { formatDate } from "@carbon/utils";
import { useParams } from "@remix-run/react";
import { useMemo, useState } from "react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
import type { PurchaseInvoice } from "~/modules/invoicing";
@@ -106,11 +106,6 @@ const PurchaseInvoiceHeader = () => {
<VStack>
{permissions.is("employee") && (
<Menubar>
- <Assign
- id={invoiceId}
- table="purchaseInvoice"
- value={assignee ?? undefined}
- />
<MenubarItem
isDisabled={!permissions.can("update", "invoicing") || isPosted}
onClick={showPostModal}
@@ -131,11 +126,11 @@ const PurchaseInvoiceHeader = () => {
<CardAttribute>
<CardAttributeLabel>Assignee</CardAttributeLabel>
<CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
+ <Assignee
+ id={invoiceId}
+ table="purchaseInvoice"
+ value={assignee ?? undefined}
+ />
</CardAttributeValue>
</CardAttribute>
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
index f2c205c6ac..3b6f5f03f3 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
@@ -11,8 +11,7 @@ import {
} from "@carbon/react";
import { useParams } from "@remix-run/react";
import { LuCopy, LuLink } from "react-icons/lu";
-import { useOptimisticAssignment } from "~/components";
-import Assignee from "~/components/Assignee";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
index 38a4629222..3536c48faa 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
@@ -11,8 +11,11 @@ import {
} from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
import { LuCopy, LuExternalLink, LuLink, LuMove3D } from "react-icons/lu";
-import { CustomerAvatar, useOptimisticAssignment } from "~/components";
-import Assignee from "~/components/Assignee";
+import {
+ Assignee,
+ CustomerAvatar,
+ useOptimisticAssignment,
+} from "~/components";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
index dce075fd1c..aa5715814e 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
@@ -11,8 +11,7 @@ import {
} from "@carbon/react";
import { useParams } from "@remix-run/react";
import { LuCopy, LuLink } from "react-icons/lu";
-import { useOptimisticAssignment } from "~/components";
-import Assignee from "~/components/Assignee";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
index 07acc188e3..dc658554f4 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
@@ -11,8 +11,7 @@ import {
} from "@carbon/react";
import { useParams } from "@remix-run/react";
import { LuCopy, LuLink } from "react-icons/lu";
-import { useOptimisticAssignment } from "~/components";
-import Assignee from "~/components/Assignee";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { useRouteData } from "~/hooks";
import { path } from "~/utils/path";
import type { BuyMethod, ItemFile, PickMethod, Service } from "../../types";
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
index 6a3be7791d..6d7733f5aa 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -11,8 +11,7 @@ import {
} from "@carbon/react";
import { useParams } from "@remix-run/react";
import { LuCopy, LuLink } from "react-icons/lu";
-import { useOptimisticAssignment } from "~/components";
-import Assignee from "~/components/Assignee";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
diff --git a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
index 7db1a1c669..ef91dea8d8 100644
--- a/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
+++ b/apps/carbon/app/modules/items/ui/useItemsSubmodules.tsx
@@ -1,8 +1,7 @@
import { AiOutlinePartition } from "react-icons/ai";
import { CiFries } from "react-icons/ci";
-import { FaRulerVertical } from "react-icons/fa";
import { GiIBeam, GiWoodBeam } from "react-icons/gi";
-import { LuGrip, LuHammer, LuShapes } from "react-icons/lu";
+import { LuGrip, LuHammer, LuRuler, LuShapes } from "react-icons/lu";
import { PiPiggyBank } from "react-icons/pi";
import { RiCustomerServiceLine } from "react-icons/ri";
import { usePermissions } from "~/hooks";
@@ -75,7 +74,7 @@ const itemsRoutes: AuthenticatedRouteGroup[] = [
name: "Units of Measure",
to: path.to.uoms,
role: "employee",
- icon: <FaRulerVertical />,
+ icon: <LuRuler />,
},
],
},
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
index 5b5f8951a4..0644eb4183 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
@@ -19,7 +19,7 @@ import {
import { formatDate } from "@carbon/utils";
import { useParams } from "@remix-run/react";
import { useMemo } from "react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { PurchaseOrder } from "~/modules/purchasing";
import { PurchasingStatus, usePurchaseOrderTotals } from "~/modules/purchasing";
@@ -73,11 +73,6 @@ const PurchaseOrderHeader = () => {
<VStack>
{permissions.is("employee") && (
<Menubar>
- <Assign
- id={orderId}
- table="purchaseOrder"
- value={assignee ?? undefined}
- />
<MenubarItem asChild>
<a
target="_blank"
@@ -142,11 +137,11 @@ const PurchaseOrderHeader = () => {
<CardAttribute>
<CardAttributeLabel>Assignee</CardAttributeLabel>
<CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
+ <Assignee
+ id={orderId}
+ table="purchaseOrder"
+ value={assignee ?? undefined}
+ />
</CardAttributeValue>
</CardAttribute>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
index 291cfa4b47..1875cadce4 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
@@ -10,12 +10,15 @@ import {
CardTitle,
Enumerable,
HStack,
- Menubar,
VStack,
} from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import {
+ Assignee,
+ EmployeeAvatar,
+ useOptimisticAssignment,
+} from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type {
SupplierDetail,
@@ -59,15 +62,6 @@ const SupplierHeader = () => {
return (
<VStack>
- {permissions.is("employee") && (
- <Menubar>
- <Assign
- id={supplierId}
- table="supplier"
- value={routeData?.supplier?.assignee ?? ""}
- />
- </Menubar>
- )}
<Card>
<HStack className="justify-between items-start">
<CardHeader>
@@ -93,16 +87,20 @@ const SupplierHeader = () => {
)}
</CardAttributeValue>
</CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
+
+ {permissions.is("employee") && (
+ <CardAttribute>
+ <CardAttributeLabel>Assignee</CardAttributeLabel>
+ <CardAttributeValue>
+ <Assignee
+ id={supplierId}
+ table="supplier"
+ value={assignee ?? ""}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ )}
+
<CardAttribute>
<CardAttributeLabel>Type</CardAttributeLabel>
<CardAttributeValue>
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 997621ba45..4842d1f093 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -1,5 +1,6 @@
import type { Database, Json } from "@carbon/database";
import { getLocalTimeZone, today } from "@internationalized/date";
+import type { FileObject } from "@supabase/storage-js";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { z } from "zod";
import { getEmployeeJob } from "~/modules/resources";
@@ -384,25 +385,41 @@ export async function getFilesByRfqId(
return lines;
}
const lineIds = lines.data?.map((line) => line.id);
- const [modelUploads, files] = await Promise.all([
+ const fileQueries = lineIds.map((lineId) =>
+ client.storage
+ .from("private")
+ .list(`${companyId}/sales-rfq/${rfqId}/${lineId}`)
+ );
+ const [modelUploads, ...files] = await Promise.all([
client
.from("modelUpload")
.select("*")
.in("salesRfqLineId", lineIds ?? []),
- client.storage.from("private").list(`${companyId}/sales-rfq/${rfqId}`),
+ ...fileQueries,
]);
if (modelUploads.error) {
return modelUploads;
}
- if (files.error) {
- return files;
- }
return {
data: {
modelUploads: modelUploads.data,
- files: files.data,
+ files: files.reduce<(FileObject & { salesRfqLineId: string | null })[]>(
+ (acc, file, index) => {
+ if (file.data) {
+ return [
+ ...acc,
+ ...file.data?.map((f) => ({
+ ...f,
+ salesRfqLineId: lineIds[index],
+ })),
+ ];
+ }
+ return acc;
+ },
+ []
+ ),
},
};
}
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
index a414b5be81..f8ca371cdd 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
@@ -10,12 +10,15 @@ import {
CardTitle,
Enumerable,
HStack,
- Menubar,
VStack,
} from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import {
+ Assignee,
+ EmployeeAvatar,
+ useOptimisticAssignment,
+} from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type {
CustomerDetail,
@@ -59,15 +62,6 @@ const CustomerHeader = () => {
return (
<VStack>
- {permissions.is("employee") && (
- <Menubar>
- <Assign
- id={customerId}
- table="customer"
- value={assignee ?? undefined}
- />
- </Menubar>
- )}
<Card>
<HStack className="justify-between items-start">
<CardHeader>
@@ -93,16 +87,18 @@ const CustomerHeader = () => {
)}
</CardAttributeValue>
</CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Assignee</CardAttributeLabel>
- <CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
- </CardAttributeValue>
- </CardAttribute>
+ {permissions.is("employee") && (
+ <CardAttribute>
+ <CardAttributeLabel>Assignee</CardAttributeLabel>
+ <CardAttributeValue>
+ <Assignee
+ id={customerId}
+ table="customer"
+ value={assignee ?? ""}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ )}
<CardAttribute>
<CardAttributeLabel>Type</CardAttributeLabel>
<CardAttributeValue>
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
index 57f118513f..757cc719f9 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
@@ -10,14 +10,13 @@ import {
CardHeader,
CardTitle,
HStack,
- Menubar,
VStack,
} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useParams } from "@remix-run/react";
import { useMemo } from "react";
-import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
+import { Assignee, useOptimisticAssignment } from "~/components";
+import { useRouteData } from "~/hooks";
import type { SalesOrder } from "~/modules/sales";
import { SalesStatus, useSalesOrderTotals } from "~/modules/sales";
import { useCustomers } from "~/stores";
@@ -25,7 +24,6 @@ import { path } from "~/utils/path";
// import { useSalesOrder } from "../SalesOrders/useSalesOrder";
const SalesOrderHeader = () => {
- const permissions = usePermissions();
const { orderId } = useParams();
if (!orderId) throw new Error("Could not find orderId");
@@ -63,54 +61,7 @@ const SalesOrderHeader = () => {
return (
<>
<VStack>
- {permissions.is("employee") && (
- <Menubar>
- <Assign
- id={orderId}
- table="salesOrder"
- value={assignee ?? undefined}
- />
- {/*<MenubarItem asChild>
- <a
- target="_blank"
- href={path.to.file.salesOrder(orderId)}
- rel="noreferrer"
- >
- Preview
- </a>
- </MenubarItem>
-
- <MenubarItem
- onClick={releaseDisclosure.onOpen}
- isDisabled={isReleased}
- >
- Release
- </MenubarItem>*/}
- {/*<MenubarItem
- onClick={() => {
- receive(routeData.salesOrder);
- }}
- isDisabled={
- routeData?.salesOrder?.status !== "To Receive" &&
- routeData?.salesOrder?.status !== "To Receive and Invoice"
- }
- >
- Receive
- </MenubarItem>
- <MenubarItem
- onClick={() => {
- invoice(routeData.salesOrder);
- }}
- isDisabled={
- routeData?.salesOrder?.status !== "To Invoice" &&
- routeData?.salesOrder?.status !== "To Receive and Invoice"
- }
- >
- Invoice
- </MenubarItem>*/}
- </Menubar>
- )}
-
+ {/* Menubar */}
<Card>
<HStack className="justify-between items-start">
<CardHeader>
@@ -134,11 +85,11 @@ const SalesOrderHeader = () => {
<CardAttribute>
<CardAttributeLabel>Assignee</CardAttributeLabel>
<CardAttributeValue>
- {assignee ? (
- <EmployeeAvatar employeeId={assignee ?? null} />
- ) : (
- "-"
- )}
+ <Assignee
+ id={orderId}
+ table="salesOrder"
+ value={assignee ?? undefined}
+ />
</CardAttributeValue>
</CardAttribute>
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx
index efddf0bf82..ef66d3aaa0 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLineDocuments.tsx
@@ -15,6 +15,7 @@ import {
toast,
} from "@carbon/react";
import { convertKbToString } from "@carbon/utils";
+import type { FileObject } from "@supabase/storage-js";
import { LuAxis3D, LuUpload } from "react-icons/lu";
import { MdMoreVert } from "react-icons/md";
import { DocumentPreview, Hyperlink } from "~/components";
@@ -45,7 +46,7 @@ const useSalesRFQLineDocuments = ({
const canDelete = permissions.can("delete", "sales");
const getPath = useCallback(
(file: ItemFile) => {
- return `${company.id}/sales-rfq/${rfqId}/${salesRfqLineId}:${file.name}`;
+ return `${company.id}/sales-rfq/${rfqId}/${salesRfqLineId}/${file.name}`;
},
[company.id, rfqId, salesRfqLineId]
);
@@ -147,7 +148,7 @@ const useSalesRFQLineDocuments = ({
};
type SalesRFQLineDocumentsProps = {
- files: ItemFile[];
+ files: (FileObject & { salesRfqLineId: string | null })[];
rfqId: string;
salesRfqLineId: string;
modelUpload?: ModelUpload;
@@ -168,21 +169,19 @@ const SalesRFQLineDocuments = ({
console.log({ files });
return (
- <>
- <HStack className="justify-between items-end">
- <SalesRFQLineDocumentForm
- rfqId={rfqId}
- salesRfqLineId={salesRfqLineId}
- />
- </HStack>
-
+ <div className="min-h-[300px]">
<Table>
<Thead>
<Tr>
<Th>Name</Th>
<Th>Size</Th>
- <Th></Th>
+ <Th className="flex items-center justify-end">
+ <SalesRFQLineDocumentForm
+ rfqId={rfqId}
+ salesRfqLineId={salesRfqLineId}
+ />
+ </Th>
</Tr>
</Thead>
<Tbody>
@@ -301,7 +300,7 @@ const SalesRFQLineDocuments = ({
)}
</Tbody>
</Table>
- </>
+ </div>
);
};
@@ -323,7 +322,7 @@ const SalesRFQLineDocumentForm = ({
const uploadFile = async (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.files && supabase && company) {
const file = e.target.files[0];
- const fileName = `${company.id}/sales-rfq/${rfqId}/${salesRfqLineId}:${file.name}`;
+ const fileName = `${company.id}/sales-rfq/${rfqId}/${salesRfqLineId}/${file.name}`;
const fileUpload = await supabase.storage
.from("private")
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx
index 554d4c4646..9bd43bb3c4 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQLines.tsx
@@ -24,7 +24,7 @@ import { AnimatePresence, LayoutGroup, motion } from "framer-motion";
import { nanoid } from "nanoid";
import type { Dispatch, SetStateAction } from "react";
import { useCallback, useEffect, useState } from "react";
-import { LuMove3D, LuSettings2, LuX } from "react-icons/lu";
+import { LuMove3D, LuPaperclip, LuSettings2, LuX } from "react-icons/lu";
import type { z } from "zod";
import { DirectionAwareTabs } from "~/components/DirectionAwareTabs";
import {
@@ -57,27 +57,26 @@ type Line = z.infer<typeof salesRfqLineValidator> & {
type ItemWithData = SortableItem & {
data: Line;
modelUpload?: ModelUpload;
- files?: FileObject[];
+ files?: (FileObject & { salesRfqLineId: string | null })[];
};
type SalesRFQLinesProps = {
lines: Line[];
- files: FileObject[];
+ files: (FileObject & { salesRfqLineId: string | null })[];
modelUploads: ModelUpload[];
};
function makeItems(
lines: Line[],
modelUploads: ModelUpload[],
- files: FileObject[]
+ files: (FileObject & { salesRfqLineId: string | null })[]
): ItemWithData[] {
return lines.map((line) =>
makeItem(
line,
modelUploads.find((m) => m?.salesRfqLineId === line.id),
files.filter((f) => {
- const [lineId] = f.name.split(":");
- return lineId === line.id;
+ return f.salesRfqLineId === line.id;
})
)
);
@@ -86,7 +85,7 @@ function makeItems(
function makeItem(
line: Line,
modelUpload?: ModelUpload,
- files?: FileObject[]
+ files?: (FileObject & { salesRfqLineId: string | null })[]
): ItemWithData {
return {
id: line.id!,
@@ -117,6 +116,11 @@ function makeItem(
<LuMove3D className="w-4 h-4 text-green-500" />
</Badge>
)}
+ {files && files.length > 0 && (
+ <Badge variant="secondary">
+ <LuPaperclip className="w-4 h-4" />
+ </Badge>
+ )}
</HStack>
),
data: line,
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
index f3f334591f..1a3fb2849e 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
@@ -10,8 +10,11 @@ import {
import { getLocalTimeZone, parseDate } from "@internationalized/date";
import { useParams } from "@remix-run/react";
import { LuCopy, LuLink } from "react-icons/lu";
-import { CustomerAvatar, useOptimisticAssignment } from "~/components";
-import Assignee from "~/components/Assignee";
+import {
+ Assignee,
+ CustomerAvatar,
+ useOptimisticAssignment,
+} from "~/components";
import { useRouteData } from "~/hooks";
import type { ModelUpload } from "~/modules/items";
import type { ListItem } from "~/types";
diff --git a/apps/carbon/app/routes/x+/quote+/$id.tsx b/apps/carbon/app/routes/x+/quote+/$id.tsx
index 7f9f798be6..95e71e0dae 100644
--- a/apps/carbon/app/routes/x+/quote+/$id.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$id.tsx
@@ -12,9 +12,8 @@ import { json, redirect } from "@remix-run/node";
import { Outlet, useLoaderData, useParams } from "@remix-run/react";
import { useEffect, useRef } from "react";
import {
- Assign,
+ Assignee,
CustomerAvatar,
- EmployeeAvatar,
useOptimisticAssignment,
} from "~/components";
import { useSupabase } from "~/lib/supabase";
@@ -183,7 +182,7 @@ export default function QuotationRoute() {
<VStack className="border-b border-border px-4 py-2 text-sm">
<HStack className="justify-between w-full">
<span className="text-xs text-muted-foreground">Assignee</span>
- {assignee && <EmployeeAvatar employeeId={assignee} />}
+ <Assignee id={id} table="quote" value={assignee ?? undefined} />
</HStack>
</VStack>
<QuotationExplorer />
@@ -196,7 +195,6 @@ export default function QuotationRoute() {
className="h-full w-full overflow-x-hidden flex-1 p-4"
>
<Menubar>
- <Assign id={id} table="quote" value={assignee ?? undefined} />
<MenubarItem asChild>
<a
target="_blank"
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 b14119fa0d..a1da8f6078 100644
--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
@@ -5,8 +5,9 @@ import { parseDate } from "@internationalized/date";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
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 { ItemFile, ModelUpload } from "~/modules/items";
+import type { ModelUpload } from "~/modules/items";
import type { SalesRFQ, SalesRFQStatus } from "~/modules/sales";
import {
SalesRFQForm,
@@ -98,7 +99,7 @@ export default function SalesRFQDetailsRoute() {
const rfqData = useRouteData<{
rfqSummary: SalesRFQ;
- files: ItemFile[];
+ files: (FileObject & { salesRfqLineId: string | null })[];
modelUploads?: ModelUpload[];
}>(path.to.salesRfq(rfqId));