feat: workspace global view, style: spreadsheet view revamp (#2273)

* chore: workspace view types, services and hooks added

* style: spreadsheet view revamp and code refactor

* feat: workspace view

* fix: build fix

* chore: sidebar workspace issues redirection updated
This commit is contained in:
Anmol Singh Bhatia 2023-09-26 19:56:59 +05:30 committed by GitHub
parent a187e7765c
commit 3a6d72e4b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 4253 additions and 733 deletions

View file

@ -8,6 +8,7 @@ import { mutate } from "swr";
import { Dialog, Transition } from "@headlessui/react";
// services
import viewsService from "services/views.service";
import workspaceService from "services/workspace.service";
// hooks
import useToast from "hooks/use-toast";
// ui
@ -17,16 +18,17 @@ import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
// types
import type { ICurrentUserResponse, IView } from "types";
// fetch-keys
import { VIEWS_LIST } from "constants/fetch-keys";
import { VIEWS_LIST, WORKSPACE_VIEWS_LIST } from "constants/fetch-keys";
type Props = {
isOpen: boolean;
viewType: "project" | "workspace";
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
data: IView | null;
user: ICurrentUserResponse | undefined;
};
export const DeleteViewModal: React.FC<Props> = ({ isOpen, data, setIsOpen, user }) => {
export const DeleteViewModal: React.FC<Props> = ({ isOpen, data, setIsOpen, viewType, user }) => {
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const router = useRouter();
@ -41,34 +43,64 @@ export const DeleteViewModal: React.FC<Props> = ({ isOpen, data, setIsOpen, user
const handleDeletion = async () => {
setIsDeleteLoading(true);
if (!workspaceSlug || !data || !projectId) return;
await viewsService
.deleteView(workspaceSlug as string, projectId as string, data.id, user)
.then(() => {
mutate<IView[]>(
VIEWS_LIST(projectId as string),
(views) => views?.filter((view) => view.id !== data.id)
);
if (viewType === "project") {
if (!workspaceSlug || !data || !projectId) return;
handleClose();
await viewsService
.deleteView(workspaceSlug as string, projectId as string, data.id, user)
.then(() => {
mutate<IView[]>(VIEWS_LIST(projectId as string), (views) =>
views?.filter((view) => view.id !== data.id)
);
setToastAlert({
type: "success",
title: "Success!",
message: "View deleted successfully.",
handleClose();
setToastAlert({
type: "success",
title: "Success!",
message: "View deleted successfully.",
});
})
.catch(() => {
setToastAlert({
type: "error",
title: "Error!",
message: "View could not be deleted. Please try again.",
});
})
.finally(() => {
setIsDeleteLoading(false);
});
})
.catch(() => {
setToastAlert({
type: "error",
title: "Error!",
message: "View could not be deleted. Please try again.",
} else {
if (!workspaceSlug || !data) return;
await workspaceService
.deleteView(workspaceSlug as string, data.id)
.then(() => {
mutate<IView[]>(WORKSPACE_VIEWS_LIST(workspaceSlug as string), (views) =>
views?.filter((view) => view.id !== data.id)
);
handleClose();
setToastAlert({
type: "success",
title: "Success!",
message: "View deleted successfully.",
});
})
.catch(() => {
setToastAlert({
type: "error",
title: "Error!",
message: "View could not be deleted. Please try again.",
});
})
.finally(() => {
setIsDeleteLoading(false);
});
})
.finally(() => {
setIsDeleteLoading(false);
});
}
};
return (