refactor: favorite projects fetch function, chore: update tooltip design (#1526)

* chore: update tooltip design

* fix: due date popup overflow

* fix: build error

* fix: build error

* chore: add key to map return value

* refactor: favorite projects sidebar list
This commit is contained in:
Aaryan Khandelwal 2023-07-14 15:08:07 +05:30 committed by GitHub
parent 7914bcf486
commit da6ecd439c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 90 additions and 128 deletions

View file

@ -482,7 +482,6 @@ const SinglePage: NextPage = () => {
? "This page is only visible to you."
: "This page can be viewed by anyone in the project."
}`}
theme="dark"
>
{pageDetails.access ? (
<button onClick={() => partialUpdatePage({ access: 0 })} className="z-10">

View file

@ -33,24 +33,24 @@ const AutomationsSettings: NextPage = () => {
const { projectDetails } = useProjectDetails();
const handleChange = async (formData: Partial<IProject>) => {
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug || !projectId || !projectDetails) return;
mutate<IProject>(
PROJECT_DETAILS(projectId as string),
(prevData) => ({ ...(prevData as IProject), ...formData }),
false
);
mutate<IProject[]>(
PROJECTS_LIST(workspaceSlug as string, { is_favorite: "all" }),
(prevData) =>
(prevData ?? []).map((p) => (p.id === projectDetails.id ? { ...p, ...formData } : p)),
false
);
await projectService
.updateProject(workspaceSlug as string, projectId as string, formData, user)
.then(() => {
mutate<IProject[]>(
PROJECTS_LIST(workspaceSlug as string),
(prevData) =>
(prevData ?? []).map((p) => (p.id === projectDetails?.id ? { ...p, ...formData } : p)),
false
);
mutate(PROJECT_DETAILS(projectId as string));
})
.then(() => {})
.catch(() => {
setToastAlert({
type: "error",

View file

@ -71,13 +71,6 @@ const ControlSettings: NextPage = () => {
.then((res) => {
mutate(PROJECT_DETAILS(projectId as string));
if (projectDetails.is_favorite)
mutate(
PROJECTS_LIST(workspaceSlug as string, {
is_favorite: true,
})
);
mutate(
PROJECTS_LIST(workspaceSlug as string, {
is_favorite: "all",

View file

@ -99,44 +99,21 @@ const FeaturesSettings: NextPage = () => {
const handleSubmit = async (formData: Partial<IProject>) => {
if (!workspaceSlug || !projectId || !projectDetails) return;
if (projectDetails.is_favorite)
mutate<IProject[]>(
PROJECTS_LIST(workspaceSlug.toString(), {
is_favorite: true,
}),
(prevData) =>
prevData?.map((p) => {
if (p.id === projectId)
return {
...p,
...formData,
};
return p;
}),
false
);
mutate<IProject[]>(
PROJECTS_LIST(workspaceSlug.toString(), {
is_favorite: "all",
}),
(prevData) =>
prevData?.map((p) => {
if (p.id === projectId)
return {
...p,
...formData,
};
return p;
}),
(prevData) => prevData?.map((p) => (p.id === projectId ? { ...p, ...formData } : p)),
false
);
mutate<IProject>(
PROJECT_DETAILS(projectId as string),
(prevData) => ({ ...(prevData as IProject), ...formData }),
(prevData) => {
if (!prevData) return prevData;
return { ...prevData, ...formData };
},
false
);

View file

@ -95,13 +95,6 @@ const GeneralSettings: NextPage = () => {
false
);
if (projectDetails.is_favorite)
mutate(
PROJECTS_LIST(workspaceSlug as string, {
is_favorite: true,
})
);
mutate(
PROJECTS_LIST(workspaceSlug as string, {
is_favorite: "all",