mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: update user profile stats (#458)
This commit is contained in:
parent
ef0e326ca0
commit
d413dd1169
@ -13,6 +13,8 @@ interface IUserContextProps {
|
|||||||
user?: IUser;
|
user?: IUser;
|
||||||
isUserLoading: boolean;
|
isUserLoading: boolean;
|
||||||
mutateUser: KeyedMutator<IUser>;
|
mutateUser: KeyedMutator<IUser>;
|
||||||
|
assignedIssuesLength?: number;
|
||||||
|
workspaceInvitesLength?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserContext = createContext<IUserContextProps>({} as IUserContextProps);
|
export const UserContext = createContext<IUserContextProps>({} as IUserContextProps);
|
||||||
@ -29,6 +31,8 @@ export const UserProvider = ({ children }: { children: ReactElement }) => {
|
|||||||
user: error ? undefined : data?.user,
|
user: error ? undefined : data?.user,
|
||||||
isUserLoading: Boolean(data?.user === undefined && error === undefined),
|
isUserLoading: Boolean(data?.user === undefined && error === undefined),
|
||||||
mutateUser: mutate,
|
mutateUser: mutate,
|
||||||
|
assignedIssuesLength: data?.assigned_issues ?? 0,
|
||||||
|
workspaceInvitesLength: data?.workspace_invites ?? 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
@ -3,8 +3,6 @@ import React, { useEffect, useState } from "react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
// react-hook-form
|
// react-hook-form
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
// lib
|
// lib
|
||||||
@ -12,7 +10,6 @@ import { requiredAuth } from "lib/auth";
|
|||||||
// services
|
// services
|
||||||
import fileService from "services/file.service";
|
import fileService from "services/file.service";
|
||||||
import userService from "services/user.service";
|
import userService from "services/user.service";
|
||||||
import workspaceService from "services/workspace.service";
|
|
||||||
// hooks
|
// hooks
|
||||||
import useUser from "hooks/use-user";
|
import useUser from "hooks/use-user";
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
@ -27,6 +24,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
|||||||
import {
|
import {
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
|
RectangleStackIcon,
|
||||||
UserIcon,
|
UserIcon,
|
||||||
UserPlusIcon,
|
UserPlusIcon,
|
||||||
XMarkIcon,
|
XMarkIcon,
|
||||||
@ -34,8 +32,6 @@ import {
|
|||||||
// types
|
// types
|
||||||
import type { NextPage, GetServerSidePropsContext } from "next";
|
import type { NextPage, GetServerSidePropsContext } from "next";
|
||||||
import type { IUser } from "types";
|
import type { IUser } from "types";
|
||||||
// fetch-keys
|
|
||||||
import { USER_WORKSPACE_INVITATIONS } from "constants/fetch-keys";
|
|
||||||
|
|
||||||
const defaultValues: Partial<IUser> = {
|
const defaultValues: Partial<IUser> = {
|
||||||
avatar: "",
|
avatar: "",
|
||||||
@ -59,11 +55,7 @@ const Profile: NextPage = () => {
|
|||||||
} = useForm<IUser>({ defaultValues });
|
} = useForm<IUser>({ defaultValues });
|
||||||
|
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
const { user: myProfile, mutateUser } = useUser();
|
const { user: myProfile, mutateUser, assignedIssuesLength, workspaceInvitesLength } = useUser();
|
||||||
|
|
||||||
const { data: invitations } = useSWR(USER_WORKSPACE_INVITATIONS, () =>
|
|
||||||
workspaceService.userWorkspaceInvitations()
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reset({ ...defaultValues, ...myProfile });
|
reset({ ...defaultValues, ...myProfile });
|
||||||
@ -134,10 +126,17 @@ const Profile: NextPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const quickLinks = [
|
const quickLinks = [
|
||||||
|
{
|
||||||
|
icon: RectangleStackIcon,
|
||||||
|
title: "Assigned Issues",
|
||||||
|
number: assignedIssuesLength,
|
||||||
|
description: "View your workspace invitations.",
|
||||||
|
href: "/invitations",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: UserPlusIcon,
|
icon: UserPlusIcon,
|
||||||
title: "Workspace Invitations",
|
title: "Workspace Invitations",
|
||||||
number: invitations?.length ?? 0,
|
number: workspaceInvitesLength,
|
||||||
description: "View your workspace invitations.",
|
description: "View your workspace invitations.",
|
||||||
href: "/invitations",
|
href: "/invitations",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user