1. Integerated DashBoard, #97
|
@ -13,6 +13,7 @@ interface DashBoardCardProps {
|
|||
projectId: string;
|
||||
handleDeleteProject?: (projectId: string) => Promise<void>;
|
||||
handleRestoreProject?: (projectId: string) => Promise<void>;
|
||||
active?: string;
|
||||
}
|
||||
|
||||
const DashboardCard: React.FC<DashBoardCardProps> = ({
|
||||
|
@ -21,6 +22,7 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
thumbnail,
|
||||
projectId,
|
||||
handleRestoreProject,
|
||||
active
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const { setProjectName } = useProjectName();
|
||||
|
@ -42,7 +44,6 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
};
|
||||
|
||||
const handleOptionClick = async (option: string) => {
|
||||
console.log('option: ', option);
|
||||
switch (option) {
|
||||
case "delete":
|
||||
if (handleDeleteProject) {
|
||||
|
@ -54,7 +55,13 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
await handleRestoreProject(projectId);
|
||||
}
|
||||
break;
|
||||
case "openInNewTab":
|
||||
case "open in new tab":
|
||||
try {
|
||||
await viewProject(organization, projectId, userId);
|
||||
setProjectName(projectName); // optional depending on scope
|
||||
} catch (error) {
|
||||
console.error("Error opening project in new tab:", error);
|
||||
}
|
||||
window.open(`/${projectId}`, "_blank");
|
||||
break;
|
||||
case "rename":
|
||||
|
@ -111,9 +118,9 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{isKebabOpen && (
|
||||
{isKebabOpen && active !== "trash" && (
|
||||
<div className="kebab-options-wrapper">
|
||||
{["rename", "restore", "delete", "duplicate", "open in new tab"].map((option) => (
|
||||
{["rename", "delete", "duplicate", "open in new tab"].map((option) => (
|
||||
<button
|
||||
key={option}
|
||||
className="option"
|
||||
|
@ -128,7 +135,25 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
|||
))}
|
||||
</div>
|
||||
)}
|
||||
</button>
|
||||
{isKebabOpen && active && active == "trash" && (
|
||||
< div className="kebab-options-wrapper">
|
||||
{["restore", "delete"].map((option) => (
|
||||
<button
|
||||
key={option}
|
||||
className="option"
|
||||
onClick={(e) => {
|
||||
console.log(option);
|
||||
e.stopPropagation();
|
||||
handleOptionClick(option);
|
||||
}}
|
||||
>
|
||||
{option}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</button >
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ const DashboardTrash: React.FC = () => {
|
|||
thumbnail={project.thumbnail}
|
||||
projectId={project._id}
|
||||
handleRestoreProject={handleRestoreProject}
|
||||
active={"trash"}
|
||||
/>
|
||||
));
|
||||
};
|
||||
|
|
|
@ -7,9 +7,9 @@ export const recentlyViewed = async (organization: string, userId: string) => {
|
|||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
Authorization: "Bearer <access_token>", // Replace with actual token
|
||||
"Content-Type": "application/json",
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
token: localStorage.getItem("token") || "", // Coerce null to empty string
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
}
|
||||
|
@ -18,9 +18,7 @@ export const recentlyViewed = async (organization: string, userId: string) => {
|
|||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch project");
|
||||
}
|
||||
|
||||
|
||||
console.log('response: ', response);
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error("Failed to get project");
|
||||
|
|
|
@ -4,7 +4,7 @@ const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_
|
|||
export const restoreTrash = async (organization: string, projectId: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}api/v2/Trash/restore?projectId=${projectId}`,
|
||||
`${url_Backend_dwinzo}/api/v2/Trash/restore?projectId=${projectId}`,
|
||||
{
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
|
|
Loading…
Reference in New Issue