mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
join owners with ProjectsByOwnerID
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Issue, Project, User } from "@issue/shared";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../client";
|
||||
import { Issue, Project, User } from "@issue/shared";
|
||||
|
||||
export async function createProject(blob: string, name: string, ownerId: number) {
|
||||
const [project] = await db
|
||||
@@ -40,8 +40,12 @@ export async function getProjectByBlob(projectBlob: string) {
|
||||
}
|
||||
|
||||
export async function getProjectsByOwnerID(ownerId: number) {
|
||||
const projects = await db.select().from(Project).where(eq(Project.ownerId, ownerId));
|
||||
return projects;
|
||||
const projectsWithOwners = await db
|
||||
.select()
|
||||
.from(Project)
|
||||
.where(eq(Project.ownerId, ownerId))
|
||||
.leftJoin(User, eq(Project.ownerId, User.id));
|
||||
return projectsWithOwners;
|
||||
}
|
||||
|
||||
export async function getAllProjects() {
|
||||
|
||||
@@ -60,7 +60,6 @@ function Index() {
|
||||
}
|
||||
const project = projects.find((p) => p.Project.id === Number(value));
|
||||
if (!project) {
|
||||
// TODO: toast here
|
||||
console.error(`NO PROJECT FOUND FOR ID: ${value}`);
|
||||
return;
|
||||
}
|
||||
@@ -81,6 +80,7 @@ function Index() {
|
||||
{project.Project.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
{/* {projects.length === 0 && <>No projects</>} */}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{selectedProject && (
|
||||
|
||||
Reference in New Issue
Block a user