Skip to content

Commit

Permalink
Merge pull request #78 from trycompai/lewis/policies
Browse files Browse the repository at this point in the history
refactor: Restructure policies module and enhance editor functionality
  • Loading branch information
carhartlewis authored Feb 24, 2025
2 parents 14806fd + 2b99c3f commit 4328fcd
Show file tree
Hide file tree
Showing 59 changed files with 1,754 additions and 1,028 deletions.
24 changes: 23 additions & 1 deletion apps/app/languine.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ files:
common.status.assessed: 2c051fa737a0d6c7274f4508448b7f8a
common.status.active: 4d3d769b812b6faa6b76e1a8abaece2d
common.status.inactive: 3cab03c00dbd11bc3569afa0748013f0
common.status.title: ec53a8c4f07baed5d8825072c89799be
common.filters.clear: 0b275442d6556cff30b75f37f1918899
common.filters.search: 2a37324bb4c331c859044121df3f576b
common.filters.status: ec53a8c4f07baed5d8825072c89799be
Expand All @@ -57,7 +58,7 @@ files:
common.table.due_date: 14c841eea7774b78caf79c58989f9625
common.table.last_updated: 4221d3e17c6eca2ca6337251a3cf9c4e
common.table.no_results: e576c23d915755d83e2d1f47bd9f6c22
common.empty_states.no_results.title: c49c29bb6656c1f25f2cfac84f83b5ba
common.empty_states.no_results.title: e576c23d915755d83e2d1f47bd9f6c22
common.empty_states.no_results.title_tasks: 8edbb9c85d4b7cce148cb9a886dc1213
common.empty_states.no_results.title_risks: 20c62e3370120c70750d361567eacc26
common.empty_states.no_results.description: 3d7c5718545b591caa83edfd8d5f42b0
Expand Down Expand Up @@ -107,6 +108,10 @@ files:
common.attachments.toasts.success_uploading_files_target: 293fc6e4068205eefc9df77baa941b5f
common.attachments.toasts.uploading_files: a538c6cacc535cf165533cc65510248f
common.attachments.toasts.remove_file: b21f085d08623fc7a5a9da204cc66c8c
common.edit: 7dce122004969d56ae2e0245cb754d35
common.errors.unexpected_error: 9789e322478c6f2d59e93d020808642a
common.description: b5a7adde1af5c87d7fd797b6245c2a39
common.last_updated: 4221d3e17c6eca2ca6337251a3cf9c4e
header.discord.button: 1d403edd5e9a373b882ebba790de6f05
header.feedback.button: bea4c2c8eb82d05891ddd71584881b56
header.feedback.title: d62968e1245fc470aa53ae9e5646215a
Expand Down Expand Up @@ -136,6 +141,7 @@ files:
sub_pages.risk.tasks.task_overview: d5a893e5bfa69efefb2667f8e7ec600c
sub_pages.policies.all: 4992678c2f629035e5c3bcde296b596a
sub_pages.policies.editor: e2c974366aff19ed493a501108cbf948
sub_pages.policies.policy_details: 8178fb068d06b0f32a7b0103e832b231
sub_pages.people.all: 78386ec8f2845742c324a3d7d3e800ff
sub_pages.people.employee_details: 62fa24399196c3b1bcb1cf2cdf771da4
sub_pages.settings.members: 8196446d7293bfeb288d7c21e36a1886
Expand Down Expand Up @@ -180,14 +186,30 @@ files:
policies.table.name: 002f7378a5fcfc2f66cfea851a7fd5f4
policies.table.statuses.draft: f03ab16cd58372c77ba45a3d9a5a1cb9
policies.table.statuses.published: 9b9d8a976b42e0bd66381797644943d5
policies.table.statuses.archived: 7d69b3cb4cada18ae61811304f8fbcb5
policies.table.filters.owner.label: 780f85493892dc48b674ac9da8974133
policies.table.filters.owner.placeholder: 40f417d9ebe868b7aa1e61f27775a03e
policies.filters.search: 417253920390e1fdb5f07216a44d61c7
policies.filters.all: 4992678c2f629035e5c3bcde296b596a
policies.status.draft: f03ab16cd58372c77ba45a3d9a5a1cb9
policies.status.published: 9b9d8a976b42e0bd66381797644943d5
policies.status.needs_review: 994f197b212a0f4dc844cc3534e889c2
policies.status.archived: 7d69b3cb4cada18ae61811304f8fbcb5
policies.policies: 94422fa6b0fe23d0ab463703c0022a63
policies.title: 9e476387322a5c250893cf9c5c4ce78c
policies.create_new: 5ff074c18e92b64ab9bad69c28267285
policies.search_placeholder: 417253920390e1fdb5f07216a44d61c7
policies.status_filter: 5dd5cd6670a0fc8e47a47aa94d27b8b2
policies.all_statuses: 96e3d398260724e0a83da53a2e9f20e7
policies.no_policies_title: 329794e590e4bbc42f2f5ae965a8ba9f
policies.no_policies_description: c6800f5122f4ff305c7923edebca30be
policies.create_first: 6d12b685797010c6f339f916c7c87adb
policies.no_description: 64edba81920f6b19c899f22f474e03d1
policies.last_updated: d4f9ce5adf5b871e10882a482927aa55
policies.save: c9cc8cce247e49bae79f15173ce97354
policies.saving: 575f5f86d2c7ea113c6710c1037c4465
policies.saved_success: 32ecb65fc52361d4131583219aee82ed
policies.saved_error: 07daa040d0eb0ae927dc05af1b6f3747
evidence_tasks.evidence_tasks: 63b1eb1a39194d82271ec937fba19714
evidence_tasks.overview: 3b878279a04dc47d60932cb294d96259
risk.risks: 2bb550bd7d03efff73cd7152d6092af1
Expand Down
4 changes: 4 additions & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"@prisma/instrumentation": "^6.3.1",
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-table": "^8.21.2",
"@tiptap/extension-table": "^2.11.5",
"@tiptap/extension-table-cell": "^2.11.5",
"@tiptap/extension-table-header": "^2.11.5",
"@tiptap/extension-table-row": "^2.11.5",
"@tiptap/pm": "^2.11.5",
"@tiptap/react": "^2.11.5",
"@tiptap/starter-kit": "^2.11.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"use client";

import { OrganizationControl } from "@bubba/db";
import useSWR from "swr";
import {
type OrganizationControlResponse,
getOrganizationControl,
OrganizationControlResponse,
} from "../Actions/getOrganizationControl";

async function fetchOrganizationControl(
controlId: string
controlId: string,
): Promise<OrganizationControlResponse> {
const result = await getOrganizationControl({ controlId });

Expand All @@ -32,7 +31,7 @@ export function useOrganizationControl(controlId: string) {
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
}
},
);

return {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

59 changes: 0 additions & 59 deletions apps/app/src/app/[locale]/(app)/(dashboard)/policies/[id]/page.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"use server";

import { authActionClient } from "@/actions/safe-action";
import { auth } from "@/auth";
import { db } from "@bubba/db";
import {
appErrors,
policyDetailsInputSchema,
} from "../types";

export const getPolicyDetails = authActionClient
.schema(policyDetailsInputSchema)
.metadata({
name: "get-policy-details",
track: {
event: "get-policy-details",
channel: "server",
},
})
.action(async ({ parsedInput }) => {
const { policyId } = parsedInput;

const session = await auth();
const organizationId = session?.user.organizationId;

if (!organizationId) {
return {
success: false,
error: appErrors.UNAUTHORIZED.message,
};
}

try {
const policy = await db.organizationPolicy.findUnique({
where: {
id: policyId,
organizationId,
},
select: {
id: true,
status: true,
content: true,
createdAt: true,
updatedAt: true,
policy: {
select: {
id: true,
name: true,
description: true,
slug: true,
},
},
},
});

if (!policy) {
return {
success: false,
error: appErrors.NOT_FOUND.message,
};
}

return {
success: true,
data: policy,
};
} catch (error) {
console.error("Error fetching policy details:", error);
return {
success: false,
error: appErrors.UNEXPECTED_ERROR.message,
};
}
});
Loading

0 comments on commit 4328fcd

Please sign in to comment.