-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from trycompai/lewis/policies
refactor: Restructure policies module and enhance editor functionality
- Loading branch information
Showing
59 changed files
with
1,754 additions
and
1,028 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
...pp/src/app/[locale]/(app)/(dashboard)/policies/(overview)/components/PoliciesOverview.tsx
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
apps/app/src/app/[locale]/(app)/(dashboard)/policies/(overview)/loading.tsx
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
apps/app/src/app/[locale]/(app)/(dashboard)/policies/[id]/actions/publish-policy.ts
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
apps/app/src/app/[locale]/(app)/(dashboard)/policies/[id]/layout.tsx
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
apps/app/src/app/[locale]/(app)/(dashboard)/policies/[id]/page.tsx
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
.../app/src/app/[locale]/(app)/(dashboard)/policies/[policyId]/actions/get-policy-details.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
} | ||
}); |
Oops, something went wrong.