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.

- implemented risk registers across all related entities

Gaurav Bhattf6fddabeefa1
diff --git a/apps/erp/app/modules/items/ui/Item/ItemRiskRegister.tsx b/apps/erp/app/modules/items/ui/Item/ItemRiskRegister.tsx
new file mode 100644
index 0000000000..9b55c09a5d
--- /dev/null
+++ b/apps/erp/app/modules/items/ui/Item/ItemRiskRegister.tsx
@@ -0,0 +1,9 @@
+import RiskRegisterCard from "~/modules/quality/ui/RiskRegister/RiskRegisterCard";
+
+type ItemRiskRegisterProps = {
+ itemId: string;
+};
+
+export default function ItemRiskRegister({ itemId }: ItemRiskRegisterProps) {
+ return <RiskRegisterCard sourceId={itemId} source="Item" />;
+}
diff --git a/apps/erp/app/modules/items/ui/Item/index.ts b/apps/erp/app/modules/items/ui/Item/index.ts
index 51849446c4..263e66be5a 100644
--- a/apps/erp/app/modules/items/ui/Item/index.ts
+++ b/apps/erp/app/modules/items/ui/Item/index.ts
@@ -8,6 +8,7 @@ import ItemForm from "./ItemForm";
import ItemNotes from "./ItemNotes";
import ItemPlanningForm from "./ItemPlanningForm";
import ItemPurchasingForm from "./ItemPurchasingForm";
+import ItemRiskRegister from "./ItemRiskRegister";
import ItemSalePriceForm from "./ItemSalePriceForm";
import MakeMethodTools from "./MakeMethodTools";
import PickMethodForm from "./PickMethodForm";
@@ -25,6 +26,7 @@ export {
ItemNotes,
ItemPlanningForm,
ItemPurchasingForm,
+ ItemRiskRegister,
ItemSalePriceForm,
MakeMethodTools,
PickMethodForm,
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobRiskRegister.tsx b/apps/erp/app/modules/production/ui/Jobs/JobRiskRegister.tsx
new file mode 100644
index 0000000000..28a4e72927
--- /dev/null
+++ b/apps/erp/app/modules/production/ui/Jobs/JobRiskRegister.tsx
@@ -0,0 +1,9 @@
+import RiskRegisterCard from "~/modules/quality/ui/RiskRegister/RiskRegisterCard";
+
+type JobRiskRegisterProps = {
+ jobId: string;
+};
+
+export default function JobRiskRegister({ jobId }: JobRiskRegisterProps) {
+ return <RiskRegisterCard sourceId={jobId} source="Job" />;
+}
diff --git a/apps/erp/app/modules/production/ui/Jobs/index.ts b/apps/erp/app/modules/production/ui/Jobs/index.ts
index cb0245c413..cf64685d92 100644
--- a/apps/erp/app/modules/production/ui/Jobs/index.ts
+++ b/apps/erp/app/modules/production/ui/Jobs/index.ts
@@ -12,6 +12,7 @@ import JobNotes from "./JobNotes";
import JobOperationStepRecordsTable from "./JobOperationStepRecordsTable";
import JobOperationsTable from "./JobOperationsTable";
import JobProperties from "./JobProperties";
+import JobRiskRegister from "./JobRiskRegister";
import JobStatus from "./JobStatus";
import JobsTable from "./JobsTable";
import ProductionEventForm from "./ProductionEventForm";
@@ -34,6 +35,7 @@ export {
JobOperationsTable,
JobOperationStepRecordsTable,
JobProperties,
+ JobRiskRegister,
JobsTable,
JobStatus,
ProductionEventForm,
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierRiskRegister.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierRiskRegister.tsx
new file mode 100644
index 0000000000..7a7ae09e31
--- /dev/null
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierRiskRegister.tsx
@@ -0,0 +1,11 @@
+import RiskRegisterCard from "~/modules/quality/ui/RiskRegister/RiskRegisterCard";
+
+type SupplierRiskRegisterProps = {
+ supplierId: string;
+};
+
+export default function SupplierRiskRegister({
+ supplierId,
+}: SupplierRiskRegisterProps) {
+ return <RiskRegisterCard sourceId={supplierId} source="Supplier" />;
+}
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx
index 70fb5106b6..6050bb3976 100644
--- a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx
@@ -5,7 +5,8 @@ import {
LuCreditCard,
LuLayoutList,
LuMapPin,
- LuPackageSearch
+ LuPackageSearch,
+ LuShieldAlert
} from "react-icons/lu";
import { useParams } from "react-router";
import { usePermissions } from "~/hooks";
@@ -59,6 +60,12 @@ export function useSupplierSidebar({ contacts, locations }: Props) {
icon: <LuCog />,
shortcut: "Command+Shift+r"
},
+ {
+ name: "Risk Register",
+ to: path.to.supplierRisks(supplierId),
+ role: ["employee"],
+ icon: <LuShieldAlert />
+ },
{
name: "Quotes",
to: `${path.to.supplierQuotes}?filter=supplierId:eq:${supplierId}`,
diff --git a/apps/erp/app/modules/quality/quality.models.ts b/apps/erp/app/modules/quality/quality.models.ts
index e16c051a31..c6b27b9d6d 100644
--- a/apps/erp/app/modules/quality/quality.models.ts
+++ b/apps/erp/app/modules/quality/quality.models.ts
@@ -61,24 +61,24 @@ export const nonConformanceAssociationType = [
] as const;
export const riskSource = [
- "GENERAL",
- "ITEM",
- "ITEM_MASTER",
- "QUOTE_LINE",
- "JOB",
- "WORK_CENTER",
- "SUPPLIER",
- "SUPPLIER_MASTER",
- "CUSTOMER",
- "CUSTOMER_MASTER",
+ "General",
+ "Item",
+ "Item Master",
+ "Quote Line",
+ "Job",
+ "Work Center",
+ "Supplier",
+ "Supplier Master",
+ "Customer",
+ "Customer Master",
] as const;
export const riskStatus = [
- "OPEN",
- "IN_REVIEW",
- "MITIGATING",
- "CLOSED",
- "ACCEPTED",
+ "Open",
+ "In Review",
+ "Mitigating",
+ "Closed",
+ "Accepted",
] as const;
export const qualityDocumentStatus = ["Draft", "Active", "Archived"] as const;
@@ -310,7 +310,6 @@ export const requiredActionValidator = z.object({
active: zfd.checkbox()
});
-
export const riskRegisterValidator = z.object({
id: zfd.text(z.string().optional()),
title: z.string().min(1, { message: "Title is required" }),
@@ -320,10 +319,5 @@ export const riskRegisterValidator = z.object({
likelihood: zfd.numeric(z.number().min(1).max(5).optional()),
status: z.enum(riskStatus),
assigneeUserId: zfd.text(z.string().optional()),
- itemId: zfd.text(z.string().optional()),
- workCenterId: zfd.text(z.string().optional()),
- supplierId: zfd.text(z.string().optional()),
- customerId: zfd.text(z.string().optional()),
- quoteLineId: zfd.text(z.string().optional()),
- jobId: zfd.text(z.string().optional()),
+ sourceId: zfd.text(z.string().optional()),
});
diff --git a/apps/erp/app/modules/quality/quality.service.ts b/apps/erp/app/modules/quality/quality.service.ts
index a977989588..36540b71a3 100644
--- a/apps/erp/app/modules/quality/quality.service.ts
+++ b/apps/erp/app/modules/quality/quality.service.ts
@@ -1654,7 +1654,6 @@ export async function upsertRisk(
.from("riskRegister")
.update({
...sanitize(data),
- score: (data.severity ?? 0) * (data.likelihood ?? 0),
updatedAt: new Date().toISOString()
})
.eq("id", risk.id)
@@ -1665,8 +1664,7 @@ export async function upsertRisk(
.from("riskRegister")
.insert([
{
- ...sanitize(risk),
- score: (risk.severity ?? 0) * (risk.likelihood ?? 0)
+ ...sanitize(risk)
}
])
.select("id")
diff --git a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegister.tsx b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegister.tsx
index 2a14051958..6661627dee 100644
--- a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegister.tsx
+++ b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegister.tsx
@@ -13,14 +13,11 @@ import {
toast,
} from "@carbon/react";
import { useEffect, useState, useCallback } from "react";
-import { LuPlus, LuShieldAlert, LuPencil, LuTrash } from "react-icons/lu";
+import { LuPlus, LuShieldAlert, LuSettings2 } from "react-icons/lu";
import { EmployeeAvatar } from "~/components";
import type { Risk } from "~/modules/quality/types";
import RiskRegisterForm from "./RiskRegisterForm";
import { useUser } from "~/hooks";
-import { Confirm } from "~/components/Modals";
-import { path } from "~/utils/path";
-import { useFetcher } from "@remix-run/react";
import type { riskSource } from "~/modules/quality/quality.models";
type RiskRegisterProps = {
@@ -28,16 +25,6 @@ type RiskRegisterProps = {
documentType: (typeof riskSource)[number];
};
-const columnMap: Record<string, string> = {
- Item: "itemId",
- "Work Center": "workCenterId",
- Supplier: "supplierId",
- Customer: "customerId",
- "Quote Line": "quoteLineId",
- Job: "jobId",
-};
-
-
export default function RiskRegister({
documentId,
documentType,
@@ -47,18 +34,17 @@ export default function RiskRegister({
const [risks, setRisks] = useState<Risk[]>([]);
const [loading, setLoading] = useState(true);
const formDisclosure = useDisclosure();
- const deleteDisclosure = useDisclosure();
const [selectedRisk, setSelectedRisk] = useState<Risk | undefined>(undefined);
const fetchRisks = useCallback(async () => {
if (!carbon || !company?.id) return;
setLoading(true);
- const column = columnMap[documentType];
const { data, error } = await carbon
.from("riskRegister")
.select("*, assignee:assigneeUserId(id, firstName, lastName, avatarUrl)")
.eq("companyId", company.id)
- .eq(column, documentId)
+ .eq("source", documentType)
+ .eq("sourceId", documentId)
.order("createdAt", { ascending: false });
if (error) {
@@ -86,21 +72,6 @@ export default function RiskRegister({
formDisclosure.onOpen();
};
- const handleDelete = (risk: Risk) => {
- setSelectedRisk(risk);
- deleteDisclosure.onOpen();
- };
-
- const deleteFetcher = useFetcher();
- useEffect(() => {
- if (deleteFetcher.state === "idle" && deleteFetcher.data) {
- deleteDisclosure.onClose();
- fetchRisks();
- }
- }, [deleteFetcher.state, deleteFetcher.data, fetchRisks, deleteDisclosure]);
-
- const column = columnMap[documentType];
-
return (
<Card className="h-full">
<CardHeader>
@@ -126,7 +97,7 @@ export default function RiskRegister({
</div>
) : risks.length === 0 ? (
<div className="p-8 text-center text-muted-foreground text-sm">
- No risks registered.
+ No risks registered
</div>
) : (
<div className="divide-y">
@@ -140,9 +111,9 @@ export default function RiskRegister({
<span className="font-medium">{risk.title}</span>
<Badge
variant={
- risk.status === "OPEN"
+ risk.status === "Open"
? "destructive"
- : risk.status === "CLOSED"
+ : risk.status === "Closed"
? "default"
: "secondary"
}
@@ -157,7 +128,6 @@ export default function RiskRegister({
<HStack className="mt-2 text-xs text-muted-foreground">
<span>Severity: {risk.severity}</span>
<span>Likelihood: {risk.likelihood}</span>
- <span>Score: {risk.score}</span>
{risk.assigneeUserId && (
<div className="flex items-center gap-1 ml-2">
<span>Assignee:</span>
@@ -172,18 +142,11 @@ export default function RiskRegister({
<div className="flex items-center opacity-0 group-hover:opacity-100 transition-opacity">
<IconButton
aria-label="Edit"
- icon={<LuPencil className="h-4 w-4" />}
+ icon={<LuSettings2 className="h-4 w-4" />}
variant="ghost"
size="sm"
onClick={() => handleEdit(risk)}
/>
- <IconButton
- aria-label="Delete"
- icon={<LuTrash className="h-4 w-4" />}
- variant="ghost"
- size="sm"
- onClick={() => handleDelete(risk)}
- />
</div>
</div>
))}
@@ -204,40 +167,19 @@ export default function RiskRegister({
...selectedRisk,
description: selectedRisk.description ?? undefined,
assigneeUserId: selectedRisk.assigneeUserId ?? undefined,
- itemId: selectedRisk.itemId ?? undefined,
- workCenterId: selectedRisk.workCenterId ?? undefined,
- supplierId: selectedRisk.supplierId ?? undefined,
- customerId: selectedRisk.customerId ?? undefined,
- quoteLineId: selectedRisk.quoteLineId ?? undefined,
- jobId: selectedRisk.jobId ?? undefined,
+ sourceId: selectedRisk.sourceId ?? undefined,
severity: selectedRisk.severity ?? undefined,
likelihood: selectedRisk.likelihood ?? undefined,
}
: {
title: "",
- status: "OPEN",
- source: (documentType ?? "GENERAL"),
- [column]: documentId,
+ status: "Open",
+ source: documentType ?? "General",
+ sourceId: documentId,
}
}
/>
)}
-
- {selectedRisk && deleteDisclosure.isOpen && (
- <Confirm
- isOpen={deleteDisclosure.isOpen}
- confirmText="Delete"
- onCancel={deleteDisclosure.onClose}
- onSubmit={() => {
- // We can't use the form action directly here because we want to stay on the page and refresh
- // But Confirm component uses a form submission.
- // We can pass the action path.
- }}
- title="Delete Risk"
- text="Are you sure you want to delete this risk?"
- action={path.to.deleteRisk(selectedRisk.id!)}
- />
- )}
</Card>
);
}
diff --git a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterCard.tsx b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterCard.tsx
new file mode 100644
index 0000000000..1c1160bee0
--- /dev/null
+++ b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterCard.tsx
@@ -0,0 +1,184 @@
+import { useCarbon } from "@carbon/auth";
+import {
+ Card,
+ CardAction,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ HStack,
+ IconButton,
+ Loading,
+ useDisclosure,
+ Badge,
+ toast,
+ Button,
+} from "@carbon/react";
+import { useEffect, useState, useCallback } from "react";
+import { LuSettings2 } from "react-icons/lu";
+import { EmployeeAvatar } from "~/components";
+import { useUser } from "~/hooks";
+import type { Risk } from "~/modules/quality/types";
+import RiskRegisterForm from "./RiskRegisterForm";
+import type { riskSource } from "~/modules/quality/quality.models";
+
+type RiskRegisterCardProps = {
+ sourceId: string;
+ source: (typeof riskSource)[number];
+};
+
+export default function RiskRegisterCard({
+ sourceId,
+ source,
+}: RiskRegisterCardProps) {
+ const { carbon } = useCarbon();
+ const { company } = useUser();
+ const [risks, setRisks] = useState<Risk[]>([]);
+ const [loading, setLoading] = useState(false);
+ const formDisclosure = useDisclosure();
+ const [selectedRisk, setSelectedRisk] = useState<Risk | undefined>(undefined);
+
+ const fetchRisks = useCallback(async () => {
+ if (!carbon || !company?.id) return;
+ setLoading(true);
+ const { data, error } = await carbon
+ .from("riskRegister")
+ .select("*, assignee:assigneeUserId(id, firstName, lastName, avatarUrl)")
+ .eq("companyId", company.id)
+ .eq("source", source)
+ .eq("sourceId", sourceId)
+ .order("createdAt", { ascending: false });
+
+ if (error) {
+ toast.error(`Failed to fetch risks`);
+ return;
+ }
+
+ if (data) {
+ setRisks(data as unknown as Risk[]);
+ }
+ setLoading(false);
+ }, [carbon, company?.id, sourceId, source]);
+
+ useEffect(() => {
+ fetchRisks();
+ }, [fetchRisks]);
+
+ const handleAdd = () => {
+ setSelectedRisk(undefined);
+ formDisclosure.onOpen();
+ };
+
+ const handleEdit = (risk: Risk) => {
+ setSelectedRisk(risk);
+ formDisclosure.onOpen();
+ };
+
+ return (
+ <Card className="h-full">
+ <HStack className="justify-between">
+ <CardHeader>
+ <CardTitle>Risk Register</CardTitle>
+ </CardHeader>
+ <CardAction>
+ <Button aria-label="Add Risk" variant="secondary" onClick={handleAdd}>
+ Add Risk
+ </Button>
+ </CardAction>
+ </HStack>
+
+ <CardContent className="p-0">
+ {loading ? (
+ <div className="p-4">
+ <Loading isLoading={true} />
+ </div>
+ ) : risks.length === 0 ? (
+ <div className="p-8 text-center text-muted-foreground text-sm">
+ No risks registered
+ </div>
+ ) : (
+ <div className="flex flex-col gap-4">
+ {risks.map((risk) => (
+ <div
+ key={risk.id}
+ className="p-4 flex items-start justify-between hover:bg-muted/50 transition-colors group rounded-md bg-muted/30 border border-border"
+ >
+ <div className="flex flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="font-medium">{risk.title}</span>
+ <Badge
+ variant={
+ risk.status === "Open"
+ ? "destructive"
+ : risk.status === "Closed"
+ ? "default"
+ : "secondary"
+ }
+ >
+ {risk.status}
+ </Badge>
+ </div>
+ {risk.description && (
+ <p className="text-sm text-muted-foreground line-clamp-2">
+ {risk.description}
+ </p>
+ )}
+ <HStack className="mt-2 text-xs text-muted-foreground">
+ {risk.severity && <span>Severity: {risk.severity}</span>}
+ {risk.likelihood && (
+ <span>Likelihood: {risk.likelihood}</span>
+ )}
+ {risk.assigneeUserId && (
+ <div className="flex items-center gap-1 ml-2">
+ <span>Assignee:</span>
+ <EmployeeAvatar
+ employeeId={risk.assigneeUserId}
+ className="h-5 w-5"
+ />
+ </div>
+ )}
+ </HStack>
+ </div>
+ <div className="flex items-center opacity-0 group-hover:opacity-100 transition-opacity">
+ <IconButton
+ aria-label="Edit"
+ icon={<LuSettings2 className="h-4 w-4" />}
+ variant="ghost"
+ size="sm"
+ onClick={() => handleEdit(risk)}
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+ </CardContent>
+
+ {formDisclosure.isOpen && (
+ <RiskRegisterForm
+ open={formDisclosure.isOpen}
+ onClose={() => {
+ formDisclosure.onClose();
+ fetchRisks();
+ }}
+ initialValues={
+ selectedRisk
+ ? {
+ ...selectedRisk,
+ description: selectedRisk.description ?? undefined,
+ assigneeUserId: selectedRisk.assigneeUserId ?? undefined,
+ sourceId: selectedRisk.sourceId ?? undefined,
+ severity: selectedRisk.severity ?? undefined,
+ likelihood: selectedRisk.likelihood ?? undefined,
+ }
+ : {
+ title: "",
+ status: "Open",
+ source: source,
+ sourceId: sourceId,
+ }
+ }
+ />
+ )}
+ </Card>
+ );
+}
diff --git a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx
index 84ea84d77d..30f4c09d84 100644
--- a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx
+++ b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx
@@ -11,6 +11,7 @@ import {
ModalDrawerTitle,
VStack,
toast,
+ useDisclosure,
} from "@carbon/react";
import { useFetcher } from "@remix-run/react";
import type { PostgrestResponse } from "@supabase/supabase-js";
@@ -25,9 +26,9 @@ import {
TextArea,
Number as NumberInput,
} from "~/components/Form";
+import { Confirm } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import {
- riskSource,
riskRegisterValidator,
riskStatus,
} from "~/modules/quality/quality.models";
@@ -47,12 +48,18 @@ const RiskRegisterForm = ({
onClose,
}: RiskRegisterFormProps) => {
const permissions = usePermissions();
- const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();
+ const fetcher =
+ useFetcher<PostgrestResponse<{ id: string; success: boolean }>>();
+ const deleteDisclosure = useDisclosure();
+ const deleteFetcher = useFetcher();
+
+ console.log("zaza", fetcher);
useEffect(() => {
- if (type !== "modal") return;
+ console.log("zaza1", fetcher.state, fetcher.data);
- if (fetcher.state === "loading" && fetcher.data?.data) {
+ if (fetcher.state === "idle" && fetcher.data?.data) {
+ console.log("zaza2", fetcher.data.data);
onClose?.();
toast.success(`Saved risk`);
} else if (fetcher.state === "idle" && fetcher.data?.error) {
@@ -60,95 +67,129 @@ const RiskRegisterForm = ({
}
}, [fetcher.data, fetcher.state, onClose, type]);
+ useEffect(() => {
+ if (deleteFetcher.state === "idle" && deleteFetcher.data) {
+ deleteDisclosure.onClose();
+ onClose?.();
+ toast.success(`Deleted risk`);
+ }
+ }, [deleteFetcher.state, deleteFetcher.data, deleteDisclosure, onClose]);
+
const isEditing = !!initialValues.id;
const isDisabled = isEditing
? !permissions.can("update", "quality")
: !permissions.can("create", "quality");
- console.log("initialValues",initialValues)
+ // Set default values for severity and likelihood
+ const formInitialValues = {
+ ...initialValues,
+ severity: initialValues.severity ?? 1,
+ likelihood: initialValues.likelihood ?? 1,
+ };
return (
- <ModalDrawerProvider type={type}>
- <ModalDrawer
- open={open}
- onOpenChange={(isOpen) => {
- if (!isOpen) onClose?.();
- }}
- >
- <ModalDrawerContent>
- <ValidatedForm
- validator={riskRegisterValidator}
- method="post"
- action={
- isEditing
- ? path.to.risk(initialValues.id!)
- : path.to.newRisk
- }
- defaultValues={initialValues}
- fetcher={fetcher}
- className="flex flex-col h-full"
- >
- <ModalDrawerHeader>
- <ModalDrawerTitle>
- {isEditing ? "Edit" : "New"} Risk
- </ModalDrawerTitle>
- </ModalDrawerHeader>
- <ModalDrawerBody>
- <Hidden name="id" />
- {/* Context fields (hidden if not provided, but form needs them if passed) */}
- <Hidden name="itemId" />
- <Hidden name="workCenterId" />
- <Hidden name="supplierId" />
- <Hidden name="customerId" />
- <Hidden name="quoteLineId" />
- <Hidden name="jobId" />
+ <>
+ <ModalDrawerProvider type={type}>
+ <ModalDrawer
+ open={open}
+ onOpenChange={(isOpen) => {
+ if (!isOpen) onClose?.();
+ }}
+ >
+ <ModalDrawerContent>
+ <ValidatedForm
+ validator={riskRegisterValidator}
+ method="post"
+ action={
+ isEditing ? path.to.risk(initialValues.id!) : path.to.newRisk
+ }
+ defaultValues={formInitialValues}
+ fetcher={fetcher}
+ className="flex flex-col h-full"
+ >
+ <ModalDrawerHeader>
+ <ModalDrawerTitle>
+ {isEditing ? "Edit" : "New"} Risk
+ </ModalDrawerTitle>
+ </ModalDrawerHeader>
+ <ModalDrawerBody>
+ <Hidden name="id" />
+ <Hidden name="source" />
+ {/* Context field for the source entity ID */}
+ <Hidden name="sourceId" />
- <VStack spacing={4}>
- <Input name="title" label="Title" />
- <TextArea name="description" label="Description" />
+ <VStack spacing={4}>
+ <Input name="title" label="Title" />
+ <TextArea name="description" label="Description" />
- <Select
- name="source"
- label="Source"
- options={riskSource.map((c) => ({ value: c, label: c }))}
- />
+ <Select
+ name="status"
+ label="Status"
+ options={riskStatus.map((s) => ({ value: s, label: s }))}
+ />
- <Select
- name="status"
- label="Status"
- options={riskStatus.map((s) => ({ value: s, label: s }))}
- />
+ <HStack spacing={4} className="w-full">
+ <NumberInput
+ name="severity"
+ label="Severity (1-5)"
+ minValue={1}
+ maxValue={5}
+ />
+ <NumberInput
+ name="likelihood"
+ label="Likelihood (1-5)"
+ minValue={1}
+ maxValue={5}
+ />
+ </HStack>
- <HStack spacing={4} className="w-full">
- <NumberInput
- name="severity"
- label="Severity (1-5)"
- minValue={1}
- maxValue={5}
- />
- <NumberInput
- name="likelihood"
- label="Likelihood (1-5)"
- minValue={1}
- maxValue={5}
- />
+ <Employee name="assigneeUserId" label="Assignee" />
+ </VStack>
+ </ModalDrawerBody>
+ <ModalDrawerFooter>
+ <HStack className="justify-between w-full">
+ <div>
+ {isEditing && permissions.can("delete", "quality") && (
+ <Button
+ size="md"
+ variant="destructive"
+ onClick={() => deleteDisclosure.onOpen()}
+ >
+ Delete
+ </Button>
+ )}
+ </div>
+ <HStack>
+ <Submit isDisabled={isDisabled}>Save</Submit>
+ <Button
+ size="md"
+ variant="solid"
+ onClick={() => onClose?.()}
+ >
+ Cancel
+ </Button>
+ </HStack>
</HStack>
+ </ModalDrawerFooter>
+ </ValidatedForm>
+ </ModalDrawerContent>
+ </ModalDrawer>
+ </ModalDrawerProvider>
- <Employee name="assigneeUserId" label="Assignee" />
- </VStack>
- </ModalDrawerBody>
- <ModalDrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={() => onClose?.()}>
- Cancel
- </Button>
- </HStack>
- </ModalDrawerFooter>
- </ValidatedForm>
- </ModalDrawerContent>
- </ModalDrawer>
- </ModalDrawerProvider>
+ {isEditing && initialValues.id && deleteDisclosure.isOpen && (
+ <Confirm
+ isOpen={deleteDisclosure.isOpen}
+ confirmText="Delete"
+ onCancel={deleteDisclosure.onClose}
+ onSubmit={() => {
+ // Handled by form action
+ }}
+ title="Delete Risk"
+ text="Are you sure you want to delete this risk?"
+ action={path.to.deleteRisk(initialValues.id)}
+ />
+ )}
+ </>
);
};
diff --git a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegistersTable.tsx b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegistersTable.tsx
index 316b78b283..47876c9369 100644
--- a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegistersTable.tsx
+++ b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegistersTable.tsx
@@ -1,11 +1,4 @@
-import {
- Button,
- HStack,
- MenuIcon,
- MenuItem,
- toast,
- useDisclosure,
-} from "@carbon/react";
+import { MenuIcon, MenuItem, useDisclosure } from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo, useState } from "react";
@@ -20,10 +13,7 @@ import {
import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
import { Enumerable } from "~/components/Enumerable";
import { Confirm } from "~/components/Modals";
-import {
- usePermissions,
- useUrlParams,
-} from "~/hooks";
+import { usePermissions, useUrlParams } from "~/hooks";
import type { Risk } from "~/modules/quality/types";
import { riskSource, riskStatus } from "~/modules/quality/quality.models";
import { path } from "~/utils/path";
@@ -40,158 +30,153 @@ const defaultColumnVisibility = {
updatedAt: false,
};
-const RiskRegistersTable = memo(
- ({ data, count }: RiskRegistersTableProps) => {
- const navigate = useNavigate();
- const [params] = useUrlParams();
- const [people] = usePeople();
+const RiskRegistersTable = memo(({ data, count }: RiskRegistersTableProps) => {
+ const navigate = useNavigate();
+ const [params] = useUrlParams();
+ const [people] = usePeople();
- const permissions = usePermissions();
- const deleteModal = useDisclosure();
- const [selectedRisk, setSelectedRisk] =
- useState<Risk | null>(null);
+ const permissions = usePermissions();
+ const deleteModal = useDisclosure();
+ const [selectedRisk, setSelectedRisk] = useState<Risk | null>(null);
- const onDelete = (data: Risk) => {
+ const onDelete = useCallback(
+ (data: Risk) => {
setSelectedRisk(data);
deleteModal.onOpen();
- };
+ },
+ [deleteModal]
+ );
- const onCancel = () => {
- setSelectedRisk(null);
- deleteModal.onClose();
- };
+ const onCancel = useCallback(() => {
+ setSelectedRisk(null);
+ deleteModal.onClose();
+ }, [deleteModal]);
- const columns = useMemo<ColumnDef<Risk>[]>(() => {
- const defaultColumns: ColumnDef<Risk>[] = [
- {
- accessorKey: "title",
- header: "Title",
- cell: ({ row }) => (
- <Hyperlink to={row.original.id!} className="font-medium">
- {row.original.title}
- </Hyperlink>
- ),
- meta: {
- icon: <LuAlignLeft />,
- },
+ const columns = useMemo<ColumnDef<Risk>[]>(() => {
+ const defaultColumns: ColumnDef<Risk>[] = [
+ {
+ accessorKey: "title",
+ header: "Title",
+ cell: ({ row }) => (
+ <Hyperlink to={row.original.id!} className="font-medium">
+ {row.original.title}
+ </Hyperlink>
+ ),
+ meta: {
+ icon: <LuAlignLeft />,
},
- {
- accessorKey: "source",
- header: "Source",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- icon: <LuShapes />,
- filter: {
- type: "static",
- options: riskSource.map((c) => ({ value: c, label: c })),
- },
+ },
+ {
+ accessorKey: "source",
+ header: "Source",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ icon: <LuShapes />,
+ filter: {
+ type: "static",
+ options: riskSource.map((c) => ({ value: c, label: c })),
},
},
- {
- accessorKey: "status",
- header: "Status",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- icon: <LuTriangleAlert />,
- filter: {
- type: "static",
- options: riskStatus.map((s) => ({ value: s, label: s })),
- },
+ },
+ {
+ accessorKey: "status",
+ header: "Status",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ icon: <LuTriangleAlert />,
+ filter: {
+ type: "static",
+ options: riskStatus.map((s) => ({ value: s, label: s })),
},
},
- {
- accessorKey: "severity",
- header: "Severity",
- cell: (item) => item.getValue<number>(),
- },
- {
- accessorKey: "likelihood",
- header: "Likelihood",
- cell: (item) => item.getValue<number>(),
- },
- {
- accessorKey: "score",
- header: "Score",
- cell: (item) => item.getValue<number>(),
- },
- {
- id: "assigneeUserId",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assigneeUserId} />
- ),
- meta: {
- icon: <LuUser />,
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ accessorKey: "severity",
+ header: "Severity",
+ cell: (item) => item.getValue<number>(),
+ },
+ {
+ accessorKey: "likelihood",
+ header: "Likelihood",
+ cell: (item) => item.getValue<number>(),
+ },
+ {
+ id: "assigneeUserId",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assigneeUserId} />
+ ),
+ meta: {
+ icon: <LuUser />,
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- ];
- return defaultColumns;
- }, [people]);
+ },
+ ];
+ return defaultColumns;
+ }, [people]);
- const renderContextMenu = useCallback<(row: Risk) => JSX.Element>(
- (row) => (
- <>
- <MenuItem
- onClick={() => {
- navigate(`${path.to.risk(row.id!)}?${params?.toString()}`);
- }}
- >
- <MenuIcon icon={<LuPencil />} />
- Edit Risk
- </MenuItem>
- <MenuItem
- destructive
- disabled={!permissions.can("delete", "quality")}
- onClick={() => onDelete(row)}
- >
- <MenuIcon icon={<LuTrash />} />
- Delete Risk
- </MenuItem>
- </>
- ),
- [navigate, params, permissions]
- );
-
- return (
+ const renderContextMenu = useCallback<(row: Risk) => JSX.Element>(
+ (row) => (
<>
- <Table<Risk>
- data={data}
- defaultColumnVisibility={defaultColumnVisibility}
- columns={columns}
- count={count ?? 0}
- primaryAction={
- permissions.can("create", "quality") && (
- <New label="Risk" to={`new?${params.toString()}`} />
- )
- }
- renderContextMenu={renderContextMenu}
- title="Risks"
- table="riskRegister"
- withSavedView
- />
-
- {selectedRisk && selectedRisk.id && (
- <Confirm
- action={path.to.deleteRisk(selectedRisk.id)}
- title={`Delete ${selectedRisk?.title} Risk`}
- text={`Are you sure you want to delete this risk? This cannot be undone.`}
- confirmText="Delete"
- isOpen={deleteModal.isOpen}
- onCancel={onCancel}
- onSubmit={onCancel}
- />
- )}
+ <MenuItem
+ onClick={() => {
+ navigate(`${path.to.risk(row.id!)}?${params?.toString()}`);
+ }}
+ >
+ <MenuIcon icon={<LuPencil />} />
+ Edit Risk
+ </MenuItem>
+ <MenuItem
+ destructive
+ disabled={!permissions.can("delete", "quality")}
+ onClick={() => onDelete(row)}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Risk
+ </MenuItem>
</>
- );
- }
-);
+ ),
+ [permissions, navigate, params, onDelete]
+ );
+
+ return (
+ <>
+ <Table<Risk>
+ data={data}
+ defaultColumnVisibility={defaultColumnVisibility}
+ columns={columns}
+ count={count ?? 0}
+ primaryAction={
+ permissions.can("create", "quality") && (
+ <New label="Risk" to={`new?${params.toString()}`} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ title="Risks"
+ table="riskRegister"
+ withSavedView
+ />
+
+ {selectedRisk && selectedRisk.id && (
+ <Confirm
+ action={path.to.deleteRisk(selectedRisk.id)}
+ title={`Delete ${selectedRisk?.title} Risk`}
+ text={`Are you sure you want to delete this risk? This cannot be undone.`}
+ confirmText="Delete"
+ isOpen={deleteModal.isOpen}
+ onCancel={onCancel}
+ onSubmit={onCancel}
+ />
+ )}
+ </>
+ );
+});
RiskRegistersTable.displayName = "RiskRegistersTable";
export default RiskRegistersTable;
diff --git a/apps/erp/app/modules/sales/ui/Customer/CustomerRiskRegister.tsx b/apps/erp/app/modules/sales/ui/Customer/CustomerRiskRegister.tsx
new file mode 100644
index 0000000000..cedc871b65
--- /dev/null
+++ b/apps/erp/app/modules/sales/ui/Customer/CustomerRiskRegister.tsx
@@ -0,0 +1,11 @@
+import RiskRegisterCard from "~/modules/quality/ui/RiskRegister/RiskRegisterCard";
+
+type CustomerRiskRegisterProps = {
+ customerId: string;
+};
+
+export default function CustomerRiskRegister({
+ customerId,
+}: CustomerRiskRegisterProps) {
+ return <RiskRegisterCard sourceId={customerId} source="Customer" />;
+}
diff --git a/apps/erp/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx b/apps/erp/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx
index e25fd8c698..9ed277d451 100644
--- a/apps/erp/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx
+++ b/apps/erp/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx
@@ -3,6 +3,7 @@ import {
LuContact,
LuCreditCard,
LuMapPin,
+ LuShieldAlert,
LuTruck
} from "react-icons/lu";
import {
@@ -61,6 +62,12 @@ export function useCustomerSidebar({ contacts, locations }: Props) {
icon: <LuTruck />,
shortcut: "Command+Shift+s"
},
+ {
+ name: "Risk Register",
+ to: path.to.customerRisks(customerId),
+ role: ["employee"],
+ icon: <LuShieldAlert />
+ },
{
name: "RFQs",
to: `${path.to.salesRfqs}?filter=customerId:eq:${customerId}`,
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineRiskRegister.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineRiskRegister.tsx
new file mode 100644
index 0000000000..61ef80b85e
--- /dev/null
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineRiskRegister.tsx
@@ -0,0 +1,11 @@
+import RiskRegisterCard from "~/modules/quality/ui/RiskRegister/RiskRegisterCard";
+
+type QuoteLineRiskRegisterProps = {
+ quoteLineId: string;
+};
+
+export default function QuoteLineRiskRegister({
+ quoteLineId,
+}: QuoteLineRiskRegisterProps) {
+ return <RiskRegisterCard sourceId={quoteLineId} source="Quote Line" />;
+}
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx
index c060f183bd..caa9560e71 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx
@@ -10,7 +10,11 @@ import { Await, redirect, useParams } from "react-router";
import { usePermissions, useRouteData } from "~/hooks";
import type { ConsumableSummary, ItemFile } from "~/modules/items";
import { consumableValidator, upsertConsumable } from "~/modules/items";
-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";
+import {
+ ItemDocuments,
+ ItemNotes,
+ ItemRiskRegister,
+} from "~/modules/items/ui/Item";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -94,6 +98,8 @@ export default function ConsumableDetailsRoute() {
)}
</Await>
</Suspense>
+
+ <ItemRiskRegister itemId={itemId} />
</>
)}
</VStack>
diff --git a/apps/erp/app/routes/x+/customer+/$customerId.risks.tsx b/apps/erp/app/routes/x+/customer+/$customerId.risks.tsx
new file mode 100644
index 0000000000..b0c33def59
--- /dev/null
+++ b/apps/erp/app/routes/x+/customer+/$customerId.risks.tsx
@@ -0,0 +1,20 @@
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { useParams } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+import CustomerRiskRegister from "~/modules/sales/ui/Customer/CustomerRiskRegister";
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ await requirePermissions(request, {
+ view: "sales",
+ });
+
+ return json({});
+}
+
+export default function CustomerRisksRoute() {
+ const { customerId } = useParams();
+ if (!customerId) throw new Error("Could not find customerId");
+
+ return <CustomerRiskRegister customerId={customerId} />;
+}
diff --git a/apps/erp/app/routes/x+/job+/$jobId.details.tsx b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
index 9736a050e9..e1a7346b35 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.details.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
@@ -35,7 +35,11 @@ import {
recalculateJobRequirements,
upsertJob
} from "~/modules/production";
-import { JobDocuments, JobNotes } from "~/modules/production/ui/Jobs";
+import {
+ JobDocuments,
+ JobNotes,
+ JobRiskRegister,
+} from "~/modules/production/ui/Jobs";
import PurchasingStatus from "~/modules/purchasing/ui/PurchaseOrder/PurchasingStatus";
import { useItems } from "~/stores";
import type { StorageItem } from "~/types";
@@ -172,6 +176,7 @@ export default function JobDetailsRoute() {
)}
</Await>
</Suspense>
+ <JobRiskRegister jobId={jobId} />
<CadModel
isReadOnly={!permissions.can("update", "production")}
metadata={{
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx
index 30771cb4ab..c5a746e1bb 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx
@@ -10,7 +10,11 @@ import { Await, redirect, useParams } from "react-router";
import { usePermissions, useRouteData } from "~/hooks";
import type { ItemFile, MaterialSummary } from "~/modules/items";
import { materialValidator, upsertMaterial } from "~/modules/items";
-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";
+import {
+ ItemDocuments,
+ ItemNotes,
+ ItemRiskRegister,
+} from "~/modules/items/ui/Item";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -91,6 +95,8 @@ export default function MaterialDetailsRoute() {
)}
</Await>
</Suspense>
+
+ <ItemRiskRegister itemId={itemId} />
</>
)}
</VStack>
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx
index 8258ec430c..93fa09fa30 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx
@@ -11,7 +11,11 @@ import { CadModel } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { ItemFile, PartSummary } from "~/modules/items";
import { partValidator, upsertPart } from "~/modules/items";
-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";
+import {
+ ItemDocuments,
+ ItemNotes,
+ ItemRiskRegister,
+} from "~/modules/items/ui/Item";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -91,6 +95,8 @@ export default function PartDetailsRoute() {
</Await>
</Suspense>
+ <ItemRiskRegister itemId={itemId} />
+
<CadModel
isReadOnly={!permissions.can("update", "parts")}
metadata={{ itemId }}
diff --git a/apps/erp/app/routes/x+/quality+/risks.$id.tsx b/apps/erp/app/routes/x+/quality+/risks.$id.tsx
index b66d7dbb5f..b8b24445b1 100644
--- a/apps/erp/app/routes/x+/quality+/risks.$id.tsx
+++ b/apps/erp/app/routes/x+/quality+/risks.$id.tsx
@@ -8,6 +8,7 @@ import RiskRegisterForm from "~/modules/quality/ui/RiskRegister/RiskRegisterForm
import { path } from "~/utils/path";
import { validationError, validator } from "@carbon/form";
import invariant from "tiny-invariant";
+import { useDisclosure } from "@carbon/react";
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const { client } = await requirePermissions(request, {
@@ -50,6 +51,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
{
data: null,
error: result.error,
+ success: false,
},
{ status: 500 }
);
@@ -57,6 +59,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
return json({
data: result.data,
+ success: true,
error: null,
});
};
@@ -64,12 +67,27 @@ export const action = async ({ request }: ActionFunctionArgs) => {
export default function EditRiskRoute() {
const { risk } = useLoaderData<typeof loader>();
const navigate = useNavigate();
- const onClose = () => navigate(path.to.risks);
+ const formDisclosure = useDisclosure({
+ defaultIsOpen: true,
+ });
+ const onClose = () => {
+ formDisclosure.onClose();
+ navigate(path.to.risks);
+ };
return (
<RiskRegisterForm
- // @ts-ignore
- initialValues={risk}
+ open={formDisclosure.isOpen}
+ initialValues={{
+ ...risk,
+ description: risk.description ?? undefined,
+ assigneeUserId: risk.assigneeUserId ?? undefined,
+ sourceId: risk.sourceId ?? undefined,
+ status: risk.status ?? undefined,
+ title: risk.title ?? undefined,
+ likelihood: risk.likelihood ?? undefined,
+ severity: risk.severity ?? undefined,
+ }}
onClose={onClose}
/>
);
diff --git a/apps/erp/app/routes/x+/quality+/risks.new.tsx b/apps/erp/app/routes/x+/quality+/risks.new.tsx
index f2133733de..b6ae4311d9 100644
--- a/apps/erp/app/routes/x+/quality+/risks.new.tsx
+++ b/apps/erp/app/routes/x+/quality+/risks.new.tsx
@@ -56,10 +56,8 @@ export default function NewRiskRoute() {
initialValues={{
title: "",
description: "",
- source: "GENERAL",
- status: "OPEN",
- severity: 1,
- likelihood: 1,
+ source: "General",
+ status: "Open",
}}
onClose={onClose}
/>
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index d648cdcc18..927c217ace 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -42,6 +42,7 @@ import {
useLineCosts
} from "~/modules/sales/ui/Quotes";
import QuoteLinePricingHistory from "~/modules/sales/ui/Quotes/QuoteLinePricingHistory";
+import QuoteLineRiskRegister from "~/modules/sales/ui/Quotes/QuoteLineRiskRegister";
import { getCustomFields, setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -256,6 +257,8 @@ export default function QuoteLine() {
</Await>
</Suspense>
+ <QuoteLineRiskRegister quoteLineId={lineId} />
+
<CadModel
isReadOnly={!permissions.can("update", "sales")}
metadata={{
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.risks.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.risks.tsx
new file mode 100644
index 0000000000..0671edef8f
--- /dev/null
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.risks.tsx
@@ -0,0 +1,20 @@
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { useParams } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+import SupplierRiskRegister from "~/modules/purchasing/ui/Supplier/SupplierRiskRegister";
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ await requirePermissions(request, {
+ view: "purchasing",
+ });
+
+ return json({});
+}
+
+export default function SupplierRisksRoute() {
+ const { supplierId } = useParams();
+ if (!supplierId) throw new Error("Could not find supplierId");
+
+ return <SupplierRiskRegister supplierId={supplierId} />;
+}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx
index 5773e517a3..447aa2dff5 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx
@@ -11,7 +11,11 @@ import { CadModel } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { ItemFile, ToolSummary } from "~/modules/items";
import { toolValidator, upsertTool } from "~/modules/items";
-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";
+import {
+ ItemDocuments,
+ ItemNotes,
+ ItemRiskRegister,
+} from "~/modules/items/ui/Item";
import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
@@ -92,6 +96,8 @@ export default function ToolDetailsRoute() {
</Await>
</Suspense>
+ <ItemRiskRegister itemId={itemId} />
+
<CadModel
isReadOnly={!permissions.can("update", "parts")}
metadata={{ itemId }}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 044e632fc9..102979da28 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -466,6 +466,7 @@ export const path = {
generatePath(`${x}/sales/customer-portals/${id}`),
customerShipping: (id: string) =>
generatePath(`${x}/customer/${id}/shipping`),
+ customerRisks: (id: string) => generatePath(`${x}/customer/${id}/risks`),
customerStatus: (id: string) =>
generatePath(`${x}/sales/customer-statuses/${id}`),
customerStatuses: `${x}/sales/customer-statuses`,
@@ -1409,6 +1410,7 @@ export const path = {
generatePath(`${x}/supplier/${supplierId}/processes/${id}`),
supplierProcesses: (id: string) =>
generatePath(`${x}/supplier/${id}/processes`),
+ supplierRisks: (id: string) => generatePath(`${x}/supplier/${id}/risks`),
supplierShipping: (id: string) =>
generatePath(`${x}/supplier/${id}/shipping`),
supplierQuote: (id: string) => generatePath(`${x}/supplier-quote/${id}`),