chore: user cannot update their own role (#1041)
This commit is contained in:
parent
290318603d
commit
9fdc56db0f
15 changed files with 55 additions and 39 deletions
|
|
@ -39,7 +39,7 @@ const BillingSettings: NextPage = () => {
|
|||
</Breadcrumbs>
|
||||
}
|
||||
>
|
||||
<div className="px-24 py-8">
|
||||
<div className="p-8 lg:px-24">
|
||||
<SettingsHeader />
|
||||
<section className="space-y-8">
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const ImportExport: NextPage = () => {
|
|||
</Breadcrumbs>
|
||||
}
|
||||
>
|
||||
<div className="px-24 py-8">
|
||||
<div className="p-8 lg:px-24">
|
||||
<SettingsHeader />
|
||||
<IntegrationGuide />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ const WorkspaceSettings: NextPage = () => {
|
|||
}}
|
||||
data={activeWorkspace ?? null}
|
||||
/>
|
||||
<div className="px-24 py-8">
|
||||
<div className="p-8 lg:px-24">
|
||||
<SettingsHeader />
|
||||
{activeWorkspace ? (
|
||||
<div className="space-y-8 sm:space-y-12">
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ const WorkspaceIntegrations: NextPage = () => {
|
|||
</Breadcrumbs>
|
||||
}
|
||||
>
|
||||
<div className="px-24 py-8">
|
||||
<div className="p-8 lg:px-24">
|
||||
<SettingsHeader />
|
||||
<section className="space-y-8">
|
||||
<div className="flex flex-col items-start gap-3">
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ import { useRouter } from "next/router";
|
|||
|
||||
import useSWR from "swr";
|
||||
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
import useUser from "hooks/use-user";
|
||||
// layouts
|
||||
import { WorkspaceAuthorizationLayout } from "layouts/auth-layout";
|
||||
import { SettingsHeader } from "components/workspace";
|
||||
|
|
@ -37,24 +38,27 @@ const MembersSettings: NextPage = () => {
|
|||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const { user } = useUser();
|
||||
|
||||
const { data: activeWorkspace } = useSWR(
|
||||
workspaceSlug ? WORKSPACE_DETAILS(workspaceSlug as string) : null,
|
||||
() => (workspaceSlug ? workspaceService.getWorkspace(workspaceSlug as string) : null)
|
||||
workspaceSlug ? WORKSPACE_DETAILS(workspaceSlug.toString()) : null,
|
||||
() => (workspaceSlug ? workspaceService.getWorkspace(workspaceSlug.toString()) : null)
|
||||
);
|
||||
|
||||
const { data: workspaceMembers, mutate: mutateMembers } = useSWR<any[]>(
|
||||
workspaceSlug ? WORKSPACE_MEMBERS(workspaceSlug as string) : null,
|
||||
workspaceSlug ? () => workspaceService.workspaceMembers(workspaceSlug as string) : null
|
||||
const { data: workspaceMembers, mutate: mutateMembers } = useSWR(
|
||||
workspaceSlug ? WORKSPACE_MEMBERS(workspaceSlug.toString()) : null,
|
||||
workspaceSlug ? () => workspaceService.workspaceMembers(workspaceSlug.toString()) : null
|
||||
);
|
||||
|
||||
const { data: workspaceInvitations, mutate: mutateInvitations } = useSWR<any[]>(
|
||||
const { data: workspaceInvitations, mutate: mutateInvitations } = useSWR(
|
||||
workspaceSlug ? WORKSPACE_INVITATIONS : null,
|
||||
workspaceSlug ? () => workspaceService.workspaceInvitations(workspaceSlug as string) : null
|
||||
workspaceSlug ? () => workspaceService.workspaceInvitations(workspaceSlug.toString()) : null
|
||||
);
|
||||
|
||||
const members = [
|
||||
...(workspaceMembers?.map((item) => ({
|
||||
id: item.id,
|
||||
memberId: item.member?.id,
|
||||
avatar: item.member?.avatar,
|
||||
first_name: item.member?.first_name,
|
||||
last_name: item.member?.last_name,
|
||||
|
|
@ -65,9 +69,10 @@ const MembersSettings: NextPage = () => {
|
|||
})) || []),
|
||||
...(workspaceInvitations?.map((item) => ({
|
||||
id: item.id,
|
||||
avatar: item.avatar ?? "",
|
||||
first_name: item.first_name ?? item.email,
|
||||
last_name: item.last_name ?? "",
|
||||
memberId: item.id,
|
||||
avatar: "",
|
||||
first_name: item.email,
|
||||
last_name: "",
|
||||
email: item.email,
|
||||
role: item.role,
|
||||
status: item.accepted,
|
||||
|
|
@ -138,7 +143,7 @@ const MembersSettings: NextPage = () => {
|
|||
</Breadcrumbs>
|
||||
}
|
||||
>
|
||||
<div className="px-24 py-8">
|
||||
<div className="p-8 lg:px-24">
|
||||
<SettingsHeader />
|
||||
<section className="space-y-8">
|
||||
<div className="flex items-end justify-between gap-4">
|
||||
|
|
@ -197,8 +202,10 @@ const MembersSettings: NextPage = () => {
|
|||
label={ROLE[member.role as keyof typeof ROLE]}
|
||||
value={member.role}
|
||||
onChange={(value: any) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
workspaceService
|
||||
.updateWorkspaceMember(activeWorkspace?.slug as string, member.id, {
|
||||
.updateWorkspaceMember(workspaceSlug?.toString(), member.id, {
|
||||
role: value,
|
||||
})
|
||||
.then(() => {
|
||||
|
|
@ -224,6 +231,7 @@ const MembersSettings: NextPage = () => {
|
|||
});
|
||||
}}
|
||||
position="right"
|
||||
disabled={member.memberId === user?.id}
|
||||
>
|
||||
{Object.keys(ROLE).map((key) => (
|
||||
<CustomSelect.Option key={key} value={key}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue