Skip to content

Team Collaboration Workspaces & Shared Analyses #5

Description

@Sumedh-6504

Description

Extend the database schema and application UI to support workspaces and team-based collaboration, allowing users to share contract analyses with their peers.

User Story

As a corporate Pro user,
I want to invite team members to my workspace and share analyses,
So that we can collaboratively review exploitative clauses and worst-case scenarios.

Technical Tasks

  • Create teams and team_members tables in the Supabase database schema.
  • Add a team_id optional foreign key column to the documents table.
  • Create API routes to invite, accept, list, and delete team members.
  • Update the app/(app)/contracts/page.tsx page to display both personal and team-shared contracts.
  • Update security policies (RLS) to ensure users can only view analyses owned by them or shared with their verified team workspace.

Database Updates

CREATE TABLE teams (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT NOT NULL,
  owner_id UUID REFERENCES users(id) ON DELETE CASCADE,
  created_at TIMESTAMPTZ DEFAULT now()
);

CREATE TABLE team_members (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  team_id UUID REFERENCES teams(id) ON DELETE CASCADE,
  user_id UUID REFERENCES users(id) ON DELETE CASCADE,
  role TEXT NOT NULL DEFAULT 'member',
  created_at TIMESTAMPTZ DEFAULT now(),
  UNIQUE(team_id, user_id)
);

ALTER TABLE documents ADD COLUMN team_id UUID REFERENCES teams(id) ON DELETE SET NULL;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions