mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
include project owner
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import type { BunRequest } from "bun";
|
import type { BunRequest } from "bun";
|
||||||
import { getAllProjects } from "../../db/queries";
|
import { getProjectsWithOwners } from "../../db/queries";
|
||||||
|
|
||||||
// /projects/all
|
// /projects/all
|
||||||
export default async function projectsAll(req: BunRequest) {
|
export default async function projectsAll(req: BunRequest) {
|
||||||
const projects = await getAllProjects();
|
const projects = await getProjectsWithOwners();
|
||||||
|
|
||||||
return Response.json(projects);
|
return Response.json(projects);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import type { IssueResponse, ProjectRecord } from "@issue/shared";
|
import type { IssueResponse, ProjectResponse } from "@issue/shared";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { IssueDetailPane } from "@/components/issue-detail-pane";
|
import { IssueDetailPane } from "@/components/issue-detail-pane";
|
||||||
import { IssuesTable } from "@/components/issues-table";
|
import { IssuesTable } from "@/components/issues-table";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
|
import SmallUserDisplay from "./components/small-user-display";
|
||||||
|
|
||||||
function Index() {
|
function Index() {
|
||||||
const [selectedProject, setSelectedProject] = useState<ProjectRecord | null>(null);
|
const [selectedProject, setSelectedProject] = useState<ProjectResponse | null>(null);
|
||||||
const [projects, setProjects] = useState<ProjectRecord[]>([]);
|
const [projects, setProjects] = useState<ProjectResponse[]>([]);
|
||||||
const projectsRef = useRef(false);
|
const projectsRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -15,7 +16,7 @@ function Index() {
|
|||||||
|
|
||||||
fetch("http://localhost:3000/projects/all")
|
fetch("http://localhost:3000/projects/all")
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data: ProjectRecord[]) => {
|
.then((data: ProjectResponse[]) => {
|
||||||
setProjects(data);
|
setProjects(data);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -31,11 +32,10 @@ function Index() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedProject) return;
|
if (!selectedProject) return;
|
||||||
|
|
||||||
fetch(`${serverURL}/issues/${selectedProject.blob}`)
|
fetch(`${serverURL}/issues/${selectedProject.Project.blob}`)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data: IssueResponse[]) => {
|
.then((data: IssueResponse[]) => {
|
||||||
setIssues(data);
|
setIssues(data);
|
||||||
console.log(data);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("error fetching issues:", err);
|
console.error("error fetching issues:", err);
|
||||||
@@ -45,7 +45,7 @@ function Index() {
|
|||||||
return (
|
return (
|
||||||
<main className="w-full h-full p-1">
|
<main className="w-full h-full p-1">
|
||||||
{/* header area */}
|
{/* header area */}
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-4 items-center">
|
||||||
<Select
|
<Select
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
if (value === "NONE") {
|
if (value === "NONE") {
|
||||||
@@ -53,7 +53,7 @@ function Index() {
|
|||||||
setSelectedIssue(null);
|
setSelectedIssue(null);
|
||||||
setIssues([]);
|
setIssues([]);
|
||||||
}
|
}
|
||||||
const project = projects.find((p) => p.id === Number(value));
|
const project = projects.find((p) => p.Project.id === Number(value));
|
||||||
if (!project) {
|
if (!project) {
|
||||||
// TODO: toast here
|
// TODO: toast here
|
||||||
console.error(`NO PROJECT FOUND FOR ID: ${value}`);
|
console.error(`NO PROJECT FOUND FOR ID: ${value}`);
|
||||||
@@ -65,20 +65,27 @@ function Index() {
|
|||||||
>
|
>
|
||||||
<SelectTrigger className="h-8 lg:flex">
|
<SelectTrigger className="h-8 lg:flex">
|
||||||
<SelectValue
|
<SelectValue
|
||||||
placeholder={selectedProject ? `P: ${selectedProject.name}` : "Select Project"}
|
placeholder={
|
||||||
|
selectedProject ? `P: ${selectedProject.Project.name}` : "Select Project"
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent side="bottom" position="popper">
|
<SelectContent side="bottom" position="popper">
|
||||||
{projects.map((project) => (
|
{projects.map((project) => (
|
||||||
<SelectItem key={project.id} value={`${project.id}`}>
|
<SelectItem key={project.Project.id} value={`${project.Project.id}`}>
|
||||||
{project.name}
|
{project.Project.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
{selectedProject && (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
Owner: <SmallUserDisplay user={selectedProject?.User} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* main body */}
|
{/* main body */}
|
||||||
<div className="w-full h-full flex items-start justify-between pt-2 gap-2">
|
<div className="w-full h-full flex items-start justify-between pt-1 gap-2">
|
||||||
{selectedProject && issuesData.length > 0 && (
|
{selectedProject && issuesData.length > 0 && (
|
||||||
<>
|
<>
|
||||||
{/* issues list (table) */}
|
{/* issues list (table) */}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import type { IssueResponse, ProjectRecord } from "@issue/shared";
|
import type { IssueResponse, ProjectResponse } from "@issue/shared";
|
||||||
import { X } from "lucide-react";
|
import { X } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { issueID } from "@/lib/utils";
|
import { issueID } from "@/lib/utils";
|
||||||
|
import SmallUserDisplay from "./small-user-display";
|
||||||
|
|
||||||
export function IssueDetailPane({
|
export function IssueDetailPane({
|
||||||
project,
|
project,
|
||||||
issueData,
|
issueData,
|
||||||
close,
|
close,
|
||||||
}: {
|
}: {
|
||||||
project: ProjectRecord;
|
project: ProjectResponse;
|
||||||
issueData: IssueResponse;
|
issueData: IssueResponse;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -16,7 +17,9 @@ export function IssueDetailPane({
|
|||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<div className="flex flex-row items-center justify-end border-b h-[25px]">
|
<div className="flex flex-row items-center justify-end border-b h-[25px]">
|
||||||
<span className="w-full">
|
<span className="w-full">
|
||||||
<p className="text-sm w-fit px-1">{issueID(project.blob, issueData.Issue.number)}</p>
|
<p className="text-sm w-fit px-1">
|
||||||
|
{issueID(project.Project.blob, issueData.Issue.number)}
|
||||||
|
</p>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<Button variant={"dummy"} onClick={close} className="px-0 py-0 w-6 h-6">
|
<Button variant={"dummy"} onClick={close} className="px-0 py-0 w-6 h-6">
|
||||||
@@ -28,10 +31,12 @@ export function IssueDetailPane({
|
|||||||
<h1 className="text-md">{issueData.Issue.title}</h1>
|
<h1 className="text-md">{issueData.Issue.title}</h1>
|
||||||
<p className="text-sm">{issueData.Issue.description}</p>
|
<p className="text-sm">{issueData.Issue.description}</p>
|
||||||
|
|
||||||
<p className="text-sm">
|
{issueData.User && (
|
||||||
Assignee:{" "}
|
<div className="flex items-center gap-2">
|
||||||
{issueData.User ? `${issueData.User.name} (${issueData.User.username})` : "Unassigned"}
|
Assignee:
|
||||||
</p>
|
{issueData.User ? <SmallUserDisplay user={issueData.User} /> : "Unassigned"}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { IssueResponse, ProjectRecord } from "@issue/shared";
|
import type { IssueResponse, ProjectResponse } from "@issue/shared";
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ export function IssuesTable({
|
|||||||
issueSelectAction,
|
issueSelectAction,
|
||||||
className,
|
className,
|
||||||
}: {
|
}: {
|
||||||
project: ProjectRecord;
|
project: ProjectResponse;
|
||||||
issuesData: IssueResponse[];
|
issuesData: IssueResponse[];
|
||||||
columns?: { id?: boolean; title?: boolean; description?: boolean; assignee?: boolean };
|
columns?: { id?: boolean; title?: boolean; description?: boolean; assignee?: boolean };
|
||||||
issueSelectAction?: (issue: IssueResponse) => void;
|
issueSelectAction?: (issue: IssueResponse) => void;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export {
|
|||||||
} from "./schema";
|
} from "./schema";
|
||||||
|
|
||||||
// Responses
|
// Responses
|
||||||
export {
|
export type {
|
||||||
IssueResponse,
|
IssueResponse,
|
||||||
|
ProjectResponse,
|
||||||
} from "./schema"
|
} from "./schema"
|
||||||
@@ -65,3 +65,8 @@ export type IssueResponse = {
|
|||||||
Issue: IssueRecord;
|
Issue: IssueRecord;
|
||||||
User?: UserRecord;
|
User?: UserRecord;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ProjectResponse = {
|
||||||
|
Project: ProjectRecord;
|
||||||
|
User: UserRecord;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user