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 optimistic ui to assignment and put it in the menu bar

Brad Barbin7a17624b28a8
diff --git a/apps/carbon/app/components/Assign.tsx b/apps/carbon/app/components/Assign.tsx
new file mode 100644
index 0000000000..b42167c9cb
--- /dev/null
+++ b/apps/carbon/app/components/Assign.tsx
@@ -0,0 +1,135 @@
+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 { usePeople } from "~/stores";
+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 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.map((part) => ({
+ value: part.id,
+ label: part.name,
+ })) ?? [];
+
+ return [{ value: "", label: "Unassigned" }, ...base];
+ }, [people]);
+ 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,
+}: {
+ id: string;
+ table: string;
+}) {
+ const fetchers = useFetchers();
+ const assignFetcher = fetchers.find(
+ (f) => f.formAction === path.to.api.assign
+ );
+
+ if (assignFetcher && assignFetcher.formData) {
+ if (
+ assignFetcher.formData.get("id") === id &&
+ assignFetcher.formData.get("table") === table
+ ) {
+ return assignFetcher.formData.get("assignee") as string;
+ }
+ }
+}
diff --git a/apps/carbon/app/components/Form/Employee.tsx b/apps/carbon/app/components/Form/Employee.tsx
index 07fa6b184c..34bde80c00 100644
--- a/apps/carbon/app/components/Form/Employee.tsx
+++ b/apps/carbon/app/components/Form/Employee.tsx
@@ -1,7 +1,7 @@
import { useMemo } from "react";
import { usePeople } from "~/stores";
import type { ComboboxProps } from "./Combobox";
-import CreatableCombobox from "./CreatableCombobox";
+import Combobox from "./Combobox";
type EmployeeSelectProps = Omit<ComboboxProps, "options" | "type"> & {
type?: "assignee";
@@ -26,7 +26,7 @@ const Employee = ({ type, ...props }: EmployeeSelectProps) => {
return (
<>
- <CreatableCombobox
+ <Combobox
options={options}
{...props}
label={props?.label ?? "Employee"}
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
index e656dddbfc..23d7fd0869 100644
--- a/apps/carbon/app/components/index.ts
+++ b/apps/carbon/app/components/index.ts
@@ -1,4 +1,5 @@
import Address from "./Address";
+import Assign, { useOptimisticAssignment } from "./Assign";
import Avatar from "./Avatar";
import { BreadcrumbItem, BreadcrumbLink, Breadcrumbs } from "./Breadcrumb";
import Combobox from "./Combobox";
@@ -14,6 +15,7 @@ import Table from "./Table";
export {
Address,
+ Assign,
Avatar,
BreadcrumbItem,
BreadcrumbLink,
@@ -28,4 +30,5 @@ export {
Select,
SupplierAvatar,
Table,
+ useOptimisticAssignment,
};
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx b/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx
new file mode 100644
index 0000000000..c2dd2d96bb
--- /dev/null
+++ b/apps/carbon/app/modules/parts/ui/Part/PartHeader.tsx
@@ -0,0 +1,108 @@
+import {
+ Card,
+ CardAction,
+ CardAttribute,
+ CardAttributeLabel,
+ CardAttributeValue,
+ CardAttributes,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ Enumerable,
+ HStack,
+ Menubar,
+ VStack,
+} from "@carbon/react";
+
+import { useParams } from "@remix-run/react";
+import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { PartSummary } from "~/modules/parts";
+import { path } from "~/utils/path";
+
+const PartHeader = () => {
+ const permissions = usePermissions();
+ const { partId } = useParams();
+ if (!partId) throw new Error("partId not found");
+
+ const routeData = useRouteData<{ partSummary: PartSummary }>(
+ path.to.part(partId)
+ );
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: partId,
+ table: "part",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.partSummary?.assignee;
+
+ return (
+ <VStack>
+ {permissions.is("employee") && (
+ <Menubar>
+ <Assign
+ id={partId}
+ table="part"
+ value={routeData?.partSummary?.assignee ?? ""}
+ />
+ </Menubar>
+ )}
+ <Card>
+ <HStack className="justify-between items-start">
+ <CardHeader>
+ <CardTitle>{routeData?.partSummary?.id}</CardTitle>
+ <CardDescription>{routeData?.partSummary?.name}</CardDescription>
+ </CardHeader>
+ <CardAction>
+ {/* <Button
+ variant="secondary"
+ onClick={() => alert("TODO")}
+ leftIcon={<FaHistory />}
+ >
+ View History
+ </Button> */}
+ </CardAction>
+ </HStack>
+ <CardContent>
+ <CardAttributes>
+ <CardAttribute>
+ <CardAttributeLabel>Assignee</CardAttributeLabel>
+ <CardAttributeValue>
+ {assignee ? (
+ <EmployeeAvatar employeeId={assignee ?? null} />
+ ) : (
+ "-"
+ )}
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Replenishment</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable
+ value={routeData?.partSummary?.replenishmentSystem ?? null}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Part Type</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable value={routeData?.partSummary?.partType ?? null} />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Unit of Measure</CardAttributeLabel>
+ <CardAttributeValue>
+ {routeData?.partSummary?.unitOfMeasureCode}
+ </CardAttributeValue>
+ </CardAttribute>
+ </CardAttributes>
+ </CardContent>
+ </Card>
+ </VStack>
+ );
+};
+
+export default PartHeader;
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartPreview.tsx b/apps/carbon/app/modules/parts/ui/Part/PartPreview.tsx
deleted file mode 100644
index 2faeb9dc07..0000000000
--- a/apps/carbon/app/modules/parts/ui/Part/PartPreview.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import {
- Card,
- CardAction,
- CardAttribute,
- CardAttributeLabel,
- CardAttributeValue,
- CardAttributes,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- HStack,
-} from "@carbon/react";
-
-import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { PartSummary } from "~/modules/parts";
-import { path } from "~/utils/path";
-
-const PartPreview = () => {
- const { partId } = useParams();
- if (!partId) throw new Error("partId not found");
-
- const routeData = useRouteData<{ partSummary: PartSummary }>(
- path.to.part(partId)
- );
-
- return (
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>{routeData?.partSummary?.id}</CardTitle>
- <CardDescription>{routeData?.partSummary?.name}</CardDescription>
- </CardHeader>
- <CardAction>
- {/* <Button
- variant="secondary"
- onClick={() => alert("TODO")}
- leftIcon={<FaHistory />}
- >
- View History
- </Button> */}
- </CardAction>
- </HStack>
- <CardContent>
- <CardAttributes>
- <CardAttribute>
- <CardAttributeLabel>Replenishment System</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.partSummary?.replenishmentSystem}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Part Type</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.partSummary?.partType}
- </CardAttributeValue>
- </CardAttribute>
- <CardAttribute>
- <CardAttributeLabel>Unit of Measure</CardAttributeLabel>
- <CardAttributeValue>
- {routeData?.partSummary?.unitOfMeasureCode}
- </CardAttributeValue>
- </CardAttribute>
- </CardAttributes>
- </CardContent>
- </Card>
- );
-};
-
-export default PartPreview;
diff --git a/apps/carbon/app/modules/parts/ui/Part/index.ts b/apps/carbon/app/modules/parts/ui/Part/index.ts
index 9b61d68d68..c16fcb2854 100644
--- a/apps/carbon/app/modules/parts/ui/Part/index.ts
+++ b/apps/carbon/app/modules/parts/ui/Part/index.ts
@@ -1,9 +1,9 @@
import PartCostingForm from "./PartCostingForm";
import PartForm from "./PartForm";
+import PartHeader from "./PartHeader";
import PartInventoryForm from "./PartInventoryForm";
import PartManufacturingForm from "./PartManufacturingForm";
import PartPlanningForm from "./PartPlanningForm";
-import PartPreview from "./PartPreview";
import PartPurchasingForm from "./PartPurchasingForm";
import PartSalePriceForm from "./PartSalePriceForm";
import PartSidebar from "./PartSidebar";
@@ -13,10 +13,10 @@ import PartSuppliers from "./PartSuppliers";
export {
PartCostingForm,
PartForm,
+ PartHeader,
PartInventoryForm,
PartManufacturingForm,
PartPlanningForm,
- PartPreview,
PartPurchasingForm,
PartSalePriceForm,
PartSidebar,
diff --git a/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
index 41900dbaaf..86abf7d4b2 100644
--- a/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/Parts/PartsTable.tsx
@@ -1,13 +1,15 @@
-import { Enumerable, 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, useMemo } from "react";
import { BsFillPenFill } from "react-icons/bs";
-import { Hyperlink, New, Table } from "~/components";
+import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Part } from "~/modules/parts";
import { partReplenishmentSystems, partTypes } from "~/modules/parts";
+import { usePeople } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -22,6 +24,7 @@ const PartsTable = memo(({ data, count, partGroups }: PartsTableProps) => {
const [params] = useUrlParams();
const permissions = usePermissions();
const customColumns = useCustomColumns<Part>("part");
+ const [people] = usePeople();
const columns = useMemo<ColumnDef<Part>[]>(() => {
const defaultColumns: ColumnDef<Part>[] = [
@@ -86,6 +89,78 @@ const PartsTable = memo(({ data, count, partGroups }: PartsTableProps) => {
},
},
},
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
+ },
+ },
+ },
+ {
+ 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,
+ })),
+ },
+ },
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
];
return [...defaultColumns, ...customColumns];
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -107,12 +182,25 @@ const PartsTable = memo(({ data, count, partGroups }: PartsTableProps) => {
count={count}
columns={columns}
data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ blocked: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
primaryAction={
permissions.can("create", "parts") && (
<New label="Part" to={path.to.newPart} />
)
}
renderContextMenu={renderContextMenu}
+ withColumnOrdering
/>
</>
);
diff --git a/apps/carbon/app/modules/purchasing/purchasing.models.ts b/apps/carbon/app/modules/purchasing/purchasing.models.ts
index 9fbb91f4c5..4adcfca910 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.models.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.models.ts
@@ -212,7 +212,6 @@ export const supplierValidator = z.object({
supplierStatusId: zfd.text(z.string().optional()),
taxId: zfd.text(z.string().optional()),
accountManagerId: zfd.text(z.string().optional()),
- assignee: zfd.text(z.string().optional()),
});
export const supplierContactValidator = z.object({
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
index 3f979453e2..65d63bf722 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
@@ -92,7 +92,7 @@ const SupplierForm = ({
/>
<Employee name="accountManagerId" label="Account Manager" />
- <Employee name="assignee" label="Assignee" type="assignee" />
+
<CustomFormFields table="supplier" />
</div>
</ModalCardBody>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
index 8777c8b15a..291cfa4b47 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
@@ -10,12 +10,13 @@ import {
CardTitle,
Enumerable,
HStack,
+ Menubar,
VStack,
} from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { EmployeeAvatar } from "~/components";
-import { useRouteData } from "~/hooks";
+import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { usePermissions, useRouteData } from "~/hooks";
import type {
SupplierDetail,
SupplierStatus,
@@ -25,11 +26,14 @@ import type { ListItem } from "~/types";
import { path } from "~/utils/path";
const SupplierHeader = () => {
+ const permissions = usePermissions();
const { supplierId } = useParams();
+
if (!supplierId) throw new Error("Could not find supplierId");
const routeData = useRouteData<{ supplier: SupplierDetail }>(
path.to.supplier(supplierId)
);
+
const sharedSupplierData = useRouteData<{
supplierTypes: SupplierType[];
supplierStatuses: SupplierStatus[];
@@ -44,8 +48,26 @@ const SupplierHeader = () => {
(type) => type.id === routeData?.supplier?.supplierTypeId
)?.name;
+ const optimisticAssignment = useOptimisticAssignment({
+ id: supplierId,
+ table: "supplier",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.supplier?.assignee;
+
return (
<VStack>
+ {permissions.is("employee") && (
+ <Menubar>
+ <Assign
+ id={supplierId}
+ table="supplier"
+ value={routeData?.supplier?.assignee ?? ""}
+ />
+ </Menubar>
+ )}
<Card>
<HStack className="justify-between items-start">
<CardHeader>
@@ -74,10 +96,8 @@ const SupplierHeader = () => {
<CardAttribute>
<CardAttributeLabel>Assignee</CardAttributeLabel>
<CardAttributeValue>
- {routeData?.supplier?.assignee ? (
- <EmployeeAvatar
- employeeId={routeData?.supplier?.assignee ?? null}
- />
+ {assignee ? (
+ <EmployeeAvatar employeeId={assignee ?? null} />
) : (
"-"
)}
diff --git a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
index d1fbb5b0ba..a601cedc46 100644
--- a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
@@ -1,6 +1,6 @@
import { Button, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
import { formatDate } from "@carbon/utils";
-import { useNavigate } from "@remix-run/react";
+import { Link, useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo } from "react";
import { BsFillPenFill } from "react-icons/bs";
@@ -40,62 +40,63 @@ const SuppliersTable = memo(
</Hyperlink>
),
},
+
{
- id: "accountManagerId",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.accountManagerId} />
- ),
+ accessorKey: "type",
+ header: "Supplier Type",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
+ options: supplierTypes?.map((type) => ({
+ value: type.name ?? "",
+ label: <Enumerable value={type.name ?? ""} />,
})),
},
},
},
{
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
+ accessorKey: "status",
+ header: "Supplier Status",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
+ options: supplierStatuses?.map((status) => ({
+ value: status.name,
+ label: <Enumerable value={status.name ?? ""} />,
})),
},
},
},
{
- accessorKey: "type",
- header: "Supplier Type",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ id: "accountManagerId",
+ header: "Account Manager",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.accountManagerId} />
+ ),
meta: {
filter: {
type: "static",
- options: supplierTypes?.map((type) => ({
- value: type.name ?? "",
- label: <Enumerable value={type.name ?? ""} />,
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
})),
},
},
},
{
- accessorKey: "status",
- header: "Supplier Status",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
meta: {
filter: {
type: "static",
- options: supplierStatuses?.map((status) => ({
- value: status.name,
- label: <Enumerable value={status.name ?? ""} />,
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
})),
},
},
@@ -104,15 +105,12 @@ const SuppliersTable = memo(
id: "orders",
header: "Orders",
cell: ({ row }) => (
- <Button
- variant="secondary"
- onClick={() =>
- navigate(
- `${path.to.purchaseOrders}?filter=supplierName:eq:${row.original.name}`
- )
- }
- >
- {row.original.orderCount ?? 0} Orders
+ <Button variant="secondary" asChild>
+ <Link
+ to={`${path.to.purchaseOrders}?filter=supplierName:eq:${row.original.name}`}
+ >
+ {row.original.orderCount ?? 0} Orders
+ </Link>
</Button>
),
},
@@ -120,13 +118,10 @@ const SuppliersTable = memo(
id: "parts",
header: "Parts",
cell: ({ row }) => (
- <Button
- variant="secondary"
- onClick={() =>
- navigate(`${path.to.partsSearch}?supplierId=${row.original.id}`)
- }
- >
- {row.original.partCount ?? 0} Parts
+ <Button variant="secondary" asChild>
+ <Link to={`${path.to.partsSearch}?supplierId=${row.original.id}`}>
+ {row.original.partCount ?? 0} Parts
+ </Link>
</Button>
),
},
@@ -175,7 +170,7 @@ const SuppliersTable = memo(
];
return [...defaultColumns, ...customColumns];
- }, [supplierTypes, supplierStatuses, people, customColumns]);
+ }, [people, supplierTypes, supplierStatuses, customColumns]);
const renderContextMenu = useMemo(
// eslint-disable-next-line react/display-name
diff --git a/apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsx
index 4de0f2c3a8..b85b012058 100644
--- a/apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsx
+++ b/apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsx
@@ -16,7 +16,7 @@ import { useRouteData } from "~/hooks";
import type { EmployeeSummary } from "~/modules/resources";
import { path } from "~/utils/path";
-const PartPreview = () => {
+const PersonHeader = () => {
const { personId } = useParams();
if (!personId) throw new Error("personId not found");
@@ -69,4 +69,4 @@ const PartPreview = () => {
);
};
-export default PartPreview;
+export default PersonHeader;
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index 47038fe588..e226c3940f 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -10,7 +10,6 @@ export const customerValidator = z.object({
customerStatusId: zfd.text(z.string().optional()),
taxId: zfd.text(z.string().optional()),
accountManagerId: zfd.text(z.string().optional()),
- assignee: zfd.text(z.string().optional()),
});
export const customerContactValidator = z.object({
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
index d6ceae2cc7..9b65833c96 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
@@ -92,7 +92,7 @@ const CustomerForm = ({
/>
<Employee name="accountManagerId" label="Account Manager" />
- <Employee name="assignee" label="Assignee" type="assignee" />
+
<CustomFormFields table="customer" />
</div>
</ModalCardBody>
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
index 28ec4e3c01..1c37751712 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
@@ -10,12 +10,13 @@ import {
CardTitle,
Enumerable,
HStack,
+ Menubar,
VStack,
} from "@carbon/react";
import { useParams } from "@remix-run/react";
-import { EmployeeAvatar } from "~/components";
-import { useRouteData } from "~/hooks";
+import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { usePermissions, useRouteData } from "~/hooks";
import type {
CustomerDetail,
CustomerStatus,
@@ -25,11 +26,14 @@ import type { ListItem } from "~/types";
import { path } from "~/utils/path";
const CustomerHeader = () => {
+ const permissions = usePermissions();
const { customerId } = useParams();
+
if (!customerId) throw new Error("Could not find customerId");
const routeData = useRouteData<{ customer: CustomerDetail }>(
path.to.customer(customerId)
);
+
const sharedCustomerData = useRouteData<{
customerTypes: CustomerType[];
customerStatuses: CustomerStatus[];
@@ -44,8 +48,26 @@ const CustomerHeader = () => {
(type) => type.id === routeData?.customer?.customerTypeId
)?.name;
+ const optimisticAssignment = useOptimisticAssignment({
+ id: customerId,
+ table: "customer",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.customer?.assignee;
+
return (
<VStack>
+ {permissions.is("employee") && (
+ <Menubar>
+ <Assign
+ id={customerId}
+ table="customer"
+ value={routeData?.customer?.assignee ?? ""}
+ />
+ </Menubar>
+ )}
<Card>
<HStack className="justify-between items-start">
<CardHeader>
@@ -74,10 +96,8 @@ const CustomerHeader = () => {
<CardAttribute>
<CardAttributeLabel>Assignee</CardAttributeLabel>
<CardAttributeValue>
- {routeData?.customer?.assignee ? (
- <EmployeeAvatar
- employeeId={routeData?.customer?.assignee ?? null}
- />
+ {assignee ? (
+ <EmployeeAvatar employeeId={assignee ?? null} />
) : (
"-"
)}
diff --git a/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
index 58cd4fe076..425f60eb5f 100644
--- a/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
@@ -36,62 +36,63 @@ const CustomersTable = memo(
</Hyperlink>
),
},
+
{
- id: "accountManagerId",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.accountManagerId} />
- ),
+ accessorKey: "type",
+ header: "Customer Type",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
+ options: customerTypes?.map((type) => ({
+ value: type.name ?? "",
+ label: <Enumerable value={type.name ?? ""} />,
})),
},
},
},
{
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
+ accessorKey: "status",
+ header: "Customer Status",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
+ options: customerStatuses?.map((status) => ({
+ value: status.name,
+ label: <Enumerable value={status.name ?? ""} />,
})),
},
},
},
{
- accessorKey: "type",
- header: "Customer Type",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ id: "accountManagerId",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.accountManagerId} />
+ ),
meta: {
filter: {
type: "static",
- options: customerTypes?.map((type) => ({
- value: type.name ?? "",
- label: <Enumerable value={type.name ?? ""} />,
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
})),
},
},
},
{
- accessorKey: "status",
- header: "Customer Status",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
meta: {
filter: {
type: "static",
- options: customerStatuses?.map((status) => ({
- value: status.name,
- label: <Enumerable value={status.name ?? ""} />,
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
})),
},
},
diff --git a/apps/carbon/app/modules/shared/shared.server.ts b/apps/carbon/app/modules/shared/shared.server.ts
index 5b8dc3365f..ac95eb95f5 100644
--- a/apps/carbon/app/modules/shared/shared.server.ts
+++ b/apps/carbon/app/modules/shared/shared.server.ts
@@ -3,6 +3,22 @@ import { redis } from "@carbon/redis";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { CustomFieldsTableType } from "../settings";
+export async function assign(
+ client: SupabaseClient<Database>,
+ args: {
+ id: string;
+ table: string;
+ assignee: string;
+ }
+) {
+ const { id, table, assignee } = args;
+
+ return client
+ .from(table)
+ .update({ assignee: assignee ? assignee : null })
+ .eq("id", id);
+}
+
export async function getCustomFieldsCacheKey(args?: {
module?: string;
table?: string;
diff --git a/apps/carbon/app/routes/api+/assign.ts b/apps/carbon/app/routes/api+/assign.ts
new file mode 100644
index 0000000000..d34bd98fbe
--- /dev/null
+++ b/apps/carbon/app/routes/api+/assign.ts
@@ -0,0 +1,30 @@
+import { json, type ActionFunctionArgs } from "@remix-run/node";
+import { assign } from "~/modules/shared/shared.server";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session.server";
+import { error } from "~/utils/result";
+
+export async function action({ request }: ActionFunctionArgs) {
+ const { client } = await requirePermissions(request, {});
+
+ const formData = await request.formData();
+ const id = formData.get("id") as string;
+ const assignee = formData.get("assignee") as string;
+ const table = formData.get("table") as string;
+
+ if (table && id) {
+ const result = await assign(client, { table, id, assignee });
+ if (result.error) {
+ return json(
+ { success: false },
+ await flash(request, error(result.error, "Failed to assign"))
+ );
+ }
+ return json({ success: true });
+ } else {
+ return json(
+ { success: false },
+ await flash(request, error(null, "Failed to assign"))
+ );
+ }
+}
diff --git a/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx b/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx
index e2838e53b4..0071a25029 100644
--- a/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx
+++ b/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx
@@ -70,7 +70,6 @@ export default function CustomerEditRoute() {
customerStatusId: routeData?.customer?.customerStatusId ?? undefined,
accountManagerId: routeData?.customer?.accountManagerId ?? undefined,
taxId: routeData?.customer?.taxId ?? "",
- assignee: routeData?.customer?.assignee ?? undefined,
...getCustomFields(routeData?.customer?.customFields),
};
diff --git a/apps/carbon/app/routes/x+/part+/$partId.tsx b/apps/carbon/app/routes/x+/part+/$partId.tsx
index 7e7b011248..db3632439e 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.tsx
+++ b/apps/carbon/app/routes/x+/part+/$partId.tsx
@@ -1,7 +1,7 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
-import { PartPreview, PartSidebar, getPartSummary } from "~/modules/parts";
+import { PartHeader, PartSidebar, getPartSummary } from "~/modules/parts";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
import { path } from "~/utils/path";
@@ -35,7 +35,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export default function PartRoute() {
return (
<>
- <PartPreview />
+ <PartHeader />
<div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-4">
<PartSidebar />
<Outlet />
diff --git a/apps/carbon/app/routes/x+/supplier+/$supplierId.details.tsx b/apps/carbon/app/routes/x+/supplier+/$supplierId.details.tsx
index 6e4c4b2a76..b3bf6d86c4 100644
--- a/apps/carbon/app/routes/x+/supplier+/$supplierId.details.tsx
+++ b/apps/carbon/app/routes/x+/supplier+/$supplierId.details.tsx
@@ -70,7 +70,6 @@ export default function SupplierEditRoute() {
supplierStatusId: routeData?.supplier?.supplierStatusId ?? undefined,
accountManagerId: routeData?.supplier?.accountManagerId ?? undefined,
taxId: routeData?.supplier?.taxId ?? "",
- assignee: routeData?.supplier?.assignee ?? undefined,
...getCustomFields(routeData?.supplier?.customFields),
};
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 55ccaef0d1..e8e5e83014 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -14,6 +14,7 @@ export const path = {
accountingCategories: `${api}/accounting/categories`,
accountingSubcategories: (id: string) =>
generatePath(`${api}/accounting/subcategories?accountCategoryId=${id}`),
+ assign: `${api}/assign`,
currencies: `${api}/accounting/currencies`,
customerContacts: (id: string) =>
generatePath(`${api}/sales/customer-contacts?customerId=${id}`),
diff --git a/apps/carbon/app/utils/result.ts b/apps/carbon/app/utils/result.ts
index 85710af5c9..804cd8ffc0 100644
--- a/apps/carbon/app/utils/result.ts
+++ b/apps/carbon/app/utils/result.ts
@@ -4,7 +4,10 @@ import type { Result } from "~/types";
export function error(error: any, message = "Request failed"): Result {
if (error) logger.error({ error, message });
- const details = "message" in error ? (error.message as string) : undefined;
+ const details =
+ typeof error === "object" && error !== null && "message" in error
+ ? (error.message as string)
+ : undefined;
return {
success: false,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 1ca117b3b3..37b7daba9a 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -132,7 +132,6 @@ export type Database = {
accountCategoryId: string | null
accountSubcategoryId: string | null
active: boolean
- assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -153,7 +152,6 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -174,7 +172,6 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -206,34 +203,6 @@ export type Database = {
referencedRelation: "accountCategory"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -5146,7 +5115,6 @@ export type Database = {
Row: {
abilityId: string
active: boolean
- assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -5158,7 +5126,6 @@ export type Database = {
Insert: {
abilityId: string
active?: boolean
- assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -5170,7 +5137,6 @@ export type Database = {
Update: {
abilityId?: string
active?: boolean
- assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -5187,34 +5153,6 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -6678,7 +6616,6 @@ export type Database = {
}
purchaseInvoice: {
Row: {
- assignee: string | null
balance: number
createdAt: string
createdBy: string
@@ -6706,7 +6643,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
balance?: number
createdAt?: string
createdBy: string
@@ -6734,7 +6670,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
balance?: number
createdAt?: string
createdBy?: string
@@ -6762,34 +6697,6 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "purchaseInvoice_createdBy_fkey"
columns: ["createdBy"]
@@ -7382,7 +7289,6 @@ export type Database = {
}
purchaseOrder: {
Row: {
- assignee: string | null
closedAt: string | null
closedBy: string | null
createdAt: string
@@ -7403,7 +7309,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7424,7 +7329,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7445,34 +7349,6 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -8479,7 +8355,6 @@ export type Database = {
}
quote: {
Row: {
- assignee: string | null
createdAt: string
createdBy: string
customerContactId: string | null
@@ -8501,7 +8376,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
createdAt?: string
createdBy: string
customerContactId?: string | null
@@ -8523,7 +8397,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
createdAt?: string
createdBy?: string
customerContactId?: string | null
@@ -8545,34 +8418,6 @@ 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"]
@@ -9534,7 +9379,6 @@ export type Database = {
}
receipt: {
Row: {
- assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -9555,7 +9399,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -9576,7 +9419,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -9597,34 +9439,6 @@ 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"]
@@ -9922,7 +9736,6 @@ export type Database = {
}
requestForQuote: {
Row: {
- assignee: string | null
createdAt: string | null
createdBy: string
customFields: Json | null
@@ -9939,7 +9752,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
createdAt?: string | null
createdBy: string
customFields?: Json | null
@@ -9956,7 +9768,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
createdAt?: string | null
createdBy?: string
customFields?: Json | null
@@ -9973,34 +9784,6 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "requestForQuote_createdBy_fkey"
columns: ["createdBy"]
@@ -10705,7 +10488,6 @@ export type Database = {
active: boolean
approved: boolean
approvedBy: string | null
- assignee: string | null
blocked: boolean
createdAt: string
createdBy: string
@@ -10724,7 +10506,6 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
- assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy: string
@@ -10743,7 +10524,6 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
- assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy?: string
@@ -10787,34 +10567,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "service_createdBy_fkey"
columns: ["createdBy"]
@@ -13476,7 +13228,6 @@ export type Database = {
accountSubCategory: string | null
accountSubcategoryId: string | null
active: boolean | null
- assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13499,7 +13250,6 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13522,7 +13272,6 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13554,34 +13303,6 @@ export type Database = {
referencedRelation: "accountCategories"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -14145,14 +13866,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -14202,9 +13923,17 @@ export type Database = {
parts: {
Row: {
active: boolean | null
+ approved: boolean | null
+ approvedBy: string | null
+ assignee: string | null
+ blocked: boolean | null
+ createdAt: string | null
+ createdBy: string | null
customFields: Json | null
description: string | null
+ fromDate: string | null
id: string | null
+ manufacturerPartNumber: string | null
name: string | null
partGroup: string | null
partGroupId: string | null
@@ -14213,8 +13942,96 @@ export type Database = {
| Database["public"]["Enums"]["partReplenishmentSystem"]
| null
supplierIds: string[] | null
+ toDate: string | null
+ unitOfMeasureCode: string | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "part_partGroupId_fkey"
columns: ["partGroupId"]
@@ -14222,6 +14039,41 @@ export type Database = {
referencedRelation: "partGroup"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "part_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
]
}
purchaseInvoices: {
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 1ca117b3b3..37b7daba9a 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -132,7 +132,6 @@ export type Database = {
accountCategoryId: string | null
accountSubcategoryId: string | null
active: boolean
- assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -153,7 +152,6 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -174,7 +172,6 @@ export type Database = {
accountCategoryId?: string | null
accountSubcategoryId?: string | null
active?: boolean
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -206,34 +203,6 @@ export type Database = {
referencedRelation: "accountCategory"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -5146,7 +5115,6 @@ export type Database = {
Row: {
abilityId: string
active: boolean
- assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -5158,7 +5126,6 @@ export type Database = {
Insert: {
abilityId: string
active?: boolean
- assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -5170,7 +5137,6 @@ export type Database = {
Update: {
abilityId?: string
active?: boolean
- assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -5187,34 +5153,6 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -6678,7 +6616,6 @@ export type Database = {
}
purchaseInvoice: {
Row: {
- assignee: string | null
balance: number
createdAt: string
createdBy: string
@@ -6706,7 +6643,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
balance?: number
createdAt?: string
createdBy: string
@@ -6734,7 +6670,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
balance?: number
createdAt?: string
createdBy?: string
@@ -6762,34 +6697,6 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseInvoice_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "purchaseInvoice_createdBy_fkey"
columns: ["createdBy"]
@@ -7382,7 +7289,6 @@ export type Database = {
}
purchaseOrder: {
Row: {
- assignee: string | null
closedAt: string | null
closedBy: string | null
createdAt: string
@@ -7403,7 +7309,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7424,7 +7329,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
closedAt?: string | null
closedBy?: string | null
createdAt?: string
@@ -7445,34 +7349,6 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -8479,7 +8355,6 @@ export type Database = {
}
quote: {
Row: {
- assignee: string | null
createdAt: string
createdBy: string
customerContactId: string | null
@@ -8501,7 +8376,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
createdAt?: string
createdBy: string
customerContactId?: string | null
@@ -8523,7 +8397,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
createdAt?: string
createdBy?: string
customerContactId?: string | null
@@ -8545,34 +8418,6 @@ 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"]
@@ -9534,7 +9379,6 @@ export type Database = {
}
receipt: {
Row: {
- assignee: string | null
createdAt: string
createdBy: string
customFields: Json | null
@@ -9555,7 +9399,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
createdAt?: string
createdBy: string
customFields?: Json | null
@@ -9576,7 +9419,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
createdAt?: string
createdBy?: string
customFields?: Json | null
@@ -9597,34 +9439,6 @@ 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"]
@@ -9922,7 +9736,6 @@ export type Database = {
}
requestForQuote: {
Row: {
- assignee: string | null
createdAt: string | null
createdBy: string
customFields: Json | null
@@ -9939,7 +9752,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- assignee?: string | null
createdAt?: string | null
createdBy: string
customFields?: Json | null
@@ -9956,7 +9768,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- assignee?: string | null
createdAt?: string | null
createdBy?: string
customFields?: Json | null
@@ -9973,34 +9784,6 @@ export type Database = {
updatedBy?: string | null
}
Relationships: [
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "requestForQuote_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "requestForQuote_createdBy_fkey"
columns: ["createdBy"]
@@ -10705,7 +10488,6 @@ export type Database = {
active: boolean
approved: boolean
approvedBy: string | null
- assignee: string | null
blocked: boolean
createdAt: string
createdBy: string
@@ -10724,7 +10506,6 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
- assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy: string
@@ -10743,7 +10524,6 @@ export type Database = {
active?: boolean
approved?: boolean
approvedBy?: string | null
- assignee?: string | null
blocked?: boolean
createdAt?: string
createdBy?: string
@@ -10787,34 +10567,6 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "service_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "service_createdBy_fkey"
columns: ["createdBy"]
@@ -13476,7 +13228,6 @@ export type Database = {
accountSubCategory: string | null
accountSubcategoryId: string | null
active: boolean | null
- assignee: string | null
class: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13499,7 +13250,6 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13522,7 +13272,6 @@ export type Database = {
accountSubCategory?: never
accountSubcategoryId?: string | null
active?: boolean | null
- assignee?: string | null
class?: Database["public"]["Enums"]["glAccountClass"] | null
consolidatedRate?:
| Database["public"]["Enums"]["glConsolidatedRate"]
@@ -13554,34 +13303,6 @@ export type Database = {
referencedRelation: "accountCategories"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "account_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "account_createdBy_fkey"
columns: ["createdBy"]
@@ -14145,14 +13866,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -14202,9 +13923,17 @@ export type Database = {
parts: {
Row: {
active: boolean | null
+ approved: boolean | null
+ approvedBy: string | null
+ assignee: string | null
+ blocked: boolean | null
+ createdAt: string | null
+ createdBy: string | null
customFields: Json | null
description: string | null
+ fromDate: string | null
id: string | null
+ manufacturerPartNumber: string | null
name: string | null
partGroup: string | null
partGroupId: string | null
@@ -14213,8 +13942,96 @@ export type Database = {
| Database["public"]["Enums"]["partReplenishmentSystem"]
| null
supplierIds: string[] | null
+ toDate: string | null
+ unitOfMeasureCode: string | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_approvedBy_fkey"
+ columns: ["approvedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "part_partGroupId_fkey"
columns: ["partGroupId"]
@@ -14222,6 +14039,41 @@ export type Database = {
referencedRelation: "partGroup"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "part_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "part_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
]
}
purchaseInvoices: {
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index 6ec341dfbe..9ea50c32c3 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -1,7 +1,7 @@
-- ALTER TABLE "account" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
ALTER TABLE "contractor" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
ALTER TABLE "customer" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
--- ALTER TABLE "part" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
+ALTER TABLE "part" ADD COLUMN "assignee" TEXT REFERENCES "user" ("id") ON DELETE SET NULL;
-- ALTER TABLE "partner" 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;
@@ -91,31 +91,21 @@ CREATE OR REPLACE VIEW "customers" AS
-- ON a2.id = p."abilityId"
-- WHERE p."active" = true;
--- DROP VIEW "parts";
--- CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
--- SELECT
--- p.id,
--- p.name,
--- p.description,
--- p."partType",
--- p."partGroupId",
--- pg.name AS "partGroup",
--- p."replenishmentSystem",
--- p.active,
--- p."customFields",
--- array_agg(ps."supplierId") AS "supplierIds"
--- FROM "part" p
--- LEFT JOIN "partGroup" pg ON pg.id = p."partGroupId"
--- LEFT JOIN "partSupplier" ps ON ps."partId" = p.id
--- GROUP BY p.id,
--- p.name,
--- p.description,
--- p."partType",
--- p."partGroupId",
--- pg.name,
--- p."replenishmentSystem",
--- p.active,
--- p."customFields";
+DROP VIEW "parts";
+CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ p.*,
+ pg.name AS "partGroup",
+ ps."supplierIds"
+ FROM "part" p
+ LEFT JOIN "partGroup" pg ON pg.id = p."partGroupId"
+ LEFT JOIN (
+ SELECT
+ "partId",
+ array_agg(ps."supplierId") AS "supplierIds"
+ FROM "partSupplier" ps
+ GROUP BY "partId"
+ ) ps ON ps."partId" = p.id;
-- DROP VIEW "purchaseOrders";
-- CREATE OR REPLACE VIEW "purchaseOrders" WITH(SECURITY_INVOKER=true) AS