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 gauge types crud

Brad Barbind39be9f9ed41
diff --git a/apps/erp/app/modules/quality/quality.models.ts b/apps/erp/app/modules/quality/quality.models.ts
index a020b2f04b..b9e9a0a19e 100644
--- a/apps/erp/app/modules/quality/quality.models.ts
+++ b/apps/erp/app/modules/quality/quality.models.ts
@@ -54,6 +54,11 @@ export const nonConformanceAssociationType = [
"trackedEntities",
] as const;
+export const gaugeTypeValidator = z.object({
+ id: zfd.text(z.string().optional()),
+ name: z.string().min(1, { message: "Name is required" }),
+});
+
export const nonConformanceAssociationValidator = z
.object({
type: z.enum(nonConformanceAssociationType),
diff --git a/apps/erp/app/modules/quality/quality.service.ts b/apps/erp/app/modules/quality/quality.service.ts
index aece349e03..152ebba98f 100644
--- a/apps/erp/app/modules/quality/quality.service.ts
+++ b/apps/erp/app/modules/quality/quality.service.ts
@@ -5,6 +5,7 @@ import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
import type {
+ gaugeTypeValidator,
nonConformanceReviewerValidator,
nonConformanceStatus,
nonConformanceTypeValidator,
@@ -12,6 +13,13 @@ import type {
nonConformanceWorkflowValidator,
} from "./quality.models";
+export async function deleteGaugeType(
+ client: SupabaseClient<Database>,
+ gaugeTypeId: string
+) {
+ return client.from("gaugeType").delete().eq("id", gaugeTypeId);
+}
+
export async function deleteNonConformance(
client: SupabaseClient<Database>,
nonConformanceId: string
@@ -90,6 +98,47 @@ export async function deleteNonConformanceWorkflow(
.eq("id", nonConformanceWorkflowId);
}
+export async function getGaugeTypesList(
+ client: SupabaseClient<Database>,
+ companyId: string
+) {
+ return client
+ .from("gaugeType")
+ .select("id, name")
+ .eq("companyId", companyId)
+ .order("name");
+}
+
+export async function getGaugeType(
+ client: SupabaseClient<Database>,
+ gaugeTypeId: string
+) {
+ return client.from("gaugeType").select("*").eq("id", gaugeTypeId).single();
+}
+
+export async function getGaugeTypes(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ args?: GenericQueryFilters & { search: string | null }
+) {
+ let query = client
+ .from("gaugeType")
+ .select("*", { count: "exact" })
+ .eq("companyId", companyId);
+
+ if (args?.search) {
+ query = query.ilike("name", `%${args.search}%`);
+ }
+
+ if (args) {
+ query = setGenericQueryFilters(query, args, [
+ { column: "name", ascending: true },
+ ]);
+ }
+
+ return query;
+}
+
export async function getNonConformance(
client: SupabaseClient<Database>,
nonConformanceId: string
@@ -176,6 +225,204 @@ export async function getNonConformanceApprovalTasks(
.order("approvalType", { ascending: true });
}
+export async function getNonConformanceAssociations(
+ client: SupabaseClient<Database>,
+ nonConformanceId: string,
+ companyId: string
+) {
+ const [
+ jobOperations,
+ purchaseOrderLines,
+ salesOrderLines,
+ shipmentLines,
+ receiptLines,
+ trackedEntities,
+ customers,
+ suppliers,
+ ] = await Promise.all([
+ // Job Operations
+ client
+ .from("nonConformanceJobOperation")
+ .select(
+ `
+ id,
+ jobOperationId,
+ jobId,
+ jobReadableId
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Purchase Order Lines
+ client
+ .from("nonConformancePurchaseOrderLine")
+ .select(
+ `
+ id,
+ purchaseOrderLineId,
+ purchaseOrderId,
+ purchaseOrderReadableId
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Sales Order Lines
+ client
+ .from("nonConformanceSalesOrderLine")
+ .select(
+ `
+ id,
+ salesOrderLineId,
+ salesOrderId,
+ salesOrderReadableId
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Shipment Lines
+ client
+ .from("nonConformanceShipmentLine")
+ .select(
+ `
+ id,
+ shipmentLineId,
+ shipmentId,
+ shipmentReadableId
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Receipt Lines
+ client
+ .from("nonConformanceReceiptLine")
+ .select(
+ `
+ id,
+ receiptLineId,
+ receiptId,
+ receiptReadableId
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Tracked Entities
+ client
+ .from("nonConformanceTrackedEntity")
+ .select(
+ `
+ id,
+ trackedEntityId
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Customers
+ client
+ .from("nonConformanceCustomer")
+ .select(
+ `
+ id,
+ customerId,
+ customer:customer (
+ id,
+ name
+ )
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+
+ // Suppliers
+ client
+ .from("nonConformanceSupplier")
+ .select(
+ `
+ id,
+ supplierId,
+ supplier:supplier (
+ id,
+ name
+ )
+ `
+ )
+ .eq("nonConformanceId", nonConformanceId)
+ .eq("companyId", companyId),
+ ]);
+
+ return {
+ jobOperations:
+ jobOperations.data?.map((item) => ({
+ type: "jobOperations",
+ id: item.id,
+ documentId: item.jobId ?? "",
+ documentLineId: item.jobOperationId,
+ documentReadableId: item.jobReadableId || "",
+ })) || [],
+ purchaseOrderLines:
+ purchaseOrderLines.data?.map((item) => ({
+ id: item.id,
+ type: "purchaseOrderLines",
+ documentId: item.purchaseOrderId ?? "",
+ documentLineId: item.purchaseOrderLineId,
+ documentReadableId: item.purchaseOrderReadableId || "",
+ })) || [],
+ salesOrderLines:
+ salesOrderLines.data?.map((item) => ({
+ id: item.id,
+ type: "salesOrderLines",
+ documentId: item.salesOrderId ?? "",
+ documentLineId: item.salesOrderLineId,
+ documentReadableId: item.salesOrderReadableId || "",
+ })) || [],
+ shipmentLines:
+ shipmentLines.data?.map((item) => ({
+ id: item.id,
+ type: "shipmentLines",
+ documentId: item.shipmentId ?? "",
+ documentLineId: item.shipmentLineId,
+ documentReadableId: item.shipmentReadableId || "",
+ })) || [],
+ receiptLines:
+ receiptLines.data?.map((item) => ({
+ id: item.id,
+ type: "receiptLines",
+ documentId: item.receiptId ?? "",
+ documentLineId: item.receiptLineId,
+ documentReadableId: item.receiptReadableId || "",
+ })) || [],
+ trackedEntities:
+ trackedEntities.data?.map((item) => ({
+ id: item.id,
+ type: "trackedEntities",
+ documentId: item.trackedEntityId ?? "",
+ documentLineId: "",
+ documentReadableId: item.trackedEntityId ?? "",
+ })) || [],
+ customers:
+ customers.data?.map((c) => ({
+ id: c.id,
+ type: "customers",
+ documentId: c.customerId ?? "",
+ documentLineId: "",
+ documentReadableId: c.customer.name,
+ })) || [],
+ suppliers:
+ suppliers.data?.map((item) => ({
+ id: item.id,
+ type: "suppliers",
+ documentId: item.supplierId ?? "",
+ documentLineId: "",
+ documentReadableId: item.supplier.name,
+ })) || [],
+ };
+}
+
export async function getNonConformanceReviewers(
client: SupabaseClient<Database>,
id: string,
@@ -281,7 +528,7 @@ export async function getNonConformanceTypes(
) {
let query = client
.from("nonConformanceType")
- .select("id, name", { count: "exact" })
+ .select("*", { count: "exact" })
.eq("companyId", companyId);
if (args?.search) {
@@ -347,6 +594,30 @@ export async function updateNonConformanceTaskStatus(
.eq("id", id);
}
+export async function upsertGaugeType(
+ client: SupabaseClient<Database>,
+ gaugeType:
+ | (Omit<z.infer<typeof gaugeTypeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof nonConformanceTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+) {
+ if ("createdBy" in gaugeType) {
+ return client.from("gaugeType").insert([gaugeType]).select("id");
+ } else {
+ return client
+ .from("gaugeType")
+ .update(sanitize(gaugeType))
+ .eq("id", gaugeType.id);
+ }
+}
+
export async function upsertNonConformance(
client: SupabaseClient<Database>,
nonConformance:
@@ -435,200 +706,3 @@ export async function upsertNonConformanceType(
.eq("id", nonConformanceType.id);
}
}
-export async function getNonConformanceAssociations(
- client: SupabaseClient<Database>,
- nonConformanceId: string,
- companyId: string
-) {
- const [
- jobOperations,
- purchaseOrderLines,
- salesOrderLines,
- shipmentLines,
- receiptLines,
- trackedEntities,
- customers,
- suppliers,
- ] = await Promise.all([
- // Job Operations
- client
- .from("nonConformanceJobOperation")
- .select(
- `
- id,
- jobOperationId,
- jobId,
- jobReadableId
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Purchase Order Lines
- client
- .from("nonConformancePurchaseOrderLine")
- .select(
- `
- id,
- purchaseOrderLineId,
- purchaseOrderId,
- purchaseOrderReadableId
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Sales Order Lines
- client
- .from("nonConformanceSalesOrderLine")
- .select(
- `
- id,
- salesOrderLineId,
- salesOrderId,
- salesOrderReadableId
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Shipment Lines
- client
- .from("nonConformanceShipmentLine")
- .select(
- `
- id,
- shipmentLineId,
- shipmentId,
- shipmentReadableId
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Receipt Lines
- client
- .from("nonConformanceReceiptLine")
- .select(
- `
- id,
- receiptLineId,
- receiptId,
- receiptReadableId
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Tracked Entities
- client
- .from("nonConformanceTrackedEntity")
- .select(
- `
- id,
- trackedEntityId
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Customers
- client
- .from("nonConformanceCustomer")
- .select(
- `
- id,
- customerId,
- customer:customer (
- id,
- name
- )
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
-
- // Suppliers
- client
- .from("nonConformanceSupplier")
- .select(
- `
- id,
- supplierId,
- supplier:supplier (
- id,
- name
- )
- `
- )
- .eq("nonConformanceId", nonConformanceId)
- .eq("companyId", companyId),
- ]);
-
- return {
- jobOperations:
- jobOperations.data?.map((item) => ({
- type: "jobOperations",
- id: item.id,
- documentId: item.jobId ?? "",
- documentLineId: item.jobOperationId,
- documentReadableId: item.jobReadableId || "",
- })) || [],
- purchaseOrderLines:
- purchaseOrderLines.data?.map((item) => ({
- id: item.id,
- type: "purchaseOrderLines",
- documentId: item.purchaseOrderId ?? "",
- documentLineId: item.purchaseOrderLineId,
- documentReadableId: item.purchaseOrderReadableId || "",
- })) || [],
- salesOrderLines:
- salesOrderLines.data?.map((item) => ({
- id: item.id,
- type: "salesOrderLines",
- documentId: item.salesOrderId ?? "",
- documentLineId: item.salesOrderLineId,
- documentReadableId: item.salesOrderReadableId || "",
- })) || [],
- shipmentLines:
- shipmentLines.data?.map((item) => ({
- id: item.id,
- type: "shipmentLines",
- documentId: item.shipmentId ?? "",
- documentLineId: item.shipmentLineId,
- documentReadableId: item.shipmentReadableId || "",
- })) || [],
- receiptLines:
- receiptLines.data?.map((item) => ({
- id: item.id,
- type: "receiptLines",
- documentId: item.receiptId ?? "",
- documentLineId: item.receiptLineId,
- documentReadableId: item.receiptReadableId || "",
- })) || [],
- trackedEntities:
- trackedEntities.data?.map((item) => ({
- id: item.id,
- type: "trackedEntities",
- documentId: item.trackedEntityId ?? "",
- documentLineId: "",
- documentReadableId: item.trackedEntityId ?? "",
- })) || [],
- customers:
- customers.data?.map((c) => ({
- id: c.id,
- type: "customers",
- documentId: c.customerId ?? "",
- documentLineId: "",
- documentReadableId: c.customer.name,
- })) || [],
- suppliers:
- suppliers.data?.map((item) => ({
- id: item.id,
- type: "suppliers",
- documentId: item.supplierId ?? "",
- documentLineId: "",
- documentReadableId: item.supplier.name,
- })) || [],
- };
-}
diff --git a/apps/erp/app/modules/quality/types.ts b/apps/erp/app/modules/quality/types.ts
index 23979cc50c..7ea7bc290d 100644
--- a/apps/erp/app/modules/quality/types.ts
+++ b/apps/erp/app/modules/quality/types.ts
@@ -1,6 +1,7 @@
import type { Database } from "@carbon/database";
import type { nonConformanceAssociationType } from "./quality.models";
import type {
+ getGaugeTypes,
getNonConformance,
getNonConformanceActionTasks,
getNonConformanceApprovalTasks,
@@ -10,6 +11,10 @@ import type {
getNonConformanceWorkflow,
} from "./quality.service";
+export type GaugeType = NonNullable<
+ Awaited<ReturnType<typeof getGaugeTypes>>["data"]
+>[number];
+
export type NonConformanceAssociationKey =
(typeof nonConformanceAssociationType)[number];
diff --git a/apps/erp/app/modules/quality/ui/GaugeTypes/GaugeTypeForm.tsx b/apps/erp/app/modules/quality/ui/GaugeTypes/GaugeTypeForm.tsx
new file mode 100644
index 0000000000..75ccde7a7b
--- /dev/null
+++ b/apps/erp/app/modules/quality/ui/GaugeTypes/GaugeTypeForm.tsx
@@ -0,0 +1,105 @@
+import { ValidatedForm } from "@carbon/form";
+import {
+ Button,
+ HStack,
+ ModalDrawer,
+ ModalDrawerBody,
+ ModalDrawerContent,
+ ModalDrawerFooter,
+ ModalDrawerHeader,
+ ModalDrawerProvider,
+ ModalDrawerTitle,
+ VStack,
+ toast,
+} from "@carbon/react";
+import { useFetcher } from "@remix-run/react";
+import type { PostgrestResponse } from "@supabase/supabase-js";
+import { useEffect } from "react";
+import type { z } from "zod";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
+import { usePermissions } from "~/hooks";
+import { path } from "~/utils/path";
+import { gaugeTypeValidator } from "../../quality.models";
+
+type GaugeTypeFormProps = {
+ initialValues: z.infer<typeof gaugeTypeValidator>;
+ type?: "modal" | "drawer";
+ open?: boolean;
+ onClose: () => void;
+};
+
+const GaugeTypeForm = ({
+ initialValues,
+ open = true,
+ type = "drawer",
+ onClose,
+}: GaugeTypeFormProps) => {
+ const permissions = usePermissions();
+ const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();
+
+ useEffect(() => {
+ if (type !== "modal") return;
+
+ if (fetcher.state === "loading" && fetcher.data?.data) {
+ onClose?.();
+ toast.success(`Created gauge type`);
+ } else if (fetcher.state === "idle" && fetcher.data?.error) {
+ toast.error(`Failed to create gauge type: ${fetcher.data.error.message}`);
+ }
+ }, [fetcher.data, fetcher.state, onClose, type]);
+
+ const isEditing = initialValues.id !== undefined;
+ const isDisabled = isEditing
+ ? !permissions.can("update", "quality")
+ : !permissions.can("create", "quality");
+
+ return (
+ <ModalDrawerProvider type={type}>
+ <ModalDrawer
+ open={open}
+ onOpenChange={(open) => {
+ if (!open) onClose?.();
+ }}
+ >
+ <ModalDrawerContent>
+ <ValidatedForm
+ validator={gaugeTypeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.gaugeType(initialValues.id!)
+ : path.to.newGaugeType
+ }
+ defaultValues={initialValues}
+ fetcher={fetcher}
+ className="flex flex-col h-full"
+ >
+ <ModalDrawerHeader>
+ <ModalDrawerTitle>
+ {isEditing ? "Edit" : "New"} Gauge Type
+ </ModalDrawerTitle>
+ </ModalDrawerHeader>
+ <ModalDrawerBody>
+ <Hidden name="id" />
+ <Hidden name="type" value={type} />
+ <VStack spacing={4}>
+ <Input name="name" label="Gauge Type" />
+ <CustomFormFields table="gaugeType" />
+ </VStack>
+ </ModalDrawerBody>
+ <ModalDrawerFooter>
+ <HStack>
+ <Submit isDisabled={isDisabled}>Save</Submit>
+ <Button size="md" variant="solid" onClick={() => onClose()}>
+ Cancel
+ </Button>
+ </HStack>
+ </ModalDrawerFooter>
+ </ValidatedForm>
+ </ModalDrawerContent>
+ </ModalDrawer>
+ </ModalDrawerProvider>
+ );
+};
+
+export default GaugeTypeForm;
diff --git a/apps/erp/app/modules/quality/ui/GaugeTypes/GaugeTypesTable.tsx b/apps/erp/app/modules/quality/ui/GaugeTypes/GaugeTypesTable.tsx
new file mode 100644
index 0000000000..f1551c8302
--- /dev/null
+++ b/apps/erp/app/modules/quality/ui/GaugeTypes/GaugeTypesTable.tsx
@@ -0,0 +1,93 @@
+import { MenuIcon, MenuItem } from "@carbon/react";
+import { useNavigate } from "@remix-run/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useCallback, useMemo } from "react";
+import { LuCircleGauge, LuPencil, LuTrash } from "react-icons/lu";
+import { Hyperlink, New, Table } from "~/components";
+import { Enumerable } from "~/components/Enumerable";
+import { usePermissions, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
+import { path } from "~/utils/path";
+import type { GaugeType } from "../../types";
+
+type GaugeTypesTableProps = {
+ data: GaugeType[];
+ count: number;
+};
+
+const GaugeTypesTable = memo(({ data, count }: GaugeTypesTableProps) => {
+ const [params] = useUrlParams();
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+
+ const customColumns = useCustomColumns<GaugeType>("gaugeType");
+
+ const columns = useMemo<ColumnDef<GaugeType>[]>(() => {
+ const defaultColumns: ColumnDef<GaugeType>[] = [
+ {
+ accessorKey: "name",
+ header: "Gauge Type",
+ cell: ({ row }) => (
+ <Hyperlink to={row.original.id}>
+ <Enumerable value={row.original.name} />
+ </Hyperlink>
+ ),
+ meta: {
+ icon: <LuCircleGauge />,
+ },
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ }, [customColumns]);
+
+ const renderContextMenu = useCallback(
+ (row: GaugeType) => {
+ return (
+ <>
+ <MenuItem
+ onClick={() => {
+ navigate(`${path.to.gaugeType(row.id)}?${params.toString()}`);
+ }}
+ >
+ <MenuIcon icon={<LuPencil />} />
+ Edit Type
+ </MenuItem>
+ <MenuItem
+ destructive
+ disabled={!permissions.can("delete", "sales")}
+ onClick={() => {
+ navigate(
+ `${path.to.deleteGaugeType(row.id)}?${params.toString()}`
+ );
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Type
+ </MenuItem>
+ </>
+ );
+ },
+ [navigate, params, permissions]
+ );
+
+ return (
+ <Table<GaugeType>
+ data={data}
+ columns={columns}
+ count={count}
+ primaryAction={
+ permissions.can("create", "quality") && (
+ <New
+ label="Gauge Type"
+ to={`${path.to.newGaugeType}?${params.toString()}`}
+ />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ title="Gauge Types"
+ />
+ );
+});
+
+GaugeTypesTable.displayName = "GaugeTypesTable";
+export default GaugeTypesTable;
diff --git a/apps/erp/app/modules/quality/ui/GaugeTypes/index.ts b/apps/erp/app/modules/quality/ui/GaugeTypes/index.ts
new file mode 100644
index 0000000000..c15ffb851b
--- /dev/null
+++ b/apps/erp/app/modules/quality/ui/GaugeTypes/index.ts
@@ -0,0 +1,4 @@
+import GaugeTypeForm from "./GaugeTypeForm";
+import GaugeTypesTable from "./GaugeTypesTable";
+
+export { GaugeTypeForm, GaugeTypesTable };
diff --git a/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypeForm.tsx b/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypeForm.tsx
index 0f3dd1bb12..efc1654516 100644
--- a/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypeForm.tsx
+++ b/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypeForm.tsx
@@ -52,8 +52,8 @@ const NonConformanceTypeForm = ({
const isEditing = initialValues.id !== undefined;
const isDisabled = isEditing
- ? !permissions.can("update", "production")
- : !permissions.can("create", "production");
+ ? !permissions.can("update", "quality")
+ : !permissions.can("create", "quality");
return (
<ModalDrawerProvider type={type}>
diff --git a/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypesTable.tsx b/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypesTable.tsx
index ab4bcb0b8c..18b0d4b874 100644
--- a/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypesTable.tsx
+++ b/apps/erp/app/modules/quality/ui/NonConformanceTypes/NonConformanceTypesTable.tsx
@@ -6,6 +6,7 @@ import { LuOctagonX, LuPencil, LuTrash } from "react-icons/lu";
import { Hyperlink, New, Table } from "~/components";
import { Enumerable } from "~/components/Enumerable";
import { usePermissions, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
import { path } from "~/utils/path";
import type { NonConformanceType } from "../../types";
@@ -20,6 +21,9 @@ const NonConformanceTypesTable = memo(
const navigate = useNavigate();
const permissions = usePermissions();
+ const customColumns =
+ useCustomColumns<NonConformanceType>("nonConformanceType");
+
const columns = useMemo<ColumnDef<NonConformanceType>[]>(() => {
const defaultColumns: ColumnDef<NonConformanceType>[] = [
{
@@ -35,8 +39,8 @@ const NonConformanceTypesTable = memo(
},
},
];
- return [...defaultColumns];
- }, []);
+ return [...defaultColumns, ...customColumns];
+ }, [customColumns]);
const renderContextMenu = useCallback(
(row: NonConformanceType) => {
@@ -78,7 +82,7 @@ const NonConformanceTypesTable = memo(
columns={columns}
count={count}
primaryAction={
- permissions.can("create", "sales") && (
+ permissions.can("create", "quality") && (
<New
label="Non-Conformance Type"
to={`${path.to.newNonConformanceType}?${params.toString()}`}
diff --git a/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx b/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx
index e08983bff5..e0fae2c85e 100644
--- a/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx
+++ b/apps/erp/app/modules/quality/ui/useQualitySubmodules.tsx
@@ -1,4 +1,11 @@
-import { LuOctagonX, LuShieldX, LuWorkflow } from "react-icons/lu";
+import {
+ LuCircleGauge,
+ LuDraftingCompass,
+ LuOctagonX,
+ LuShapes,
+ LuShieldX,
+ LuWorkflow,
+} from "react-icons/lu";
import { usePermissions } from "~/hooks";
import { useSavedViews } from "~/hooks/useSavedViews";
import type { AuthenticatedRouteGroup } from "~/types";
@@ -6,7 +13,7 @@ import { path } from "~/utils/path";
const qualityRoutes: AuthenticatedRouteGroup[] = [
{
- name: "Manage",
+ name: "History",
routes: [
{
name: "Non-Conformances",
@@ -22,24 +29,29 @@ const qualityRoutes: AuthenticatedRouteGroup[] = [
// },
],
},
- // {
- // name: "Gauges",
- // routes: [
- // {
- // name: "Gauges",
- // to: "#",
- // icon: <LuDraftingCompass />,
- // },
- // {
- // name: "Calibrations",
- // to: "#",
- // icon: <LuCircleGauge />,
- // },
- // ],
- // },
+ {
+ name: "Gauges",
+ routes: [
+ {
+ name: "Gauges",
+ to: path.to.gauges,
+ icon: <LuDraftingCompass />,
+ },
+ {
+ name: "Calibrations",
+ to: path.to.calibrations,
+ icon: <LuCircleGauge />,
+ },
+ ],
+ },
{
name: "Configure",
routes: [
+ {
+ name: "Gauge Types",
+ to: path.to.gaugeTypes,
+ icon: <LuShapes />,
+ },
{
name: "NCR Types",
to: path.to.nonConformanceTypes,
diff --git a/apps/erp/app/routes/x+/quality+/gauge-types.$id.tsx b/apps/erp/app/routes/x+/quality+/gauge-types.$id.tsx
new file mode 100644
index 0000000000..8ea9203fef
--- /dev/null
+++ b/apps/erp/app/routes/x+/quality+/gauge-types.$id.tsx
@@ -0,0 +1,96 @@
+import { assertIsPost, error, notFound, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import { useLoaderData, useNavigate } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import {
+ gaugeTypeValidator,
+ getGaugeType,
+ upsertGaugeType,
+} from "~/modules/quality";
+import GaugeTypeForm from "~/modules/quality/ui/GaugeTypes/GaugeTypeForm";
+import { getCustomFields, setCustomFields } from "~/utils/form";
+import { path } from "~/utils/path";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "quality",
+ role: "employee",
+ });
+
+ const { id } = params;
+ if (!id) throw notFound("id not found");
+
+ const gaugeType = await getGaugeType(client, id);
+
+ if (gaugeType.error) {
+ throw redirect(
+ path.to.gaugeTypes,
+ await flash(request, error(gaugeType.error, "Failed to get gauge type"))
+ );
+ }
+
+ return json({
+ gaugeType: gaugeType.data,
+ });
+}
+
+export async function action({ request }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "quality",
+ });
+
+ const formData = await request.formData();
+ const validation = await validator(gaugeTypeValidator).validate(formData);
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, ...data } = validation.data;
+ if (!id) throw new Error("id not found");
+
+ const updateGaugeType = await upsertGaugeType(client, {
+ id,
+ ...data,
+ updatedBy: userId,
+ customFields: setCustomFields(formData),
+ });
+
+ if (updateGaugeType.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error(updateGaugeType.error, "Failed to update gauge type")
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.gaugeTypes,
+ await flash(request, success("Updated gauge type"))
+ );
+}
+
+export default function EditGaugeTypeRoute() {
+ const { gaugeType } = useLoaderData<typeof loader>();
+ const navigate = useNavigate();
+
+ const initialValues = {
+ id: gaugeType.id ?? undefined,
+ name: gaugeType.name ?? "",
+ ...getCustomFields(gaugeType.customFields),
+ };
+
+ return (
+ <GaugeTypeForm
+ key={initialValues.id}
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
+ );
+}
diff --git a/apps/erp/app/routes/x+/quality+/gauge-types.delete.$id.tsx b/apps/erp/app/routes/x+/quality+/gauge-types.delete.$id.tsx
new file mode 100644
index 0000000000..88bb520e0e
--- /dev/null
+++ b/apps/erp/app/routes/x+/quality+/gauge-types.delete.$id.tsx
@@ -0,0 +1,79 @@
+import { error, notFound, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { ConfirmDelete } from "~/components/Modals";
+import { deleteGaugeType, getGaugeType } from "~/modules/quality";
+import { getParams, path } from "~/utils/path";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "quality",
+ role: "employee",
+ });
+ const { id } = params;
+ if (!id) throw notFound("id not found");
+
+ const gaugeType = await getGaugeType(client, id);
+ if (gaugeType.error) {
+ throw redirect(
+ `${path.to.gaugeTypes}?${getParams(request)}`,
+ await flash(request, error(gaugeType.error, "Failed to get gauge type"))
+ );
+ }
+
+ return json({ gaugeType: gaugeType.data });
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ delete: "quality",
+ });
+
+ const { id } = params;
+ if (!id) {
+ throw redirect(
+ `${path.to.nonConformanceTypes}?${getParams(request)}`,
+ await flash(request, error(params, "Failed to get an gauge id"))
+ );
+ }
+
+ const { error: deleteGaugeTypeError } = await deleteGaugeType(client, id);
+ if (deleteGaugeTypeError) {
+ const errorMessage =
+ deleteGaugeTypeError.code === "23503"
+ ? "Gauge type is used elsewhere, cannot delete"
+ : "Failed to delete gauge type";
+
+ throw redirect(
+ `${path.to.nonConformanceTypes}?${getParams(request)}`,
+ await flash(request, error(deleteGaugeTypeError, errorMessage))
+ );
+ }
+
+ throw redirect(
+ `${path.to.nonConformanceTypes}?${getParams(request)}`,
+ await flash(request, success("Successfully deleted scrap reason"))
+ );
+}
+
+export default function DeleteGaugeTypesRoute() {
+ const { id } = useParams();
+ const { gaugeType } = useLoaderData<typeof loader>();
+ const navigate = useNavigate();
+
+ if (!gaugeType) return null;
+ if (!id) throw notFound("id not found");
+
+ const onCancel = () => navigate(path.to.gaugeTypes);
+ return (
+ <ConfirmDelete
+ action={path.to.deleteGaugeType(id)}
+ name={gaugeType.name}
+ text={`Are you sure you want to delete the gauge type: ${gaugeType.name}? This cannot be undone.`}
+ onCancel={onCancel}
+ />
+ );
+}
diff --git a/apps/erp/app/routes/x+/quality+/gauge-types.new.tsx b/apps/erp/app/routes/x+/quality+/gauge-types.new.tsx
new file mode 100644
index 0000000000..5a997b8766
--- /dev/null
+++ b/apps/erp/app/routes/x+/quality+/gauge-types.new.tsx
@@ -0,0 +1,74 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import { useNavigate } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
+import { gaugeTypeValidator, upsertGaugeType } from "~/modules/quality";
+import GaugeTypeForm from "~/modules/quality/ui/GaugeTypes/GaugeTypeForm";
+import { setCustomFields } from "~/utils/form";
+import { getParams, path, requestReferrer } from "~/utils/path";
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ await requirePermissions(request, {
+ create: "quality",
+ });
+
+ return null;
+}
+
+export async function action({ request }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ create: "quality",
+ });
+
+ const formData = await request.formData();
+ const modal = formData.get("type") === "modal";
+
+ const validation = await validator(gaugeTypeValidator).validate(formData);
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, ...data } = validation.data;
+
+ const insertGaugeType = await upsertGaugeType(client, {
+ ...data,
+ companyId,
+ createdBy: userId,
+ customFields: setCustomFields(formData),
+ });
+ if (insertGaugeType.error) {
+ return modal
+ ? json(insertGaugeType)
+ : redirect(
+ requestReferrer(request) ??
+ `${path.to.gaugeTypes}?${getParams(request)}`,
+ await flash(
+ request,
+ error(insertGaugeType.error, "Failed to insert gauge type")
+ )
+ );
+ }
+
+ return modal
+ ? json(insertGaugeType)
+ : redirect(
+ `${path.to.gaugeTypes}?${getParams(request)}`,
+ await flash(request, success("Non-conformance type created"))
+ );
+}
+
+export default function NewCustomerStatusesRoute() {
+ const navigate = useNavigate();
+ const initialValues = {
+ name: "",
+ };
+
+ return (
+ <GaugeTypeForm initialValues={initialValues} onClose={() => navigate(-1)} />
+ );
+}
diff --git a/apps/erp/app/routes/x+/quality+/gauge-types.tsx b/apps/erp/app/routes/x+/quality+/gauge-types.tsx
new file mode 100644
index 0000000000..5c361853a6
--- /dev/null
+++ b/apps/erp/app/routes/x+/quality+/gauge-types.tsx
@@ -0,0 +1,49 @@
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { VStack } from "@carbon/react";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+import { getGaugeTypes } from "~/modules/quality";
+import GaugeTypesTable from "~/modules/quality/ui/GaugeTypes/GaugeTypesTable";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+import { getGenericQueryFilters } from "~/utils/query";
+
+export const handle: Handle = {
+ breadcrumb: "Gauge Types",
+ to: path.to.gaugeTypes,
+};
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "quality",
+ role: "employee",
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const search = searchParams.get("search");
+ const { limit, offset, sorts, filters } =
+ getGenericQueryFilters(searchParams);
+
+ return json(
+ await getGaugeTypes(client, companyId, {
+ search,
+ limit,
+ offset,
+ sorts,
+ filters,
+ })
+ );
+}
+
+export default function NonConformanceTypesRoute() {
+ const { data, count } = useLoaderData<typeof loader>();
+
+ return (
+ <VStack spacing={0} className="h-full">
+ <GaugeTypesTable data={data ?? []} count={count ?? 0} />
+ <Outlet />
+ </VStack>
+ );
+}
diff --git a/apps/erp/app/routes/x+/quality+/non-conformance-types.$id.tsx b/apps/erp/app/routes/x+/quality+/non-conformance-types.$id.tsx
index e6cb3cbb7b..8d798e3ac0 100644
--- a/apps/erp/app/routes/x+/quality+/non-conformance-types.$id.tsx
+++ b/apps/erp/app/routes/x+/quality+/non-conformance-types.$id.tsx
@@ -11,6 +11,7 @@ import {
upsertNonConformanceType,
} from "~/modules/quality";
import NonConformanceTypeForm from "~/modules/quality/ui/NonConformanceTypes/NonConformanceTypeForm";
+import { getCustomFields, setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
@@ -46,7 +47,9 @@ export async function action({ request }: ActionFunctionArgs) {
});
const formData = await request.formData();
- const validation = await validator(nonConformanceTypeValidator).validate(formData);
+ const validation = await validator(nonConformanceTypeValidator).validate(
+ formData
+ );
if (validation.error) {
return validationError(validation.error);
@@ -58,6 +61,7 @@ export async function action({ request }: ActionFunctionArgs) {
const updateNonConformanceType = await upsertNonConformanceType(client, {
id,
...data,
+ customFields: setCustomFields(formData),
updatedBy: userId,
});
@@ -66,7 +70,10 @@ export async function action({ request }: ActionFunctionArgs) {
{},
await flash(
request,
- error(updateNonConformanceType.error, "Failed to update non-conformance type")
+ error(
+ updateNonConformanceType.error,
+ "Failed to update non-conformance type"
+ )
)
);
}
@@ -84,6 +91,7 @@ export default function EditNonConformanceTypeRoute() {
const initialValues = {
id: nonConformanceType.id ?? undefined,
name: nonConformanceType.name ?? "",
+ ...getCustomFields(nonConformanceType.customFields),
};
return (
diff --git a/apps/erp/app/routes/x+/quality+/non-conformance-types.delete.$id.tsx b/apps/erp/app/routes/x+/quality+/non-conformance-types.delete.$id.tsx
index a283e2adc9..4f3a1d7f09 100644
--- a/apps/erp/app/routes/x+/quality+/non-conformance-types.delete.$id.tsx
+++ b/apps/erp/app/routes/x+/quality+/non-conformance-types.delete.$id.tsx
@@ -5,7 +5,10 @@ import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import { ConfirmDelete } from "~/components/Modals";
-import { deleteNonConformanceType, getNonConformanceType } from "~/modules/quality";
+import {
+ deleteNonConformanceType,
+ getNonConformanceType,
+} from "~/modules/quality";
import { getParams, path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
@@ -39,14 +42,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (!id) {
throw redirect(
`${path.to.nonConformanceTypes}?${getParams(request)}`,
- await flash(request, error(params, "Failed to get an scrap reason id"))
+ await flash(
+ request,
+ error(params, "Failed to get an non-conformance type id")
+ )
);
}
- const { error: deleteNonConformanceTypeError } = await deleteNonConformanceType(
- client,
- id
- );
+ const { error: deleteNonConformanceTypeError } =
+ await deleteNonConformanceType(client, id);
if (deleteNonConformanceTypeError) {
const errorMessage =
deleteNonConformanceTypeError.code === "23503"
diff --git a/apps/erp/app/routes/x+/quality+/non-conformance-types.new.tsx b/apps/erp/app/routes/x+/quality+/non-conformance-types.new.tsx
index ba806a28dd..989185d1ac 100644
--- a/apps/erp/app/routes/x+/quality+/non-conformance-types.new.tsx
+++ b/apps/erp/app/routes/x+/quality+/non-conformance-types.new.tsx
@@ -5,8 +5,12 @@ import { validationError, validator } from "@carbon/form";
import { useNavigate } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
-import { nonConformanceTypeValidator, upsertNonConformanceType } from "~/modules/quality";
+import {
+ nonConformanceTypeValidator,
+ upsertNonConformanceType,
+} from "~/modules/quality";
import NonConformanceTypeForm from "~/modules/quality/ui/NonConformanceTypes/NonConformanceTypeForm";
+import { setCustomFields } from "~/utils/form";
import { getParams, path, requestReferrer } from "~/utils/path";
export async function loader({ request }: LoaderFunctionArgs) {
@@ -26,7 +30,9 @@ export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const modal = formData.get("type") === "modal";
- const validation = await validator(nonConformanceTypeValidator).validate(formData);
+ const validation = await validator(nonConformanceTypeValidator).validate(
+ formData
+ );
if (validation.error) {
return validationError(validation.error);
@@ -38,6 +44,7 @@ export async function action({ request }: ActionFunctionArgs) {
...data,
companyId,
createdBy: userId,
+ customFields: setCustomFields(formData),
});
if (insertNonConformanceType.error) {
return modal
@@ -47,7 +54,10 @@ export async function action({ request }: ActionFunctionArgs) {
`${path.to.nonConformanceTypes}?${getParams(request)}`,
await flash(
request,
- error(insertNonConformanceType.error, "Failed to insert non-conformance type")
+ error(
+ insertNonConformanceType.error,
+ "Failed to insert non-conformance type"
+ )
)
);
}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 1f83480534..1f21c2d259 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -282,6 +282,7 @@ export const path = {
bulkUpdateSalesRfq: `${x}/sales-rfq/update`,
bulkUpdateShipmentLine: `${x}/shipment/lines/update`,
bulkUpdateSupplierQuote: `${x}/supplier-quote/update`,
+ calibrations: `${x}/quality/calibrations`,
chartOfAccount: (id: string) =>
generatePath(`${x}/accounting/charts/${id}`),
chartOfAccounts: `${x}/accounting/charts`,
@@ -419,6 +420,8 @@ export const path = {
generatePath(`${x}/resources/ability/${abilityId}/employee/delete/${id}`),
deleteEmployeeType: (id: string) =>
generatePath(`${x}/users/employee-types/delete/${id}`),
+ deleteGaugeType: (id: string) =>
+ generatePath(`${x}/quality/gauge-types/delete/${id}`),
deleteGroup: (id: string) => generatePath(`${x}/users/groups/delete/${id}`),
deleteHoliday: (id: string) =>
generatePath(`${x}/people/holidays/delete/${id}`),
@@ -563,6 +566,9 @@ export const path = {
feedback: `${x}/feedback`,
fiscalYears: `${x}/accounting/years`,
forgotPassword: "/forgot-password",
+ gauges: `${x}/quality/gauges`,
+ gaugeTypes: `${x}/quality/gauge-types`,
+ gaugeType: (id: string) => generatePath(`${x}/quality/gauge-types/${id}`),
group: (id: string) => generatePath(`${x}/users/groups/${id}`),
groups: `${x}/users/groups`,
holiday: (id: string) => generatePath(`${x}/people/holidays/${id}`),
@@ -719,6 +725,7 @@ export const path = {
newFixture: `${x}/fixture/new`,
newFixtureSupplier: (id: string) =>
generatePath(`${x}/fixture/${id}/purchasing/new`),
+ newGaugeType: `${x}/quality/gauge-types/new`,
newGroup: `${x}/users/groups/new`,
newHoliday: `${x}/people/holidays/new`,
newJob: `${x}/job/new`,
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 2c54cdd2c8..3228441953 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -27210,6 +27210,168 @@ export default {
tags: ["jobOperationAttributeRecord"],
},
},
+ "/gaugeType": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.updatedBy",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/gaugeType",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["gaugeType"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.gaugeType",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["gaugeType"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["gaugeType"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeType.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.gaugeType",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["gaugeType"],
+ },
+ },
"/receiptLine": {
get: {
parameters: [
@@ -33192,6 +33354,9 @@ export default {
{
$ref: "#/parameters/rowFilter.nonConformanceType.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.nonConformanceType.customFields",
+ },
{
$ref: "#/parameters/select",
},
@@ -33272,6 +33437,9 @@ export default {
{
$ref: "#/parameters/rowFilter.nonConformanceType.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.nonConformanceType.customFields",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -33306,6 +33474,9 @@ export default {
{
$ref: "#/parameters/rowFilter.nonConformanceType.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.nonConformanceType.customFields",
+ },
{
$ref: "#/parameters/body.nonConformanceType",
},
@@ -63927,7 +64098,7 @@ export default {
type: "object",
},
feedback: {
- required: ["id", "location", "userId", "feedback"],
+ required: ["id", "location", "feedback"],
properties: {
id: {
default: "public.xid()",
@@ -64680,6 +64851,52 @@ export default {
},
type: "object",
},
+ gaugeType: {
+ required: ["id", "name", "customFields", "createdAt", "createdBy"],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ name: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ customFields: {
+ format: "json",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
receiptLine: {
required: [
"id",
@@ -67510,7 +67727,7 @@ export default {
type: "object",
},
nonConformanceType: {
- required: ["id", "name", "createdAt", "createdBy"],
+ required: ["id", "name", "createdAt", "createdBy", "customFields"],
properties: {
id: {
default: "public.xid()",
@@ -67549,6 +67766,9 @@ export default {
format: "text",
type: "string",
},
+ customFields: {
+ format: "json",
+ },
},
type: "object",
},
@@ -88533,6 +88753,63 @@ export default {
in: "query",
type: "string",
},
+ "body.gaugeType": {
+ name: "gaugeType",
+ description: "gaugeType",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/gaugeType",
+ },
+ },
+ "rowFilter.gaugeType.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.name": {
+ name: "name",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeType.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.receiptLine": {
name: "receiptLine",
description: "receiptLine",
@@ -91827,6 +92104,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.nonConformanceType.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.group": {
name: "group",
description: "group",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 61dfea90fd..b50ed403cb 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -5699,21 +5699,21 @@ export type Database = {
feedback: string
id: string
location: string
- userId: string
+ userId: string | null
}
Insert: {
attachmentPath?: string | null
feedback: string
id?: string
location: string
- userId: string
+ userId?: string | null
}
Update: {
attachmentPath?: string | null
feedback?: string
id?: string
location?: string
- userId?: string
+ userId?: string | null
}
Relationships: [
{
@@ -6173,6 +6173,138 @@ export type Database = {
},
]
}
+ gaugeType: {
+ Row: {
+ companyId: string | null
+ createdAt: string
+ createdBy: string
+ customFields: Json
+ id: string
+ name: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy: string
+ customFields?: Json
+ id?: string
+ name: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json
+ id?: string
+ name?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
group: {
Row: {
companyId: string | null
@@ -14252,6 +14384,7 @@ export type Database = {
companyId: string | null
createdAt: string
createdBy: string
+ customFields: Json
id: string
name: string
updatedAt: string | null
@@ -14261,6 +14394,7 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy: string
+ customFields?: Json
id?: string
name: string
updatedAt?: string | null
@@ -14270,6 +14404,7 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy?: string
+ customFields?: Json
id?: string
name?: string
updatedAt?: string | null
diff --git a/packages/database/supabase/functions/lib/seed.ts b/packages/database/supabase/functions/lib/seed.ts
index e86b731c84..37fa6ce49b 100644
--- a/packages/database/supabase/functions/lib/seed.ts
+++ b/packages/database/supabase/functions/lib/seed.ts
@@ -1529,6 +1529,29 @@ export const fiscalYearSettings: Omit<
updatedBy: "system",
};
+export const gaugeTypes = [
+ "Gauge Block",
+ "Caliper - Inside",
+ "Caliper - Outside",
+ "Caliper - Depth",
+ "Micrometer - Outside",
+ "Micrometer - Inside",
+ "Micrometer - Depth",
+ "Dial Indicator",
+ "Height Gauge",
+ "Thread Gauge",
+ "Pin Gauge",
+ "Ring Gauge",
+ "Plug Gauge",
+ "Bore Gauge",
+ "Feeler Gauge",
+ "Surface Plate",
+ "Go/No-Go Gauge",
+ "Profile Gauge",
+ "Coordinate Measuring Machine (CMM)",
+ "Optical Comparator",
+];
+
function getDefaultAccount(key: string) {
if (!(key in accountDefaults))
throw new Error(`Account default not found for ${key}`);
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 61dfea90fd..b50ed403cb 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -5699,21 +5699,21 @@ export type Database = {
feedback: string
id: string
location: string
- userId: string
+ userId: string | null
}
Insert: {
attachmentPath?: string | null
feedback: string
id?: string
location: string
- userId: string
+ userId?: string | null
}
Update: {
attachmentPath?: string | null
feedback?: string
id?: string
location?: string
- userId?: string
+ userId?: string | null
}
Relationships: [
{
@@ -6173,6 +6173,138 @@ export type Database = {
},
]
}
+ gaugeType: {
+ Row: {
+ companyId: string | null
+ createdAt: string
+ createdBy: string
+ customFields: Json
+ id: string
+ name: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy: string
+ customFields?: Json
+ id?: string
+ name: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json
+ id?: string
+ name?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeType_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeType_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
group: {
Row: {
companyId: string | null
@@ -14252,6 +14384,7 @@ export type Database = {
companyId: string | null
createdAt: string
createdBy: string
+ customFields: Json
id: string
name: string
updatedAt: string | null
@@ -14261,6 +14394,7 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy: string
+ customFields?: Json
id?: string
name: string
updatedAt?: string | null
@@ -14270,6 +14404,7 @@ export type Database = {
companyId?: string | null
createdAt?: string
createdBy?: string
+ customFields?: Json
id?: string
name?: string
updatedAt?: string | null
diff --git a/packages/database/supabase/functions/seed-company/index.ts b/packages/database/supabase/functions/seed-company/index.ts
index 79cf95de30..34823c8d49 100644
--- a/packages/database/supabase/functions/seed-company/index.ts
+++ b/packages/database/supabase/functions/seed-company/index.ts
@@ -9,6 +9,7 @@ import {
currencies,
customerStatuses,
fiscalYearSettings,
+ gaugeTypes,
groupCompanyTemplate,
groups,
nonConformanceTypes,
@@ -176,6 +177,13 @@ serve(async (req: Request) => {
.values(unitOfMeasures.map((uom) => ({ ...uom, companyId })))
.execute();
+ await trx
+ .insertInto("gaugeType")
+ .values(
+ gaugeTypes.map((gt) => ({ name: gt, companyId, createdBy: "system" }))
+ )
+ .execute();
+
await trx
.insertInto("nonConformanceType")
.values(nonConformanceTypes.map((nc) => ({ ...nc, companyId })))
@@ -252,7 +260,6 @@ serve(async (req: Request) => {
.values([{ ...fiscalYearSettings, companyId }])
.execute();
-
const user = await client
.from("userPermission")
.select("permissions")
diff --git a/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql b/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql
new file mode 100644
index 0000000000..ee8bb04e50
--- /dev/null
+++ b/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql
@@ -0,0 +1,100 @@
+INSERT INTO "customFieldTable" ("table", "name", "module")
+VALUES ('nonConformanceType', 'Non-Conformance Type', 'Quality');
+
+INSERT INTO "customFieldTable" ("table", "name", "module")
+VALUES ('gaugeType', 'Gauge Type', 'Quality');
+
+ALTER TABLE "nonConformanceType"
+ADD COLUMN "customFields" JSON NOT NULL DEFAULT '{}';
+
+CREATE TABLE "gaugeType" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "name" TEXT NOT NULL,
+ "companyId" TEXT,
+ "customFields" JSON NOT NULL DEFAULT '{}',
+ "createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "gaugeType_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "gaugeType_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "gaugeType_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE,
+ CONSTRAINT "gaugeType_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE
+);
+
+CREATE INDEX "gaugeType_companyId_idx" ON "gaugeType" ("companyId");
+
+CREATE POLICY "SELECT" ON "public"."gaugeType"
+FOR SELECT USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_role()
+ )::text[]
+ )
+);
+
+CREATE POLICY "INSERT" ON "public"."gaugeType"
+FOR INSERT WITH CHECK (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission ('quality_create')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "public"."gaugeType"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission ('quality_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "public"."gaugeType"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission ('quality_delete')
+ )::text[]
+ )
+);
+
+-- Insert non-conformance types for all existing companies
+WITH nc_types AS (
+ SELECT unnest(ARRAY[
+ 'Gauge Block',
+ 'Caliper - Inside',
+ 'Caliper - Outside',
+ 'Caliper - Depth',
+ 'Micrometer - Outside',
+ 'Micrometer - Inside',
+ 'Micrometer - Depth',
+ 'Dial Indicator',
+ 'Height Gauge',
+ 'Thread Gauge',
+ 'Pin Gauge',
+ 'Ring Gauge',
+ 'Plug Gauge',
+ 'Bore Gauge',
+ 'Feeler Gauge',
+ 'Surface Plate',
+ 'Go/No-Go Gauge',
+ 'Profile Gauge',
+ 'Coordinate Measuring Machine (CMM)',
+ 'Optical Comparator'
+ ]) AS name
+)
+INSERT INTO "gaugeType" ("name", "companyId", "createdBy")
+SELECT
+ nc_types.name,
+ c.id,
+ 'system'
+FROM
+ "company" c,
+ nc_types;
\ No newline at end of file
diff --git a/scripts/delete-company-files.ts b/scripts/delete-company-files.ts
index 92b0749c58..3680f3d7da 100644
--- a/scripts/delete-company-files.ts
+++ b/scripts/delete-company-files.ts
@@ -29,7 +29,7 @@ console.log(process.env.SUPABASE_URL);
const supabaseAdmin = createClient(
process.env.SUPABASE_URL!,
- process.env.SUPABASE_SERVICE_ROLE_KEY!,
+ process.env.SUPABASE_SERVICE_ROLE!,
{
auth: {
autoRefreshToken: false,
diff --git a/scripts/generate-job-dependencies.ts b/scripts/generate-job-dependencies.ts
new file mode 100644
index 0000000000..591c2e45e1
--- /dev/null
+++ b/scripts/generate-job-dependencies.ts
@@ -0,0 +1,45 @@
+// import type { User } from "@supabase/supabase-js";
+import { createClient } from "@supabase/supabase-js";
+import * as dotenv from "dotenv";
+
+dotenv.config();
+
+const COMPANY_ID = "cs868u84gfk07v78v9e0";
+const USER_ID = "7b37e09f-79f6-4a7d-b965-d92e676b3e6a";
+const OPEN_JOB_STATUSES = ["Ready", "In Progress", "Paused"] as const;
+
+console.log(process.env.SUPABASE_URL);
+
+const supabaseAdmin = createClient(
+ process.env.SUPABASE_URL!,
+ process.env.SUPABASE_SERVICE_ROLE!,
+ {
+ auth: {
+ autoRefreshToken: false,
+ persistSession: false,
+ },
+ }
+);
+
+(async () => {
+ const { data: jobs } = await supabaseAdmin
+ .from("job")
+ .select("id, status")
+ .eq("companyId", COMPANY_ID)
+ .in("status", OPEN_JOB_STATUSES);
+
+ if (!jobs) throw new Error("No jobs found");
+
+ for await (const job of jobs) {
+ const result = await supabaseAdmin.functions.invoke("scheduler", {
+ body: {
+ type: "dependencies",
+ jobId: job.id,
+ companyId: COMPANY_ID,
+ userId: USER_ID,
+ },
+ });
+ console.log(result);
+ await new Promise((resolve) => setTimeout(resolve, 5000));
+ }
+})();