diff --git a/src/config/Pages.ts b/src/config/Pages.ts index a74d3ba..fcd4026 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -170,5 +170,6 @@ export const Pages = { workspace: "/taskmanager/workspace/", createWorkspace: "/workspace/create", createProject: "/project/create", + projectList: "/project/list", }, }; diff --git a/src/langs/fa.json b/src/langs/fa.json index b742227..dffa79c 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -987,6 +987,8 @@ "background": "پس زمینه", "background_image": "تصویر پس زمینه", "upload_background": "تصویر مورد نظر را دراپ کنید", - "select_date": "انتخاب تاریخ" + "select_date": "انتخاب تاریخ", + "projects": "پروژه‌ها", + "delete_project": "پاک کردن" } } diff --git a/src/pages/taskmanager/project/List.tsx b/src/pages/taskmanager/project/List.tsx new file mode 100644 index 0000000..1a8ec74 --- /dev/null +++ b/src/pages/taskmanager/project/List.tsx @@ -0,0 +1,31 @@ +import { useState } from "react"; +import projectsData from "./data/projects.json"; +import ProjectGrid from "./components/ProjectGrid"; +import ProjectListHeader from "./components/ProjectListHeader"; +import WorkspaceInfoBanner from "./components/WorkspaceInfoBanner"; +import type { ProjectItem, WorkspaceInfo } from "./types/ProjectTypes"; + +const List = () => { + const { workspace, projects: initialProjects } = projectsData as { + workspace: WorkspaceInfo; + projects: ProjectItem[]; + }; + + const [projects, setProjects] = useState(initialProjects); + + const handleDelete = (id: string) => { + setProjects((prev) => prev.filter((project) => project.id !== id)); + }; + + return ( +
+ + + + + +
+ ); +}; + +export default List; diff --git a/src/pages/taskmanager/project/components/ProjectCard.tsx b/src/pages/taskmanager/project/components/ProjectCard.tsx new file mode 100644 index 0000000..f05b939 --- /dev/null +++ b/src/pages/taskmanager/project/components/ProjectCard.tsx @@ -0,0 +1,48 @@ +import { FC } from "react"; +import { Link } from "react-router-dom"; +import { Pages } from "../../../../config/Pages"; +import type { ProjectItem } from "../types/ProjectTypes"; +import ProjectCardMenu from "./ProjectCardMenu"; + +type Props = { + project: ProjectItem; + onDelete: (id: string) => void; +}; + +const hexToRgba = (hex: string, alpha: number) => { + const normalized = hex.replace("#", ""); + const r = parseInt(normalized.slice(0, 2), 16); + const g = parseInt(normalized.slice(2, 4), 16); + const b = parseInt(normalized.slice(4, 6), 16); + return `rgba(${r}, ${g}, ${b}, ${alpha})`; +}; + +const getCardBackground = (background: string) => { + const color = /^#[0-9A-Fa-f]{6}$/i.test(background) ? background : (background.match(/#[0-9A-Fa-f]{6}/i)?.[0] ?? "#A8E6CF"); + + return `linear-gradient(135deg, ${color}, ${hexToRgba(color, 0.5)})`; +}; + +const ProjectCard: FC = ({ project, onDelete }) => { + const handleEdit = () => { + // TODO: navigate to edit page when available + }; + + return ( +
+ +
+ + +
+ + {project.name} + + + onDelete(project.id)} /> +
+
+ ); +}; + +export default ProjectCard; diff --git a/src/pages/taskmanager/project/components/ProjectCardMenu.tsx b/src/pages/taskmanager/project/components/ProjectCardMenu.tsx new file mode 100644 index 0000000..76e9931 --- /dev/null +++ b/src/pages/taskmanager/project/components/ProjectCardMenu.tsx @@ -0,0 +1,43 @@ +import { Popover, PopoverButton, PopoverPanel } from "@headlessui/react"; +import { More } from "iconsax-react"; +import { FC } from "react"; +import { useTranslation } from "react-i18next"; + +type Props = { + onEdit: () => void; + onDelete: () => void; +}; + +const ProjectCardMenu: FC = ({ onEdit, onDelete }) => { + const { t } = useTranslation("global"); + + return ( + + + + + + + + + + + ); +}; + +export default ProjectCardMenu; diff --git a/src/pages/taskmanager/project/components/ProjectGrid.tsx b/src/pages/taskmanager/project/components/ProjectGrid.tsx new file mode 100644 index 0000000..405208d --- /dev/null +++ b/src/pages/taskmanager/project/components/ProjectGrid.tsx @@ -0,0 +1,27 @@ +import { FC } from "react"; +import { useTranslation } from "react-i18next"; +import type { ProjectItem } from "../types/ProjectTypes"; +import ProjectCard from "./ProjectCard"; + +type Props = { + projects: ProjectItem[]; + onDelete: (id: string) => void; +}; + +const ProjectGrid: FC = ({ projects, onDelete }) => { + const { t } = useTranslation("global"); + + return ( +
+

{t("taskmanager.projects")}

+ +
+ {projects.map((project) => ( + + ))} +
+
+ ); +}; + +export default ProjectGrid; diff --git a/src/pages/taskmanager/project/components/ProjectListHeader.tsx b/src/pages/taskmanager/project/components/ProjectListHeader.tsx new file mode 100644 index 0000000..ed79777 --- /dev/null +++ b/src/pages/taskmanager/project/components/ProjectListHeader.tsx @@ -0,0 +1,37 @@ +import { Add, Setting2 } from "iconsax-react"; +import { FC } from "react"; +import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; +import Button from "../../../../components/Button"; +import { Pages } from "../../../../config/Pages"; + +type Props = { + title: string; + onSettingsClick?: () => void; +}; + +const ProjectListHeader: FC = ({ title, onSettingsClick }) => { + const { t } = useTranslation("global"); + + return ( +
+

{title}

+ +
+ + + + + +
+
+ ); +}; + +export default ProjectListHeader; diff --git a/src/pages/taskmanager/project/components/WorkspaceInfoBanner.tsx b/src/pages/taskmanager/project/components/WorkspaceInfoBanner.tsx new file mode 100644 index 0000000..59b131b --- /dev/null +++ b/src/pages/taskmanager/project/components/WorkspaceInfoBanner.tsx @@ -0,0 +1,11 @@ +import { FC } from "react"; + +type Props = { + description: string; +}; + +const WorkspaceInfoBanner: FC = ({ description }) => { + return
{description}
; +}; + +export default WorkspaceInfoBanner; diff --git a/src/pages/taskmanager/project/data/projects.json b/src/pages/taskmanager/project/data/projects.json new file mode 100644 index 0000000..be26c56 --- /dev/null +++ b/src/pages/taskmanager/project/data/projects.json @@ -0,0 +1,23 @@ +{ + "workspace": { + "name": "فضای کار طراحی", + "description": "در این فضا می‌توانید پروژه‌های طراحی خود را مدیریت و سازماندهی کنید. از مرحله ایده تا پیاده‌سازی نهایی، تمام پروژه‌هایتان در یک جا قابل دسترسی و پیگیری هستند." + }, + "projects": [ + { + "id": "1", + "name": "طراحی Dpage", + "background": "linear-gradient(135deg, #0052d4, #4364f7)" + }, + { + "id": "2", + "name": "طراحی Dmenu", + "background": "linear-gradient(135deg, #2c3e50, #1a1a2e)" + }, + { + "id": "3", + "name": "طراحی Dmail", + "background": "linear-gradient(135deg, #ff00cc, #c71585)" + } + ] +} diff --git a/src/pages/taskmanager/project/types/ProjectTypes.ts b/src/pages/taskmanager/project/types/ProjectTypes.ts new file mode 100644 index 0000000..a3d2f52 --- /dev/null +++ b/src/pages/taskmanager/project/types/ProjectTypes.ts @@ -0,0 +1,10 @@ +export type ProjectItem = { + id: string; + name: string; + background: string; +}; + +export type WorkspaceInfo = { + name: string; + description: string; +}; diff --git a/src/router/Main.tsx b/src/router/Main.tsx index 0319023..44c6813 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -79,6 +79,7 @@ import SupportList from "../pages/support/List"; import PlanUsers from "../pages/support/PlanUsers"; import UpdateSupport from "../pages/support/Update"; import CreateProject from "../pages/taskmanager/project/Create.tsx"; +import ProjectList from "../pages/taskmanager/project/List.tsx"; import Workspace from "../pages/taskmanager/workspace.tsx"; import CreateWorkspace from "../pages/taskmanager/workspace/Create.tsx"; import TicketCategory from "../pages/ticket/Category"; @@ -211,6 +212,7 @@ const MainRouter: FC = () => { } /> } /> } /> + } />