2023-02-04 14:38:13 +00:00
|
|
|
// react-beautiful-dnd
|
2023-02-06 09:48:57 +00:00
|
|
|
import { DragDropContext, DropResult } from "react-beautiful-dnd";
|
2023-02-04 14:38:13 +00:00
|
|
|
// hooks
|
|
|
|
import useIssueView from "hooks/use-issue-view";
|
|
|
|
// components
|
|
|
|
import StrictModeDroppable from "components/dnd/StrictModeDroppable";
|
2023-02-05 11:27:37 +00:00
|
|
|
import { SingleBoard } from "components/core/board-view/single-board";
|
2023-02-04 14:38:13 +00:00
|
|
|
// types
|
2023-02-05 11:27:37 +00:00
|
|
|
import { IIssue, IProjectMember, IState, UserAuth } from "types";
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-02-05 11:27:37 +00:00
|
|
|
type: "issue" | "cycle" | "module";
|
2023-02-04 14:38:13 +00:00
|
|
|
issues: IIssue[];
|
2023-02-05 11:27:37 +00:00
|
|
|
states: IState[] | undefined;
|
|
|
|
members: IProjectMember[] | undefined;
|
|
|
|
addIssueToState: (groupTitle: string, stateId: string | null) => void;
|
|
|
|
openIssuesListModal?: (() => void) | null;
|
|
|
|
handleDeleteIssue: (issue: IIssue) => void;
|
|
|
|
handleOnDragEnd: (result: DropResult) => void;
|
2023-02-04 14:38:13 +00:00
|
|
|
userAuth: UserAuth;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AllBoards: React.FC<Props> = ({
|
2023-02-05 11:27:37 +00:00
|
|
|
type,
|
2023-02-04 14:38:13 +00:00
|
|
|
issues,
|
2023-02-05 11:27:37 +00:00
|
|
|
states,
|
|
|
|
members,
|
|
|
|
addIssueToState,
|
2023-02-04 14:38:13 +00:00
|
|
|
openIssuesListModal,
|
|
|
|
handleDeleteIssue,
|
2023-02-05 11:27:37 +00:00
|
|
|
handleOnDragEnd,
|
2023-02-04 14:38:13 +00:00
|
|
|
userAuth,
|
|
|
|
}) => {
|
2023-02-06 09:48:57 +00:00
|
|
|
const { groupedByIssues, groupByProperty: selectedGroup, orderBy } = useIssueView(issues);
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{groupedByIssues ? (
|
|
|
|
<div className="h-[calc(100vh-157px)] lg:h-[calc(100vh-115px)] w-full">
|
|
|
|
<DragDropContext onDragEnd={handleOnDragEnd}>
|
|
|
|
<div className="h-full w-full overflow-hidden">
|
|
|
|
<StrictModeDroppable droppableId="state" type="state" direction="horizontal">
|
|
|
|
{(provided) => (
|
|
|
|
<div
|
|
|
|
className="h-full w-full"
|
|
|
|
{...provided.droppableProps}
|
|
|
|
ref={provided.innerRef}
|
|
|
|
>
|
|
|
|
<div className="flex h-full gap-x-4 overflow-x-auto overflow-y-hidden">
|
|
|
|
{Object.keys(groupedByIssues).map((singleGroup, index) => {
|
|
|
|
const stateId =
|
|
|
|
selectedGroup === "state_detail.name"
|
|
|
|
? states?.find((s) => s.name === singleGroup)?.id ?? null
|
|
|
|
: null;
|
|
|
|
|
|
|
|
const bgColor =
|
|
|
|
selectedGroup === "state_detail.name"
|
|
|
|
? states?.find((s) => s.name === singleGroup)?.color
|
|
|
|
: "#000000";
|
|
|
|
|
|
|
|
return (
|
2023-02-06 09:48:57 +00:00
|
|
|
<SingleBoard
|
|
|
|
key={index}
|
|
|
|
index={index}
|
|
|
|
type={type}
|
|
|
|
bgColor={bgColor}
|
|
|
|
groupTitle={singleGroup}
|
|
|
|
groupedByIssues={groupedByIssues}
|
|
|
|
selectedGroup={selectedGroup}
|
|
|
|
members={members}
|
|
|
|
addIssueToState={() => addIssueToState(singleGroup, stateId)}
|
|
|
|
handleDeleteIssue={handleDeleteIssue}
|
|
|
|
openIssuesListModal={openIssuesListModal ?? null}
|
|
|
|
orderBy={orderBy}
|
|
|
|
userAuth={userAuth}
|
|
|
|
/>
|
2023-02-04 14:38:13 +00:00
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
{provided.placeholder}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</StrictModeDroppable>
|
|
|
|
</div>
|
|
|
|
</DragDropContext>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="flex h-full w-full items-center justify-center">Loading...</div>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|