2023-02-04 14:38:13 +00:00
|
|
|
// hooks
|
2023-03-15 06:14:44 +00:00
|
|
|
import useProjectIssuesView from "hooks/use-issues-view";
|
2023-02-04 14:38:13 +00:00
|
|
|
// components
|
2023-02-05 11:27:37 +00:00
|
|
|
import { SingleBoard } from "components/core/board-view/single-board";
|
2023-03-22 20:43:52 +00:00
|
|
|
// helpers
|
|
|
|
import { addSpaceIfCamelCase } from "helpers/string.helper";
|
2023-02-04 14:38:13 +00:00
|
|
|
// types
|
2023-03-15 06:14:44 +00:00
|
|
|
import { IIssue, IState, UserAuth } from "types";
|
2023-03-22 20:43:52 +00:00
|
|
|
import { getStateGroupIcon } from "components/icons";
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
type Props = {
|
2023-02-05 11:27:37 +00:00
|
|
|
type: "issue" | "cycle" | "module";
|
|
|
|
states: IState[] | undefined;
|
2023-03-15 06:14:44 +00:00
|
|
|
addIssueToState: (groupTitle: string) => void;
|
2023-03-04 21:54:24 +00:00
|
|
|
makeIssueCopy: (issue: IIssue) => void;
|
2023-02-14 14:35:32 +00:00
|
|
|
handleEditIssue: (issue: IIssue) => void;
|
2023-02-05 11:27:37 +00:00
|
|
|
openIssuesListModal?: (() => void) | null;
|
|
|
|
handleDeleteIssue: (issue: IIssue) => void;
|
2023-02-13 05:02:02 +00:00
|
|
|
handleTrashBox: (isDragging: boolean) => void;
|
2023-02-14 14:35:32 +00:00
|
|
|
removeIssue: ((bridgeId: string) => void) | null;
|
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,
|
|
|
|
states,
|
|
|
|
addIssueToState,
|
2023-03-04 21:54:24 +00:00
|
|
|
makeIssueCopy,
|
2023-02-14 14:35:32 +00:00
|
|
|
handleEditIssue,
|
2023-02-04 14:38:13 +00:00
|
|
|
openIssuesListModal,
|
|
|
|
handleDeleteIssue,
|
2023-02-13 05:02:02 +00:00
|
|
|
handleTrashBox,
|
2023-02-14 14:35:32 +00:00
|
|
|
removeIssue,
|
2023-02-04 14:38:13 +00:00
|
|
|
userAuth,
|
|
|
|
}) => {
|
2023-03-22 20:43:52 +00:00
|
|
|
const {
|
|
|
|
groupedByIssues,
|
|
|
|
groupByProperty: selectedGroup,
|
|
|
|
showEmptyGroups,
|
|
|
|
} = useProjectIssuesView();
|
2023-02-04 14:38:13 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{groupedByIssues ? (
|
2023-03-15 06:14:44 +00:00
|
|
|
<div className="horizontal-scroll-enable flex h-[calc(100vh-140px)] gap-x-4">
|
|
|
|
{Object.keys(groupedByIssues).map((singleGroup, index) => {
|
|
|
|
const currentState =
|
|
|
|
selectedGroup === "state" ? states?.find((s) => s.id === singleGroup) : null;
|
2023-02-28 09:12:46 +00:00
|
|
|
|
2023-03-22 20:43:52 +00:00
|
|
|
if (!showEmptyGroups && groupedByIssues[singleGroup].length === 0) return null;
|
|
|
|
|
2023-03-15 06:14:44 +00:00
|
|
|
return (
|
|
|
|
<SingleBoard
|
|
|
|
key={index}
|
|
|
|
type={type}
|
|
|
|
currentState={currentState}
|
|
|
|
groupTitle={singleGroup}
|
|
|
|
handleEditIssue={handleEditIssue}
|
|
|
|
makeIssueCopy={makeIssueCopy}
|
|
|
|
addIssueToState={() => addIssueToState(singleGroup)}
|
|
|
|
handleDeleteIssue={handleDeleteIssue}
|
|
|
|
openIssuesListModal={openIssuesListModal ?? null}
|
|
|
|
handleTrashBox={handleTrashBox}
|
|
|
|
removeIssue={removeIssue}
|
|
|
|
userAuth={userAuth}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
2023-03-22 20:43:52 +00:00
|
|
|
{!showEmptyGroups && (
|
|
|
|
<div className="h-full w-96 flex-shrink-0 space-y-3 p-1">
|
|
|
|
<h2 className="text-lg font-semibold">Hidden groups</h2>
|
|
|
|
<div className="space-y-3">
|
|
|
|
{Object.keys(groupedByIssues).map((singleGroup, index) => {
|
|
|
|
const currentState =
|
|
|
|
selectedGroup === "state" ? states?.find((s) => s.id === singleGroup) : null;
|
|
|
|
|
|
|
|
if (groupedByIssues[singleGroup].length === 0)
|
|
|
|
return (
|
|
|
|
<div className="flex items-center justify-between gap-2 rounded bg-white p-2 shadow">
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
{currentState &&
|
|
|
|
getStateGroupIcon(currentState.group, "16", "16", currentState.color)}
|
|
|
|
<h4 className="text-sm capitalize">
|
|
|
|
{selectedGroup === "state"
|
|
|
|
? addSpaceIfCamelCase(currentState?.name ?? "")
|
|
|
|
: addSpaceIfCamelCase(singleGroup)}
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<span className="text-xs text-gray-500">0</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
2023-02-04 14:38:13 +00:00
|
|
|
</div>
|
2023-03-15 06:14:44 +00:00
|
|
|
) : null}
|
2023-02-04 14:38:13 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|