Merge branch 'develop' of github.com:makeplane/plane into feat/multiple_sub_issues

This commit is contained in:
pablohashescobar 2023-02-14 20:08:39 +05:30
commit 9a5d7b1049
33 changed files with 768 additions and 686 deletions

View File

@ -17,7 +17,7 @@
color: #FFFFFF; color: #FFFFFF;
} }
</style> </style>
<h1 id="site-name">{% trans 'plane Admin' %} </h1> <h1 id="site-name">{% trans 'Plane Django Admin' %} </h1>
{% endblock %}{% block nav-global %}{% endblock %} {% endblock %}{% block nav-global %}{% endblock %}

View File

@ -114,15 +114,15 @@ export const EmailCodeForm = ({ onSuccess }: any) => {
error={errors.token} error={errors.token}
placeholder="Enter code" placeholder="Enter code"
/> />
{/* <span {/* <button
className="text-xs outline-none hover:text-theme" type="button"
className="text-xs outline-none hover:text-theme cursor-pointer"
onClick={() => { onClick={() => {
console.log("Triggered");
handleSubmit(onSubmit); handleSubmit(onSubmit);
}} }}
> >
Resend code Resend code
</span> */} </button> */}
</div> </div>
)} )}
<div> <div>

View File

@ -105,7 +105,7 @@ export const CommandPalette: React.FC = () => {
if ((e.ctrlKey || e.metaKey) && (e.key === "k" || e.key === "K")) { if ((e.ctrlKey || e.metaKey) && (e.key === "k" || e.key === "K")) {
e.preventDefault(); e.preventDefault();
setIsPaletteOpen(true); setIsPaletteOpen(true);
} else if (e.ctrlKey && (e.key === "c" || e.key === "C")) { } else if ((e.ctrlKey || e.metaKey) && (e.key === "c" || e.key === "C")) {
if (e.altKey) { if (e.altKey) {
e.preventDefault(); e.preventDefault();
if (!router.query.issueId) return; if (!router.query.issueId) return;

View File

@ -11,9 +11,11 @@ type Props = {
states: IState[] | undefined; states: IState[] | undefined;
members: IProjectMember[] | undefined; members: IProjectMember[] | undefined;
addIssueToState: (groupTitle: string, stateId: string | null) => void; addIssueToState: (groupTitle: string, stateId: string | null) => void;
handleEditIssue: (issue: IIssue) => void;
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
handleTrashBox: (isDragging: boolean) => void; handleTrashBox: (isDragging: boolean) => void;
removeIssue: ((bridgeId: string) => void) | null;
userAuth: UserAuth; userAuth: UserAuth;
}; };
@ -23,9 +25,11 @@ export const AllBoards: React.FC<Props> = ({
states, states,
members, members,
addIssueToState, addIssueToState,
handleEditIssue,
openIssuesListModal, openIssuesListModal,
handleDeleteIssue, handleDeleteIssue,
handleTrashBox, handleTrashBox,
removeIssue,
userAuth, userAuth,
}) => { }) => {
const { groupedByIssues, groupByProperty: selectedGroup, orderBy } = useIssueView(issues); const { groupedByIssues, groupByProperty: selectedGroup, orderBy } = useIssueView(issues);
@ -57,11 +61,13 @@ export const AllBoards: React.FC<Props> = ({
groupedByIssues={groupedByIssues} groupedByIssues={groupedByIssues}
selectedGroup={selectedGroup} selectedGroup={selectedGroup}
members={members} members={members}
handleEditIssue={handleEditIssue}
addIssueToState={() => addIssueToState(singleGroup, stateId)} addIssueToState={() => addIssueToState(singleGroup, stateId)}
handleDeleteIssue={handleDeleteIssue} handleDeleteIssue={handleDeleteIssue}
openIssuesListModal={openIssuesListModal ?? null} openIssuesListModal={openIssuesListModal ?? null}
orderBy={orderBy} orderBy={orderBy}
handleTrashBox={handleTrashBox} handleTrashBox={handleTrashBox}
removeIssue={removeIssue}
userAuth={userAuth} userAuth={userAuth}
/> />
); );

View File

@ -12,80 +12,97 @@ import {
// helpers // helpers
import { addSpaceIfCamelCase } from "helpers/string.helper"; import { addSpaceIfCamelCase } from "helpers/string.helper";
// types // types
import { IIssue } from "types"; import { IIssue, IProjectMember, NestedKeyOf } from "types";
type Props = { type Props = {
isCollapsed: boolean;
setIsCollapsed: React.Dispatch<React.SetStateAction<boolean>>;
groupedByIssues: { groupedByIssues: {
[key: string]: IIssue[]; [key: string]: IIssue[];
}; };
selectedGroup: NestedKeyOf<IIssue> | null;
groupTitle: string; groupTitle: string;
createdBy: string | null;
bgColor?: string; bgColor?: string;
addIssueToState: () => void; addIssueToState: () => void;
members: IProjectMember[] | undefined;
isCollapsed: boolean;
setIsCollapsed: React.Dispatch<React.SetStateAction<boolean>>;
}; };
export const BoardHeader: React.FC<Props> = ({ export const BoardHeader: React.FC<Props> = ({
isCollapsed,
setIsCollapsed,
groupedByIssues, groupedByIssues,
selectedGroup,
groupTitle, groupTitle,
createdBy,
bgColor, bgColor,
addIssueToState, addIssueToState,
}) => ( isCollapsed,
<div setIsCollapsed,
className={`flex justify-between p-3 pb-0 ${ members,
!isCollapsed ? "flex-col rounded-md border bg-gray-50" : "" }) => {
}`} const createdBy =
> selectedGroup === "created_by"
<div className={`flex items-center ${!isCollapsed ? "flex-col gap-2" : "gap-1"}`}> ? members?.find((m) => m.member.id === groupTitle)?.member.first_name ?? "loading..."
<div : null;
className={`flex cursor-pointer items-center gap-x-1 rounded-md bg-slate-900 px-2 ${
!isCollapsed ? "mb-2 flex-col gap-y-2 py-2" : "" let assignees: any;
}`} if (selectedGroup === "assignees") {
style={{ assignees = groupTitle.split(",");
border: `2px solid ${bgColor}`, assignees = assignees
backgroundColor: `${bgColor}20`, .map((a: string) => members?.find((m) => m.member.id === a)?.member.first_name)
}} .join(", ");
> }
<h2
className={`text-[0.9rem] font-medium capitalize`} return (
<div
className={`flex justify-between p-3 pb-0 ${
!isCollapsed ? "flex-col rounded-md border bg-gray-50" : ""
}`}
>
<div className={`flex items-center ${!isCollapsed ? "flex-col gap-2" : "gap-1"}`}>
<div
className={`flex cursor-pointer items-center gap-x-1 rounded-md bg-slate-900 px-2 ${
!isCollapsed ? "mb-2 flex-col gap-y-2 py-2" : ""
}`}
style={{ style={{
writingMode: !isCollapsed ? "vertical-rl" : "horizontal-tb", border: `2px solid ${bgColor}`,
backgroundColor: `${bgColor}20`,
}} }}
> >
{groupTitle === null || groupTitle === "null" <h2
? "None" className={`text-[0.9rem] font-medium capitalize`}
: createdBy style={{
? createdBy writingMode: !isCollapsed ? "vertical-rl" : "horizontal-tb",
: addSpaceIfCamelCase(groupTitle)} }}
</h2> >
<span className="ml-0.5 text-sm text-gray-500">{groupedByIssues[groupTitle].length}</span> {selectedGroup === "created_by"
? createdBy
: selectedGroup === "assignees"
? assignees
: addSpaceIfCamelCase(groupTitle)}
</h2>
<span className="ml-0.5 text-sm text-gray-500">{groupedByIssues[groupTitle].length}</span>
</div>
</div>
<div className={`flex items-center ${!isCollapsed ? "flex-col pb-2" : ""}`}>
<button
type="button"
className="grid h-7 w-7 place-items-center rounded p-1 outline-none duration-300 hover:bg-gray-200"
onClick={() => {
setIsCollapsed((prevData) => !prevData);
}}
>
{isCollapsed ? (
<ArrowsPointingInIcon className="h-4 w-4" />
) : (
<ArrowsPointingOutIcon className="h-4 w-4" />
)}
</button>
<button
type="button"
className="grid h-7 w-7 place-items-center rounded p-1 outline-none duration-300 hover:bg-gray-200"
onClick={addIssueToState}
>
<PlusIcon className="h-4 w-4" />
</button>
</div> </div>
</div> </div>
);
<div className={`flex items-center ${!isCollapsed ? "flex-col pb-2" : ""}`}> };
<button
type="button"
className="grid h-7 w-7 place-items-center rounded p-1 outline-none duration-300 hover:bg-gray-200"
onClick={() => {
setIsCollapsed((prevData) => !prevData);
}}
>
{isCollapsed ? (
<ArrowsPointingInIcon className="h-4 w-4" />
) : (
<ArrowsPointingOutIcon className="h-4 w-4" />
)}
</button>
<button
type="button"
className="grid h-7 w-7 place-items-center rounded p-1 outline-none duration-300 hover:bg-gray-200"
onClick={addIssueToState}
>
<PlusIcon className="h-4 w-4" />
</button>
</div>
</div>
);

View File

@ -25,11 +25,13 @@ type Props = {
}; };
selectedGroup: NestedKeyOf<IIssue> | null; selectedGroup: NestedKeyOf<IIssue> | null;
members: IProjectMember[] | undefined; members: IProjectMember[] | undefined;
handleEditIssue: (issue: IIssue) => void;
addIssueToState: () => void; addIssueToState: () => void;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
orderBy: NestedKeyOf<IIssue> | "manual" | null; orderBy: NestedKeyOf<IIssue> | "manual" | null;
handleTrashBox: (isDragging: boolean) => void; handleTrashBox: (isDragging: boolean) => void;
removeIssue: ((bridgeId: string) => void) | null;
userAuth: UserAuth; userAuth: UserAuth;
}; };
@ -40,11 +42,13 @@ export const SingleBoard: React.FC<Props> = ({
groupedByIssues, groupedByIssues,
selectedGroup, selectedGroup,
members, members,
handleEditIssue,
addIssueToState, addIssueToState,
handleDeleteIssue, handleDeleteIssue,
openIssuesListModal, openIssuesListModal,
orderBy, orderBy,
handleTrashBox, handleTrashBox,
removeIssue,
userAuth, userAuth,
}) => { }) => {
// collapse/expand // collapse/expand
@ -55,11 +59,6 @@ export const SingleBoard: React.FC<Props> = ({
const [properties] = useIssuesProperties(workspaceSlug as string, projectId as string); const [properties] = useIssuesProperties(workspaceSlug as string, projectId as string);
const createdBy =
selectedGroup === "created_by"
? members?.find((m) => m.member.id === groupTitle)?.member.first_name ?? "loading..."
: null;
if (selectedGroup === "priority") if (selectedGroup === "priority")
groupTitle === "high" groupTitle === "high"
? (bgColor = "#dc2626") ? (bgColor = "#dc2626")
@ -77,11 +76,12 @@ export const SingleBoard: React.FC<Props> = ({
<BoardHeader <BoardHeader
addIssueToState={addIssueToState} addIssueToState={addIssueToState}
bgColor={bgColor} bgColor={bgColor}
createdBy={createdBy} selectedGroup={selectedGroup}
groupTitle={groupTitle} groupTitle={groupTitle}
groupedByIssues={groupedByIssues} groupedByIssues={groupedByIssues}
isCollapsed={isCollapsed} isCollapsed={isCollapsed}
setIsCollapsed={setIsCollapsed} setIsCollapsed={setIsCollapsed}
members={members}
/> />
<StrictModeDroppable key={groupTitle} droppableId={groupTitle}> <StrictModeDroppable key={groupTitle} droppableId={groupTitle}>
{(provided, snapshot) => ( {(provided, snapshot) => (
@ -97,7 +97,9 @@ export const SingleBoard: React.FC<Props> = ({
key={issue.id} key={issue.id}
draggableId={issue.id} draggableId={issue.id}
index={index} index={index}
isDragDisabled={isNotAllowed || selectedGroup === "created_by"} isDragDisabled={
isNotAllowed || selectedGroup === "created_by" || selectedGroup === "assignees"
}
> >
{(provided, snapshot) => ( {(provided, snapshot) => (
<SingleBoardIssue <SingleBoardIssue
@ -106,10 +108,15 @@ export const SingleBoard: React.FC<Props> = ({
snapshot={snapshot} snapshot={snapshot}
type={type} type={type}
issue={issue} issue={issue}
selectedGroup={selectedGroup}
properties={properties} properties={properties}
editIssue={() => handleEditIssue(issue)}
handleDeleteIssue={handleDeleteIssue} handleDeleteIssue={handleDeleteIssue}
orderBy={orderBy} orderBy={orderBy}
handleTrashBox={handleTrashBox} handleTrashBox={handleTrashBox}
removeIssue={() => {
removeIssue && removeIssue(issue.bridge);
}}
userAuth={userAuth} userAuth={userAuth}
/> />
)} )}

View File

@ -23,6 +23,8 @@ import {
ViewPrioritySelect, ViewPrioritySelect,
ViewStateSelect, ViewStateSelect,
} from "components/issues/view-select"; } from "components/issues/view-select";
// ui
import { CustomMenu } from "components/ui";
// types // types
import { import {
CycleIssueResponse, CycleIssueResponse,
@ -41,7 +43,10 @@ type Props = {
provided: DraggableProvided; provided: DraggableProvided;
snapshot: DraggableStateSnapshot; snapshot: DraggableStateSnapshot;
issue: IIssue; issue: IIssue;
selectedGroup: NestedKeyOf<IIssue> | null;
properties: Properties; properties: Properties;
editIssue: () => void;
removeIssue?: (() => void) | null;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
orderBy: NestedKeyOf<IIssue> | "manual" | null; orderBy: NestedKeyOf<IIssue> | "manual" | null;
handleTrashBox: (isDragging: boolean) => void; handleTrashBox: (isDragging: boolean) => void;
@ -53,7 +58,10 @@ export const SingleBoardIssue: React.FC<Props> = ({
provided, provided,
snapshot, snapshot,
issue, issue,
selectedGroup,
properties, properties,
editIssue,
removeIssue,
handleDeleteIssue, handleDeleteIssue,
orderBy, orderBy,
handleTrashBox, handleTrashBox,
@ -170,13 +178,26 @@ export const SingleBoardIssue: React.FC<Props> = ({
<div className="group/card relative select-none p-2"> <div className="group/card relative select-none p-2">
{!isNotAllowed && ( {!isNotAllowed && (
<div className="absolute top-1.5 right-1.5 z-10 opacity-0 group-hover/card:opacity-100"> <div className="absolute top-1.5 right-1.5 z-10 opacity-0 group-hover/card:opacity-100">
<button {/* <button
type="button" type="button"
className="grid h-7 w-7 place-items-center rounded bg-white p-1 text-red-500 outline-none duration-300 hover:bg-red-50" className="grid h-7 w-7 place-items-center rounded bg-white p-1 text-red-500 outline-none duration-300 hover:bg-red-50"
onClick={() => handleDeleteIssue(issue)} onClick={() => handleDeleteIssue(issue)}
> >
<TrashIcon className="h-4 w-4" /> <TrashIcon className="h-4 w-4" />
</button> </button> */}
{type && !isNotAllowed && (
<CustomMenu width="auto" ellipsis>
<CustomMenu.MenuItem onClick={editIssue}>Edit</CustomMenu.MenuItem>
{type !== "issue" && removeIssue && (
<CustomMenu.MenuItem onClick={removeIssue}>
<>Remove from {type}</>
</CustomMenu.MenuItem>
)}
<CustomMenu.MenuItem onClick={() => handleDeleteIssue(issue)}>
Delete permanently
</CustomMenu.MenuItem>
</CustomMenu>
)}
</div> </div>
)} )}
<Link href={`/${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`}> <Link href={`/${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`}>
@ -195,7 +216,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
</a> </a>
</Link> </Link>
<div className="flex flex-wrap items-center gap-x-1 gap-y-2 text-xs"> <div className="flex flex-wrap items-center gap-x-1 gap-y-2 text-xs">
{properties.priority && ( {properties.priority && selectedGroup !== "priority" && (
<ViewPrioritySelect <ViewPrioritySelect
issue={issue} issue={issue}
partialUpdateIssue={partialUpdateIssue} partialUpdateIssue={partialUpdateIssue}
@ -203,7 +224,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
position="left" position="left"
/> />
)} )}
{properties.state && ( {properties.state && selectedGroup !== "state_detail.name" && (
<ViewStateSelect <ViewStateSelect
issue={issue} issue={issue}
partialUpdateIssue={partialUpdateIssue} partialUpdateIssue={partialUpdateIssue}

View File

@ -178,20 +178,29 @@ export const IssuesFilterView: React.FC<Props> = ({ issues }) => {
<div className="space-y-2 py-3"> <div className="space-y-2 py-3">
<h4 className="text-sm text-gray-600">Display Properties</h4> <h4 className="text-sm text-gray-600">Display Properties</h4>
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
{Object.keys(properties).map((key) => ( {Object.keys(properties).map((key) => {
<button if (
key={key} issueView === "kanban" &&
type="button" ((groupByProperty === "state_detail.name" && key === "state") ||
className={`rounded border px-2 py-1 text-xs capitalize ${ (groupByProperty === "priority" && key === "priority"))
properties[key as keyof Properties] )
? "border-theme bg-theme text-white" return;
: "border-gray-300"
}`} return (
onClick={() => setProperties(key as keyof Properties)} <button
> key={key}
{replaceUnderscoreIfSnakeCase(key)} type="button"
</button> className={`rounded border px-2 py-1 text-xs capitalize ${
))} properties[key as keyof Properties]
? "border-theme bg-theme text-white"
: "border-gray-300"
}`}
onClick={() => setProperties(key as keyof Properties)}
>
{replaceUnderscoreIfSnakeCase(key)}
</button>
);
})}
</div> </div>
</div> </div>
</div> </div>

View File

@ -452,9 +452,17 @@ export const IssuesView: React.FC<Props> = ({
states={states} states={states}
members={members} members={members}
addIssueToState={addIssueToState} addIssueToState={addIssueToState}
handleEditIssue={handleEditIssue}
openIssuesListModal={type !== "issue" ? openIssuesListModal : null} openIssuesListModal={type !== "issue" ? openIssuesListModal : null}
handleDeleteIssue={handleDeleteIssue} handleDeleteIssue={handleDeleteIssue}
handleTrashBox={handleTrashBox} handleTrashBox={handleTrashBox}
removeIssue={
type === "cycle"
? removeIssueFromCycle
: type === "module"
? removeIssueFromModule
: null
}
userAuth={userAuth} userAuth={userAuth}
/> />
)} )}

View File

@ -50,9 +50,17 @@ export const SingleList: React.FC<Props> = ({
const createdBy = const createdBy =
selectedGroup === "created_by" selectedGroup === "created_by"
? members?.find((m) => m.member.id === groupTitle)?.member.first_name ?? "loading..." ? members?.find((m) => m.member.id === groupTitle)?.member.first_name ?? "Loading..."
: null; : null;
let assignees: any;
if (selectedGroup === "assignees") {
assignees = groupTitle.split(",");
assignees = assignees
.map((a: string) => members?.find((m) => m.member.id === a)?.member.first_name)
.join(", ");
}
return ( return (
<Disclosure key={groupTitle} as="div" defaultOpen> <Disclosure key={groupTitle} as="div" defaultOpen>
{({ open }) => ( {({ open }) => (
@ -67,10 +75,10 @@ export const SingleList: React.FC<Props> = ({
</span> </span>
{selectedGroup !== null ? ( {selectedGroup !== null ? (
<h2 className="font-medium capitalize leading-5"> <h2 className="font-medium capitalize leading-5">
{groupTitle === null || groupTitle === "null" {selectedGroup === "created_by"
? "None"
: createdBy
? createdBy ? createdBy
: selectedGroup === "assignees"
? assignees
: addSpaceIfCamelCase(groupTitle)} : addSpaceIfCamelCase(groupTitle)}
</h2> </h2>
) : ( ) : (

View File

@ -10,6 +10,8 @@ import { Tab } from "@headlessui/react";
// services // services
import issuesServices from "services/issues.service"; import issuesServices from "services/issues.service";
import projectService from "services/project.service"; import projectService from "services/project.service";
// hooks
import useLocalStorage from "hooks/use-local-storage";
// components // components
import { SingleProgressStats } from "components/core"; import { SingleProgressStats } from "components/core";
// ui // ui
@ -20,7 +22,6 @@ import User from "public/user.png";
import { IIssue, IIssueLabels } from "types"; import { IIssue, IIssueLabels } from "types";
// fetch-keys // fetch-keys
import { PROJECT_ISSUE_LABELS, PROJECT_MEMBERS } from "constants/fetch-keys"; import { PROJECT_ISSUE_LABELS, PROJECT_MEMBERS } from "constants/fetch-keys";
import useLocalStorage from "hooks/use-local-storage";
// types // types
type Props = { type Props = {
groupedIssues: any; groupedIssues: any;
@ -39,8 +40,10 @@ const stateGroupColours: {
export const SidebarProgressStats: React.FC<Props> = ({ groupedIssues, issues }) => { export const SidebarProgressStats: React.FC<Props> = ({ groupedIssues, issues }) => {
const router = useRouter(); const router = useRouter();
const [tab, setTab] = useLocalStorage("tab", "Assignees");
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
const [tab, setTab] = useLocalStorage("tab", "Assignees");
const { data: issueLabels } = useSWR<IIssueLabels[]>( const { data: issueLabels } = useSWR<IIssueLabels[]>(
workspaceSlug && projectId ? PROJECT_ISSUE_LABELS(projectId as string) : null, workspaceSlug && projectId ? PROJECT_ISSUE_LABELS(projectId as string) : null,
workspaceSlug && projectId workspaceSlug && projectId

View File

@ -16,8 +16,9 @@ import {
IssueStateSelect, IssueStateSelect,
} from "components/issues/select"; } from "components/issues/select";
import { CycleSelect as IssueCycleSelect } from "components/cycles/select"; import { CycleSelect as IssueCycleSelect } from "components/cycles/select";
import { CreateUpdateStateModal } from "components/states"; import { CreateStateModal } from "components/states";
import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal"; import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal";
import { CreateLabelModal } from "components/labels";
// ui // ui
import { Button, CustomDatePicker, CustomMenu, Input, Loader } from "components/ui"; import { Button, CustomDatePicker, CustomMenu, Input, Loader } from "components/ui";
// icons // icons
@ -74,6 +75,7 @@ export const IssueForm: FC<IssueFormProps> = ({
const [mostSimilarIssue, setMostSimilarIssue] = useState<IIssue | undefined>(); const [mostSimilarIssue, setMostSimilarIssue] = useState<IIssue | undefined>();
const [cycleModal, setCycleModal] = useState(false); const [cycleModal, setCycleModal] = useState(false);
const [stateModal, setStateModal] = useState(false); const [stateModal, setStateModal] = useState(false);
const [labelModal, setLabelModal] = useState(false);
const [parentIssueListModalOpen, setParentIssueListModalOpen] = useState(false); const [parentIssueListModalOpen, setParentIssueListModalOpen] = useState(false);
const router = useRouter(); const router = useRouter();
@ -121,7 +123,7 @@ export const IssueForm: FC<IssueFormProps> = ({
<> <>
{projectId && ( {projectId && (
<> <>
<CreateUpdateStateModal <CreateStateModal
isOpen={stateModal} isOpen={stateModal}
handleClose={() => setStateModal(false)} handleClose={() => setStateModal(false)}
projectId={projectId} projectId={projectId}
@ -131,6 +133,11 @@ export const IssueForm: FC<IssueFormProps> = ({
setIsOpen={setCycleModal} setIsOpen={setCycleModal}
projectId={projectId} projectId={projectId}
/> />
<CreateLabelModal
isOpen={labelModal}
handleClose={() => setLabelModal(false)}
projectId={projectId}
/>
</> </>
)} )}
<form onSubmit={handleSubmit(handleCreateUpdateIssue)}> <form onSubmit={handleSubmit(handleCreateUpdateIssue)}>
@ -281,7 +288,12 @@ export const IssueForm: FC<IssueFormProps> = ({
control={control} control={control}
name="labels_list" name="labels_list"
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<IssueLabelSelect value={value} onChange={onChange} projectId={projectId} /> <IssueLabelSelect
setIsOpen={setLabelModal}
value={value}
onChange={onChange}
projectId={projectId}
/>
)} )}
/> />
<div> <div>

View File

@ -1,15 +1,13 @@
import React, { useEffect, useState } from "react"; import React, { useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR from "swr"; import useSWR from "swr";
// react-hook-form
import { useForm } from "react-hook-form";
// headless ui // headless ui
import { Combobox, Transition } from "@headlessui/react"; import { Combobox, Transition } from "@headlessui/react";
// icons // icons
import { RectangleGroupIcon, TagIcon } from "@heroicons/react/24/outline"; import { PlusIcon, RectangleGroupIcon, TagIcon } from "@heroicons/react/24/outline";
// services // services
import issuesServices from "services/issues.service"; import issuesServices from "services/issues.service";
// types // types
@ -18,55 +16,26 @@ import type { IIssueLabels } from "types";
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys"; import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
type Props = { type Props = {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
value: string[]; value: string[];
onChange: (value: string[]) => void; onChange: (value: string[]) => void;
projectId: string; projectId: string;
}; };
const defaultValues: Partial<IIssueLabels> = { export const IssueLabelSelect: React.FC<Props> = ({ setIsOpen, value, onChange, projectId }) => {
name: "",
};
export const IssueLabelSelect: React.FC<Props> = ({ value, onChange, projectId }) => {
// states // states
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
const [isOpen, setIsOpen] = useState(false); const { data: issueLabels } = useSWR<IIssueLabels[]>(
const { data: issueLabels, mutate: issueLabelsMutate } = useSWR<IIssueLabels[]>(
projectId ? PROJECT_ISSUE_LABELS(projectId) : null, projectId ? PROJECT_ISSUE_LABELS(projectId) : null,
workspaceSlug && projectId workspaceSlug && projectId
? () => issuesServices.getIssueLabels(workspaceSlug as string, projectId) ? () => issuesServices.getIssueLabels(workspaceSlug as string, projectId)
: null : null
); );
const onSubmit = async (data: IIssueLabels) => {
if (!projectId || !workspaceSlug || isSubmitting) return;
await issuesServices
.createIssueLabel(workspaceSlug as string, projectId as string, data)
.then((response) => {
issueLabelsMutate((prevData) => [...(prevData ?? []), response], false);
setIsOpen(false);
reset(defaultValues);
})
.catch((error) => {
console.log(error);
});
};
const {
formState: { isSubmitting },
setFocus,
reset,
} = useForm<IIssueLabels>({ defaultValues });
useEffect(() => {
isOpen && setFocus("name");
}, [isOpen, setFocus]);
const filteredOptions = const filteredOptions =
query === "" query === ""
? issueLabels ? issueLabels
@ -175,48 +144,14 @@ export const IssueLabelSelect: React.FC<Props> = ({ value, onChange, projectId }
) : ( ) : (
<p className="text-xs text-gray-500 px-2">Loading...</p> <p className="text-xs text-gray-500 px-2">Loading...</p>
)} )}
{/* <div className="cursor-default select-none p-2 hover:bg-indigo-50 hover:text-gray-900"> <button
{isOpen ? ( type="button"
<div className="flex items-center gap-x-1"> className="flex select-none w-full items-center gap-2 p-2 text-gray-400 outline-none hover:bg-indigo-50 hover:text-gray-900"
<Input onClick={() => setIsOpen(true)}
id="name" >
name="name" <PlusIcon className="h-3 w-3 text-gray-400" aria-hidden="true" />
type="text" <span className="text-xs whitespace-nowrap">Create label</span>
placeholder="Title" </button>
className="w-full"
autoComplete="off"
register={register}
validations={{
required: true,
}}
/>
<button
type="button"
className="grid place-items-center text-green-600"
disabled={isSubmitting}
onClick={handleSubmit(onSubmit)}
>
<PlusIcon className="h-4 w-4" />
</button>
<button
type="button"
className="grid place-items-center text-red-600"
onClick={() => setIsOpen(false)}
>
<XMarkIcon className="h-4 w-4" aria-hidden="true" />
</button>
</div>
) : (
<button
type="button"
className="flex items-center gap-2 w-full"
onClick={() => setIsOpen(true)}
>
<PlusIcon className="h-4 w-4 text-gray-400" aria-hidden="true" />
<span className="text-xs whitespace-nowrap">Create label</span>
</button>
)}
</div> */}
</div> </div>
</Combobox.Options> </Combobox.Options>
</Transition> </Transition>

View File

@ -82,14 +82,14 @@ export const SidebarCycleSelect: React.FC<Props> = ({
{cycles ? ( {cycles ? (
cycles.length > 0 ? ( cycles.length > 0 ? (
<> <>
<CustomSelect.Option value={null} className="capitalize">
None
</CustomSelect.Option>
{cycles.map((option) => ( {cycles.map((option) => (
<CustomSelect.Option key={option.id} value={option.id}> <CustomSelect.Option key={option.id} value={option.id}>
{option.name} {option.name}
</CustomSelect.Option> </CustomSelect.Option>
))} ))}
<CustomSelect.Option value={null} className="capitalize">
None
</CustomSelect.Option>
</> </>
) : ( ) : (
<div className="text-center">No cycles found</div> <div className="text-center">No cycles found</div>

View File

@ -81,14 +81,14 @@ export const SidebarModuleSelect: React.FC<Props> = ({
{modules ? ( {modules ? (
modules.length > 0 ? ( modules.length > 0 ? (
<> <>
<CustomSelect.Option value={null} className="capitalize">
None
</CustomSelect.Option>
{modules.map((option) => ( {modules.map((option) => (
<CustomSelect.Option key={option.id} value={option.id}> <CustomSelect.Option key={option.id} value={option.id}>
{option.name} {option.name}
</CustomSelect.Option> </CustomSelect.Option>
))} ))}
<CustomSelect.Option value={null} className="capitalize">
None
</CustomSelect.Option>
</> </>
) : ( ) : (
<div className="text-center">No modules found</div> <div className="text-center">No modules found</div>

View File

@ -1,4 +1,4 @@
import React, { useCallback, useState } from "react"; import React, { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
@ -144,6 +144,12 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
[workspaceSlug, projectId, issueId, issueDetail] [workspaceSlug, projectId, issueId, issueDetail]
); );
useEffect(() => {
if (!createLabelForm) return;
reset();
}, [createLabelForm, reset]);
const isNotAllowed = userAuth.isGuest || userAuth.isViewer; const isNotAllowed = userAuth.isGuest || userAuth.isViewer;
return ( return (
@ -431,24 +437,25 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
</Listbox> </Listbox>
)} )}
/> />
<button {!isNotAllowed && (
type="button" <button
className={`flex ${ type="button"
isNotAllowed ? "cursor-not-allowed" : "cursor-pointer hover:bg-gray-100" className={`flex ${
} items-center gap-1 rounded-2xl border px-2 py-0.5 text-xs`} isNotAllowed ? "cursor-not-allowed" : "cursor-pointer hover:bg-gray-100"
onClick={() => setCreateLabelForm((prevData) => !prevData)} } items-center gap-1 rounded-2xl border px-2 py-0.5 text-xs`}
disabled={isNotAllowed} onClick={() => setCreateLabelForm((prevData) => !prevData)}
> >
{createLabelForm ? ( {createLabelForm ? (
<> <>
<XMarkIcon className="h-3 w-3" /> Cancel <XMarkIcon className="h-3 w-3" /> Cancel
</> </>
) : ( ) : (
<> <>
<PlusIcon className="h-3 w-3" /> New <PlusIcon className="h-3 w-3" /> New
</> </>
)} )}
</button> </button>
)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,189 @@
import React, { useEffect } from "react";
import { useRouter } from "next/router";
import { mutate } from "swr";
// react-hook-form
import { Controller, useForm } from "react-hook-form";
// react-color
import { TwitterPicker } from "react-color";
// headless ui
import { Dialog, Popover, Transition } from "@headlessui/react";
// services
import issuesService from "services/issues.service";
// ui
import { Button, Input } from "components/ui";
// icons
import { ChevronDownIcon } from "@heroicons/react/24/outline";
// types
import type { IIssueLabels, IState } from "types";
// constants
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
// types
type Props = {
isOpen: boolean;
projectId: string;
handleClose: () => void;
};
const defaultValues: Partial<IState> = {
name: "",
color: "#000000",
};
export const CreateLabelModal: React.FC<Props> = ({ isOpen, projectId, handleClose }) => {
const router = useRouter();
const { workspaceSlug } = router.query;
const {
register,
formState: { errors, isSubmitting },
handleSubmit,
watch,
control,
reset,
setError,
} = useForm<IIssueLabels>({
defaultValues,
});
const onClose = () => {
handleClose();
reset(defaultValues);
};
const onSubmit = async (formData: IIssueLabels) => {
if (!workspaceSlug) return;
await issuesService
.createIssueLabel(workspaceSlug as string, projectId as string, formData)
.then((res) => {
mutate<IIssueLabels[]>(
PROJECT_ISSUE_LABELS(projectId),
(prevData) => [res, ...(prevData ?? [])],
false
);
onClose();
})
.catch((error) => {
console.log(error);
});
};
return (
<Transition.Root show={isOpen} as={React.Fragment}>
<Dialog as="div" className="relative z-30" onClose={onClose}>
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
</Transition.Child>
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<Dialog.Panel className="relative transform rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-2xl sm:p-6">
<form onSubmit={handleSubmit(onSubmit)}>
<div>
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
Create Label
</Dialog.Title>
<div className="mt-8 flex items-center gap-2">
<Popover className="relative">
{({ open }) => (
<>
<Popover.Button
className={`group inline-flex items-center rounded-sm bg-white text-base font-medium hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
open ? "text-gray-900" : "text-gray-500"
}`}
>
<span>Color</span>
{watch("color") && watch("color") !== "" && (
<span
className="ml-2 h-4 w-4 rounded"
style={{
backgroundColor: watch("color") ?? "green",
}}
/>
)}
<ChevronDownIcon
className={`ml-2 h-5 w-5 group-hover:text-gray-500 ${
open ? "text-gray-600" : "text-gray-400"
}`}
aria-hidden="true"
/>
</Popover.Button>
<Transition
as={React.Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-1"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
>
<Popover.Panel className="fixed left-5 z-50 mt-3 w-screen max-w-xs transform px-2 sm:px-0">
<Controller
name="color"
control={control}
render={({ field: { value, onChange } }) => (
<TwitterPicker
color={value}
onChange={(value) => onChange(value.hex)}
/>
)}
/>
</Popover.Panel>
</Transition>
</>
)}
</Popover>
<Input
type="text"
id="name"
name="name"
placeholder="Enter name"
autoComplete="off"
error={errors.name}
register={register}
width="full"
validations={{
required: "Name is required",
}}
/>
</div>
</div>
<div className="mt-5 flex justify-end gap-2">
<Button theme="secondary" onClick={onClose}>
Cancel
</Button>
<Button type="submit" disabled={isSubmitting}>
{isSubmitting ? "Creating Label..." : "Create Label"}
</Button>
</div>
</form>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
);
};

View File

@ -1,3 +1,4 @@
export * from "./create-label-modal";
export * from "./create-update-label-inline"; export * from "./create-update-label-inline";
export * from "./labels-list-modal"; export * from "./labels-list-modal";
export * from "./single-label-group"; export * from "./single-label-group";

View File

@ -65,10 +65,6 @@ export const DeleteModuleModal: React.FC<Props> = ({ isOpen, setIsOpen, data })
}); });
}; };
useEffect(() => {
data && setIsOpen(true);
}, [data, setIsOpen]);
return ( return (
<Transition.Root show={isOpen} as={React.Fragment}> <Transition.Root show={isOpen} as={React.Fragment}>
<Dialog <Dialog

View File

@ -23,6 +23,7 @@ import modulesService from "services/modules.service";
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
// components // components
import { import {
DeleteModuleModal,
ModuleLinkModal, ModuleLinkModal,
SidebarLeadSelect, SidebarLeadSelect,
SidebarMembersSelect, SidebarMembersSelect,
@ -57,16 +58,10 @@ type Props = {
module?: IModule; module?: IModule;
isOpen: boolean; isOpen: boolean;
moduleIssues: ModuleIssueResponse[] | undefined; moduleIssues: ModuleIssueResponse[] | undefined;
handleDeleteModule: () => void;
}; };
export const ModuleDetailsSidebar: React.FC<Props> = ({ export const ModuleDetailsSidebar: React.FC<Props> = ({ issues, module, isOpen, moduleIssues }) => {
issues, const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
module,
isOpen,
moduleIssues,
handleDeleteModule,
}) => {
const [moduleLinkModal, setModuleLinkModal] = useState(false); const [moduleLinkModal, setModuleLinkModal] = useState(false);
const router = useRouter(); const router = useRouter();
@ -127,6 +122,11 @@ export const ModuleDetailsSidebar: React.FC<Props> = ({
handleClose={() => setModuleLinkModal(false)} handleClose={() => setModuleLinkModal(false)}
module={module} module={module}
/> />
<DeleteModuleModal
isOpen={moduleDeleteModal}
setIsOpen={setModuleDeleteModal}
data={module}
/>
<div <div
className={`fixed top-0 ${ className={`fixed top-0 ${
isOpen ? "right-0" : "-right-[24rem]" isOpen ? "right-0" : "-right-[24rem]"
@ -163,7 +163,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = ({
<button <button
type="button" type="button"
className="rounded-md border border-red-500 p-2 text-red-500 shadow-sm duration-300 hover:bg-red-50 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500" className="rounded-md border border-red-500 p-2 text-red-500 shadow-sm duration-300 hover:bg-red-50 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
onClick={() => handleDeleteModule()} onClick={() => setModuleDeleteModal(true)}
> >
<TrashIcon className="h-3.5 w-3.5" /> <TrashIcon className="h-3.5 w-3.5" />
</button> </button>

View File

@ -1,18 +1,18 @@
import React, { useState } from "react"; import React, { useState } from "react";
import Link from "next/link"; import Link from "next/link";
import Image from "next/image";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
// components // components
import { DeleteModuleModal } from "components/modules"; import { DeleteModuleModal } from "components/modules";
// ui
import { AssigneesList, Avatar } from "components/ui";
// icons // icons
import { CalendarDaysIcon, TrashIcon } from "@heroicons/react/24/outline"; import { CalendarDaysIcon, TrashIcon } from "@heroicons/react/24/outline";
import User from "public/user.png";
// helpers // helpers
import { renderShortNumericDateFormat } from "helpers/date-time.helper"; import { renderShortNumericDateFormat } from "helpers/date-time.helper";
// types // types
import { IModule, SelectModuleType } from "types"; import { IModule } from "types";
// common // common
import { MODULE_STATUS } from "constants/module"; import { MODULE_STATUS } from "constants/module";
@ -21,132 +21,73 @@ type Props = {
}; };
export const SingleModuleCard: React.FC<Props> = ({ module }) => { export const SingleModuleCard: React.FC<Props> = ({ module }) => {
const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
const [selectedModuleForDelete, setSelectedModuleForDelete] = useState<SelectModuleType>();
const handleDeleteModule = () => { const handleDeleteModule = () => {
if (!module) return; if (!module) return;
setSelectedModuleForDelete({ ...module, actionType: "delete" });
setModuleDeleteModal(true); setModuleDeleteModal(true);
}; };
return ( return (
<div className="group/card h-full w-full relative select-none p-2"> <>
<div className="absolute top-4 right-4 z-50 bg-red-200 opacity-0 group-hover/card:opacity-100">
<button
type="button"
className="grid h-7 w-7 place-items-center bg-white p-1 text-red-500 outline-none duration-300 hover:bg-red-50"
onClick={() => handleDeleteModule()}
>
<TrashIcon className="h-4 w-4" />
</button>
</div>
<DeleteModuleModal <DeleteModuleModal
isOpen={ isOpen={moduleDeleteModal}
moduleDeleteModal &&
!!selectedModuleForDelete &&
selectedModuleForDelete.actionType === "delete"
}
setIsOpen={setModuleDeleteModal} setIsOpen={setModuleDeleteModal}
data={selectedModuleForDelete} data={module}
/> />
<Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}> <div className="group/card h-full w-full relative select-none p-2">
<a className="flex flex-col cursor-pointer rounded-md border bg-white p-3 "> <div className="absolute top-4 right-4 z-10 bg-red-200 opacity-0 group-hover/card:opacity-100">
<span className="w-3/4 text-ellipsis overflow-hidden">{module.name}</span> <button
<div className="mt-4 grid grid-cols-2 gap-2 text-xs md:grid-cols-4"> type="button"
<div className="space-y-2"> className="grid h-7 w-7 place-items-center bg-white p-1 text-red-500 outline-none duration-300 hover:bg-red-50"
<h6 className="text-gray-500">LEAD</h6> onClick={() => handleDeleteModule()}
<div> >
{module.lead ? ( <TrashIcon className="h-4 w-4" />
module.lead_detail?.avatar && module.lead_detail.avatar !== "" ? ( </button>
<div className="h-5 w-5 rounded-full border-2 border-white"> </div>
<Image <Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}>
src={module.lead_detail.avatar} <a className="flex flex-col cursor-pointer rounded-md border bg-white p-3 ">
height="100%" <span className="w-3/4 text-ellipsis overflow-hidden">{module.name}</span>
width="100%" <div className="mt-4 grid grid-cols-2 gap-2 text-xs md:grid-cols-4">
className="rounded-full" <div className="space-y-2">
alt={module.lead_detail.first_name} <h6 className="text-gray-500">LEAD</h6>
/> <div>
</div> <Avatar user={module.lead_detail} />
) : ( </div>
<div className="grid h-5 w-5 place-items-center rounded-full border-2 border-white bg-gray-700 capitalize text-white"> </div>
{module.lead_detail?.first_name && module.lead_detail.first_name !== "" <div className="space-y-2">
? module.lead_detail.first_name.charAt(0) <h6 className="text-gray-500">MEMBERS</h6>
: module.lead_detail?.email.charAt(0)} <div className="flex items-center gap-1 text-xs">
</div> <AssigneesList users={module.members_detail} />
) </div>
) : ( </div>
"N/A" <div className="space-y-2">
)} <h6 className="text-gray-500">END DATE</h6>
<div className="flex w-min cursor-pointer items-center gap-1 whitespace-nowrap rounded border px-1.5 py-0.5 text-xs shadow-sm">
<CalendarDaysIcon className="h-3 w-3" />
{renderShortNumericDateFormat(module.target_date ?? "")}
</div>
</div>
<div className="space-y-2">
<h6 className="text-gray-500">STATUS</h6>
<div className="flex items-center gap-2 capitalize">
<span
className="h-2 w-2 flex-shrink-0 rounded-full"
style={{
backgroundColor: MODULE_STATUS.find((s) => s.value === module.status)?.color,
}}
/>
{module.status}
</div>
</div> </div>
</div> </div>
<div className="space-y-2"> </a>
<h6 className="text-gray-500">MEMBERS</h6> </Link>
<div className="flex items-center gap-1 text-xs"> </div>
{module.members && module.members.length > 0 ? ( </>
module?.members_detail?.map((member, index: number) => (
<div
key={index}
className={`relative z-[1] h-5 w-5 rounded-full ${
index !== 0 ? "-ml-2.5" : ""
}`}
>
{member?.avatar && member.avatar !== "" ? (
<div className="h-5 w-5 rounded-full border-2 border-white bg-white">
<Image
src={member.avatar}
height="100%"
width="100%"
className="rounded-full"
alt={member?.first_name}
/>
</div>
) : (
<div className="grid h-5 w-5 place-items-center rounded-full border-2 border-white bg-gray-700 capitalize text-white">
{member?.first_name && member.first_name !== ""
? member.first_name.charAt(0)
: member?.email?.charAt(0)}
</div>
)}
</div>
))
) : (
<div className="h-5 w-5 rounded-full border-2 border-white bg-white">
<Image
src={User}
height="100%"
width="100%"
className="rounded-full"
alt="No user"
/>
</div>
)}
</div>
</div>
<div className="space-y-2">
<h6 className="text-gray-500">END DATE</h6>
<div className="flex w-min cursor-pointer items-center gap-1 whitespace-nowrap rounded border px-1.5 py-0.5 text-xs shadow-sm">
<CalendarDaysIcon className="h-3 w-3" />
{renderShortNumericDateFormat(module.target_date ?? "")}
</div>
</div>
<div className="space-y-2">
<h6 className="text-gray-500">STATUS</h6>
<div className="flex items-center gap-2 capitalize">
<span
className="h-2 w-2 flex-shrink-0 rounded-full"
style={{
backgroundColor: MODULE_STATUS.find((s) => s.value === module.status)?.color,
}}
/>
{module.status}
</div>
</div>
</div>
</a>
</Link>
</div>
); );
}; };

View File

@ -0,0 +1,227 @@
import React, { useEffect } from "react";
import { useRouter } from "next/router";
import { mutate } from "swr";
// react-hook-form
import { Controller, useForm } from "react-hook-form";
// react-color
import { TwitterPicker } from "react-color";
// headless ui
import { Dialog, Popover, Transition } from "@headlessui/react";
// services
import stateService from "services/state.service";
// ui
import { Button, Input, Select, TextArea } from "components/ui";
// icons
import { ChevronDownIcon } from "@heroicons/react/24/outline";
// types
import type { IState } from "types";
// fetch keys
import { STATE_LIST } from "constants/fetch-keys";
// constants
import { GROUP_CHOICES } from "constants/project";
// types
type Props = {
isOpen: boolean;
projectId: string;
handleClose: () => void;
};
const defaultValues: Partial<IState> = {
name: "",
description: "",
color: "#000000",
group: "backlog",
};
export const CreateStateModal: React.FC<Props> = ({ isOpen, projectId, handleClose }) => {
const router = useRouter();
const { workspaceSlug } = router.query;
const {
register,
formState: { errors, isSubmitting },
handleSubmit,
watch,
control,
reset,
setError,
} = useForm<IState>({
defaultValues,
});
const onClose = () => {
handleClose();
reset(defaultValues);
};
const onSubmit = async (formData: IState) => {
if (!workspaceSlug) return;
const payload: IState = {
...formData,
};
await stateService
.createState(workspaceSlug as string, projectId, payload)
.then((res) => {
mutate(STATE_LIST(projectId));
onClose();
})
.catch((err) => {
Object.keys(err).map((key) => {
setError(key as keyof IState, {
message: err[key].join(", "),
});
});
});
};
return (
<Transition.Root show={isOpen} as={React.Fragment}>
<Dialog as="div" className="relative z-30" onClose={onClose}>
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
</Transition.Child>
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-2xl sm:p-6">
<form onSubmit={handleSubmit(onSubmit)}>
<div>
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
Create State
</Dialog.Title>
<div className="mt-2 space-y-3">
<div>
<Input
id="name"
label="Name"
name="name"
type="name"
placeholder="Enter name"
autoComplete="off"
error={errors.name}
register={register}
validations={{
required: "Name is required",
}}
/>
</div>
<div>
<Select
id="group"
label="Group"
name="group"
error={errors.group}
register={register}
validations={{
required: "Group is required",
}}
options={Object.keys(GROUP_CHOICES).map((key) => ({
value: key,
label: GROUP_CHOICES[key as keyof typeof GROUP_CHOICES],
}))}
/>
</div>
<div>
<Popover className="relative">
{({ open }) => (
<>
<Popover.Button
className={`group inline-flex items-center rounded-md bg-white text-base font-medium hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
open ? "text-gray-900" : "text-gray-500"
}`}
>
<span>Color</span>
{watch("color") && watch("color") !== "" && (
<span
className="ml-2 h-4 w-4 rounded"
style={{
backgroundColor: watch("color") ?? "green",
}}
/>
)}
<ChevronDownIcon
className={`ml-2 h-5 w-5 group-hover:text-gray-500 ${
open ? "text-gray-600" : "text-gray-400"
}`}
aria-hidden="true"
/>
</Popover.Button>
<Transition
as={React.Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-1"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
>
<Popover.Panel className="fixed left-5 z-50 mt-3 w-screen max-w-xs transform px-2 sm:px-0">
<Controller
name="color"
control={control}
render={({ field: { value, onChange } }) => (
<TwitterPicker
color={value}
onChange={(value) => onChange(value.hex)}
/>
)}
/>
</Popover.Panel>
</Transition>
</>
)}
</Popover>
</div>
<div>
<TextArea
id="description"
name="description"
label="Description"
placeholder="Enter description"
error={errors.description}
register={register}
/>
</div>
</div>
</div>
<div className="mt-5 flex justify-end gap-2">
<Button theme="secondary" onClick={onClose}>
Cancel
</Button>
<Button type="submit" disabled={isSubmitting}>
{isSubmitting ? "Creating State..." : "Create State"}
</Button>
</div>
</form>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
);
};

View File

@ -1,263 +0,0 @@
import React, { useEffect } from "react";
import { useRouter } from "next/router";
import { mutate } from "swr";
// react-hook-form
import { Controller, useForm } from "react-hook-form";
// react-color
import { TwitterPicker } from "react-color";
// headless ui
import { Dialog, Popover, Transition } from "@headlessui/react";
// services
import stateService from "services/state.service";
// ui
import { Button, Input, Select, TextArea } from "components/ui";
// icons
import { ChevronDownIcon } from "@heroicons/react/24/outline";
// types
import type { IState } from "types";
// fetch keys
import { STATE_LIST } from "constants/fetch-keys";
// constants
import { GROUP_CHOICES } from "constants/project";
// types
type Props = {
isOpen: boolean;
projectId: string;
data?: IState;
handleClose: () => void;
};
const defaultValues: Partial<IState> = {
name: "",
description: "",
color: "#000000",
group: "backlog",
};
export const CreateUpdateStateModal: React.FC<Props> = ({
isOpen,
data,
projectId,
handleClose,
}) => {
const router = useRouter();
const { workspaceSlug } = router.query;
const {
register,
formState: { errors, isSubmitting },
handleSubmit,
watch,
control,
reset,
setError,
} = useForm<IState>({
defaultValues,
});
useEffect(() => {
if (data) {
reset(data);
} else {
reset(defaultValues);
}
}, [data, reset]);
const onClose = () => {
handleClose();
reset(defaultValues);
};
const onSubmit = async (formData: IState) => {
if (!workspaceSlug) return;
const payload: IState = {
...formData,
};
if (!data) {
await stateService
.createState(workspaceSlug as string, projectId, payload)
.then((res) => {
mutate(STATE_LIST(projectId));
onClose();
})
.catch((err) => {
Object.keys(err).map((key) => {
setError(key as keyof IState, {
message: err[key].join(", "),
});
});
});
} else {
await stateService
.updateState(workspaceSlug as string, projectId, data.id, payload)
.then((res) => {
mutate(STATE_LIST(projectId));
onClose();
})
.catch((err) => {
Object.keys(err).map((key) => {
setError(key as keyof IState, {
message: err[key].join(", "),
});
});
});
}
};
return (
<Transition.Root show={isOpen} as={React.Fragment}>
<Dialog as="div" className="relative z-30" onClose={onClose}>
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
</Transition.Child>
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
<Transition.Child
as={React.Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-2xl sm:p-6">
<form onSubmit={handleSubmit(onSubmit)}>
<div>
<div className="mt-3 sm:mt-5">
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
{data ? "Update" : "Create"} State
</Dialog.Title>
<div className="mt-2 space-y-3">
<div>
<Input
id="name"
label="Name"
name="name"
type="name"
placeholder="Enter name"
autoComplete="off"
error={errors.name}
register={register}
validations={{
required: "Name is required",
}}
/>
</div>
<div>
<Select
id="group"
label="Group"
name="group"
error={errors.group}
register={register}
validations={{
required: "Group is required",
}}
options={Object.keys(GROUP_CHOICES).map((key) => ({
value: key,
label: GROUP_CHOICES[key as keyof typeof GROUP_CHOICES],
}))}
/>
</div>
<div>
<Popover className="relative">
{({ open }) => (
<>
<Popover.Button
className={`group inline-flex items-center rounded-md bg-white text-base font-medium hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
open ? "text-gray-900" : "text-gray-500"
}`}
>
<span>Color</span>
{watch("color") && watch("color") !== "" && (
<span
className="ml-2 h-4 w-4 rounded"
style={{
backgroundColor: watch("color") ?? "green",
}}
/>
)}
<ChevronDownIcon
className={`ml-2 h-5 w-5 group-hover:text-gray-500 ${
open ? "text-gray-600" : "text-gray-400"
}`}
aria-hidden="true"
/>
</Popover.Button>
<Transition
as={React.Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-1"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
>
<Popover.Panel className="fixed left-5 z-50 mt-3 w-screen max-w-xs transform px-2 sm:px-0">
<Controller
name="color"
control={control}
render={({ field: { value, onChange } }) => (
<TwitterPicker
color={value}
onChange={(value) => onChange(value.hex)}
/>
)}
/>
</Popover.Panel>
</Transition>
</>
)}
</Popover>
</div>
<div>
<TextArea
id="description"
name="description"
label="Description"
placeholder="Enter description"
error={errors.description}
register={register}
/>
</div>
</div>
</div>
</div>
<div className="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3">
<Button theme="secondary" onClick={onClose}>
Cancel
</Button>
<Button type="submit" disabled={isSubmitting}>
{data
? isSubmitting
? "Updating State..."
: "Update State"
: isSubmitting
? "Creating State..."
: "Create State"}
</Button>
</div>
</form>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
);
};

View File

@ -1,4 +1,4 @@
export * from "./create-update-state-inline"; export * from "./create-update-state-inline";
export * from "./create-update-state-modal"; export * from "./create-state-modal";
export * from "./delete-state-modal"; export * from "./delete-state-modal";
export * from "./single-state"; export * from "./single-state";

View File

@ -142,13 +142,16 @@ export const SingleState: React.FC<Props> = ({
}`} }`}
> >
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<div <span
className="h-3 w-3 flex-shrink-0 rounded-full" className="h-3 w-3 flex-shrink-0 rounded-full"
style={{ style={{
backgroundColor: state.color, backgroundColor: state.color,
}} }}
/> />
<h6 className="text-sm">{addSpaceIfCamelCase(state.name)}</h6> <div>
<h6 className="text-sm">{addSpaceIfCamelCase(state.name)}</h6>
<p className="text-xs text-gray-400">{state.description}</p>
</div>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{index !== 0 && ( {index !== 0 && (

View File

@ -13,7 +13,7 @@ import { IUser, IUserLite } from "types";
import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; import { WORKSPACE_MEMBERS } from "constants/fetch-keys";
type AvatarProps = { type AvatarProps = {
user: Partial<IUser> | Partial<IUserLite> | undefined; user?: Partial<IUser> | Partial<IUserLite> | IUser | IUserLite | undefined | null;
index?: number; index?: number;
}; };

View File

@ -1 +0,0 @@
export * from "./avatar";

View File

@ -1,4 +1,3 @@
// components
export * from "./button"; export * from "./button";
export * from "./custom-listbox"; export * from "./custom-listbox";
export * from "./custom-menu"; export * from "./custom-menu";
@ -11,6 +10,6 @@ export * from "./outline-button";
export * from "./select"; export * from "./select";
export * from "./spinner"; export * from "./spinner";
export * from "./text-area"; export * from "./text-area";
export * from "./tooltip";
export * from "./avatar"; export * from "./avatar";
export * from "./datepicker"; export * from "./datepicker";
export * from "./tooltip";

View File

@ -5,6 +5,7 @@ export const GROUP_BY_OPTIONS: Array<{ name: string; key: NestedKeyOf<IIssue> |
{ name: "State", key: "state_detail.name" }, { name: "State", key: "state_detail.name" },
{ name: "Priority", key: "priority" }, { name: "Priority", key: "priority" },
{ name: "Created By", key: "created_by" }, { name: "Created By", key: "created_by" },
{ name: "Assignee", key: "assignees" },
{ name: "None", key: null }, { name: "None", key: null },
]; ];

View File

@ -58,7 +58,7 @@ type ReducerFunctionType = (state: StateType, action: ReducerActionType) => Stat
export const initialState: StateType = { export const initialState: StateType = {
issueView: "list", issueView: "list",
groupByProperty: null, groupByProperty: null,
orderBy: null, orderBy: "created_at",
filterIssue: null, filterIssue: null,
}; };
@ -122,6 +122,7 @@ export const reducer: ReducerFunctionType = (state, action) => {
...payload, ...payload,
}; };
} }
default: { default: {
return state; return state;
} }

View File

@ -23,20 +23,12 @@ import AppLayout from "layouts/app-layout";
import { IssueViewContextProvider } from "contexts/issue-view.context"; import { IssueViewContextProvider } from "contexts/issue-view.context";
// components // components
import { ExistingIssuesListModal, IssuesFilterView, IssuesView } from "components/core"; import { ExistingIssuesListModal, IssuesFilterView, IssuesView } from "components/core";
import { CreateUpdateIssueModal } from "components/issues"; import { ModuleDetailsSidebar } from "components/modules";
import { DeleteModuleModal, ModuleDetailsSidebar } from "components/modules";
// ui // ui
import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui"; import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui";
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
// types // types
import { import { IModule, ModuleIssueResponse, UserAuth } from "types";
IIssue,
IModule,
ModuleIssueResponse,
SelectIssue,
SelectModuleType,
UserAuth,
} from "types";
// fetch-keys // fetch-keys
import { import {
@ -47,15 +39,8 @@ import {
} from "constants/fetch-keys"; } from "constants/fetch-keys";
const SingleModule: React.FC<UserAuth> = (props) => { const SingleModule: React.FC<UserAuth> = (props) => {
const [moduleSidebar, setModuleSidebar] = useState(true);
const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
const [selectedIssues, setSelectedIssues] = useState<SelectIssue>(null);
const [moduleIssuesListModal, setModuleIssuesListModal] = useState(false); const [moduleIssuesListModal, setModuleIssuesListModal] = useState(false);
const [createUpdateIssueModal, setCreateUpdateIssueModal] = useState(false); const [moduleSidebar, setModuleSidebar] = useState(true);
const [selectedModuleForDelete, setSelectedModuleForDelete] = useState<SelectModuleType>();
const [preloadedData, setPreloadedData] = useState<
(Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | null
>(null);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, moduleId } = router.query; const { workspaceSlug, projectId, moduleId } = router.query;
@ -119,43 +104,12 @@ const SingleModule: React.FC<UserAuth> = (props) => {
.catch((e) => console.log(e)); .catch((e) => console.log(e));
}; };
const openCreateIssueModal = (
issue?: IIssue,
actionType: "create" | "edit" | "delete" = "create"
) => {
if (issue) {
setPreloadedData(null);
setSelectedIssues({ ...issue, actionType });
} else setSelectedIssues(null);
setCreateUpdateIssueModal(true);
};
const openIssuesListModal = () => { const openIssuesListModal = () => {
setModuleIssuesListModal(true); setModuleIssuesListModal(true);
}; };
const handleDeleteModule = () => {
if (!moduleDetails) return;
setSelectedModuleForDelete({ ...moduleDetails, actionType: "delete" });
setModuleDeleteModal(true);
};
return ( return (
<IssueViewContextProvider> <IssueViewContextProvider>
{moduleId && (
<CreateUpdateIssueModal
isOpen={createUpdateIssueModal && selectedIssues?.actionType !== "delete"}
data={selectedIssues}
prePopulateData={
preloadedData
? { module: moduleId as string, ...preloadedData }
: { module: moduleId as string, ...selectedIssues }
}
handleClose={() => setCreateUpdateIssueModal(false)}
/>
)}
<ExistingIssuesListModal <ExistingIssuesListModal
isOpen={moduleIssuesListModal} isOpen={moduleIssuesListModal}
handleClose={() => setModuleIssuesListModal(false)} handleClose={() => setModuleIssuesListModal(false)}
@ -163,15 +117,6 @@ const SingleModule: React.FC<UserAuth> = (props) => {
issues={issues?.results.filter((i) => !i.issue_module) ?? []} issues={issues?.results.filter((i) => !i.issue_module) ?? []}
handleOnSubmit={handleAddIssuesToModule} handleOnSubmit={handleAddIssuesToModule}
/> />
<DeleteModuleModal
isOpen={
moduleDeleteModal &&
!!selectedModuleForDelete &&
selectedModuleForDelete.actionType === "delete"
}
setIsOpen={setModuleDeleteModal}
data={selectedModuleForDelete}
/>
<AppLayout <AppLayout
breadcrumbs={ breadcrumbs={
<Breadcrumbs> <Breadcrumbs>
@ -271,7 +216,6 @@ const SingleModule: React.FC<UserAuth> = (props) => {
module={moduleDetails} module={moduleDetails}
isOpen={moduleSidebar} isOpen={moduleSidebar}
moduleIssues={moduleIssues} moduleIssues={moduleIssues}
handleDeleteModule={handleDeleteModule}
/> />
</AppLayout> </AppLayout>
</IssueViewContextProvider> </IssueViewContextProvider>

View File

@ -80,7 +80,7 @@ const StatesSettings: NextPage<UserAuth> = (props) => {
<div className="space-y-8"> <div className="space-y-8">
<div> <div>
<h3 className="text-3xl font-bold leading-6 text-gray-900">States</h3> <h3 className="text-3xl font-bold leading-6 text-gray-900">States</h3>
<p className="mt-4 text-sm text-gray-500">Manage the state of this project.</p> <p className="mt-4 text-sm text-gray-500">Manage the states of this project.</p>
</div> </div>
<div className="flex flex-col justify-between gap-4"> <div className="flex flex-col justify-between gap-4">
{states && projectDetails ? ( {states && projectDetails ? (

View File

@ -3,19 +3,21 @@ import Link from "next/link";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR from "swr"; import useSWR from "swr";
// icons // lib
import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline"; import { requiredAuth } from "lib/auth";
// services // services
import workspaceService from "services/workspace.service"; import workspaceService from "services/workspace.service";
// hooks // hooks
import useUser from "hooks/use-user"; import useUser from "hooks/use-user";
import { requiredAuth } from "lib/auth"; import useToast from "hooks/use-toast";
// layouts // layouts
import DefaultLayout from "layouts/default-layout"; import DefaultLayout from "layouts/default-layout";
// components // components
import SingleInvitation from "components/workspace/single-invitation"; import SingleInvitation from "components/workspace/single-invitation";
// ui // ui
import { Button, Spinner, EmptySpace, EmptySpaceItem } from "components/ui"; import { Button, Spinner, EmptySpace, EmptySpaceItem } from "components/ui";
// icons
import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline";
// types // types
import type { NextPage, NextPageContext } from "next"; import type { NextPage, NextPageContext } from "next";
import type { IWorkspaceMemberInvitation } from "types"; import type { IWorkspaceMemberInvitation } from "types";
@ -27,6 +29,8 @@ const OnBoard: NextPage = () => {
const router = useRouter(); const router = useRouter();
const { setToastAlert } = useToast();
const { data: invitations, mutate: mutateInvitations } = useSWR( const { data: invitations, mutate: mutateInvitations } = useSWR(
"USER_WORKSPACE_INVITATIONS", "USER_WORKSPACE_INVITATIONS",
() => workspaceService.userWorkspaceInvitations() () => workspaceService.userWorkspaceInvitations()
@ -52,6 +56,15 @@ const OnBoard: NextPage = () => {
const submitInvitations = () => { const submitInvitations = () => {
// userService.updateUserOnBoard(); // userService.updateUserOnBoard();
if (invitationsRespond.length === 0) {
setToastAlert({
type: "error",
title: "Error!",
message: "Please select atleast one invitation.",
});
return;
}
workspaceService workspaceService
.joinWorkspaces({ invitations: invitationsRespond }) .joinWorkspaces({ invitations: invitationsRespond })
.then(() => { .then(() => {
@ -100,9 +113,13 @@ const OnBoard: NextPage = () => {
))} ))}
</ul> </ul>
<div className="mt-6 flex items-center gap-2"> <div className="mt-6 flex items-center gap-2">
<Button className="w-full" theme="secondary" onClick={() => router.push("/")}> <Link href="/">
Skip <a className="w-full">
</Button> <Button className="w-full" theme="secondary">
Go to Home
</Button>
</a>
</Link>
<Button className="w-full" onClick={submitInvitations}> <Button className="w-full" onClick={submitInvitations}>
Accept and Continue Accept and Continue
</Button> </Button>
@ -112,26 +129,20 @@ const OnBoard: NextPage = () => {
<div className="mt-3 flex flex-col gap-y-3"> <div className="mt-3 flex flex-col gap-y-3">
<h2 className="mb-4 text-2xl font-medium">Your workspaces</h2> <h2 className="mb-4 text-2xl font-medium">Your workspaces</h2>
{workspaces.map((workspace) => ( {workspaces.map((workspace) => (
<div <Link key={workspace.id} href={workspace.slug}>
className="mb-2 flex items-center justify-between rounded border px-4 py-2" <a>
key={workspace.id} <div className="mb-2 flex items-center justify-between rounded border px-4 py-2">
> <div className="flex items-center gap-x-2">
<div className="flex items-center gap-x-2"> <CubeIcon className="h-5 w-5 text-gray-400" />
<CubeIcon className="h-5 w-5 text-gray-400" /> {workspace.name}
<Link href={workspace.slug}> </div>
<a>{workspace.name}</a> <div className="flex items-center gap-x-2">
</Link> <p className="text-sm">{workspace.owner.first_name}</p>
</div> </div>
<div className="flex items-center gap-x-2"> </div>
<p className="text-sm">{workspace.owner.first_name}</p> </a>
</div> </Link>
</div>
))} ))}
<Link href="/">
<a>
<Button type="button">Go to workspaces</Button>
</a>
</Link>
</div> </div>
) : ( ) : (
invitations.length === 0 && invitations.length === 0 &&