Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions apps/app/src/actions/organization/create-organization-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ export const createOrganizationAction = authActionClient
headers: await headers(),
});

if (env.ZAPIER_HUBSPOT_WEBHOOK_URL) {
await ky.post(env.ZAPIER_HUBSPOT_WEBHOOK_URL, {
json: {
email: session?.user.email,
website: website,
organization: name,
frameworks: frameworks,
first_name: session?.user.name?.split(" ")[0] || "",
last_name: session?.user.name?.split(" ")[1] || "",
},
});
}

timings.getAuthSession = (performance.now() - start) / 1000;

if (!session?.session.activeOrganizationId) {
Expand Down
1 change: 0 additions & 1 deletion apps/app/src/actions/organization/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
type PolicyStatus,
RequirementId,
TaskStatus,
TaskEntityType,
TaskFrequency,
Departments,
ArtifactType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { auth } from "@/utils/auth";
import { db } from "@comp/db";
import { TaskEntityType } from "@comp/db/types";
import { ArtifactType } from "@prisma/client";
import { headers } from "next/headers";

Expand Down Expand Up @@ -110,15 +109,8 @@ export const getOrganizationControlProgress = async (controlId: string) => {

progress.byType["control"].total++;

// Check completion based on task type
let isCompleted = false;
switch (task.entityType) {
case TaskEntityType.control:
isCompleted = task.status === "done";
break;
default:
isCompleted = false;
}
// Check completion based on task status (all tasks here are implicitly control-related)
const isCompleted = task.status === "done";

if (isCompleted) {
progress.completed++;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SingleControl } from "./components/SingleControl";
import { getControl } from "./data/getControl";
import { getOrganizationControlProgress } from "./data/getOrganizationControlProgress";
import type { ControlProgressResponse } from "./data/getOrganizationControlProgress";
import { getRelatedTasks } from "./data/getRelatedTasks";
import { getRelatedArtifacts } from "./data/getRelatedArtifacts";

interface ControlPageProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Progress } from "@comp/ui/progress";
import { getFrameworkDetails } from "../../lib/getFrameworkDetails";
import { getControlStatus } from "../../lib/utils";
import { FrameworkInstanceWithControls } from "../../types";
import { Task } from "@comp/db/types";
import { Control, Task } from "@comp/db/types";

interface FrameworkOverviewProps {
frameworkInstanceWithControls: FrameworkInstanceWithControls;
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}

export function FrameworkOverview({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getFrameworkDetails } from "../lib/getFrameworkDetails";
import { FrameworkOverview } from "./components/FrameworkOverview";
import { FrameworkRequirements } from "./components/FrameworkRequirements";
import { db } from "@comp/db";
import { TaskEntityType } from "@comp/db/types";

interface PageProps {
params: Promise<{
frameworkInstanceId: string;
Expand Down Expand Up @@ -48,7 +48,14 @@ export default async function FrameworkPage({ params }: PageProps) {
const tasks = await db.task.findMany({
where: {
organizationId,
entityType: TaskEntityType.control,
controls: {
some: {
id: frameworkInstanceWithControls.id,
},
},
},
include: {
controls: true,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { FrameworkId } from "@comp/db/types";
import { Card, CardContent, CardHeader, CardTitle } from "@comp/ui/card";
import { FrameworkInstanceWithControls } from "../../../../types";
import { RequirementControlsTable } from "./table/RequirementControlsTable";
import type { Task } from "@comp/db/types";
import type { Control, Task } from "@comp/db/types";

interface RequirementControlsProps {
requirement: Requirement;
requirementKey: string;
frameworkInstanceWithControls: FrameworkInstanceWithControls;
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}

export function RequirementControls({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface RequirementControlsTableProps {
policy: Policy | null;
})[];
})[];
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}

export function RequirementControlsTable({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type OrganizationControlType = Control & {
export function RequirementControlsTableColumns({
tasks,
}: {
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}): ColumnDef<OrganizationControlType>[] {
const t = useI18n();
const { orgId } = useParams<{ orgId: string }>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getFrameworkDetails } from "../../../lib/getFrameworkDetails";
import { getFrameworkRequirements } from "../../../lib/getFrameworkRequirements";
import { RequirementControls } from "./components/RequirementControls";
import { db } from "@comp/db";
import { TaskEntityType } from "@comp/db/types";

interface PageProps {
params: Promise<{
Expand Down Expand Up @@ -70,7 +69,14 @@ export default async function RequirementPage({ params }: PageProps) {
(await db.task.findMany({
where: {
organizationId,
entityType: TaskEntityType.control,
controls: {
some: {
id: frameworkInstanceWithControls.id,
},
},
},
include: {
controls: true,
},
})) || [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useI18n } from "@/locales/client";
import { Task } from "@comp/db/types";
import { Task, Control } from "@comp/db/types";
import { Badge } from "@comp/ui/badge";
import {
Card,
Expand All @@ -21,7 +21,7 @@ import { FrameworkInstanceWithControls } from "../types";
interface FrameworkCardProps {
frameworkInstance: FrameworkInstanceWithControls;
complianceScore: number;
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}

export function FrameworkCard({
Expand Down Expand Up @@ -75,8 +75,8 @@ export function FrameworkCard({
const notStartedControlsCount =
frameworkInstance.controls?.filter((control) => {
// If a control has no artifacts and no tasks, it's not started.
const controlTasks = tasks.filter(
(task) => task.entityId === control.id,
const controlTasks = tasks.filter((task) =>
task.controls.some((c) => c.id === control.id),
);

if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { Task } from "@comp/db/types";
import { Control, Task } from "@comp/db/types";
import { FrameworkCard } from "./FrameworkCard";
import type { FrameworkInstanceWithComplianceScore } from "./types";

Expand All @@ -9,7 +9,7 @@ export function FrameworkList({
tasks,
}: {
frameworksWithControlsAndComplianceScores: FrameworkInstanceWithComplianceScore[];
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}) {
if (!frameworksWithControlsAndComplianceScores.length) return null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Task } from "@comp/db/types";
import { Control, Task } from "@comp/db/types";
import { getFrameworkWithComplianceScores } from "../data/getFrameworkWithComplianceScores";
import type { FrameworkInstanceWithControls } from "../types";
import { FrameworkList } from "./FrameworkList";

export interface FrameworksOverviewProps {
frameworksWithControls: FrameworkInstanceWithControls[];
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}

export async function FrameworksOverview({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
"use server";

import {
Control,
type Artifact,
type Task,
type Policy,
TaskEntityType,
type Task,
} from "@comp/db/types";
import { FrameworkInstanceWithComplianceScore } from "../components/types";
import { FrameworkInstanceWithControls } from "../types";
import { db } from "@comp/db";
import { headers } from "next/headers";
import { auth } from "@/utils/auth";

/**
* Checks if a control is compliant based on its artifacts and tasks
Expand Down Expand Up @@ -62,7 +59,7 @@ export async function getFrameworkWithComplianceScores({
tasks,
}: {
frameworksWithControls: FrameworkInstanceWithControls[];
tasks: Task[];
tasks: (Task & { controls: Control[] })[];
}): Promise<FrameworkInstanceWithComplianceScore[]> {
// Calculate compliance for each framework
const frameworksWithComplianceScores = frameworksWithControls.map(
Expand All @@ -73,8 +70,8 @@ export async function getFrameworkWithComplianceScores({
// Calculate compliance percentage
const totalControls = controls.length;
const compliantControls = controls.filter((control) => {
const controlTasks = tasks.filter(
(task) => task.entityId === control.id,
const controlTasks = tasks.filter((task) =>
task.controls.some((c) => c.id === control.id),
);
return isControlCompliant(control.artifacts, controlTasks);
}).length;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StatusType } from "@/components/status-indicator";
// Import base types explicitly
import type { Artifact, Policy, PolicyStatus } from "@comp/db/types";
import type { Artifact, Control, Policy, PolicyStatus } from "@comp/db/types";
import { Task } from "@comp/db/types";

// Define the expected artifact structure explicitly, allowing null status
Expand All @@ -11,10 +11,12 @@ type ArtifactWithRelations = Artifact & {
// Function to determine control status based on artifacts
export function getControlStatus(
artifacts: ArtifactWithRelations[], // Use the explicit type
tasks: Task[],
tasks: (Task & { controls: Control[] })[],
controlId: string,
): StatusType {
const controlTasks = tasks.filter((task) => task.entityId === controlId);
const controlTasks = tasks.filter((task) =>
task.controls.some((c) => c.id === controlId),
);

// All artifacts are draft or none
const allArtifactsDraft =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { redirect } from "next/navigation";
import { FrameworksOverview } from "./components/FrameworksOverview";
import { getAllFrameworkInstancesWithControls } from "./data/getAllFrameworkInstancesWithControls";
import { db } from "@comp/db";
import { TaskEntityType } from "@comp/db/types";

export async function generateMetadata() {
const t = await getI18n();
Expand Down Expand Up @@ -58,7 +57,14 @@ const getControlTasks = async () => {
const tasks = await db.task.findMany({
where: {
organizationId,
entityType: TaskEntityType.control,
controls: {
some: {
organizationId
},
},
},
include: {
controls: true,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const getTask = cache(async (riskId: string, taskId: string) => {

const task = await db.task.findUnique({
where: {
entityId: riskId,
entityType: "risk",
id: taskId,
organizationId: session.session.activeOrganizationId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { db } from "@comp/db";
import { z } from "zod";
import { TaskStatus, TaskEntityType } from "@comp/db/types";
import { TaskStatus } from "@comp/db/types";
import { revalidatePath } from "next/cache";
import type { ActionResponse } from "@/types/actions";
import { auth } from "@/utils/auth";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { Member, Task, User, TaskEntityType } from "@comp/db/types";
import { Member, Task, User } from "@comp/db/types";
import { useDrop } from "react-dnd";
import { useRef } from "react";
import { TaskCard, DragItem, ItemTypes, StatusId } from "./TaskCard";
Expand Down
Loading
Loading