project delete issue fixed
This commit is contained in:
parent
6b29e136f4
commit
9806a21af2
1 changed files with 22 additions and 1 deletions
|
|
@ -10,6 +10,8 @@ import {
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import CanvasContext from "../Context/canvasContext/CanvasContext";
|
import CanvasContext from "../Context/canvasContext/CanvasContext";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
|
||||||
const sidebarItems = [
|
const sidebarItems = [
|
||||||
{ id: "design", icon: Text, label: "Design" },
|
{ id: "design", icon: Text, label: "Design" },
|
||||||
|
|
@ -23,6 +25,25 @@ const sidebarItems = [
|
||||||
|
|
||||||
export function Sidebar() {
|
export function Sidebar() {
|
||||||
const { selectedPanel, setSelectedPanel } = useContext(CanvasContext);
|
const { selectedPanel, setSelectedPanel } = useContext(CanvasContext);
|
||||||
|
|
||||||
|
const params = useParams();
|
||||||
|
const { id } = params;
|
||||||
|
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const handleSelectedPanel = (panelId) => {
|
||||||
|
if (panelId === "project" && id) {
|
||||||
|
toast({
|
||||||
|
title: "Unsaved Project",
|
||||||
|
description: "Please save the project first, or delete it. If you don't want to save it.",
|
||||||
|
variant: "destructive",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setSelectedPanel(panelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full xl:w-20 lg:w-20 md:w-20 sm:w-20 border-r bg-background flex xl:flex-col lg:flex-col md:flex-col sm:flex-col items-center justify-center py-4 gap-6 md:pt-16 xl:pt-0 h-full overflow-x-scroll">
|
<div className="w-full xl:w-20 lg:w-20 md:w-20 sm:w-20 border-r bg-background flex xl:flex-col lg:flex-col md:flex-col sm:flex-col items-center justify-center py-4 gap-6 md:pt-16 xl:pt-0 h-full overflow-x-scroll">
|
||||||
{sidebarItems.map((item) => {
|
{sidebarItems.map((item) => {
|
||||||
|
|
@ -31,7 +52,7 @@ export function Sidebar() {
|
||||||
<button
|
<button
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedPanel(item.id);
|
handleSelectedPanel(item.id);
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col items-center gap-1 p-2 rounded-lg w-16 hover:bg-accent",
|
"flex flex-col items-center gap-1 p-2 rounded-lg w-16 hover:bg-accent",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue