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 customer table

Brad Barbin4fca0cffd5b2
diff --git a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
index dfb2e9024a..35d7824b47 100644
--- a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
+++ b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
@@ -49,7 +49,7 @@ const Pagination = (props: PaginationProps) => {
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="secondary">{pageSize}/page</Button>
+ <Button variant="secondary">{pageSize} rows</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="w-48">
<DropdownMenuLabel>Results per page</DropdownMenuLabel>
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index e226c3940f..47038fe588 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -10,6 +10,7 @@ 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/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 6de3ba4071..524c75b53a 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -593,7 +593,10 @@ export async function upsertCustomer(
}
return client
.from("customer")
- .update(sanitize(customer))
+ .update({
+ ...sanitize(customer),
+ updatedAt: today(getLocalTimeZone()).toString(),
+ })
.eq("id", customer.id)
.select("id")
.single();
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
index 8195f7f126..d6ceae2cc7 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
@@ -92,6 +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 831f83103d..6e5164b66e 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerHeader.tsx
@@ -8,11 +8,13 @@ import {
CardContent,
CardHeader,
CardTitle,
+ Enumerable,
HStack,
VStack,
} from "@carbon/react";
import { useParams } from "@remix-run/react";
+import { EmployeeAvatar } from "~/components";
import { useRouteData } from "~/hooks";
import type {
CustomerDetail,
@@ -34,6 +36,14 @@ const CustomerHeader = () => {
paymentTerms: ListItem[];
}>(path.to.customerRoot);
+ const customerStatus = sharedCustomerData?.customerStatuses?.find(
+ (status) => status.id === routeData?.customer?.customerStatusId
+ )?.name;
+
+ const customerType = sharedCustomerData?.customerTypes?.find(
+ (type) => type.id === routeData?.customer?.customerTypeId
+ )?.name;
+
return (
<VStack>
<Card>
@@ -50,28 +60,33 @@ const CustomerHeader = () => {
<CardContent>
<CardAttributes>
<CardAttribute>
- <CardAttributeLabel>Type</CardAttributeLabel>
+ <CardAttributeLabel>Account Manager</CardAttributeLabel>
<CardAttributeValue>
- {sharedCustomerData?.customerTypes?.find(
- (type) => type.id === routeData?.customer?.customerTypeId
- )?.name ?? "-"}
+ <EmployeeAvatar
+ employeeId={routeData?.customer?.accountManagerId ?? null}
+ />
</CardAttributeValue>
</CardAttribute>
<CardAttribute>
- <CardAttributeLabel>Status</CardAttributeLabel>
+ <CardAttributeLabel>Assignee</CardAttributeLabel>
+ <CardAttributeValue>
+ <EmployeeAvatar
+ employeeId={routeData?.customer?.assignee ?? null}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Type</CardAttributeLabel>
<CardAttributeValue>
- {sharedCustomerData?.customerStatuses?.find(
- (status) =>
- status.id === routeData?.customer?.customerStatusId
- )?.name ?? "-"}
+ {customerType ? <Enumerable value={customerType!} /> : "-"}
</CardAttributeValue>
</CardAttribute>
- {/* <CardAttribute>
- <CardAttributeLabel>Payment Terms</CardAttributeLabel>
+ <CardAttribute>
+ <CardAttributeLabel>Status</CardAttributeLabel>
<CardAttributeValue>
-
+ {customerStatus ? <Enumerable value={customerStatus!} /> : "-"}
</CardAttributeValue>
- </CardAttribute> */}
+ </CardAttribute>
</CardAttributes>
</CardContent>
</Card>
diff --git a/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
index dfed5ee11f..06aab62cfe 100644
--- a/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
@@ -1,12 +1,14 @@
import { 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 } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Customer, CustomerStatus, CustomerType } from "~/modules/sales";
+import { usePeople } from "~/stores";
import { path } from "~/utils/path";
type CustomersTableProps = {
@@ -20,6 +22,7 @@ const CustomersTable = memo(
({ data, count, customerStatuses, customerTypes }: CustomersTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
+ const [people] = usePeople();
const customColumns = useCustomColumns<Customer>("customer");
const columns = useMemo<ColumnDef<Customer>[]>(() => {
@@ -33,6 +36,38 @@ const CustomersTable = memo(
</Hyperlink>
),
},
+ {
+ id: "accountManagerId",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.accountManagerId} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ 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: "type",
header: "Customer Type",
@@ -61,25 +96,52 @@ const CustomersTable = memo(
},
},
},
- // {
- // id: "orders",
- // header: "Orders",
- // cell: ({ row }) => (
- //
- // <Button
- // variant="secondary"
- // onClick={() =>
- // navigate(`${path.to.salesOrders}?customerId=${row.original.id}`)
- // }
- // >
- // {row.original.orderCount ?? 0} Orders
- // </Button>
- // ),
- // },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.accountManagerId} />
+ ),
+ 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.accountManagerId} />
+ ),
+ 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];
- }, [customerStatuses, customerTypes, customColumns]);
+ }, [customerTypes, customerStatuses, people, customColumns]);
const renderContextMenu = useMemo(
// eslint-disable-next-line react/display-name
@@ -99,12 +161,22 @@ const CustomersTable = memo(
count={count}
columns={columns}
data={data}
+ defaultColumnPinning={{
+ left: ["name"],
+ }}
+ defaultColumnVisibility={{
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
primaryAction={
permissions.can("create", "sales") && (
<New label="Customer" to={path.to.newCustomer} />
)
}
renderContextMenu={renderContextMenu}
+ withColumnOrdering
/>
</>
);
diff --git a/apps/carbon/app/root.tsx b/apps/carbon/app/root.tsx
index 89ebeee062..27fa9c6dbd 100644
--- a/apps/carbon/app/root.tsx
+++ b/apps/carbon/app/root.tsx
@@ -46,7 +46,8 @@ export const meta: MetaFunction = () => {
title: "Carbon ERP",
},
{
- viewport: "width=device-width",
+ name: "viewport",
+ content: "width=device-width",
},
];
};
diff --git a/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx b/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx
index 2889c0cb81..e2838e53b4 100644
--- a/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx
+++ b/apps/carbon/app/routes/x+/customer+/$customerId.details.tsx
@@ -64,12 +64,13 @@ export default function CustomerEditRoute() {
if (!routeData?.customer) return null;
const initialValues = {
- id: routeData?.customer?.id ?? undefined,
+ ...routeData.customer,
name: routeData?.customer?.name ?? "",
customerTypeId: routeData?.customer?.customerTypeId ?? undefined,
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+/resources+/contractors.new.tsx b/apps/carbon/app/routes/x+/resources+/contractors.new.tsx
index a1e0264bc7..c7028dc1fb 100644
--- a/apps/carbon/app/routes/x+/resources+/contractors.new.tsx
+++ b/apps/carbon/app/routes/x+/resources+/contractors.new.tsx
@@ -42,14 +42,14 @@ export async function action({ request }: ActionFunctionArgs) {
path.to.contractors,
await flash(
request,
- error(createContractor.error, "Failed to create contractor.")
+ error(createContractor.error, "Failed to create contractor")
)
);
}
return redirect(
path.to.contractors,
- await flash(request, success("Contractor created."))
+ await flash(request, success("Contractor created"))
);
}
diff --git a/package-lock.json b/package-lock.json
index 0f371a29c3..262dde652d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -27548,9 +27548,9 @@
}
},
"node_modules/sonner": {
- "version": "1.4.3",
- "resolved": "https://registry.npmjs.org/sonner/-/sonner-1.4.3.tgz",
- "integrity": "sha512-SArYlHbkjqRuLiR0iGY2ZSr09oOrxw081ZZkQPfXrs8aZQLIBOLOdzTYxGJB5yIZ7qL56UEPmrX1YqbODwG0Lw==",
+ "version": "1.4.41",
+ "resolved": "https://registry.npmjs.org/sonner/-/sonner-1.4.41.tgz",
+ "integrity": "sha512-uG511ggnnsw6gcn/X+YKkWPo5ep9il9wYi3QJxHsYe7yTZ4+cOd1wuodOUmOpFuXL+/RE3R04LczdNCDygTDgQ==",
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
@@ -32196,7 +32196,7 @@
"is-hotkey": "^0.2.0",
"react-aria-components": "1.0.1",
"react-colorful": "^5.6.1",
- "sonner": "^1.3.1",
+ "sonner": "1.4.41",
"tailwind-merge": "2.2.1",
"tailwindcss-animate": "^1.0.7"
},
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index b5192b833a..f2065b4124 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -13693,15 +13693,107 @@ export type Database = {
}
customers: {
Row: {
+ accountManagerId: string | null
+ assignee: string | null
+ createdAt: string | null
+ createdBy: string | null
customerStatusId: string | null
customerTypeId: string | null
customFields: Json | null
id: string | null
+ logo: string | null
name: string | null
status: string | null
+ taxId: string | null
type: string | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "customer_customerStatusId_fkey"
columns: ["customerStatusId"]
@@ -13716,6 +13808,34 @@ export type Database = {
referencedRelation: "customerType"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
]
}
customFieldTables: {
@@ -13974,7 +14094,6 @@ export type Database = {
abilityId: string | null
abilityName: string | null
active: boolean | null
- assignee: string | null
city: string | null
createdAt: string | null
createdBy: string | null
@@ -13996,34 +14115,6 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -14054,14 +14145,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -14585,7 +14676,6 @@ export type Database = {
}
purchaseOrders: {
Row: {
- assignee: string | null
closedAt: string | null
closedBy: string | null
closedByAvatar: string | null
@@ -14622,34 +14712,6 @@ export type Database = {
updatedByFullName: string | null
}
Relationships: [
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -14952,7 +15014,6 @@ export type Database = {
}
receipts: {
Row: {
- assignee: string | null
createdAt: string | null
createdBy: string | null
createdByAvatar: string | null
@@ -14979,34 +15040,6 @@ export type Database = {
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 b5192b833a..f2065b4124 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -13693,15 +13693,107 @@ export type Database = {
}
customers: {
Row: {
+ accountManagerId: string | null
+ assignee: string | null
+ createdAt: string | null
+ createdBy: string | null
customerStatusId: string | null
customerTypeId: string | null
customFields: Json | null
id: string | null
+ logo: string | null
name: string | null
status: string | null
+ taxId: string | null
type: string | null
+ updatedAt: string | null
+ updatedBy: string | null
}
Relationships: [
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_accountManagerId_fkey"
+ columns: ["accountManagerId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_assignee_fkey"
+ columns: ["assignee"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "customer_customerStatusId_fkey"
columns: ["customerStatusId"]
@@ -13716,6 +13808,34 @@ export type Database = {
referencedRelation: "customerType"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "customer_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
]
}
customFieldTables: {
@@ -13974,7 +14094,6 @@ export type Database = {
abilityId: string | null
abilityName: string | null
active: boolean | null
- assignee: string | null
city: string | null
createdAt: string | null
createdBy: string | null
@@ -13996,34 +14115,6 @@ export type Database = {
referencedRelation: "ability"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "partner_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "partner_createdBy_fkey"
columns: ["createdBy"]
@@ -14054,14 +14145,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -14585,7 +14676,6 @@ export type Database = {
}
purchaseOrders: {
Row: {
- assignee: string | null
closedAt: string | null
closedBy: string | null
closedByAvatar: string | null
@@ -14622,34 +14712,6 @@ export type Database = {
updatedByFullName: string | null
}
Relationships: [
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "purchaseOrder_assignee_fkey"
- columns: ["assignee"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
{
foreignKeyName: "purchaseOrder_closedBy_fkey"
columns: ["closedBy"]
@@ -14952,7 +15014,6 @@ export type Database = {
}
receipts: {
Row: {
- assignee: string | null
createdAt: string | null
createdBy: string | null
createdByAvatar: string | null
@@ -14979,34 +15040,6 @@ export type Database = {
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 6c74fc9a5c..fe451ea383 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -45,20 +45,15 @@ CREATE OR REPLACE VIEW "contractors" WITH(SECURITY_INVOKER=true) AS
WHERE p."active" = true
GROUP BY p.id, p.active, p."hoursPerWeek", p."customFields", s.id, c.id, s.name, c."firstName", c."lastName", c."email";
--- DROP VIEW "customers";
--- CREATE OR REPLACE VIEW "customers" AS
--- SELECT
--- c.id,
--- c.name,
--- c."customerTypeId",
--- ct.name AS "type",
--- c."customerStatusId",
--- cs.name AS "status",
--- c."customFields"
--- -- so.count AS "orderCount"
--- FROM "customer" c
--- LEFT JOIN "customerType" ct ON ct.id = c."customerTypeId"
--- LEFT JOIN "customerStatus" cs ON cs.id = c."customerStatusId";
+DROP VIEW "customers";
+CREATE OR REPLACE VIEW "customers" AS
+ SELECT
+ c.*,
+ ct.name AS "type",
+ cs.name AS "status"
+ FROM "customer" c
+ LEFT JOIN "customerType" ct ON ct.id = c."customerTypeId"
+ LEFT JOIN "customerStatus" cs ON cs.id = c."customerStatusId";
-- DROP VIEW "documents";
-- CREATE OR REPLACE VIEW "documents" WITH(SECURITY_INVOKER=true) AS
diff --git a/packages/react/package.json b/packages/react/package.json
index 78d1b64f62..4b5a342237 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -44,7 +44,7 @@
"is-hotkey": "^0.2.0",
"react-aria-components": "1.0.1",
"react-colorful": "^5.6.1",
- "sonner": "^1.3.1",
+ "sonner": "1.4.41",
"tailwind-merge": "2.2.1",
"tailwindcss-animate": "^1.0.7"
},
diff --git a/packages/react/src/DataTable/DataTablePagination.tsx b/packages/react/src/DataTable/DataTablePagination.tsx
index 1530b1b98e..ba7f1ee422 100644
--- a/packages/react/src/DataTable/DataTablePagination.tsx
+++ b/packages/react/src/DataTable/DataTablePagination.tsx
@@ -30,7 +30,7 @@ export function DataTablePagination<TData>({
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="secondary">
- {table.getState().pagination.pageSize}/page
+ {table.getState().pagination.pageSize} rows
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48">