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: add assignee to receipt

Brad Barbinb6ffa8184ce1
diff --git a/apps/carbon/app/components/Assign.tsx b/apps/carbon/app/components/Assign.tsx
index b42167c9cb..f894a75ced 100644
--- a/apps/carbon/app/components/Assign.tsx
+++ b/apps/carbon/app/components/Assign.tsx
@@ -14,6 +14,7 @@ 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 { path } from "~/utils/path";
@@ -38,6 +39,7 @@ const Assign = forwardRef<HTMLButtonElement, ComboboxProps>(
const [open, setOpen] = useState(false);
const [people] = usePeople();
const fetcher = useFetcher();
+ const user = useUser();
const handleChange = (value: string) => {
const formData = new FormData();
@@ -53,13 +55,20 @@ const Assign = forwardRef<HTMLButtonElement, ComboboxProps>(
const options = useMemo(() => {
const base =
- people.map((part) => ({
- value: part.id,
- label: part.name,
- })) ?? [];
+ 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 [{ value: "", label: "Unassigned" }, ...base];
- }, [people]);
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
diff --git a/apps/carbon/app/components/Avatar.tsx b/apps/carbon/app/components/Avatar.tsx
index ed5164f594..2ebc4a9b7b 100644
--- a/apps/carbon/app/components/Avatar.tsx
+++ b/apps/carbon/app/components/Avatar.tsx
@@ -12,7 +12,6 @@ const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(
({ name, path, bucket = "avatars", ...props }, ref) => {
const imagePath = path ? getStoragePath(bucket, path) : undefined;
- // @ts-ignore
return <AvatarBase src={imagePath} name={name} ref={ref} {...props} />;
}
);
diff --git a/apps/carbon/app/components/CustomerAvatar.tsx b/apps/carbon/app/components/CustomerAvatar.tsx
new file mode 100644
index 0000000000..c46ce4ac7b
--- /dev/null
+++ b/apps/carbon/app/components/CustomerAvatar.tsx
@@ -0,0 +1,32 @@
+import type { AvatarProps } from "@carbon/react";
+import { HStack } from "@carbon/react";
+import { useCustomers } from "~/stores";
+import Avatar from "./Avatar";
+
+type CustomerAvatarProps = AvatarProps & {
+ customerId: string | null;
+};
+
+const CustomerAvatar = ({
+ customerId,
+ size,
+ ...props
+}: CustomerAvatarProps) => {
+ const [customers] = useCustomers();
+
+ if (!customerId) return null;
+
+ const customer = customers.find((s) => s.id === customerId) ?? {
+ name: "",
+ id: "",
+ };
+
+ return (
+ <HStack className="truncate">
+ <Avatar size={size ?? "xs"} {...props} name={customer?.name ?? ""} />
+ <span>{customer.name}</span>
+ </HStack>
+ );
+};
+
+export default CustomerAvatar;
diff --git a/apps/carbon/app/components/EmployeeAvatar.tsx b/apps/carbon/app/components/EmployeeAvatar.tsx
index f4d8c1492a..4b08cfa298 100644
--- a/apps/carbon/app/components/EmployeeAvatar.tsx
+++ b/apps/carbon/app/components/EmployeeAvatar.tsx
@@ -1,8 +1,17 @@
+import type { AvatarProps } from "@carbon/react";
import { HStack } from "@carbon/react";
import { usePeople } from "~/stores";
import Avatar from "./Avatar";
-const EmployeeAvatar = ({ employeeId }: { employeeId: string | null }) => {
+type EmployeeAvatarProps = AvatarProps & {
+ employeeId: string | null;
+};
+
+const EmployeeAvatar = ({
+ employeeId,
+ size,
+ ...props
+}: EmployeeAvatarProps) => {
const [people] = usePeople();
if (!employeeId) return null;
@@ -11,7 +20,7 @@ const EmployeeAvatar = ({ employeeId }: { employeeId: string | null }) => {
if (!person && people.length > 0) {
return (
<HStack>
- <Avatar size="sm" />
+ <Avatar size={"xs"} {...props} />
<span className="text-muted-foreground">Deactivated user</span>
</HStack>
);
@@ -22,9 +31,9 @@ const EmployeeAvatar = ({ employeeId }: { employeeId: string | null }) => {
}
return (
- <HStack>
+ <HStack className="truncate">
<Avatar
- size="sm"
+ size={size ?? "xs"}
src={person.avatarUrl ?? undefined}
name={person?.name ?? ""}
/>
diff --git a/apps/carbon/app/components/SupplierAvatar.tsx b/apps/carbon/app/components/SupplierAvatar.tsx
index 96b8ec98c0..c1ff931daa 100644
--- a/apps/carbon/app/components/SupplierAvatar.tsx
+++ b/apps/carbon/app/components/SupplierAvatar.tsx
@@ -1,10 +1,19 @@
+import type { AvatarProps } from "@carbon/react";
import { HStack } from "@carbon/react";
import { useSuppliers } from "~/stores";
import Avatar from "./Avatar";
-const SupplierAvatar = ({ supplierId }: { supplierId: string | null }) => {
+type SupplierAvatarProps = AvatarProps & {
+ supplierId: string | null;
+};
+
+const SupplierAvatar = ({
+ supplierId,
+ size,
+ ...props
+}: SupplierAvatarProps) => {
const [suppliers] = useSuppliers();
- console.log({ supplierId });
+
if (!supplierId) return null;
const supplier = suppliers.find((s) => s.id === supplierId) ?? {
@@ -13,8 +22,8 @@ const SupplierAvatar = ({ supplierId }: { supplierId: string | null }) => {
};
return (
- <HStack>
- <Avatar size="sm" name={supplier?.name ?? ""} />
+ <HStack className="truncate">
+ <Avatar size={size ?? "xs"} {...props} name={supplier?.name ?? ""} />
<span>{supplier.name}</span>
</HStack>
);
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
index 23d7fd0869..66e014761b 100644
--- a/apps/carbon/app/components/index.ts
+++ b/apps/carbon/app/components/index.ts
@@ -5,6 +5,7 @@ import { BreadcrumbItem, BreadcrumbLink, Breadcrumbs } from "./Breadcrumb";
import Combobox from "./Combobox";
import Contact from "./Contact";
import CreatableCombobox from "./CreateableCombobox";
+import CustomerAvatar from "./CustomerAvatar";
import EmployeeAvatar from "./EmployeeAvatar";
import Hyperlink from "./Hyperlink";
import MultiSelect from "./MultiSelect";
@@ -23,6 +24,7 @@ export {
Combobox,
Contact,
CreatableCombobox,
+ CustomerAvatar,
EmployeeAvatar,
Hyperlink,
MultiSelect,
diff --git a/apps/carbon/app/modules/inventory/inventory.service.ts b/apps/carbon/app/modules/inventory/inventory.service.ts
index ef1c6c5fd3..c3f70a846e 100644
--- a/apps/carbon/app/modules/inventory/inventory.service.ts
+++ b/apps/carbon/app/modules/inventory/inventory.service.ts
@@ -1,4 +1,5 @@
import type { Database, Json } from "@carbon/database";
+import { getLocalTimeZone, today } from "@internationalized/date";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { z } from "zod";
import type { GenericQueryFilters } from "~/utils/query";
@@ -137,7 +138,10 @@ export async function upsertReceipt(
}
return client
.from("receipt")
- .update(sanitize(receipt))
+ .update({
+ ...sanitize(receipt),
+ updatedAt: today(getLocalTimeZone()).toString(),
+ })
.eq("id", receipt.id)
.select("id")
.single();
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
index 7e3330893f..7b79eddb2b 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
@@ -3,7 +3,6 @@ import {
Drawer,
DrawerBody,
DrawerContent,
- DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
@@ -15,6 +14,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { Outlet } from "@remix-run/react";
import type { z } from "zod";
+import { Assign, useOptimisticAssignment } from "~/components";
import {
ComboboxControlled,
CustomFormFields,
@@ -31,7 +31,6 @@ import type {
receiptStatusType,
} from "~/modules/inventory";
import {
- ReceiptStatus,
receiptSourceDocumentType,
receiptValidator,
} from "~/modules/inventory";
@@ -41,6 +40,7 @@ import { path } from "~/utils/path";
import useReceiptForm from "./useReceiptForm";
type ReceiptFormProps = {
+ assignee: string | null;
initialValues: z.infer<typeof receiptValidator>;
status: (typeof receiptStatusType)[number];
notes: Note[];
@@ -50,6 +50,7 @@ type ReceiptFormProps = {
const formId = "receipt-form";
const ReceiptForm = ({
+ assignee,
initialValues,
status,
notes,
@@ -79,6 +80,13 @@ const ReceiptForm = ({
const isPosted = status === "Posted";
+ const optimisticAssignment = useOptimisticAssignment({
+ id: initialValues.id,
+ table: "receipt",
+ });
+ const optimisticAssignee =
+ optimisticAssignment !== undefined ? optimisticAssignment : assignee;
+
return (
<>
<Drawer
@@ -90,13 +98,15 @@ const ReceiptForm = ({
<DrawerContent size="full">
<DrawerHeader>
<DrawerTitle>{initialValues.receiptId}</DrawerTitle>
- <DrawerDescription>
- <ReceiptStatus status={status} />
- </DrawerDescription>
</DrawerHeader>
<DrawerBody>
<VStack spacing={4}>
<Menubar className="mb-2 mt--2">
+ <Assign
+ id={initialValues.id}
+ table="receipt"
+ value={optimisticAssignee ?? undefined}
+ />
<MenubarItem isDisabled={!canPost || isPosted} onClick={onPost}>
Post
</MenubarItem>
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx
index 03467946cc..bc417a55fa 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable.tsx
@@ -1,27 +1,27 @@
-import {
- Checkbox,
- Enumerable,
- HStack,
- MenuIcon,
- MenuItem,
-} from "@carbon/react";
+import { Checkbox, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import { BsFillPenFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Avatar, Hyperlink, New, Table } from "~/components";
+import {
+ EmployeeAvatar,
+ Hyperlink,
+ New,
+ SupplierAvatar,
+ Table,
+} from "~/components";
import { usePermissions, useRealtime, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Receipt } from "~/modules/inventory";
import {
ReceiptStatus,
receiptSourceDocumentType,
receiptStatusType,
} from "~/modules/inventory";
-import { useSuppliers } from "~/stores";
+import { usePeople, useSuppliers } from "~/stores";
import type { ListItem } from "~/types";
-import { useCustomColumns } from "~/hooks/useCustomColumns";
import { path } from "~/utils/path";
type ReceiptsTableProps = {
@@ -38,6 +38,7 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
const permissions = usePermissions();
const rows = useMemo(() => data, [data]);
+ const [people] = usePeople();
const [suppliers] = useSuppliers();
const customColumns = useCustomColumns<Receipt>("receipt");
@@ -107,20 +108,7 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
},
},
},
- {
- accessorKey: "supplierName",
- header: "Supplier",
- cell: (item) => item.getValue() ?? null,
- meta: {
- filter: {
- type: "static",
- options: suppliers.map(({ name }) => ({
- value: name,
- label: name,
- })),
- },
- },
- },
+
{
accessorKey: "status",
header: "Status",
@@ -139,11 +127,43 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
pluralHeader: "Statuses",
},
},
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
{
accessorKey: "postingDate",
header: "Posting Date",
cell: (item) => formatDate(item.getValue<string>()),
},
+ {
+ id: "supplierId",
+ header: "Supplier",
+ cell: ({ row }) => {
+ return <SupplierAvatar supplierId={row.original.supplierId} />;
+ },
+ meta: {
+ filter: {
+ type: "static",
+ options: suppliers?.map((supplier) => ({
+ value: supplier.id,
+ label: supplier.name,
+ })),
+ },
+ },
+ },
{
accessorKey: "invoiced",
header: "Invoiced",
@@ -160,15 +180,24 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
},
},
{
- accessorKey: "createdByFullName",
+ accessorKey: "externalDocumentId",
+ header: "External Ref.",
+ cell: (item) => item.getValue(),
+ },
+ {
+ id: "createdBy",
header: "Created By",
- cell: ({ row }) => {
- return (
- <HStack>
- <Avatar size="sm" path={row.original.createdByAvatar} />
- <p>{row.original.createdByFullName}</p>
- </HStack>
- );
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
{
@@ -177,27 +206,30 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
cell: (item) => formatDate(item.getValue<string>()),
},
{
- accessorKey: "updatedByFullName",
+ id: "updatedBy",
header: "Updated By",
- cell: ({ row }) => {
- return row.original.updatedByFullName ? (
- <HStack>
- <Avatar size="sm" path={row.original.updatedByAvatar ?? null} />
- <p>{row.original.updatedByFullName}</p>
- </HStack>
- ) : null;
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
{
accessorKey: "updatedAt",
- header: "Updated At",
+ header: "Created At",
cell: (item) => formatDate(item.getValue<string>()),
},
];
- return [...result,...customColumns];
- }, [locations, suppliers, customColumns]);
-
+ return [...result, ...customColumns];
+ }, [locations, suppliers, people, customColumns]);
const renderContextMenu = useCallback(
(row: Receipt) => {
@@ -241,6 +273,12 @@ const ReceiptsTable = memo(({ data, count, locations }: ReceiptsTableProps) => {
defaultColumnPinning={{
left: ["receiptId"],
}}
+ defaultColumnVisibility={{
+ createdAt: false,
+ createdBy: false,
+ updatedAt: false,
+ updatedBy: false,
+ }}
primaryAction={
permissions.can("create", "inventory") && (
<New label="Receipt" to={path.to.newReceipt} />
diff --git a/apps/carbon/app/modules/invoicing/invoicing.service.ts b/apps/carbon/app/modules/invoicing/invoicing.service.ts
index 332218ec4d..a96943b44c 100644
--- a/apps/carbon/app/modules/invoicing/invoicing.service.ts
+++ b/apps/carbon/app/modules/invoicing/invoicing.service.ts
@@ -1,4 +1,5 @@
import type { Database, Json } from "@carbon/database";
+import { getLocalTimeZone, today } from "@internationalized/date";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { z } from "zod";
import { getSupplierPayment } from "~/modules/purchasing";
@@ -104,7 +105,10 @@ export async function upsertPurchaseInvoice(
if ("id" in purchaseInvoice) {
return client
.from("purchaseInvoice")
- .update(sanitize(purchaseInvoice))
+ .update({
+ ...sanitize(purchaseInvoice),
+ updatedAt: today(getLocalTimeZone()).toString(),
+ })
.eq("id", purchaseInvoice.id)
.select("id, invoiceId");
}
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index e226c3940f..344a1b9e34 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -77,7 +77,6 @@ export const quotationValidator = z.object({
customerContactId: zfd.text(z.string().optional()),
customerReference: zfd.text(z.string().optional()),
locationId: zfd.text(z.string().optional()),
- ownerId: z.string().min(36, { message: "Owner is required" }),
notes: zfd.text(z.string().optional()),
expirationDate: 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 524c75b53a..f676525504 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -768,7 +768,13 @@ export async function upsertQuote(
if ("createdBy" in quote) {
return client.from("quote").insert([quote]).select("id, quoteId");
} else {
- return client.from("quote").update(sanitize(quote)).eq("id", quote.id);
+ return client
+ .from("quote")
+ .update({
+ ...sanitize(quote),
+ updatedAt: today(getLocalTimeZone()).toString(),
+ })
+ .eq("id", quote.id);
}
}
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
index 594265ae54..910950eeef 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
@@ -433,26 +433,28 @@ const QuotationExplorer = () => {
return result;
}, [tree]);
- const [expandedNodes, setExpandedNodes] = useState<Record<string, boolean>>({
- [params.id]: true,
- });
+ const [collapsedNodes, setCollapsedNodes] = useState<Record<string, boolean>>(
+ {}
+ );
+
+ console.log({ collapsedNodes });
const openNode = (id: string) => {
- const result = { [id]: true };
+ const collapsed = { [id]: false };
let currentId = id;
while (nodeParentById[currentId]) {
- result[nodeParentById[currentId]] = true;
+ collapsed[nodeParentById[currentId]] = false;
currentId = nodeParentById[currentId];
}
- setExpandedNodes((prev) => ({
+ setCollapsedNodes((prev) => ({
...prev,
- ...result,
+ ...collapsed,
}));
};
const toggleNode = (id: string) => {
- setExpandedNodes((prev) => ({
+ setCollapsedNodes((prev) => ({
...prev,
[id]: !prev[id],
}));
@@ -473,14 +475,15 @@ const QuotationExplorer = () => {
}}
>
<IconButton
- aria-label={expandedNodes[node.id] ? "Collapse" : "Expand"}
+ aria-label={collapsedNodes[node.id] ? "Expand" : "Collapse"}
onClick={() => toggleNode(node.id)}
isDisabled={!node.children}
icon={<RxChevronDown />}
style={{
transition: "transform .25s ease",
transform:
- expandedNodes[node.id] ||
+ collapsedNodes[node.id] === undefined ||
+ collapsedNodes[node.id] === false ||
!node.children ||
node.children?.length === 0
? undefined
@@ -500,7 +503,7 @@ const QuotationExplorer = () => {
/>
</HStack>
{node.children &&
- expandedNodes[node.id] &&
+ !collapsedNodes[node.id] &&
renderBillOfMaterial(node.children, level + 1)}
</div>
);
@@ -532,7 +535,7 @@ const QuotationExplorer = () => {
</Tooltip>
</HStack>
</VStack>
- <VStack className="h-[calc(100vh-183px)] p-2 w-full">
+ <VStack className="min-h-[calc(100vh-210px)] p-2 w-full">
<div className="w-full h-full overflow-auto" role="tree">
{renderBillOfMaterial(tree)}
</div>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
index d41ee8ffc9..3a249f7e72 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
@@ -17,7 +17,6 @@ import {
CustomerContact,
CustomerLocation,
DatePicker,
- Employee,
Hidden,
Input,
Location,
@@ -77,12 +76,9 @@ const QuotationForm = ({ initialValues }: QuotationFormProps) => {
name="name"
label="Name"
helperText={
- isEditing
- ? undefined
- : "The name of the RFQ or a reference number"
+ isEditing ? undefined : "The name of the RFQ or a description"
}
/>
- <Employee name="ownerId" label="Quoter" />
<Location name="locationId" label="Location" />
<CustomerLocation
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx
deleted file mode 100644
index b1cf5e5c3d..0000000000
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- HStack,
- Menubar,
- MenubarItem,
- VStack,
- useDisclosure,
-} from "@carbon/react";
-import { useParams } from "@remix-run/react";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { Quotation } from "~/modules/sales";
-import { path } from "~/utils/path";
-import QuotationReleaseModal from "./QuotationReleaseModal";
-import QuotationStatus from "./QuotationStatus";
-
-const QuotationHeader = () => {
- const permissions = usePermissions();
- const { id } = useParams();
- if (!id) throw new Error("Could not find id");
-
- const routeData = useRouteData<{ quotation: Quotation }>(path.to.quote(id));
-
- if (!routeData?.quotation) throw new Error("quotation not found");
-
- const releaseDisclosure = useDisclosure();
-
- return (
- <>
- <VStack>
- {permissions.is("employee") && (
- <Menubar>
- <MenubarItem asChild>
- <a target="_blank" href={path.to.file.quote(id)} rel="noreferrer">
- Preview
- </a>
- </MenubarItem>
- </Menubar>
- )}
-
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.quotation?.quoteId}</CardTitle>
- <CardDescription>
- {routeData?.quotation?.customerName}
- </CardDescription>
- </CardHeader>
- <CardAction></CardAction>
- </HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Name</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.quotation?.name}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Quote Date</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.quotation?.quoteDate}
- </CardAttributeValue>
- </CardAttribute>
-
- <CardAttribute>
- <CardAttributeLabel>Expiration Date</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.quotation?.expirationDate}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Location</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.quotation?.locationName}
- </CardAttributeValue>
- </CardAttribute>
-
- <CardAttribute>
- <CardAttributeLabel>Status</CardAttributeLabel>
- <QuotationStatus status={routeData?.quotation?.status} />
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- </VStack>
- {releaseDisclosure.isOpen && (
- <QuotationReleaseModal
- quotation={routeData?.quotation}
- onClose={releaseDisclosure.onClose}
- />
- )}
- </>
- );
-};
-
-export default QuotationHeader;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/index.ts b/apps/carbon/app/modules/sales/ui/Quotation/index.ts
index 719198d0f6..f21505e0ac 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/index.ts
+++ b/apps/carbon/app/modules/sales/ui/Quotation/index.ts
@@ -2,7 +2,6 @@ import QuotationAssemblyForm from "./QuotationAssemblyForm";
import QuotationDocuments from "./QuotationDocuments";
import QuotationExplorer from "./QuotationExplorer";
import QuotationForm from "./QuotationForm";
-import QuotationHeader from "./QuotationHeader";
import QuotationLineForm from "./QuotationLineForm";
import QuotationLineQuantities from "./QuotationLineQuantities";
import QuotationMaterialForm from "./QuotationMaterialForm";
@@ -21,7 +20,6 @@ export {
QuotationDocuments,
QuotationExplorer,
QuotationForm,
- QuotationHeader,
QuotationLineForm,
QuotationLineQuantities,
QuotationMaterialForm,
diff --git a/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx b/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
index 032399aaad..4c2b0dbe7e 100644
--- a/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
@@ -5,18 +5,25 @@ import {
MenuItem,
useDisclosure,
} from "@carbon/react";
+import { formatDate } from "@carbon/utils";
import { useFetcher, useFetchers, useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo, useState } from "react";
import { BsFillPenFill, BsPin, BsPinFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Avatar, Hyperlink, New, Table } from "~/components";
+import {
+ CustomerAvatar,
+ EmployeeAvatar,
+ Hyperlink,
+ New,
+ Table,
+} from "~/components";
import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Quotation } from "~/modules/sales";
import { quoteStatusType } from "~/modules/sales";
-import { useCustomers, useParts } from "~/stores";
-import { useCustomColumns } from "~/hooks/useCustomColumns";
+import { useCustomers, useParts, usePeople } from "~/stores";
import { favoriteSchema } from "~/types/validators";
import { path } from "~/utils/path";
import { QuotationStatus } from "../Quotation";
@@ -37,6 +44,7 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
const [customers] = useCustomers();
const [parts] = useParts();
+ const [people] = usePeople();
const fetcher = useFetcher();
const optimisticFavorite = useOptimisticFavorite();
@@ -101,14 +109,16 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
),
},
{
- accessorKey: "customerName",
+ id: "customerId",
header: "Customer",
- cell: (item) => item.getValue(),
+ cell: ({ row }) => (
+ <CustomerAvatar customerId={row.original.customerId} />
+ ),
meta: {
filter: {
type: "static",
options: customers?.map((customer) => ({
- value: customer.name,
+ value: customer.id,
label: customer.name,
})),
},
@@ -157,6 +167,22 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
},
},
},
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
{
accessorKey: "quoteDate",
header: "Quote Date",
@@ -189,43 +215,51 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
cell: (item) => item.getValue(),
},
{
- accessorKey: "createdByFullName",
+ id: "createdBy",
header: "Created By",
- cell: ({ row }) => {
- return (
- <HStack>
- <Avatar size="sm" path={row.original.createdByAvatar} />
- <p>{row.original.createdByFullName}</p>
- </HStack>
- );
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
{
accessorKey: "createdAt",
header: "Created At",
- cell: (item) => item.getValue(),
+ cell: (item) => formatDate(item.getValue<string>()),
},
{
- accessorKey: "updatedByFullName",
+ id: "updatedBy",
header: "Updated By",
- cell: ({ row }) => {
- return row.original.updatedByFullName ? (
- <HStack>
- <Avatar size="sm" path={row.original.updatedByAvatar ?? null} />
- <p>{row.original.updatedByFullName}</p>
- </HStack>
- ) : null;
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
},
},
{
accessorKey: "updatedAt",
- header: "Updated At",
- cell: (item) => item.getValue(),
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
},
];
return [...defaultColumns, ...customColumns];
- }, [customers, fetcher, parts, customColumns]);
+ }, [customers, parts, people, customColumns, fetcher]);
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
@@ -258,6 +292,12 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
defaultColumnPinning={{
left: ["quoteId"],
}}
+ defaultColumnVisibility={{
+ createdAt: false,
+ createdBy: false,
+ updatedAt: false,
+ updatedBy: false,
+ }}
primaryAction={
permissions.can("create", "sales") && (
<New label="Quote" to={path.to.newQuote} />
diff --git a/apps/carbon/app/routes/x+/customer+/_layout.tsx b/apps/carbon/app/routes/x+/customer+/_layout.tsx
index 554142e858..2960683fd5 100644
--- a/apps/carbon/app/routes/x+/customer+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/customer+/_layout.tsx
@@ -52,7 +52,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function CustomerRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/inventory+/receipts.$receiptId.tsx b/apps/carbon/app/routes/x+/inventory+/receipts.$receiptId.tsx
index ca07494d65..a40b58cacb 100644
--- a/apps/carbon/app/routes/x+/inventory+/receipts.$receiptId.tsx
+++ b/apps/carbon/app/routes/x+/inventory+/receipts.$receiptId.tsx
@@ -100,6 +100,7 @@ export default function EditReceiptsRoute() {
return (
<ReceiptForm
key={initialValues.id}
+ assignee={receipt.assignee}
// @ts-ignore
initialValues={initialValues}
status={receipt.status}
diff --git a/apps/carbon/app/routes/x+/part+/_layout.tsx b/apps/carbon/app/routes/x+/part+/_layout.tsx
index dfb8ca8b41..f34c99f077 100644
--- a/apps/carbon/app/routes/x+/part+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/part+/_layout.tsx
@@ -35,7 +35,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function PartRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/person+/_layout.tsx b/apps/carbon/app/routes/x+/person+/_layout.tsx
index 0a02582de9..c783c540e9 100644
--- a/apps/carbon/app/routes/x+/person+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/person+/_layout.tsx
@@ -25,7 +25,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function PersonRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx b/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx
index be5fd899f5..839ec8f0fc 100644
--- a/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx
@@ -29,7 +29,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function PurchaseInvoiceRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx b/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx
index ddcbbad908..1d63fade62 100644
--- a/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx
@@ -16,7 +16,7 @@ export const handle: Handle = {
export default function PurchaseOrderRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/quote+/$id.details.tsx b/apps/carbon/app/routes/x+/quote+/$id.details.tsx
index cddcb87f84..e306e4d651 100644
--- a/apps/carbon/app/routes/x+/quote+/$id.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$id.details.tsx
@@ -73,7 +73,6 @@ export default function QuotationBasicRoute() {
quoteId: quoteData?.quotation?.quoteId ?? "",
name: quoteData?.quotation?.name ?? "",
customerId: quoteData?.quotation?.customerId ?? "",
- ownerId: quoteData?.quotation.ownerId ?? "",
customerContactId: quoteData?.quotation?.customerContactId ?? "",
customerLocationId: quoteData?.quotation?.customerLocationId ?? "",
customerReference: quoteData?.quotation?.customerReference ?? "",
diff --git a/apps/carbon/app/routes/x+/quote+/$id.tsx b/apps/carbon/app/routes/x+/quote+/$id.tsx
index 049eb40943..f02bea605f 100644
--- a/apps/carbon/app/routes/x+/quote+/$id.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$id.tsx
@@ -1,4 +1,5 @@
import {
+ HStack,
Heading,
Menubar,
MenubarItem,
@@ -11,6 +12,12 @@ import { json, redirect } from "@remix-run/node";
import type { ShouldRevalidateFunction } from "@remix-run/react";
import { Outlet, useLoaderData, useParams } from "@remix-run/react";
import { useEffect, useRef } from "react";
+import {
+ Assign,
+ CustomerAvatar,
+ EmployeeAvatar,
+ useOptimisticAssignment,
+} from "~/components";
import { CollapsibleSidebar } from "~/components/Layout";
import { useSupabase } from "~/lib/supabase";
import { getLocationsList } from "~/modules/resources";
@@ -31,6 +38,7 @@ import QuotationReleaseModal from "~/modules/sales/ui/Quotation/QuotationRelease
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
+import { useCustomers } from "~/stores";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
import { error } from "~/utils/result";
@@ -152,19 +160,53 @@ export default function QuotationRoute() {
},
});
+ const [customers] = useCustomers();
+ const customer = customers.find((s) => s.id === quotation?.customerId) ?? {
+ name: "",
+ id: "",
+ };
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: id,
+ table: "quote",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : quotation?.assignee;
+
return (
<div className="grid grid-cols-[auto_1fr] w-full">
<CollapsibleSidebar width={260}>
- <VStack className="border-b border-border p-4" spacing={1}>
+ <VStack className="border-b border-border p-2" spacing={1}>
<Heading size="h3" noOfLines={1}>
{quote.quote?.quoteId}
</Heading>
- {quote.quote && <QuotationStatus status={quote.quote?.status} />}
+ </VStack>
+ <VStack className="border-b border-border p-2 text-sm">
+ <HStack className="justify-between w-full">
+ <span className="text-xs text-muted-foreground">Status</span>
+ {quote.quote && <QuotationStatus status={quote.quote?.status} />}
+ </HStack>
+ </VStack>
+ <VStack className="border-b border-border p-2 text-sm">
+ <HStack className="justify-between w-full">
+ <span className="text-xs text-muted-foreground">Customer</span>
+ <CustomerAvatar customerId={customer.id} />
+ </HStack>
+ </VStack>
+ <VStack className="border-b border-border p-2 text-sm">
+ <HStack className="justify-between w-full">
+ <span className="text-xs text-muted-foreground">Assignee</span>
+ {assignee && <EmployeeAvatar employeeId={assignee} />}
+ </HStack>
</VStack>
<QuotationExplorer />
</CollapsibleSidebar>
+
<VStack className="p-2">
<Menubar>
+ <Assign id={id} table="quote" value={assignee ?? undefined} />
<MenubarItem asChild>
<a target="_blank" href={path.to.file.quote(id)} rel="noreferrer">
Preview
diff --git a/apps/carbon/app/routes/x+/quote+/new.tsx b/apps/carbon/app/routes/x+/quote+/new.tsx
index c8dab5ba26..99039b7460 100644
--- a/apps/carbon/app/routes/x+/quote+/new.tsx
+++ b/apps/carbon/app/routes/x+/quote+/new.tsx
@@ -66,7 +66,6 @@ export async function action({ request }: ActionFunctionArgs) {
export default function QuotationNewRoute() {
const user = useUser();
const initialValues = {
- ownerId: user.id,
locationId: user.defaults.locationId,
description: "",
status: "Draft" as "Draft",
diff --git a/apps/carbon/app/routes/x+/rfq+/$id.tsx b/apps/carbon/app/routes/x+/rfq+/$id.tsx
index ca73fb467f..90a22f1847 100644
--- a/apps/carbon/app/routes/x+/rfq+/$id.tsx
+++ b/apps/carbon/app/routes/x+/rfq+/$id.tsx
@@ -2,7 +2,7 @@ import { VStack } from "@carbon/react";
export default function RequestForQuoteRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<pre>TODO</pre>
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/rfq+/_layout.tsx b/apps/carbon/app/routes/x+/rfq+/_layout.tsx
index e471b37abb..d482e92191 100644
--- a/apps/carbon/app/routes/x+/rfq+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/rfq+/_layout.tsx
@@ -16,7 +16,7 @@ export const handle: Handle = {
export default function RequestForQuoteRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/service+/_layout.tsx b/apps/carbon/app/routes/x+/service+/_layout.tsx
index 417a895aad..3470842e12 100644
--- a/apps/carbon/app/routes/x+/service+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/service+/_layout.tsx
@@ -35,7 +35,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function ServiceRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/apps/carbon/app/routes/x+/supplier+/_layout.tsx b/apps/carbon/app/routes/x+/supplier+/_layout.tsx
index 4ad03201b1..e3bdc4d29b 100644
--- a/apps/carbon/app/routes/x+/supplier+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/supplier+/_layout.tsx
@@ -52,7 +52,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function SupplierRoute() {
return (
- <VStack spacing={4} className="h-full p-4">
+ <VStack spacing={4} className="h-full p-2">
<Outlet />
</VStack>
);
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 20cff17a66..c721006e15 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -8386,6 +8386,7 @@ export type Database = {
}
quote: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customerContactId: string | null
@@ -8398,7 +8399,6 @@ export type Database = {
locationId: string | null
name: string
notes: string | null
- ownerId: string
quoteDate: string | null
quoteId: string
revisionId: number
@@ -8407,6 +8407,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customerContactId?: string | null
@@ -8419,7 +8420,6 @@ export type Database = {
locationId?: string | null
name: string
notes?: string | null
- ownerId: string
quoteDate?: string | null
quoteId: string
revisionId?: number
@@ -8428,6 +8428,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customerContactId?: string | null
@@ -8440,7 +8441,6 @@ export type Database = {
locationId?: string | null
name?: string
notes?: string | null
- ownerId?: string
quoteDate?: string | null
quoteId?: string
revisionId?: number
@@ -8449,6 +8449,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_createdBy_fkey"
columns: ["createdBy"]
@@ -8526,34 +8554,6 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["locationId"]
},
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
@@ -9410,6 +9410,7 @@ export type Database = {
}
receipt: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -9430,6 +9431,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -9450,6 +9452,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -9470,6 +9473,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
@@ -14762,14 +14793,12 @@ export type Database = {
}
quotes: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string | null
- createdByAvatar: string | null
- createdByFullName: string | null
customerContactId: string | null
customerId: string | null
customerLocationId: string | null
- customerName: string | null
customerReference: string | null
customFields: Json | null
expirationDate: string | null
@@ -14779,17 +14808,43 @@ export type Database = {
locationName: string | null
name: string | null
notes: string | null
- ownerAvatar: string | null
- ownerFullName: string | null
- ownerId: string | null
partIds: string[] | null
quoteDate: string | null
quoteId: string | null
+ revisionId: number | null
status: Database["public"]["Enums"]["quoteStatus"] | null
- updatedByAvatar: string | null
- updatedByFullName: string | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_createdBy_fkey"
columns: ["createdBy"]
@@ -14868,29 +14923,29 @@ export type Database = {
referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
@@ -14899,10 +14954,9 @@ export type Database = {
}
receipts: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string | null
- createdByAvatar: string | null
- createdByFullName: string | null
customFields: Json | null
externalDocumentId: string | null
id: string | null
@@ -14918,13 +14972,38 @@ export type Database = {
sourceDocumentReadableId: string | null
status: Database["public"]["Enums"]["receiptStatus"] | null
supplierId: string | null
- supplierName: string | null
updatedAt: string | null
updatedBy: string | null
- updatedByAvatar: string | null
- updatedByFullName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 20cff17a66..c721006e15 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -8386,6 +8386,7 @@ export type Database = {
}
quote: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customerContactId: string | null
@@ -8398,7 +8399,6 @@ export type Database = {
locationId: string | null
name: string
notes: string | null
- ownerId: string
quoteDate: string | null
quoteId: string
revisionId: number
@@ -8407,6 +8407,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customerContactId?: string | null
@@ -8419,7 +8420,6 @@ export type Database = {
locationId?: string | null
name: string
notes?: string | null
- ownerId: string
quoteDate?: string | null
quoteId: string
revisionId?: number
@@ -8428,6 +8428,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customerContactId?: string | null
@@ -8440,7 +8441,6 @@ export type Database = {
locationId?: string | null
name?: string
notes?: string | null
- ownerId?: string
quoteDate?: string | null
quoteId?: string
revisionId?: number
@@ -8449,6 +8449,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_createdBy_fkey"
columns: ["createdBy"]
@@ -8526,34 +8554,6 @@ export type Database = {
referencedRelation: "purchaseOrders"
referencedColumns: ["locationId"]
},
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
@@ -9410,6 +9410,7 @@ export type Database = {
}
receipt: {
Row: {
+ assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -9430,6 +9431,7 @@ export type Database = {
updatedBy: string | null
}
Insert: {
+ assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -9450,6 +9452,7 @@ export type Database = {
updatedBy?: string | null
}
Update: {
+ assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -9470,6 +9473,34 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
@@ -14762,14 +14793,12 @@ export type Database = {
}
quotes: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string | null
- createdByAvatar: string | null
- createdByFullName: string | null
customerContactId: string | null
customerId: string | null
customerLocationId: string | null
- customerName: string | null
customerReference: string | null
customFields: Json | null
expirationDate: string | null
@@ -14779,17 +14808,43 @@ export type Database = {
locationName: string | null
name: string | null
notes: string | null
- ownerAvatar: string | null
- ownerFullName: string | null
- ownerId: string | null
partIds: string[] | null
quoteDate: string | null
quoteId: string | null
+ revisionId: number | null
status: Database["public"]["Enums"]["quoteStatus"] | null
- updatedByAvatar: string | null
- updatedByFullName: string | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_createdBy_fkey"
columns: ["createdBy"]
@@ -14868,29 +14923,29 @@ export type Database = {
referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_ownerId_fkey"
- columns: ["ownerId"]
+ foreignKeyName: "quote_updatedBy_fkey"
+ columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
@@ -14899,10 +14954,9 @@ export type Database = {
}
receipts: {
Row: {
+ assignee: string | null
createdAt: string | null
createdBy: string | null
- createdByAvatar: string | null
- createdByFullName: string | null
customFields: Json | null
externalDocumentId: string | null
id: string | null
@@ -14918,13 +14972,38 @@ export type Database = {
sourceDocumentReadableId: string | null
status: Database["public"]["Enums"]["receiptStatus"] | null
supplierId: string | null
- supplierName: string | null
updatedAt: string | null
updatedBy: string | null
- updatedByAvatar: string | null
- updatedByFullName: string | null
}
Relationships: [
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "receipt_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "receipt_createdBy_fkey"
columns: ["createdBy"]
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index 09369d3077..851c170d60 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -2,8 +2,8 @@ ALTER TABLE "customer" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DE
ALTER TABLE "part" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
ALTER TABLE "purchaseOrder" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
ALTER TABLE "purchaseInvoice" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
--- ALTER TABLE "quote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
--- ALTER TABLE "receipt" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "quote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "receipt" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
-- ALTER TABLE "requestForQuote" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
-- ALTER TABLE "service" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
ALTER TABLE "supplier" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
@@ -89,92 +89,33 @@ CREATE OR REPLACE VIEW "purchaseInvoices" WITH(SECURITY_INVOKER=true) AS
FROM "purchaseInvoice" pi
LEFT JOIN "paymentTerm" pt ON pt."id" = pi."paymentTermId";
--- DROP VIEW "quotes";
--- CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
--- SELECT
--- q."id",
--- q."quoteId",
--- q."customerId",
--- q."customerLocationId",
--- q."customerContactId",
--- q."name",
--- q."status",
--- q."notes",
--- q."quoteDate",
--- q."expirationDate",
--- q."customerReference",
--- q."locationId",
--- q."createdAt",
--- q."createdBy",
--- q."ownerId",
--- q."customFields",
--- uo."fullName" AS "ownerFullName",
--- uo."avatarUrl" AS "ownerAvatar",
--- c."name" AS "customerName",
--- uc."fullName" AS "createdByFullName",
--- uc."avatarUrl" AS "createdByAvatar",
--- uu."fullName" AS "updatedByFullName",
--- uu."avatarUrl" AS "updatedByAvatar",
--- l."name" AS "locationName",
--- array_agg(ql."partId") AS "partIds",
--- EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
--- FROM "quote" q
--- LEFT JOIN "customer" c
--- ON c.id = q."customerId"
--- LEFT JOIN "location" l
--- ON l.id = q."locationId"
--- LEFT JOIN "quoteLine" ql
--- ON ql."quoteId" = q.id
--- LEFT JOIN "user" uo
--- ON uo.id = q."ownerId"
--- LEFT JOIN "user" uc
--- ON uc.id = q."createdBy"
--- LEFT JOIN "user" uu
--- ON uu.id = q."updatedBy"
--- GROUP BY
--- q."id",
--- q."quoteId",
--- q."customerId",
--- q."customerLocationId",
--- q."customerContactId",
--- q."name",
--- q."status",
--- q."notes",
--- q."quoteDate",
--- q."expirationDate",
--- q."customerReference",
--- q."locationId",
--- q."createdAt",
--- q."createdBy",
--- q."customFields",
--- c."name",
--- uo."fullName",
--- uo."avatarUrl",
--- uc."fullName",
--- uc."avatarUrl",
--- uu."fullName",
--- uu."avatarUrl",
--- l."name";
+DROP VIEW "quotes";
+ALTER TABLE "quote" DROP COLUMN "ownerId";
+CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ q.*,
+ l."name" AS "locationName",
+ ql."partIds",
+ EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
+ FROM "quote" q
+ LEFT JOIN (
+ SELECT
+ "quoteId",
+ array_agg("partId") AS "partIds"
+ FROM "quoteLine"
+ GROUP BY "quoteId"
+ ) ql ON ql."quoteId" = q.id
+ LEFT JOIN "location" l
+ ON l.id = q."locationId";
--- DROP VIEW "receipts";
--- CREATE OR REPLACE VIEW "receipts" WITH(SECURITY_INVOKER=true) AS
--- SELECT
--- r.*,
--- cb."fullName" as "createdByFullName",
--- cb."avatarUrl" as "createdByAvatar",
--- ub."fullName" as "updatedByFullName",
--- ub."avatarUrl" as "updatedByAvatar",
--- l."name" as "locationName",
--- s."name" as "supplierName"
--- FROM "receipt" r
--- LEFT JOIN "user" cb
--- ON cb.id = r."createdBy"
--- LEFT JOIN "user" ub
--- ON ub.id = r."updatedBy"
--- LEFT JOIN "location" l
--- ON l.id = r."locationId"
--- LEFT JOIN "supplier" s
--- ON s.id = r."supplierId";
+DROP VIEW "receipts";
+CREATE OR REPLACE VIEW "receipts" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ r.*,
+ l."name" as "locationName"
+ FROM "receipt" r
+ LEFT JOIN "location" l
+ ON l.id = r."locationId";
-- DROP VIEW "requestForQuotes";
-- CREATE OR REPLACE VIEW "requestForQuotes" WITH(SECURITY_INVOKER=true) AS
diff --git a/packages/react/src/Avatar.tsx b/packages/react/src/Avatar.tsx
index 168b5585b2..2e6c158ee5 100644
--- a/packages/react/src/Avatar.tsx
+++ b/packages/react/src/Avatar.tsx
@@ -29,7 +29,7 @@ export const avatarVariants = cva(
lg: "h-16 w-16 text-2xl",
md: "h-12 w-12 text-base",
sm: "h-8 w-8 text-xs",
- xs: "h-6 w-6 text-sm",
+ xs: "h-6 w-6 text-xxs",
},
isGroup: {
true: "ring-2 ring-background",
diff --git a/packages/tailwind/tailwind.config.js b/packages/tailwind/tailwind.config.js
index 62cdb40272..4b3e0871d9 100644
--- a/packages/tailwind/tailwind.config.js
+++ b/packages/tailwind/tailwind.config.js
@@ -57,6 +57,9 @@ module.exports = {
md: `calc(var(--radius) - 2px)`,
sm: "calc(var(--radius) - 4px)",
},
+ fontSize: {
+ xxs: "0.675rem",
+ },
fontFamily: {
sans: ["Triangle", ...fontFamily.sans],
mono: ["Roboto Mono", ...fontFamily.mono],