mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
sprint data fetching
This commit is contained in:
@@ -5,6 +5,7 @@ import type {
|
|||||||
OrganisationMemberResponse,
|
OrganisationMemberResponse,
|
||||||
OrganisationResponse,
|
OrganisationResponse,
|
||||||
ProjectResponse,
|
ProjectResponse,
|
||||||
|
SprintRecord,
|
||||||
UserRecord,
|
UserRecord,
|
||||||
} from "@issue/shared";
|
} from "@issue/shared";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
@@ -30,7 +31,7 @@ import {
|
|||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { ResizablePanel, ResizablePanelGroup, ResizableSeparator } from "@/components/ui/resizable";
|
import { ResizablePanel, ResizablePanelGroup, ResizableSeparator } from "@/components/ui/resizable";
|
||||||
import { issue, organisation, project } from "@/lib/server";
|
import { issue, organisation, project, sprint } from "@/lib/server";
|
||||||
|
|
||||||
const BREATHING_ROOM = 1;
|
const BREATHING_ROOM = 1;
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ export default function App() {
|
|||||||
const [selectedIssue, setSelectedIssue] = useState<IssueResponse | null>(null);
|
const [selectedIssue, setSelectedIssue] = useState<IssueResponse | null>(null);
|
||||||
|
|
||||||
const [members, setMembers] = useState<UserRecord[]>([]);
|
const [members, setMembers] = useState<UserRecord[]>([]);
|
||||||
|
const [sprints, setSprints] = useState<SprintRecord[]>([]);
|
||||||
|
|
||||||
const isAdmin =
|
const isAdmin =
|
||||||
selectedOrganisation?.OrganisationMember.role === "owner" ||
|
selectedOrganisation?.OrganisationMember.role === "owner" ||
|
||||||
@@ -255,6 +257,24 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const refetchSprints = async (projectId: number) => {
|
||||||
|
try {
|
||||||
|
await sprint.byProject({
|
||||||
|
projectId,
|
||||||
|
onSuccess: (data: SprintRecord[]) => {
|
||||||
|
setSprints(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error("error fetching sprints:", error);
|
||||||
|
setSprints([]);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("error fetching sprints:", err);
|
||||||
|
setSprints([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// fetch projects when organisation is selected
|
// fetch projects when organisation is selected
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setProjects([]);
|
setProjects([]);
|
||||||
@@ -314,6 +334,7 @@ export default function App() {
|
|||||||
if (!selectedProject) return;
|
if (!selectedProject) return;
|
||||||
|
|
||||||
void refetchIssues();
|
void refetchIssues();
|
||||||
|
void refetchSprints(selectedProject.Project.id);
|
||||||
}, [selectedProject]);
|
}, [selectedProject]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -398,7 +419,15 @@ export default function App() {
|
|||||||
await refetchIssues();
|
await refetchIssues();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{isAdmin && <CreateSprint projectId={selectedProject?.Project.id} />}
|
{isAdmin && (
|
||||||
|
<CreateSprint
|
||||||
|
projectId={selectedProject?.Project.id}
|
||||||
|
completeAction={async () => {
|
||||||
|
if (!selectedProject) return;
|
||||||
|
await refetchSprints(selectedProject?.Project.id);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -472,6 +501,7 @@ export default function App() {
|
|||||||
<div className="border">
|
<div className="border">
|
||||||
<IssueDetailPane
|
<IssueDetailPane
|
||||||
project={selectedProject}
|
project={selectedProject}
|
||||||
|
sprints={sprints}
|
||||||
issueData={selectedIssue}
|
issueData={selectedIssue}
|
||||||
members={members}
|
members={members}
|
||||||
statuses={selectedOrganisation.Organisation.statuses}
|
statuses={selectedOrganisation.Organisation.statuses}
|
||||||
|
|||||||
Reference in New Issue
Block a user