-
Notifications
You must be signed in to change notification settings - Fork 425
feat: add policy layout components and enhance policy details page #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { getI18n } from "@/locales/server"; | ||
| import { SecondaryMenu } from "@comp/ui/secondary-menu"; | ||
|
|
||
| interface LayoutProps { | ||
| children: React.ReactNode; | ||
| params: Promise<{ policyId: string; orgId: string }>; | ||
| } | ||
|
|
||
| export default async function Layout({ children, params }: LayoutProps) { | ||
| const t = await getI18n(); | ||
| const { orgId, policyId } = await params; | ||
|
|
||
| return ( | ||
| <div className="max-w-[1200px] m-auto flex flex-col gap-6"> | ||
| <SecondaryMenu | ||
| items={[ | ||
| { | ||
| path: `/${orgId}/policies`, | ||
| label: t("policies.dashboard.title"), | ||
| }, | ||
| { | ||
| path: `/${orgId}/policies/all`, | ||
| label: t("policies.dashboard.all"), | ||
| activeOverrideIdPrefix: "pol_", | ||
| }, | ||
| ]} | ||
| /> | ||
| <div>{children}</div> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||
| import { getI18n } from "@/locales/server"; | ||||||||||||||||||
| import { SecondaryMenu } from "@comp/ui/secondary-menu"; | ||||||||||||||||||
|
|
||||||||||||||||||
| interface LayoutProps { | ||||||||||||||||||
| children: React.ReactNode; | ||||||||||||||||||
| params: Promise<{ policyId: string; orgId: string }>; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Revise the params interface for the all policies layout The interface LayoutProps {
children: React.ReactNode;
- params: Promise<{ policyId: string; orgId: string }>;
+ params: Promise<{ orgId: string }>;
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| export default async function Layout({ children, params }: LayoutProps) { | ||||||||||||||||||
| const t = await getI18n(); | ||||||||||||||||||
| const { orgId } = await params; | ||||||||||||||||||
|
|
||||||||||||||||||
| return ( | ||||||||||||||||||
| <div className="max-w-[1200px] m-auto flex flex-col gap-6"> | ||||||||||||||||||
| <SecondaryMenu | ||||||||||||||||||
| items={[ | ||||||||||||||||||
| { | ||||||||||||||||||
| path: `/${orgId}/policies`, | ||||||||||||||||||
| label: t("policies.dashboard.title"), | ||||||||||||||||||
| }, | ||||||||||||||||||
| { | ||||||||||||||||||
| path: `/${orgId}/policies/all`, | ||||||||||||||||||
| label: t("policies.dashboard.all"), | ||||||||||||||||||
| activeOverrideIdPrefix: "pol_", | ||||||||||||||||||
| }, | ||||||||||||||||||
| ]} | ||||||||||||||||||
| /> | ||||||||||||||||||
| <div>{children}</div> | ||||||||||||||||||
| </div> | ||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add null check for policy content
The code casts
policy?.contentdirectly toJSONContent[]without verification. This might cause runtime errors if the content is null or undefined.<PolicyPageEditor policyId={policyId} - policyContent={policy?.content as JSONContent[]} + policyContent={policy?.content ? (policy.content as JSONContent[]) : []} />📝 Committable suggestion