forked from github/plane
style: workspace settings pages
This commit is contained in:
parent
433276c833
commit
1d8b4296fb
@ -3,6 +3,8 @@ import React, { useRef, useState } from "react";
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
|
import useSWR, { mutate } from "swr";
|
||||||
|
|
||||||
// services
|
// services
|
||||||
import workspaceService from "services/workspace.service";
|
import workspaceService from "services/workspace.service";
|
||||||
// hooks
|
// hooks
|
||||||
@ -10,10 +12,11 @@ import useToast from "hooks/use-toast";
|
|||||||
// ui
|
// ui
|
||||||
import { Button, Loader } from "components/ui";
|
import { Button, Loader } from "components/ui";
|
||||||
// icons
|
// icons
|
||||||
import GithubLogo from "public/logos/github-black.png";
|
import GithubLogo from "public/logos/github-square.png";
|
||||||
import useSWR, { mutate } from "swr";
|
// types
|
||||||
import { APP_INTEGRATIONS, WORKSPACE_INTEGRATIONS } from "constants/fetch-keys";
|
|
||||||
import { IWorkspaceIntegrations } from "types";
|
import { IWorkspaceIntegrations } from "types";
|
||||||
|
// fetch-keys
|
||||||
|
import { WORKSPACE_INTEGRATIONS } from "constants/fetch-keys";
|
||||||
|
|
||||||
const OAuthPopUp = ({ integration }: any) => {
|
const OAuthPopUp = ({ integration }: any) => {
|
||||||
const [deletingIntegration, setDeletingIntegration] = useState(false);
|
const [deletingIntegration, setDeletingIntegration] = useState(false);
|
||||||
@ -97,28 +100,28 @@ const OAuthPopUp = ({ integration }: any) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between gap-2 border p-4 rounded-lg">
|
<div className="flex items-center justify-between gap-2 rounded-[10px] border bg-white p-5">
|
||||||
<div className="flex items-start gap-4">
|
<div className="flex items-start gap-4">
|
||||||
<div className="h-12 w-12">
|
<div className="h-12 w-12 flex-shrink-0">
|
||||||
<Image src={GithubLogo} alt="GithubLogo" />
|
<Image src={GithubLogo} alt="GithubLogo" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="flex items-center gap-4 font-semibold text-xl">
|
<h3 className="flex items-center gap-4 text-xl font-semibold">
|
||||||
{integration.title}
|
{integration.title}
|
||||||
{workspaceIntegrations ? (
|
{workspaceIntegrations ? (
|
||||||
isInstalled ? (
|
isInstalled ? (
|
||||||
<span className="flex items-center text-green-500 font-normal text-sm gap-1">
|
<span className="flex items-center gap-1 text-sm font-normal text-green-500">
|
||||||
<span className="h-1.5 w-1.5 bg-green-500 flex-shrink-0 rounded-full" /> Installed
|
<span className="h-1.5 w-1.5 flex-shrink-0 rounded-full bg-green-500" /> Installed
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="flex items-center text-gray-400 font-normal text-sm gap-1">
|
<span className="flex items-center gap-1 text-sm font-normal text-gray-400">
|
||||||
<span className="h-1.5 w-1.5 bg-gray-400 flex-shrink-0 rounded-full" /> Not
|
<span className="h-1.5 w-1.5 flex-shrink-0 rounded-full bg-gray-400" /> Not
|
||||||
Installed
|
Installed
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
) : null}
|
) : null}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-gray-400 text-sm">
|
<p className="text-sm text-gray-400">
|
||||||
{workspaceIntegrations
|
{workspaceIntegrations
|
||||||
? isInstalled
|
? isInstalled
|
||||||
? "Activate GitHub integrations on individual projects to sync with specific repositories."
|
? "Activate GitHub integrations on individual projects to sync with specific repositories."
|
||||||
|
@ -87,7 +87,7 @@ export const SingleIntegration: React.FC<Props> = ({ integration }) => {
|
|||||||
{integration && (
|
{integration && (
|
||||||
<div className="flex items-center justify-between gap-2 rounded-[10px] border bg-white p-5">
|
<div className="flex items-center justify-between gap-2 rounded-[10px] border bg-white p-5">
|
||||||
<div className="flex items-start gap-4">
|
<div className="flex items-start gap-4">
|
||||||
<div className="h-12 w-12">
|
<div className="h-12 w-12 flex-shrink-0">
|
||||||
<Image src={GithubLogo} alt="GithubLogo" />
|
<Image src={GithubLogo} alt="GithubLogo" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -64,7 +64,7 @@ const SettingsNavbar: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap gap-4">
|
<div className="flex flex-wrap gap-4">
|
||||||
{(projectId ? projectLinks : workspaceLinks).map((link) => (
|
{(projectId ? projectLinks : workspaceLinks).map((link) => (
|
||||||
<Link href={link.href}>
|
<Link key={link.href} href={link.href}>
|
||||||
<a>
|
<a>
|
||||||
<div
|
<div
|
||||||
className={`rounded-3xl border px-5 py-1.5 text-sm sm:px-7 sm:py-2 sm:text-base ${
|
className={`rounded-3xl border px-5 py-1.5 text-sm sm:px-7 sm:py-2 sm:text-base ${
|
||||||
|
@ -18,12 +18,13 @@ import AppLayout from "layouts/app-layout";
|
|||||||
import ConfirmProjectMemberRemove from "components/project/confirm-project-member-remove";
|
import ConfirmProjectMemberRemove from "components/project/confirm-project-member-remove";
|
||||||
import SendProjectInvitationModal from "components/project/send-project-invitation-modal";
|
import SendProjectInvitationModal from "components/project/send-project-invitation-modal";
|
||||||
// ui
|
// ui
|
||||||
import { Button, CustomMenu, CustomSelect, Loader } from "components/ui";
|
import { CustomMenu, CustomSelect, Loader } from "components/ui";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||||
// types
|
// types
|
||||||
import type { NextPage, GetServerSidePropsContext } from "next";
|
import type { NextPage, GetServerSidePropsContext } from "next";
|
||||||
|
import { UserAuth } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import {
|
import {
|
||||||
PROJECT_DETAILS,
|
PROJECT_DETAILS,
|
||||||
@ -34,18 +35,8 @@ import {
|
|||||||
// constants
|
// constants
|
||||||
import { ROLE } from "constants/workspace";
|
import { ROLE } from "constants/workspace";
|
||||||
|
|
||||||
type TMemberSettingsProps = {
|
const MembersSettings: NextPage<UserAuth> = ({ isMember, isOwner, isViewer, isGuest }) => {
|
||||||
isMember: boolean;
|
|
||||||
isOwner: boolean;
|
|
||||||
isViewer: boolean;
|
|
||||||
isGuest: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const MembersSettings: NextPage<TMemberSettingsProps> = (props) => {
|
|
||||||
const { isMember, isOwner, isViewer, isGuest } = props;
|
|
||||||
|
|
||||||
const [inviteModal, setInviteModal] = useState(false);
|
const [inviteModal, setInviteModal] = useState(false);
|
||||||
const [selectedMember, setSelectedMember] = useState<string | null>(null);
|
|
||||||
const [selectedRemoveMember, setSelectedRemoveMember] = useState<string | null>(null);
|
const [selectedRemoveMember, setSelectedRemoveMember] = useState<string | null>(null);
|
||||||
const [selectedInviteRemoveMember, setSelectedInviteRemoveMember] = useState<string | null>(null);
|
const [selectedInviteRemoveMember, setSelectedInviteRemoveMember] = useState<string | null>(null);
|
||||||
|
|
||||||
@ -251,7 +242,6 @@ const MembersSettings: NextPage<TMemberSettingsProps> = (props) => {
|
|||||||
),
|
),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
setSelectedMember(null);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -259,7 +249,7 @@ const MembersSettings: NextPage<TMemberSettingsProps> = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Object.keys(ROLE).map((key) => (
|
{Object.keys(ROLE).map((key) => (
|
||||||
<CustomSelect.Option value={key}>
|
<CustomSelect.Option key={key} value={key}>
|
||||||
<>{ROLE[parseInt(key) as keyof typeof ROLE]}</>
|
<>{ROLE[parseInt(key) as keyof typeof ROLE]}</>
|
||||||
</CustomSelect.Option>
|
</CustomSelect.Option>
|
||||||
))}
|
))}
|
||||||
|
@ -27,7 +27,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
|||||||
// helpers
|
// helpers
|
||||||
import { copyTextToClipboard } from "helpers/string.helper";
|
import { copyTextToClipboard } from "helpers/string.helper";
|
||||||
// types
|
// types
|
||||||
import type { IWorkspace } from "types";
|
import type { IWorkspace, UserAuth } from "types";
|
||||||
import type { GetServerSideProps, NextPage } from "next";
|
import type { GetServerSideProps, NextPage } from "next";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { WORKSPACE_DETAILS, USER_WORKSPACES } from "constants/fetch-keys";
|
import { WORKSPACE_DETAILS, USER_WORKSPACES } from "constants/fetch-keys";
|
||||||
@ -41,14 +41,7 @@ const defaultValues: Partial<IWorkspace> = {
|
|||||||
logo: null,
|
logo: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
type TWorkspaceSettingsProps = {
|
const WorkspaceSettings: NextPage<UserAuth> = (props) => {
|
||||||
isOwner: boolean;
|
|
||||||
isMember: boolean;
|
|
||||||
isViewer: boolean;
|
|
||||||
isGuest: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isImageUploading, setIsImageUploading] = useState(false);
|
const [isImageUploading, setIsImageUploading] = useState(false);
|
||||||
const [isImageUploadModalOpen, setIsImageUploadModalOpen] = useState(false);
|
const [isImageUploadModalOpen, setIsImageUploadModalOpen] = useState(false);
|
||||||
@ -135,17 +128,16 @@ const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|||||||
data={activeWorkspace ?? null}
|
data={activeWorkspace ?? null}
|
||||||
/>
|
/>
|
||||||
{activeWorkspace ? (
|
{activeWorkspace ? (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8 sm:space-y-12">
|
||||||
<div>
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<h3 className="text-3xl font-bold leading-6 text-gray-900">General</h3>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<p className="mt-4 text-sm text-gray-500">
|
<h4 className="text-xl font-semibold">Logo</h4>
|
||||||
This information will be displayed to every member of the workspace.
|
<p className="text-gray-500">
|
||||||
|
Max file size is 5MB. Supported file types are .jpg and .png.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 gap-x-16 gap-y-8 lg:grid-cols-12">
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<div className="col-span lg:col-span-5">
|
<div className="flex items-center gap-4">
|
||||||
<h4 className="text-md mb-1 leading-6 text-gray-900">Logo</h4>
|
|
||||||
<div className="flex w-full gap-2">
|
|
||||||
<button type="button" onClick={() => setIsImageUploadModalOpen(true)}>
|
<button type="button" onClick={() => setIsImageUploadModalOpen(true)}>
|
||||||
{watch("logo") && watch("logo") !== null && watch("logo") !== "" ? (
|
{watch("logo") && watch("logo") !== null && watch("logo") !== "" ? (
|
||||||
<div className="relative mx-auto flex h-12 w-12">
|
<div className="relative mx-auto flex h-12 w-12">
|
||||||
@ -165,9 +157,6 @@ const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-2 text-sm text-gray-500">
|
|
||||||
Max file size is 5MB. Supported file types are .jpg and .png.
|
|
||||||
</p>
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsImageUploadModalOpen(true);
|
setIsImageUploadModalOpen(true);
|
||||||
@ -178,35 +167,13 @@ const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="lg:col-span-5">
|
|
||||||
<div className="mb-3 flex items-end justify-between gap-2">
|
|
||||||
<div>
|
|
||||||
<h4 className="text-md mb-1 leading-6 text-gray-900">URL</h4>
|
|
||||||
<p className="text-sm text-gray-500">Give a name to your workspace.</p>
|
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
type="button"
|
<div className="col-span-12 sm:col-span-6">
|
||||||
theme="secondary"
|
<h4 className="text-xl font-semibold">URL</h4>
|
||||||
className="h-min"
|
<p className="text-gray-500">Your workspace URL.</p>
|
||||||
onClick={() =>
|
|
||||||
copyTextToClipboard(`https://app.plane.so/${activeWorkspace.slug}`)
|
|
||||||
.then(() => {
|
|
||||||
setToastAlert({
|
|
||||||
type: "success",
|
|
||||||
title: "Workspace link copied to clipboard",
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
setToastAlert({
|
|
||||||
type: "error",
|
|
||||||
title: "Some error occurred",
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<LinkIcon className="h-3.5 w-3.5" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-span-12 flex items-center gap-2 sm:col-span-6">
|
||||||
<Input
|
<Input
|
||||||
id="url"
|
id="url"
|
||||||
name="url"
|
name="url"
|
||||||
@ -217,10 +184,30 @@ const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|||||||
value={`app.plane.so/${activeWorkspace.slug}`}
|
value={`app.plane.so/${activeWorkspace.slug}`}
|
||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
theme="secondary"
|
||||||
|
className="h-min"
|
||||||
|
onClick={() =>
|
||||||
|
copyTextToClipboard(`https://app.plane.so/${activeWorkspace.slug}`).then(() => {
|
||||||
|
setToastAlert({
|
||||||
|
type: "success",
|
||||||
|
title: "Link Copied!",
|
||||||
|
message: "Workspace link copied to clipboard.",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LinkIcon className="h-[18px] w-[18px]" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="lg:col-span-5">
|
</div>
|
||||||
<h4 className="text-md mb-1 leading-6 text-gray-900">Name</h4>
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<p className="mb-3 text-sm text-gray-500">Give a name to your workspace.</p>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<h4 className="text-xl font-semibold">Name</h4>
|
||||||
|
<p className="text-gray-500">Give a name to your workspace.</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<Input
|
<Input
|
||||||
id="name"
|
id="name"
|
||||||
name="name"
|
name="name"
|
||||||
@ -231,12 +218,15 @@ const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|||||||
validations={{
|
validations={{
|
||||||
required: "Name is required",
|
required: "Name is required",
|
||||||
}}
|
}}
|
||||||
className="w-full"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="lg:col-span-5">
|
</div>
|
||||||
<h4 className="text-md mb-1 leading-6 text-gray-900">Company Size</h4>
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<p className="mb-3 text-sm text-gray-500">How big is your company?</p>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<h4 className="text-xl font-semibold">Company Size</h4>
|
||||||
|
<p className="text-gray-500">How big is your company?</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<Controller
|
<Controller
|
||||||
name="company_size"
|
name="company_size"
|
||||||
control={control}
|
control={control}
|
||||||
@ -256,29 +246,28 @@ const WorkspaceSettings: NextPage<TWorkspaceSettingsProps> = (props) => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-full">
|
</div>
|
||||||
|
<div className="sm:text-right">
|
||||||
<Button onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
<Button onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||||
{isSubmitting ? "Updating..." : "Update Workspace"}
|
{isSubmitting ? "Updating..." : "Update Workspace"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-8 lg:col-span-10">
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<div>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<h4 className="text-md mb-1 leading-6 text-gray-900">Danger Zone</h4>
|
<h4 className="text-xl font-semibold">Danger Zone</h4>
|
||||||
<p className="mb-3 text-sm text-gray-500">
|
<p className="text-gray-500">
|
||||||
The danger zone of the workspace delete page is a critical area that requires
|
The danger zone of the workspace delete page is a critical area that requires
|
||||||
careful consideration and attention. When deleting a workspace, all of the data
|
careful consideration and attention. When deleting a workspace, all of the data and
|
||||||
and resources within that workspace will be permanently removed and cannot be
|
resources within that workspace will be permanently removed and cannot be recovered.
|
||||||
recovered.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<OutlineButton theme="danger" onClick={() => setIsOpen(true)}>
|
<OutlineButton theme="danger" onClick={() => setIsOpen(true)}>
|
||||||
Delete the workspace
|
Delete the workspace
|
||||||
</OutlineButton>
|
</OutlineButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="grid h-full w-full place-items-center px-4 sm:px-0">
|
<div className="grid h-full w-full place-items-center px-4 sm:px-0">
|
||||||
<Spinner />
|
<Spinner />
|
||||||
|
@ -50,11 +50,8 @@ const WorkspaceIntegrations: NextPage<UserAuth> = (props) => {
|
|||||||
settingsLayout
|
settingsLayout
|
||||||
>
|
>
|
||||||
<section className="space-y-8">
|
<section className="space-y-8">
|
||||||
<div>
|
<h3 className="text-2xl font-semibold">Integrations</h3>
|
||||||
<h3 className="text-3xl font-bold leading-6 text-gray-900">Integrations</h3>
|
<div className="space-y-5">
|
||||||
<p className="mt-4 text-sm text-gray-500">Manage the workspace integrations.</p>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-4">
|
|
||||||
{integrations ? (
|
{integrations ? (
|
||||||
integrations.map((integration) => (
|
integrations.map((integration) => (
|
||||||
<OAuthPopUp
|
<OAuthPopUp
|
||||||
|
@ -17,33 +17,25 @@ import AppLayout from "layouts/app-layout";
|
|||||||
import ConfirmWorkspaceMemberRemove from "components/workspace/confirm-workspace-member-remove";
|
import ConfirmWorkspaceMemberRemove from "components/workspace/confirm-workspace-member-remove";
|
||||||
import SendWorkspaceInvitationModal from "components/workspace/send-workspace-invitation-modal";
|
import SendWorkspaceInvitationModal from "components/workspace/send-workspace-invitation-modal";
|
||||||
// ui
|
// ui
|
||||||
import { Button, CustomListbox, CustomMenu, Loader } from "components/ui";
|
import { CustomMenu, CustomSelect, Loader } from "components/ui";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||||
// types
|
// types
|
||||||
import type { GetServerSideProps, NextPage } from "next";
|
import type { GetServerSideProps, NextPage } from "next";
|
||||||
|
import { UserAuth } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { WORKSPACE_DETAILS, WORKSPACE_INVITATIONS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
import { WORKSPACE_DETAILS, WORKSPACE_INVITATIONS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
||||||
// constants
|
// constants
|
||||||
import { ROLE } from "constants/workspace";
|
import { ROLE } from "constants/workspace";
|
||||||
|
|
||||||
type TMembersSettingsProps = {
|
const MembersSettings: NextPage<UserAuth> = (props) => {
|
||||||
isOwner: boolean;
|
|
||||||
isMember: boolean;
|
|
||||||
isViewer: boolean;
|
|
||||||
isGuest: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|
||||||
const [selectedMember, setSelectedMember] = useState<string | null>(null);
|
|
||||||
const [selectedRemoveMember, setSelectedRemoveMember] = useState<string | null>(null);
|
const [selectedRemoveMember, setSelectedRemoveMember] = useState<string | null>(null);
|
||||||
const [selectedInviteRemoveMember, setSelectedInviteRemoveMember] = useState<string | null>(null);
|
const [selectedInviteRemoveMember, setSelectedInviteRemoveMember] = useState<string | null>(null);
|
||||||
const [inviteModal, setInviteModal] = useState(false);
|
const [inviteModal, setInviteModal] = useState(false);
|
||||||
|
|
||||||
const {
|
const router = useRouter();
|
||||||
query: { workspaceSlug },
|
const { workspaceSlug } = router.query;
|
||||||
} = useRouter();
|
|
||||||
|
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
@ -151,43 +143,38 @@ const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|||||||
settingsLayout
|
settingsLayout
|
||||||
>
|
>
|
||||||
<section className="space-y-8">
|
<section className="space-y-8">
|
||||||
<div>
|
<div className="flex items-end justify-between gap-4">
|
||||||
<h3 className="text-3xl font-bold leading-6 text-gray-900">Members</h3>
|
<h3 className="text-2xl font-semibold">Members</h3>
|
||||||
<p className="mt-4 text-sm text-gray-500">Manage all the members of the workspace.</p>
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex items-center gap-2 text-theme outline-none"
|
||||||
|
onClick={() => setInviteModal(true)}
|
||||||
|
>
|
||||||
|
<PlusIcon className="h-4 w-4" />
|
||||||
|
Add Member
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{!workspaceMembers || !workspaceInvitations ? (
|
{!workspaceMembers || !workspaceInvitations ? (
|
||||||
<Loader className="space-y-5 md:w-2/3">
|
<Loader className="space-y-5">
|
||||||
<Loader.Item height="40px" />
|
<Loader.Item height="40px" />
|
||||||
<Loader.Item height="40px" />
|
<Loader.Item height="40px" />
|
||||||
<Loader.Item height="40px" />
|
<Loader.Item height="40px" />
|
||||||
<Loader.Item height="40px" />
|
<Loader.Item height="40px" />
|
||||||
</Loader>
|
</Loader>
|
||||||
) : (
|
) : (
|
||||||
<div className="md:w-2/3">
|
<div className="divide-y rounded-[10px] border border-gray-200 bg-white px-6">
|
||||||
<div className="flex items-center justify-between gap-2">
|
|
||||||
<h4 className="text-md mb-1 leading-6 text-gray-900">Manage members</h4>
|
|
||||||
<Button
|
|
||||||
theme="secondary"
|
|
||||||
className="flex items-center gap-x-1"
|
|
||||||
onClick={() => setInviteModal(true)}
|
|
||||||
>
|
|
||||||
<PlusIcon className="h-4 w-4" />
|
|
||||||
Add Member
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div className="mt-6 space-y-6">
|
|
||||||
{members.length > 0
|
{members.length > 0
|
||||||
? members.map((member) => (
|
? members.map((member) => (
|
||||||
<div key={member.id} className="flex items-center justify-between">
|
<div key={member.id} className="flex items-center justify-between py-6">
|
||||||
<div className="flex items-center gap-x-8 gap-y-2">
|
<div className="flex items-center gap-x-8 gap-y-2">
|
||||||
<div className="relative flex h-10 w-10 items-center justify-center rounded bg-gray-700 p-4 capitalize text-white">
|
<div className="relative flex h-10 w-10 items-center justify-center rounded-lg bg-gray-700 p-4 capitalize text-white">
|
||||||
{member.avatar && member.avatar !== "" ? (
|
{member.avatar && member.avatar !== "" ? (
|
||||||
<Image
|
<Image
|
||||||
src={member.avatar}
|
src={member.avatar}
|
||||||
alt={member.first_name}
|
alt={member.first_name}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
objectFit="cover"
|
objectFit="cover"
|
||||||
className="rounded"
|
className="rounded-lg"
|
||||||
/>
|
/>
|
||||||
) : member.first_name !== "" ? (
|
) : member.first_name !== "" ? (
|
||||||
member.first_name.charAt(0)
|
member.first_name.charAt(0)
|
||||||
@ -203,28 +190,19 @@ const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 text-xs">
|
<div className="flex items-center gap-2 text-xs">
|
||||||
{selectedMember === member.id ? (
|
<CustomSelect
|
||||||
<CustomListbox
|
label={ROLE[member.role as keyof typeof ROLE]}
|
||||||
options={Object.keys(ROLE).map((key) => ({
|
|
||||||
display: ROLE[parseInt(key) as keyof typeof ROLE],
|
|
||||||
value: key,
|
|
||||||
}))}
|
|
||||||
title={ROLE[member.role as keyof typeof ROLE] ?? "None"}
|
|
||||||
value={member.role}
|
value={member.role}
|
||||||
onChange={(value) => {
|
onChange={(value: any) => {
|
||||||
workspaceService
|
workspaceService
|
||||||
.updateWorkspaceMember(
|
.updateWorkspaceMember(activeWorkspace?.slug as string, member.id, {
|
||||||
activeWorkspace?.slug as string,
|
|
||||||
member.id,
|
|
||||||
{
|
|
||||||
role: value,
|
role: value,
|
||||||
}
|
})
|
||||||
)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
mutateMembers(
|
mutateMembers(
|
||||||
(prevData) =>
|
(prevData) =>
|
||||||
prevData?.map((m) =>
|
prevData?.map((m) =>
|
||||||
m.id === selectedMember ? { ...m, role: value } : m
|
m.id === member.id ? { ...m, role: value } : m
|
||||||
),
|
),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -233,7 +211,6 @@ const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|||||||
type: "success",
|
type: "success",
|
||||||
message: "Member role updated successfully.",
|
message: "Member role updated successfully.",
|
||||||
});
|
});
|
||||||
setSelectedMember(null);
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
@ -243,26 +220,14 @@ const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
ROLE[member.role as keyof typeof ROLE] ?? "None"
|
|
||||||
)}
|
|
||||||
<CustomMenu ellipsis>
|
|
||||||
<CustomMenu.MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
if (!member.member) {
|
|
||||||
setToastAlert({
|
|
||||||
type: "error",
|
|
||||||
message: "You can't edit a pending invitation.",
|
|
||||||
title: "Error",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setSelectedMember(member.id);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Edit
|
{Object.keys(ROLE).map((key) => (
|
||||||
</CustomMenu.MenuItem>
|
<CustomSelect.Option key={key} value={key}>
|
||||||
|
<>{ROLE[parseInt(key) as keyof typeof ROLE]}</>
|
||||||
|
</CustomSelect.Option>
|
||||||
|
))}
|
||||||
|
</CustomSelect>
|
||||||
|
<CustomMenu ellipsis>
|
||||||
<CustomMenu.MenuItem
|
<CustomMenu.MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (member.member) {
|
if (member.member) {
|
||||||
@ -272,7 +237,7 @@ const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Remove
|
Remove member
|
||||||
</CustomMenu.MenuItem>
|
</CustomMenu.MenuItem>
|
||||||
</CustomMenu>
|
</CustomMenu>
|
||||||
</div>
|
</div>
|
||||||
@ -280,7 +245,6 @@ const MembersSettings: NextPage<TMembersSettingsProps> = (props) => {
|
|||||||
))
|
))
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user