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
refactor: update service table page
Brad Barbincc2ff65bd5b8
diff --git a/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx b/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsxindex 60d33dc2cf..86f6cadc5b 100644--- a/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx+++ b/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx@@ -23,8 +23,8 @@ const ServicesTable = memo(({ data, count }: ServicesTableProps) => {accessorKey: "name",header: "Name",cell: ({ row }) => (- <Link onClick={() => navigate(path.to.service(row.original.id))}>- {row.original.id}+ <Link onClick={() => navigate(path.to.service(row.original.id!))}>+ {row.original.name}</Link>),},@@ -53,7 +53,7 @@ const ServicesTable = memo(({ data, count }: ServicesTableProps) => {return (row: Service) => (<MenuItemicon={<BsPencilSquare />}- onClick={() => navigate(path.to.service(row.id))}+ onClick={() => navigate(path.to.service(row.id!))}>Edit Service</MenuItem>diff --git a/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx b/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsxindex 61757a440f..7909fe4ee2 100644--- a/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx+++ b/apps/carbon/app/modules/parts/ui/Services/ServicesTableFilters/ServicesTableFilters.tsx@@ -56,7 +56,7 @@ const ServicesTableFilters = ({ serviceGroups }: ServicesTableFiltersProps) => {setParams({ group: selected?.value });}}aria-label="Groups"- placeholder="Part Groups"+ placeholder="Service Groups"/>)}{serviceTypeOptions.length > 0 && (@@ -70,8 +70,8 @@ const ServicesTableFilters = ({ serviceGroups }: ServicesTableFiltersProps) => {onChange={(selected) => {setParams({ type: selected?.value });}}- aria-label="Part Type"- placeholder="Part Type"+ aria-label="Service Type"+ placeholder="Service Type"/>)}</HStack>diff --git a/apps/carbon/app/modules/parts/ui/usePartsSidebar.tsx b/apps/carbon/app/modules/parts/ui/usePartsSidebar.tsxindex 3a4e4724db..6087585174 100644--- a/apps/carbon/app/modules/parts/ui/usePartsSidebar.tsx+++ b/apps/carbon/app/modules/parts/ui/usePartsSidebar.tsx@@ -10,6 +10,10 @@ const partsRoutes: AuthenticatedRouteGroup[] = [name: "Parts",to: path.to.partsSearch,},+ {+ name: "Services",+ to: path.to.services,+ },{name: "Routing",to: path.to.routings,@@ -25,6 +29,11 @@ const partsRoutes: AuthenticatedRouteGroup[] = [to: path.to.partGroups,role: "employee",},+ // {+ // name: "Service Groups",+ // to: path.to.serviceGroups,+ // role: "employee",+ // },{name: "Units of Measure",to: path.to.uoms,diff --git a/apps/carbon/app/routes/x+/parts+/services.tsx b/apps/carbon/app/routes/x+/parts+/services.tsxindex 4d63415f43..a9c1e4b489 100644--- a/apps/carbon/app/routes/x+/parts+/services.tsx+++ b/apps/carbon/app/routes/x+/parts+/services.tsx@@ -10,10 +10,16 @@ import {} from "~/modules/parts";import { requirePermissions } from "~/services/auth";import { flash } from "~/services/session";+import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { getGenericQueryFilters } from "~/utils/query";import { error } from "~/utils/result";+export const handle: Handle = {+ breadcrumb: "Services",+ to: path.to.services,+};+export async function loader({ request }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {view: "parts",diff --git a/packages/database/SCHEMA.md b/packages/database/SCHEMA.mdindex 9ed75257fe..a7928dc95d 100644--- a/packages/database/SCHEMA.md+++ b/packages/database/SCHEMA.md@@ -7163,46 +7163,44 @@ CREATE POLICY "Employees with parts_delete can delete service suppliers" ON "serAND (get_my_claim('role'::text)) = '"employee"'::jsonb);-CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "partSupplier"+CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "serviceSupplier"FOR SELECTUSING (coalesce(get_my_claim('parts_view')::boolean,false)AND (get_my_claim('role'::text)) = '"supplier"'::jsonb- AND "serviceTypeId" = 'External'AND "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()));-CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "partSupplier"+CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "serviceSupplier"FOR UPDATEUSING (coalesce(get_my_claim('parts_update')::boolean,false)AND (get_my_claim('role'::text)) = '"supplier"'::jsonb- AND "serviceTypeId" = 'External'AND "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()));-CREATE OR REPLACE VIEW "view" WITH(SECURITY_INVOKER=true) AS+CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) ASSELECTs.id,s.name,s.description,s."serviceType",- s."serviceGroupId",+ sg.id AS "serviceGroupId",sg.name AS "serviceGroup",s.active,- array_agg(ps."supplierId") AS "supplierIds"- FROM "supplier" s+ array_agg(ss."supplierId") AS "supplierIds"+ FROM "service" sLEFT JOIN "serviceGroup" sg ON sg.id = s."serviceGroupId"LEFT JOIN "serviceSupplier" ss ON ss."serviceId" = s.idGROUP BY s.id,s.name,s.description,s."serviceType",- s."serviceGroupId",+ sg.id,sg.name,s.active;```diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 50a82bcadb..2c017b0e9d 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -6417,6 +6417,12 @@ export interface Database {referencedRelation: "serviceGroup";referencedColumns: ["id"];},+ {+ foreignKeyName: "service_serviceGroupId_fkey";+ columns: ["serviceGroupId"];+ referencedRelation: "services";+ referencedColumns: ["serviceGroupId"];+ },{foreignKeyName: "service_updatedBy_fkey";columns: ["updatedBy"];@@ -6489,6 +6495,109 @@ export interface Database {}];};+ serviceSupplier: {+ Row: {+ active: boolean;+ createdAt: string;+ createdBy: string;+ id: string;+ serviceId: string;+ supplierId: string;+ supplierServiceId: string | null;+ updatedAt: string | null;+ updatedBy: string | null;+ };+ Insert: {+ active?: boolean;+ createdAt?: string;+ createdBy: string;+ id?: string;+ serviceId: string;+ supplierId: string;+ supplierServiceId?: string | null;+ updatedAt?: string | null;+ updatedBy?: string | null;+ };+ Update: {+ active?: boolean;+ createdAt?: string;+ createdBy?: string;+ id?: string;+ serviceId?: string;+ supplierId?: string;+ supplierServiceId?: string | null;+ updatedAt?: string | null;+ updatedBy?: string | null;+ };+ Relationships: [+ {+ foreignKeyName: "serviceSupplier_createdBy_fkey";+ columns: ["createdBy"];+ referencedRelation: "user";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_createdBy_fkey";+ columns: ["createdBy"];+ referencedRelation: "userDefaults";+ referencedColumns: ["userId"];+ },+ {+ foreignKeyName: "serviceSupplier_serviceId_fkey";+ columns: ["serviceId"];+ referencedRelation: "service";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_serviceId_fkey";+ columns: ["serviceId"];+ referencedRelation: "services";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_supplierId_fkey";+ columns: ["supplierId"];+ referencedRelation: "supplier";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_supplierId_fkey";+ columns: ["supplierId"];+ referencedRelation: "contractors";+ referencedColumns: ["supplierId"];+ },+ {+ foreignKeyName: "serviceSupplier_supplierId_fkey";+ columns: ["supplierId"];+ referencedRelation: "partners";+ referencedColumns: ["supplierId"];+ },+ {+ foreignKeyName: "serviceSupplier_supplierId_fkey";+ columns: ["supplierId"];+ referencedRelation: "purchaseOrderSuppliers";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_supplierId_fkey";+ columns: ["supplierId"];+ referencedRelation: "suppliers";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_updatedBy_fkey";+ columns: ["updatedBy"];+ referencedRelation: "user";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "serviceSupplier_updatedBy_fkey";+ columns: ["updatedBy"];+ referencedRelation: "userDefaults";+ referencedColumns: ["userId"];+ }+ ];+ };shelf: {Row: {active: boolean;@@ -8760,6 +8869,19 @@ export interface Database {}];};+ services: {+ Row: {+ active: boolean | null;+ description: string | null;+ id: string | null;+ name: string | null;+ serviceGroup: string | null;+ serviceGroupId: string | null;+ serviceType: Database["public"]["Enums"]["serviceType"] | null;+ supplierIds: string[] | null;+ };+ Relationships: [];+ };suppliers: {Row: {id: string | null;diff --git a/packages/database/supabase/migrations/20231212120726_services.sql b/packages/database/supabase/migrations/20231212120726_services.sqlindex eb0f04c8dd..7a92ff2a91 100644--- a/packages/database/supabase/migrations/20231212120726_services.sql+++ b/packages/database/supabase/migrations/20231212120726_services.sql@@ -153,45 +153,43 @@ CREATE POLICY "Employees with parts_delete can delete service suppliers" ON "serAND (get_my_claim('role'::text)) = '"employee"'::jsonb);-CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "partSupplier"+CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "serviceSupplier"FOR SELECTUSING (coalesce(get_my_claim('parts_view')::boolean,false)AND (get_my_claim('role'::text)) = '"supplier"'::jsonb- AND "serviceTypeId" = 'External'AND "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()));-CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "partSupplier"+CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "serviceSupplier"FOR UPDATEUSING (coalesce(get_my_claim('parts_update')::boolean,false)AND (get_my_claim('role'::text)) = '"supplier"'::jsonb- AND "serviceTypeId" = 'External'AND "supplierId" IN (SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()));-CREATE OR REPLACE VIEW "view" WITH(SECURITY_INVOKER=true) AS+CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) ASSELECTs.id,s.name,s.description,s."serviceType",- s."serviceGroupId",+ sg.id AS "serviceGroupId",sg.name AS "serviceGroup",s.active,- array_agg(ps."supplierId") AS "supplierIds"- FROM "supplier" s+ array_agg(ss."supplierId") AS "supplierIds"+ FROM "service" sLEFT JOIN "serviceGroup" sg ON sg.id = s."serviceGroupId"LEFT JOIN "serviceSupplier" ss ON ss."serviceId" = s.idGROUP BY s.id,s.name,s.description,s."serviceType",- s."serviceGroupId",+ sg.id,sg.name,s.active;\ No newline at end of file