diff --git a/README.md b/README.md index ba89bd99..1ebcebb4 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Orbit ships with a comprehensive set of management tools out of the box: | **Documentation** | Host your group's docs natively inside Orbit | | **Policies** | Create and assign policy documents for members to review and sign | | **Sessions** | Schedule and host sessions with minimal overhead | +| **Forms** | Build custom forms, manage submissions, and track analytics from a single dashboard. | --- diff --git a/components/settings/general/form.tsx b/components/settings/general/form.tsx index b6246acf..e94cf17c 100644 --- a/components/settings/general/form.tsx +++ b/components/settings/general/form.tsx @@ -26,14 +26,8 @@ const Forms: FC = (props) => {

Create, customize, and manage workspace forms for collecting structured data, submissions, and user input across your workspace (Coming Soon)

- {/**/} diff --git a/package-lock.json b/package-lock.json index 9ca56f1e..49a51440 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orbit", - "version": "2.1.10beta20", + "version": "2.1.10beta21", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orbit", - "version": "2.1.10beta20", + "version": "2.1.10beta21", "dependencies": { "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", diff --git a/pages/api/workspace/[id]/forms/helpers.ts b/pages/api/workspace/[id]/forms/helpers.ts deleted file mode 100644 index 58cda7c6..00000000 --- a/pages/api/workspace/[id]/forms/helpers.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Orbit Forms - * Licensed under GPL-3.0 (see LICENSE for details) - * - * Helpers to make life easier in the other scripts - * - * @author BuddyWinte - * @since 2.1.10-beta20 - */ - -type Permission = string; -interface Role { - permissions: Permission[]; -} -interface UserWithRoles { - roles: Role[]; -} - -/** - * Checks if a user has a given permission. - * - * Supports: - * - Exact matches: "Form.View" - * - Wildcards: "Form.*" - * - * @returns true if the user has permissions - * @returns false if the user doesn't have permissions - * @readonly - */ -export function hasPerms( - user: UserWithRoles, - permission: string -): boolean { - if (!user?.roles?.length) return false; - for (const role of user.roles) { - if (!role?.permissions?.length) continue; - for (const perm of role.permissions) { - if (perm === permission) return true; - if (perm.endsWith(".*")) { - const prefix = perm.slice(0,-2); - if (permission.startsWith(prefix + ".")) { - return true; - } - } - } - } - - return false; -} \ No newline at end of file diff --git a/pages/api/workspace/[id]/forms/index.ts b/pages/api/workspace/[id]/forms/index.ts deleted file mode 100644 index 3c21c65a..00000000 --- a/pages/api/workspace/[id]/forms/index.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from "next"; -import prisma from "@/utils/database"; -type Data = { - success: boolean; - error?: string; - forms?: unknown[]; -}; -import { withAuth, AuthenticatedRequest } from "@/lib/withAuth"; -import { hasPerms } from "./helpers"; - -export default withAuth(handler); - -// GET /api/workspace/[id]/forms - Returns a list of forms a specific user can see -// POST /api/workspace/[id]/forms - Create a new form -export async function handler( - req: AuthenticatedRequest, - res: NextApiResponse, -) { - const user = await prisma.user.findUnique({ - where: { - userid: req.auth.userId, - }, - include: { - roles: { - select: { - id: true, - name: true, - permissions: true, - }, - }, - workspaceMemberships: { - where: { - workspaceGroupId: Number(req.query.id), - }, - include: { - workspace: true, - }, - }, - }, - }); - - if (!user) { - return res.status(404).json({ - success: false, - error: "User not found", - }); - } - - if (req.method === "GET") { - if (!hasPerms(user, "Form.View")) { - return res.status(403).json({ - success: false, - error: "Missing permission: Form.View", - }); - } - - const forms = await prisma.form.findMany({ - where: { - workspaceGroupId: workspaceId, - }, - }); - - return res.status(200).json({ - success: true, - forms, - }); - } - - return res.status(405).json({ - success: false, - error: "Method Not Allowed" - }) -}