Skip to content

AUTH-9 - Implemented UserProject server actions#5

Open
leec18 wants to merge 2 commits intomainfrom
auth-9
Open

AUTH-9 - Implemented UserProject server actions#5
leec18 wants to merge 2 commits intomainfrom
auth-9

Conversation

@leec18
Copy link
Copy Markdown
Collaborator

@leec18 leec18 commented Apr 7, 2026

Created lib/userProject.ts for managing the UserProject join table which contains:

  • createUserProject: prevents duplicate assignments by checking for an existing record before inserting
  • getUserProject
  • getUserProjects: optional filtering by userId or projectId
  • deleteUserProject

Comment thread src/app/login/EmailForm.tsx Outdated
}

export function EmailForm({ onNext }: Props) {
const [email, setEmail] = useState("");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets install react hook form and zod (or other packages if you have better ones) for this to avoid having useStates cause that gets out of hand very quickly

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can integrate with shadcn here too. They seem to support both react hook form and tanstack form so take your pick! https://ui.shadcn.com/docs/forms

Comment thread src/app/login/EmailForm.tsx Outdated
</button>
</form>
);
} No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line end of file please

Comment thread src/app/login/EmailForm.tsx Outdated
onChange={(e) => setEmail(e.target.value)}
required
/>
<button
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets install the shadcn button from here

Comment thread src/app/globals.css Outdated
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you set up a tailwind config and colors file? Guide: https://tailwindcss.com/docs/installation/framework-guides/nextjs

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of our colors for the application should be defined in this file (e.g. primary, secondary, accent, etc) and then referenced by those names throughout all files

Comment thread src/app/login/page.tsx Outdated
</div>
</main>
);
} No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add newlines at the ends of all files

Comment thread src/lib/userProject.ts Outdated

async function createUserProject(userId: string, projectId: string) {
const existing = await prisma.userProject.findUnique({
where: { userId_projectId: { userId, projectId } }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this inline

Comment thread src/lib/userProject.ts
}

async function getUserProject(userId: string, projectId: string) {
return await prisma.userProject.findUnique({
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also move inline, anything this short can be inline

Comment thread src/lib/userProject.ts Outdated
});
}

async function getUserProjects(filters?: { userId?: string, projectId?: string }) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for simplicity, lets destructure the args in the function definition so go { userId?, projectId? } : { userId: ..., projectId: string } or however it goes

Comment thread src/lib/userProject.ts Outdated
}

async function deleteUserProject(userId: string, projectId: string) {
return await prisma.userProject.delete({
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have soft deletes for this or not on this one?

Comment thread src/lib/userProject.ts Outdated
});
}

async function deleteUserProject(userId: string, projectId: string) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be better off being named removeUserFromProject

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants