all code added
This commit is contained in:
parent
2e74a0d0a0
commit
4f55e0ced6
1 changed files with 4 additions and 8 deletions
12
src/Home.jsx
12
src/Home.jsx
|
|
@ -28,6 +28,8 @@ export const Home = () => {
|
||||||
|
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
|
||||||
|
const path = location.pathname;
|
||||||
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
// Fetch token only if it doesn't exist
|
// Fetch token only if it doesn't exist
|
||||||
|
|
@ -66,13 +68,7 @@ export const Home = () => {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
toast({ variant: "destructive", title: projectData?.status, description: "No project found" });
|
toast({ variant: "destructive", title: projectData?.status, description: "No project found" });
|
||||||
}
|
}
|
||||||
if (!projectData && canvas) {
|
if (projectData && projectData?.status === 200 && !projectLoading && canvas && (selectedPanel === "project" || selectedPanel === "") && path !== "/") {
|
||||||
canvas.clear();
|
|
||||||
canvas.renderAll();
|
|
||||||
canvas.setBackgroundColor("#ffffff", canvas.renderAll.bind(canvas));
|
|
||||||
setActiveObject(null);
|
|
||||||
}
|
|
||||||
if (projectData && projectData?.status === 200 && !projectLoading && canvas && (selectedPanel === "project" || selectedPanel === "") && id) {
|
|
||||||
if (canvas?._objects?.length === 0) {
|
if (canvas?._objects?.length === 0) {
|
||||||
const isEmpty = (obj) => Object.values(obj).length === 0;
|
const isEmpty = (obj) => Object.values(obj).length === 0;
|
||||||
if (!isEmpty(projectData?.data?.object)) {
|
if (!isEmpty(projectData?.data?.object)) {
|
||||||
|
|
@ -87,7 +83,7 @@ export const Home = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [navigate, isLoading, data, projectData, id, toast, canvas, selectedPanel, projectLoading, setActiveObject]);
|
}, [navigate, isLoading, data, projectData, id, toast, canvas, selectedPanel, projectLoading, setActiveObject, path]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative flex flex-col'>
|
<div className='relative flex flex-col'>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue