mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: bugs on the user profile page (#2018)
This commit is contained in:
parent
54527cc2bb
commit
5e00ffee05
@ -3,8 +3,6 @@ import Link from "next/link";
|
|||||||
|
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
// next-themes
|
|
||||||
import { useTheme } from "next-themes";
|
|
||||||
// headless ui
|
// headless ui
|
||||||
import { Disclosure, Transition } from "@headlessui/react";
|
import { Disclosure, Transition } from "@headlessui/react";
|
||||||
// services
|
// services
|
||||||
@ -25,8 +23,6 @@ export const ProfileSidebar = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, userId } = router.query;
|
const { workspaceSlug, userId } = router.query;
|
||||||
|
|
||||||
const { theme } = useTheme();
|
|
||||||
|
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
|
|
||||||
const { data: userProjectsData } = useSWR(
|
const { data: userProjectsData } = useSWR(
|
||||||
@ -56,15 +52,7 @@ export const ProfileSidebar = () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className="flex-shrink-0 md:h-full w-full md:w-80 overflow-y-auto shadow-custom-shadow-sm">
|
||||||
className="flex-shrink-0 md:h-full w-full md:w-80 overflow-y-auto"
|
|
||||||
style={{
|
|
||||||
boxShadow:
|
|
||||||
theme === "light"
|
|
||||||
? "0px 1px 4px 0px rgba(0, 0, 0, 0.01), 0px 4px 8px 0px rgba(0, 0, 0, 0.02), 0px 1px 12px 0px rgba(0, 0, 0, 0.12)"
|
|
||||||
: "0px 0px 4px 0px rgba(0, 0, 0, 0.20), 0px 2px 6px 0px rgba(0, 0, 0, 0.50)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{userProjectsData ? (
|
{userProjectsData ? (
|
||||||
<>
|
<>
|
||||||
<div className="relative h-32">
|
<div className="relative h-32">
|
||||||
@ -127,12 +115,11 @@ export const ProfileSidebar = () => {
|
|||||||
project.assigned_issues +
|
project.assigned_issues +
|
||||||
project.pending_issues +
|
project.pending_issues +
|
||||||
project.completed_issues;
|
project.completed_issues;
|
||||||
const totalAssignedIssues = totalIssues - project.created_issues;
|
|
||||||
|
|
||||||
const completedIssuePercentage =
|
const completedIssuePercentage =
|
||||||
totalAssignedIssues === 0
|
project.assigned_issues === 0
|
||||||
? 0
|
? 0
|
||||||
: Math.round((project.completed_issues / totalAssignedIssues) * 100);
|
: Math.round((project.completed_issues / project.assigned_issues) * 100);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Disclosure
|
<Disclosure
|
||||||
|
@ -197,7 +197,8 @@ export const ProfileIssuesContextProvider: React.FC<{ children: React.ReactNode
|
|||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useReducer(reducer, initialState);
|
const [state, dispatch] = useReducer(reducer, initialState);
|
||||||
|
|
||||||
const setIssueView = useCallback((property: TIssueViewOptions) => {
|
const setIssueView = useCallback(
|
||||||
|
(property: TIssueViewOptions) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "SET_ISSUE_VIEW",
|
type: "SET_ISSUE_VIEW",
|
||||||
payload: {
|
payload: {
|
||||||
@ -205,7 +206,7 @@ export const ProfileIssuesContextProvider: React.FC<{ children: React.ReactNode
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (property === "kanban") {
|
if (property === "kanban" && state.groupByProperty === null) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "SET_GROUP_BY_PROPERTY",
|
type: "SET_GROUP_BY_PROPERTY",
|
||||||
payload: {
|
payload: {
|
||||||
@ -213,7 +214,9 @@ export const ProfileIssuesContextProvider: React.FC<{ children: React.ReactNode
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
},
|
||||||
|
[state]
|
||||||
|
);
|
||||||
|
|
||||||
const setGroupByProperty = useCallback((property: TIssueGroupByOptions) => {
|
const setGroupByProperty = useCallback((property: TIssueGroupByOptions) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -71,8 +71,23 @@ const useProfileIssues = (workspaceSlug: string | undefined, userId: string | un
|
|||||||
allIssues: userProfileIssues,
|
allIssues: userProfileIssues,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (groupByProperty === "state_detail.group") {
|
||||||
|
return userProfileIssues
|
||||||
|
? Object.assign(
|
||||||
|
{
|
||||||
|
backlog: [],
|
||||||
|
unstarted: [],
|
||||||
|
started: [],
|
||||||
|
completed: [],
|
||||||
|
cancelled: [],
|
||||||
|
},
|
||||||
|
userProfileIssues
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return userProfileIssues;
|
return userProfileIssues;
|
||||||
}, [userProfileIssues]);
|
}, [groupByProperty, userProfileIssues]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!userId || !filters) return;
|
if (!userId || !filters) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user