diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx index 014a40a..048bdd3 100644 --- a/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx @@ -34,6 +34,7 @@ import { PortfolioStatus as PortfolioStatusOptions } from "@/app/db/schema/portf import { PortfolioGoal as PortfolioGoalOptions } from "@/app/db/schema/portfolio"; import { useSession } from "next-auth/react"; import PortfolioPlanTable from "@/app/components/portfolio/measures/PlanTable"; +import { UsersPermissionsCard } from "./UsersPermissionsCard"; // dropdown selection component for both goal and status @@ -459,6 +460,7 @@ export default function PortfolioSettings({ +
Danger Zone: diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/UsersPermissionsCard.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/UsersPermissionsCard.tsx new file mode 100644 index 0000000..7cd2f29 --- /dev/null +++ b/src/app/portfolio/[slug]/(portfolio)/settings/UsersPermissionsCard.tsx @@ -0,0 +1,132 @@ +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/app/shadcn_components/ui/table"; +import { Input } from "@/app/shadcn_components/ui/input"; +import { Button } from "@/app/shadcn_components/ui/button"; + +import { useState } from "react"; +import { Role, RoleDropdown, Collaborator } from "@/app/portfolio/[slug]/(portfolio)/settings/roles"; + +export function UsersPermissionsCard({ +}: { +}) { + const [inviteEmail, setInviteEmail] = useState(""); + const [inviteRole, setInviteRole] = useState("read"); + const collaborators: Collaborator[] = [ + { name: "Name 1", email: "name1@example.com", role: "read" }, + { name: "Name 2", email: "name2@example.com", role: "read" }, + ]; + + function handleInvite() { + console.log("handle invite") + } + + function onChangeRole(email:string, role:Role) { + console.log(`on change role ${email} ${role}`) + } + + function onRemove(email:string) { + console.log(`remove user ${email}`) + } + + return ( +
+
+ + + + Users Permission: +

Add users and manage roles

+
+
+ + {/* Invite row */} + + + Add a user +

+ Invite by email and choose a role +

+
+ + setInviteEmail(e.target.value)} + /> +
+ +
+
+ + + +
+ + {/* Current collaborators list */} + + + Current users +

+ Update roles or remove access +

+
+ +
+
+ + + Name + Email + Role + Actions + + + + {collaborators.length === 0 ? ( + + + No users yet. + + + ) : ( + collaborators.map((c) => ( + + {c.name || "—"} + {c.email} + + onChangeRole(c.email, r)} + /> + + + + + + )) + )} + +
+
+ + + + + + ); +} diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/roles.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/roles.tsx new file mode 100644 index 0000000..97ecf3e --- /dev/null +++ b/src/app/portfolio/[slug]/(portfolio)/settings/roles.tsx @@ -0,0 +1,44 @@ +import { + Select, + SelectTrigger, + SelectValue, + SelectContent, + SelectGroup, + SelectItem, +} from "@/app/shadcn_components/ui/select"; + +// Roles you support in your app (adjust as needed) +const ROLE_OPTIONS = ["read", "write"] as const; +export type Role = typeof ROLE_OPTIONS[number]; + +export type Collaborator = { + name?: string | null; + email: string; + role: Role; +}; + +// Small role dropdown using shadcn Select +export function RoleDropdown({ + value, + onChange, +}: { + value: Role; + onChange: (role: Role) => void; +}) { + return ( + + ); +} \ No newline at end of file