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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: add location to people table (#826)
Brad Barbin72d36d836735
diff --git a/apps/erp/app/modules/people/ui/People/PeopleTable.tsx b/apps/erp/app/modules/people/ui/People/PeopleTable.tsxindex 3efdba2576..962bc286fa 100644--- a/apps/erp/app/modules/people/ui/People/PeopleTable.tsx+++ b/apps/erp/app/modules/people/ui/People/PeopleTable.tsx@@ -6,6 +6,7 @@ import { memo, useCallback, useMemo } from "react";import {LuBriefcase,LuMail,+ LuMapPin,LuPencil,LuToggleRight,LuUser,@@ -14,6 +15,7 @@ import {import { useNavigate } from "react-router";import { Avatar, EmployeeAvatar, Hyperlink, New, Table } from "~/components";import { Enumerable } from "~/components/Enumerable";+import { useLocations } from "~/components/Form/Location";import { usePermissions, useUrlParams } from "~/hooks";import { DataType } from "~/modules/shared";import type { EmployeeType } from "~/modules/users";@@ -33,6 +35,7 @@ const PeopleTable = memo(const { locale } = useLocale();const navigate = useNavigate();const permissions = usePermissions();+ const locations = useLocations();const [params] = useUrlParams();const employeeTypesById = useMemo(@@ -156,6 +159,21 @@ const PeopleTable = memo(icon: <LuBriefcase />}},+ {+ id: "locationId",+ header: t`Location`,+ cell: ({ row }) => <Enumerable value={row.original.locationName} />,+ meta: {+ filter: {+ type: "static",+ options: locations.map((location) => ({+ value: location.value,+ label: <Enumerable value={location.label} />+ }))+ },+ icon: <LuMapPin />+ }+ },{accessorKey: "active",header: t`Active`,@@ -197,6 +215,7 @@ const PeopleTable = memo(attributeCategories,employeeTypes,employeeTypesById,+ locations,renderGenericAttribute,t]);diff --git a/apps/erp/app/modules/people/ui/Person/PersonPreview.tsx b/apps/erp/app/modules/people/ui/Person/PersonPreview.tsxindex 47200b2194..0abfa1c3ef 100644--- a/apps/erp/app/modules/people/ui/Person/PersonPreview.tsx+++ b/apps/erp/app/modules/people/ui/Person/PersonPreview.tsx@@ -16,6 +16,7 @@ import { Trans } from "@lingui/react/macro";import { useParams } from "react-router";import { Avatar } from "~/components";import { AuditLogDrawer } from "~/components/AuditLog";+import { Enumerable } from "~/components/Enumerable";import { useRouteData, useUser } from "~/hooks";import { path } from "~/utils/path";import type { EmployeeSummary } from "../../types";@@ -63,7 +64,9 @@ const PersonHeader = () => {<Trans>Location</Trans></CardAttributeLabel><CardAttributeValue>- {routeData?.employeeSummary?.locationName}+ <Enumerable+ value={routeData?.employeeSummary?.locationName ?? null}+ /></CardAttributeValue></CardAttribute><CardAttribute>diff --git a/apps/erp/app/routes/x+/person+/$personId.details.tsx b/apps/erp/app/routes/x+/person+/$personId.details.tsxindex 5e25a48f3b..1865256974 100644--- a/apps/erp/app/routes/x+/person+/$personId.details.tsx+++ b/apps/erp/app/routes/x+/person+/$personId.details.tsx@@ -1,8 +1,6 @@import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";-import { Card, CardContent, CardHeader, CardTitle } from "@carbon/react";-import { Trans } from "@lingui/react/macro";import type { LoaderFunctionArgs } from "react-router";import { redirect, useLoaderData } from "react-router";import { getAccount } from "~/modules/account";@@ -33,16 +31,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export default function PersonProfileRoute() {const { user } = useLoaderData<typeof loader>();- return (- <Card>- <CardHeader>- <CardTitle>- <Trans>Profile</Trans>- </CardTitle>- </CardHeader>- <CardContent>- <ProfileForm user={user} />- </CardContent>- </Card>- );+ return <ProfileForm user={user} />;}diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.tsindex 39f93ce894..51dd449eee 100644--- a/packages/database/src/swagger-docs-schema.ts+++ b/packages/database/src/swagger-docs-schema.ts@@ -89039,6 +89039,16 @@ export default {active: {format: "boolean",type: "boolean"+ },+ locationId: {+ description:+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",+ format: "text",+ type: "string"+ },+ locationName: {+ format: "text",+ type: "string"}},type: "object"diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex d540cc93a5..817a135a08 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -15314,6 +15314,7 @@ export type Database = {machineRate: number | nullmachineTime: numbermachineUnit: Database["public"]["Enums"]["factor"]+ manuallyScheduled: booleanoperationLeadTime: numberoperationMinimumCost: numberoperationOrder: Database["public"]["Enums"]["methodOperationOrder"]@@ -15359,6 +15360,7 @@ export type Database = {machineRate?: number | nullmachineTime?: numbermachineUnit?: Database["public"]["Enums"]["factor"]+ manuallyScheduled?: booleanoperationLeadTime?: numberoperationMinimumCost?: numberoperationOrder?: Database["public"]["Enums"]["methodOperationOrder"]@@ -15404,6 +15406,7 @@ export type Database = {machineRate?: number | nullmachineTime?: numbermachineUnit?: Database["public"]["Enums"]["factor"]+ manuallyScheduled?: booleanoperationLeadTime?: numberoperationMinimumCost?: numberoperationOrder?: Database["public"]["Enums"]["methodOperationOrder"]@@ -37716,6 +37719,48 @@ export type Database = {},]}+ searchIndex_6AimzWd73UmqpUhtHXgzio: {+ Row: {+ createdAt: string+ description: string | null+ entityId: string+ entityType: string+ id: number+ link: string+ metadata: Json | null+ searchVector: unknown+ tags: string[] | null+ title: string+ updatedAt: string | null+ }+ Insert: {+ createdAt?: string+ description?: string | null+ entityId: string+ entityType: string+ id?: number+ link: string+ metadata?: Json | null+ searchVector?: unknown+ tags?: string[] | null+ title: string+ updatedAt?: string | null+ }+ Update: {+ createdAt?: string+ description?: string | null+ entityId?: string+ entityType?: string+ id?: number+ link?: string+ metadata?: Json | null+ searchVector?: unknown+ tags?: string[] | null+ title?: string+ updatedAt?: string | null+ }+ Relationships: []+ }searchIndexRegistry: {Row: {companyId: string@@ -49175,6 +49220,8 @@ export type Database = {firstName: string | nullid: string | nulllastName: string | null+ locationId: string | null+ locationName: string | nullname: string | null}Relationships: [@@ -49213,6 +49260,13 @@ export type Database = {referencedRelation: "employeeType"referencedColumns: ["id"]},+ {+ foreignKeyName: "employeeJob_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "location"+ referencedColumns: ["id"]+ },]}employeesAcrossCompanies: {@@ -54592,14 +54646,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["supplierCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["supplierCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -58600,14 +58654,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex d540cc93a5..817a135a08 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -15314,6 +15314,7 @@ export type Database = {machineRate: number | nullmachineTime: numbermachineUnit: Database["public"]["Enums"]["factor"]+ manuallyScheduled: booleanoperationLeadTime: numberoperationMinimumCost: numberoperationOrder: Database["public"]["Enums"]["methodOperationOrder"]@@ -15359,6 +15360,7 @@ export type Database = {machineRate?: number | nullmachineTime?: numbermachineUnit?: Database["public"]["Enums"]["factor"]+ manuallyScheduled?: booleanoperationLeadTime?: numberoperationMinimumCost?: numberoperationOrder?: Database["public"]["Enums"]["methodOperationOrder"]@@ -15404,6 +15406,7 @@ export type Database = {machineRate?: number | nullmachineTime?: numbermachineUnit?: Database["public"]["Enums"]["factor"]+ manuallyScheduled?: booleanoperationLeadTime?: numberoperationMinimumCost?: numberoperationOrder?: Database["public"]["Enums"]["methodOperationOrder"]@@ -37716,6 +37719,48 @@ export type Database = {},]}+ searchIndex_6AimzWd73UmqpUhtHXgzio: {+ Row: {+ createdAt: string+ description: string | null+ entityId: string+ entityType: string+ id: number+ link: string+ metadata: Json | null+ searchVector: unknown+ tags: string[] | null+ title: string+ updatedAt: string | null+ }+ Insert: {+ createdAt?: string+ description?: string | null+ entityId: string+ entityType: string+ id?: number+ link: string+ metadata?: Json | null+ searchVector?: unknown+ tags?: string[] | null+ title: string+ updatedAt?: string | null+ }+ Update: {+ createdAt?: string+ description?: string | null+ entityId?: string+ entityType?: string+ id?: number+ link?: string+ metadata?: Json | null+ searchVector?: unknown+ tags?: string[] | null+ title?: string+ updatedAt?: string | null+ }+ Relationships: []+ }searchIndexRegistry: {Row: {companyId: string@@ -49175,6 +49220,8 @@ export type Database = {firstName: string | nullid: string | nulllastName: string | null+ locationId: string | null+ locationName: string | nullname: string | null}Relationships: [@@ -49213,6 +49260,13 @@ export type Database = {referencedRelation: "employeeType"referencedColumns: ["id"]},+ {+ foreignKeyName: "employeeJob_locationId_fkey"+ columns: ["locationId"]+ isOneToOne: false+ referencedRelation: "location"+ referencedColumns: ["id"]+ },]}employeesAcrossCompanies: {@@ -54592,14 +54646,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["supplierCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["supplierCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -58600,14 +58654,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/migrations/20260526091437_employee-location.sql b/packages/database/supabase/migrations/20260526091437_employee-location.sqlnew file mode 100644index 0000000000..61177cfb19--- /dev/null+++ b/packages/database/supabase/migrations/20260526091437_employee-location.sql@@ -0,0 +1,40 @@+DROP VIEW IF EXISTS "employeesAcrossCompanies";+DROP VIEW IF EXISTS "employees";++CREATE OR REPLACE VIEW "employees" WITH(SECURITY_INVOKER=true) AS+ SELECT+ u.id,+ u."email",+ u."firstName",+ u."lastName",+ u."fullName" AS "name",+ u."avatarUrl",+ e."employeeTypeId",+ e."companyId",+ e."active",+ ej."locationId",+ l."name" AS "locationName"+ FROM "user" u+ INNER JOIN "employee" e+ ON e.id = u.id+ LEFT JOIN "employeeJob" ej+ ON e.id = ej.id AND e."companyId" = ej."companyId"+ LEFT JOIN "location" l+ ON l.id = ej."locationId"+ WHERE u.active = TRUE;++CREATE OR REPLACE VIEW "employeesAcrossCompanies" WITH(SECURITY_INVOKER=true) AS+ SELECT+ u.id,+ u.email,+ u."firstName",+ u."lastName",+ u."fullName" AS "name",+ u."avatarUrl",+ u.active,+ array_agg(e."companyId") as "companyId"+ FROM "user" u+ INNER JOIN "employee" e+ ON e.id = u.id+ WHERE u.active = TRUE+ GROUP BY u.id, u.email, u."firstName", u."lastName", u."fullName", u."avatarUrl", u.active;