diff --git a/apps/app/src/actions/policies/create-new-policy.ts b/apps/app/src/actions/policies/create-new-policy.ts index 862250ef39..da22797b01 100644 --- a/apps/app/src/actions/policies/create-new-policy.ts +++ b/apps/app/src/actions/policies/create-new-policy.ts @@ -7,91 +7,92 @@ import { authActionClient } from "../safe-action"; import { createPolicySchema } from "../schema"; export const createPolicyAction = authActionClient - .schema(createPolicySchema) - .metadata({ - name: "create-policy", - track: { - event: "create-policy", - channel: "server", - }, - }) - .action(async ({ parsedInput, ctx }) => { - const { title, description, frameworkIds, controlIds } = parsedInput; - const { activeOrganizationId } = ctx.session; - const { user } = ctx; + .schema(createPolicySchema) + .metadata({ + name: "create-policy", + track: { + event: "create-policy", + channel: "server", + }, + }) + .action(async ({ parsedInput, ctx }) => { + const { title, description, frameworkIds, controlIds } = parsedInput; + const { activeOrganizationId } = ctx.session; + const { user } = ctx; - if (!activeOrganizationId) { - return { - success: false, - error: "Not authorized", - }; - } + if (!activeOrganizationId) { + return { + success: false, + error: "Not authorized", + }; + } - if (!user) { - return { - success: false, - error: "Not authorized", - }; - } + if (!user) { + return { + success: false, + error: "Not authorized", + }; + } - try { - // Create the policy - const policy = await db.policy.create({ - data: { - name: title, - description, - organizationId: activeOrganizationId, - ownerId: user.id, - department: Departments.none, - frequency: Frequency.monthly, - content: [ - { type: "paragraph", content: [{ type: "text", text: "" }] }, - ], - }, - }); + try { + // Create the policy + const policy = await db.policy.create({ + data: { + name: title, + description, + organizationId: activeOrganizationId, + ownerId: user.id, + department: Departments.none, + frequency: Frequency.monthly, + content: [ + { type: "paragraph", content: [{ type: "text", text: "" }] }, + ], + }, + }); - // Create artifacts for each control - if (controlIds && controlIds.length > 0) { - // Create artifacts that link the policy to controls - await Promise.all( - controlIds.map(async (controlId) => { - // Create the artifact - const artifact = await db.artifact.create({ - data: { - type: "policy", - policyId: policy.id, - organizationId: activeOrganizationId, - }, - }); + // Create artifacts for each control + if (controlIds && controlIds.length > 0) { + // Create artifacts that link the policy to controls + await Promise.all( + controlIds.map(async (controlId) => { + // Create the artifact + const artifact = await db.artifact.create({ + data: { + type: "policy", + policyId: policy.id, + organizationId: activeOrganizationId, + }, + }); - // Connect the artifact to the control - await db.control.update({ - where: { id: controlId }, - data: { - artifacts: { - connect: { id: artifact.id }, - }, - }, - }); + // Connect the artifact to the control + await db.control.update({ + where: { id: controlId }, + data: { + artifacts: { + connect: { id: artifact.id }, + }, + }, + }); - return artifact; - }) - ); - } + return artifact; + }), + ); + } - revalidatePath(`/${activeOrganizationId}/policies`); - revalidateTag("policies"); + revalidatePath(`/${activeOrganizationId}/policies/all`); + revalidatePath(`/${activeOrganizationId}/policies`); + revalidateTag("policies"); - return { - success: true, - policyId: policy.id, - }; - } catch (error) { - console.error(error); + return { + success: true, + policyId: policy.id, + }; + } catch (error) { + console.error(error); - return { - success: false, - error: "Failed to create policy", - }; - } - }); + return { + success: false, + error: "Failed to create policy", + }; + } + }); diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/[employeeId]/layout.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/[employeeId]/layout.tsx index 836de8922e..2479c3dfb9 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/[employeeId]/layout.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/[employeeId]/layout.tsx @@ -9,10 +9,11 @@ export default async function Layout({ children: React.ReactNode; }) { const t = await getI18n(); + const session = await auth.api.getSession({ headers: await headers(), }); - const user = session?.user; + const orgId = session?.session.activeOrganizationId; return ( diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table-columns.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table-columns.tsx index 3b26a992e4..52f4cb6974 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table-columns.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table-columns.tsx @@ -3,6 +3,8 @@ import { ColumnDef } from "@tanstack/react-table"; import { Policy } from "@bubba/db/types"; import { DataTableColumnHeader } from "@/components/data-table/data-table-column-header"; +import { StatusPolicies } from "@/components/status-policies"; +import { formatDate } from "@/lib/format"; export function getPolicyColumns(): ColumnDef[] { return [ @@ -10,7 +12,7 @@ export function getPolicyColumns(): ColumnDef[] { id: "name", accessorKey: "name", header: ({ column }) => ( - + ), cell: ({ row }) => { return ( @@ -22,8 +24,8 @@ export function getPolicyColumns(): ColumnDef[] { ); }, meta: { - label: "Name", - placeholder: "Search names...", + label: "Policy Name", + placeholder: "Search for a policy...", variant: "text", }, enableColumnFilter: true, @@ -35,11 +37,7 @@ export function getPolicyColumns(): ColumnDef[] { ), cell: ({ row }) => { - return ( -

- {row.getValue("status")} -

- ) + return ; }, meta: { label: "Status", @@ -47,5 +45,24 @@ export function getPolicyColumns(): ColumnDef[] { variant: "select", }, }, + { + id: "updatedAt", + accessorKey: "updatedAt", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + return ( +
+ {formatDate(row.getValue("updatedAt"))} +
+ ); + }, + meta: { + label: "Last Updated", + placeholder: "Search last updated...", + variant: "date", + }, + }, ]; } diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table.tsx index 27b9d82ef3..af3fd5f8ff 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/components/policies-table.tsx @@ -8,6 +8,7 @@ import { getPolicies } from "../data/queries"; import { DataTableSortList } from "@/components/data-table/data-table-sort-list"; import { getPolicyColumns } from "./policies-table-columns"; import { DataTableToolbar } from "@/components/data-table/data-table-toolbar"; +import { CreatePolicySheet } from "@/components/sheets/create-policy-sheet"; interface PoliciesTableProps { promises: Promise<[ @@ -37,11 +38,13 @@ export function PoliciesTable({ promises }: PoliciesTableProps) { <> row.id} > - + + ); } \ No newline at end of file diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/queries.ts b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/queries.ts index 0643d27b93..873fb5da2f 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/queries.ts +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/queries.ts @@ -2,10 +2,9 @@ import "server-only"; import { db } from "@bubba/db"; import { auth } from "@bubba/auth"; -import type { GetPolicySchema } from "@/lib/validations"; +import type { GetPolicySchema } from "./validations"; import { cache } from "react"; import { headers } from "next/headers"; -import { getValidFilters } from "@/lib/data-table"; import { Prisma } from "@prisma/client"; export async function getPolicies(input: GetPolicySchema) { @@ -30,6 +29,11 @@ export async function getPolicies(input: GetPolicySchema) { mode: Prisma.QueryMode.insensitive, }, }), + ...(input.status.length > 0 && { + status: { + in: input.status, + }, + }), }; const policies = await db.policy.findMany({ diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/validations.ts b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/validations.ts new file mode 100644 index 0000000000..f776abeb37 --- /dev/null +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/data/validations.ts @@ -0,0 +1,29 @@ +import { + createSearchParamsCache, + parseAsArrayOf, + parseAsInteger, + parseAsString, + parseAsStringEnum, +} from "nuqs/server"; +import * as z from "zod"; +import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers"; +import { Policy, PolicyStatus } from "@bubba/db/types"; + +export const searchParamsCache = createSearchParamsCache({ + page: parseAsInteger.withDefault(1), + perPage: parseAsInteger.withDefault(10), + sort: getSortingStateParser().withDefault([ + { id: "createdAt", desc: true }, + ]), + name: parseAsString.withDefault(""), + status: parseAsArrayOf(z.nativeEnum(PolicyStatus)).withDefault([]), + createdAt: parseAsArrayOf(z.coerce.date()).withDefault([]), + updatedAt: parseAsArrayOf(z.coerce.date()).withDefault([]), + // advanced filter + filters: getFiltersStateParser().withDefault([]), + joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"), +}); + +export type GetPolicySchema = Awaited< + ReturnType +>; diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/page.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/page.tsx index 1c3da0422d..f85bc11be5 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/page.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/(overview)/page.tsx @@ -2,7 +2,7 @@ import { getI18n } from "@/locales/server"; import type { Metadata } from "next"; import { setStaticParamsLocale } from "next-international/server"; import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"; -import React from "react"; +import { Suspense } from "react"; import type { SearchParams } from "@/types"; import { searchParamsCache } from "@/lib/validations"; import { getValidFilters } from "@/lib/data-table"; @@ -33,7 +33,7 @@ export default async function PoliciesPage({ ]); return ( - - + ); } diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/actions/update-policy.ts b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/actions/update-policy.ts index fb7034ff6c..44a3f91976 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/actions/update-policy.ts +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/actions/update-policy.ts @@ -7,6 +7,27 @@ import { db } from "@bubba/db"; import { appErrors, updatePolicySchema } from "../types"; import { headers } from "next/headers"; +// Helper function to clean the content by removing function references +function cleanContent(content: any): any { + if (!content) return content; + + if (Array.isArray(content)) { + return content.map((item) => cleanContent(item)); + } + + if (typeof content === "object") { + const cleaned: any = {}; + for (const [key, value] of Object.entries(content)) { + // Skip function properties + if (typeof value === "function") continue; + cleaned[key] = cleanContent(value); + } + return cleaned; + } + + return content; +} + export const updatePolicy = authActionClient .schema(updatePolicySchema) .metadata({ @@ -50,25 +71,24 @@ export const updatePolicy = authActionClient const updateData: Record = {}; if (content !== undefined) { - console.log("CONTENT TYPE:", typeof content); + // Clean the content before processing + const cleanedContent = cleanContent(content); - if (typeof content === "object" && content !== null) { + if (typeof cleanedContent === "object" && cleanedContent !== null) { if ( - "type" in content && - content.type === "doc" && - "content" in content && - Array.isArray(content.content) + "type" in cleanedContent && + cleanedContent.type === "doc" && + "content" in cleanedContent && + Array.isArray(cleanedContent.content) ) { - updateData.content = content.content; - console.log("Extracted content array from TipTap doc"); - } else if (Array.isArray(content)) { - updateData.content = content; + updateData.content = cleanedContent.content; + } else if (Array.isArray(cleanedContent)) { + updateData.content = cleanedContent; } else { - console.log("Unknown content format - using as is"); - updateData.content = content; + updateData.content = cleanedContent; } } else { - updateData.content = content; + updateData.content = cleanedContent; } } @@ -86,6 +106,7 @@ export const updatePolicy = authActionClient const updatedPolicy = await db.policy.update({ where: { id: policyId, + organizationId, }, data: { ...updateData, diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/components/PolicyDetails.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/components/PolicyDetails.tsx index a80bd88f09..0aeeddacab 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/components/PolicyDetails.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/components/PolicyDetails.tsx @@ -1,69 +1,37 @@ "use client"; -import { Card, CardContent, CardHeader } from "@bubba/ui/card"; -import { Skeleton } from "@bubba/ui/skeleton"; -import { redirect, useParams } from "next/navigation"; import { PolicyEditor } from "@/components/editor/policy-editor"; -import { usePolicyDetails } from "../../../(overview)/hooks/usePolicy"; import type { JSONContent } from "@tiptap/react"; import "@bubba/ui/editor.css"; - +import { updatePolicy } from "../actions/update-policy"; interface PolicyDetailsProps { - policyId: string; + policyId: string; + policyContent: JSONContent | JSONContent[]; } -export function PolicyDetails({ policyId }: PolicyDetailsProps) { - const { policy, isLoading, updatePolicy } = usePolicyDetails(policyId); - const { orgId } = useParams(); - - if (isLoading) { - return ( -
-
- - -
- - - - - -
- - - -
-
-
-
- ); - } - - if (!policy) return redirect(`/${orgId}/policies`); - - const formattedContent = Array.isArray(policy.content) - ? policy.content - : typeof policy.content === "object" && policy.content !== null - ? [policy.content as JSONContent] - : []; - - const handleSavePolicy = async (content: JSONContent[]): Promise => { - if (!policy) return; - - try { - await updatePolicy({ - ...policy, - content, - }); - } catch (error) { - console.error("Error saving policy:", error); - throw error; - } - }; - - return ( -
- -
- ); +export function PolicyDetails({ policyId, policyContent }: PolicyDetailsProps) { + + const formattedContent = Array.isArray(policyContent) + ? policyContent + : typeof policyContent === "object" && policyContent !== null + ? [policyContent as JSONContent] + : []; + + const handleSavePolicy = async (policyContent: JSONContent[]): Promise => { + if (!policyId) return; + + try { + await updatePolicy({ policyId, content: policyContent }); + } catch (error) { + console.error("Error saving policy:", error); + throw error; + } + }; + + return ( +
+ +
+ ); } + diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/page.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/page.tsx index ede811316c..20b96b9d8c 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/page.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/editor/page.tsx @@ -2,29 +2,59 @@ import { getI18n } from "@/locales/server"; import type { Metadata } from "next"; import { setStaticParamsLocale } from "next-international/server"; import { PolicyDetails } from "./components/PolicyDetails"; +import { auth } from "@bubba/auth"; +import { db } from "@bubba/db"; +import { headers } from "next/headers"; +import { cache } from "react"; +import { redirect } from "next/navigation"; +import { JSONContent } from "novel"; export default async function PolicyEditor({ - params, + params, }: { - params: Promise<{ locale: string; policyId: string }>; + params: Promise<{ locale: string; policyId: string }>; }) { - const { locale, policyId } = await params; - setStaticParamsLocale(locale); + const { locale, policyId } = await params; + setStaticParamsLocale(locale); - return ; + const policy = await getPolicy(policyId); + + return ; } export async function generateMetadata({ - params, + params, }: { - params: Promise<{ locale: string; policyId: string }>; + params: Promise<{ locale: string; policyId: string }>; }): Promise { - const { locale } = await params; + const { locale } = await params; - setStaticParamsLocale(locale); - const t = await getI18n(); + setStaticParamsLocale(locale); + const t = await getI18n(); - return { - title: t("policies.dashboard.sub_pages.edit_policy"), - }; + return { + title: t("policies.dashboard.sub_pages.edit_policy"), + }; } + +const getPolicy = cache(async (policyId: string) => { + const session = await auth.api.getSession({ + headers: await headers(), + }); + + const organizationId = session?.session.activeOrganizationId; + + if (!organizationId) { + return null; + } + + const policy = await db.policy.findUnique({ + where: { id: policyId, organizationId }, + }); + + if (!policy) { + return redirect("/"); + } + + return policy; +}); diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/layout.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/layout.tsx index f950cceb8b..9035ad923d 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/layout.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/layout.tsx @@ -1,9 +1,5 @@ -import { auth } from "@bubba/auth"; import { getI18n } from "@/locales/server"; -import { db } from "@bubba/db"; import { SecondaryMenu } from "@bubba/ui/secondary-menu"; -import { headers } from "next/headers"; -import { redirect } from "next/navigation"; interface LayoutProps { children: React.ReactNode; @@ -14,22 +10,6 @@ export default async function Layout({ children, params }: LayoutProps) { const t = await getI18n(); const { policyId, orgId } = await params; - const session = await auth.api.getSession({ - headers: await headers(), - }); - - const organizationId = session?.session.activeOrganizationId; - - if (!organizationId) { - redirect("/"); - } - - const policy = await getPolicy(policyId, organizationId); - - if (!policy) { - redirect("/"); - } - return (
{children}
); -} - -const getPolicy = async (policyId: string, organizationId: string) => { - const policy = await db.policy.findUnique({ - where: { - id: policyId, - organizationId: organizationId, - }, - }); - - return policy; -}; +} \ No newline at end of file diff --git a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/page.tsx b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/page.tsx index 446716d3bf..3e3fea54fb 100644 --- a/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/page.tsx +++ b/apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/all/[policyId]/page.tsx @@ -9,68 +9,54 @@ import { headers } from "next/headers"; import { redirect } from "next/navigation"; export default async function PolicyDetails({ - params, + params, }: { - params: Promise<{ locale: string; policyId: string; orgId: string }>; + params: Promise<{ locale: string; policyId: string }>; }) { - const { locale, policyId, orgId } = await params; - setStaticParamsLocale(locale); - - const session = await auth.api.getSession({ - headers: await headers(), - }); - - const organizationId = session?.session.activeOrganizationId; - - if (!organizationId) { - redirect(`/${orgId}/policies/all`); - } - - const policy = await getPolicy(policyId, organizationId); - const users = await getUsers(organizationId); - - if (!policy) { - redirect(`/${orgId}/policies/all`); - } - - return ( -
- -
- ); + const { locale, policyId } = await params; + setStaticParamsLocale(locale); + const policy = await getPolicy(policyId); + + return ( +
+ +
+ ); } export async function generateMetadata({ - params, + params, }: { - params: Promise<{ locale: string; policyId: string }>; + params: Promise<{ locale: string; policyId: string }>; }): Promise { - const { locale } = await params; + const { locale } = await params; - setStaticParamsLocale(locale); - const t = await getI18n(); + setStaticParamsLocale(locale); + const t = await getI18n(); - return { - title: t("policies.overview.title"), - }; + return { + title: t("policies.overview.title"), + }; } -const getPolicy = cache(async (policyId: string, organizationId: string) => { - const policy = await db.policy.findUnique({ - where: { id: policyId, organizationId }, - }); - return policy; -}); +const getPolicy = cache(async (policyId: string) => { + const session = await auth.api.getSession({ + headers: await headers(), + }); + + const organizationId = session?.session.activeOrganizationId; + + if (!organizationId) { + return null; + } -const getUsers = cache(async (organizationId: string) => { - const orgMembers = await db.member.findMany({ - where: { organizationId }, - include: { - user: true, - }, - }); + const policy = await db.policy.findUnique({ + where: { id: policyId, organizationId }, + }); - const users = orgMembers.map((member) => member.user); + if (!policy) { + return null; + } - return users; + return policy; }); diff --git a/apps/app/src/components/data-table/data-table-pagination.tsx b/apps/app/src/components/data-table/data-table-pagination.tsx index 1338655d74..2328d3b3cb 100644 --- a/apps/app/src/components/data-table/data-table-pagination.tsx +++ b/apps/app/src/components/data-table/data-table-pagination.tsx @@ -35,8 +35,12 @@ export function DataTablePagination({ )} {...props} > -
-
+
+

+ {table.getCoreRowModel().rows.length} items +

+
+

Rows per page

form.handleSubmit(onSubmit)} - > - - - - - - - - - - - )} - /> - {policy.status === "archived" && ( - -
- -
{t("policies.archive.status")}
-
- - {policy.status === "archived" && ( - <> - {t("policies.archive.archived_on")}{" "} - {format(new Date(policy.updatedAt), "PPP")} - - )} - - -
- )} + return ( +
+ {policy?.status === "archived" && ( + +
+ +
{t("policies.archive.status")}
+
+ + {policy?.status === "archived" && ( + <> + {t("policies.archive.archived_on")}{" "} + {format(new Date(policy?.updatedAt ?? new Date()), "PPP")} + + )} + + +
+ )} - - - -
- {policy.name} -
- - -
-
-
- - {policy.description} - -
+ + + +
+ {policy?.name} +
+ + +
+
+
+ + {policy?.description} + +
- - - -
- {t("policies.overview.title")} -
-
-
- - - -
+ + + +
+ {t("policies.overview.title")} +
+
+
+ + {policy && } + +
- - -
- ); + {policy && ( + <> + + + + )} +
+ ); } diff --git a/apps/app/src/lib/validations.ts b/apps/app/src/lib/validations.ts index 4029597d93..3a3c33c5cf 100644 --- a/apps/app/src/lib/validations.ts +++ b/apps/app/src/lib/validations.ts @@ -7,7 +7,7 @@ import { } from "nuqs/server"; import * as z from "zod"; import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers"; -import { Departments, Frequency, Policy, PolicyStatus } from "@bubba/db/types"; +import { Policy, PolicyStatus } from "@bubba/db/types"; export const searchParamsCache = createSearchParamsCache({ page: parseAsInteger.withDefault(1), @@ -27,8 +27,6 @@ export const searchParamsCache = createSearchParamsCache({ export const createPolicySchema = z.object({ name: z.string(), status: z.nativeEnum(PolicyStatus), - frequency: z.nativeEnum(Frequency), - department: z.nativeEnum(Departments), }); export type GetPolicySchema = Awaited< diff --git a/packages/ui/src/components/input.tsx b/packages/ui/src/components/input.tsx index 2c263c7ba1..6293e4501e 100644 --- a/packages/ui/src/components/input.tsx +++ b/packages/ui/src/components/input.tsx @@ -8,14 +8,14 @@ const Input = React.forwardRef( ({ className, type, ...props }, ref) => { return ( + type={type} + className={cn( + "flex h-9 w-full border bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", + className + )} + ref={ref} + {...props} + /> ); }, );