mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
issue modal component
This commit is contained in:
55
packages/frontend/src/components/issue-modal.tsx
Normal file
55
packages/frontend/src/components/issue-modal.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import type { IssueResponse } from "@sprint/shared";
|
||||||
|
import { type ReactNode, useMemo } from "react";
|
||||||
|
import { IssueDetails } from "@/components/issue-details";
|
||||||
|
import { Dialog, DialogContent, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||||
|
import {
|
||||||
|
useOrganisationMembers,
|
||||||
|
useSelectedOrganisation,
|
||||||
|
useSelectedProject,
|
||||||
|
useSprints,
|
||||||
|
} from "@/lib/query/hooks";
|
||||||
|
import { issueID } from "@/lib/utils";
|
||||||
|
|
||||||
|
export function IssueModal({
|
||||||
|
issueData,
|
||||||
|
open,
|
||||||
|
onOpenChange,
|
||||||
|
trigger,
|
||||||
|
}: {
|
||||||
|
issueData: IssueResponse | null;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
trigger: ReactNode;
|
||||||
|
}) {
|
||||||
|
const selectedOrganisation = useSelectedOrganisation();
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const { data: sprints = [] } = useSprints(selectedProject?.Project.id);
|
||||||
|
const { data: membersData = [] } = useOrganisationMembers(selectedOrganisation?.Organisation.id);
|
||||||
|
|
||||||
|
const members = useMemo(() => membersData.map((member) => member.User), [membersData]);
|
||||||
|
const statuses = selectedOrganisation?.Organisation.statuses ?? {};
|
||||||
|
|
||||||
|
if (!issueData || !selectedProject || !selectedOrganisation) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<DialogTrigger asChild>{trigger}</DialogTrigger>
|
||||||
|
<DialogContent className="w-lg p-0" showCloseButton={false}>
|
||||||
|
<DialogTitle className="sr-only">
|
||||||
|
{issueID(selectedProject.Project.key, issueData.Issue.number)}
|
||||||
|
</DialogTitle>
|
||||||
|
<IssueDetails
|
||||||
|
issueData={issueData}
|
||||||
|
projectKey={selectedProject.Project.key}
|
||||||
|
sprints={sprints}
|
||||||
|
members={members}
|
||||||
|
statuses={statuses}
|
||||||
|
onClose={() => onOpenChange(false)}
|
||||||
|
onDelete={() => onOpenChange(false)}
|
||||||
|
/>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user