(Archived)
}{project.description}
diff --git a/app/routes/projects/archive.tsx b/app/routes/projects/archive.tsx new file mode 100644 index 00000000..368da693 --- /dev/null +++ b/app/routes/projects/archive.tsx @@ -0,0 +1,20 @@ +import type { ActionFunction } from "@remix-run/node"; +import { redirect } from "@remix-run/node"; +import { requireProfile, requireUser } from "~/session.server"; +import { archiveProject } from "~/models/project.server"; +import { adminRoleName } from "~/constants"; + +export const action: ActionFunction = async ({ request }) => { + let formData = await request.formData(); + let projectId: string = formData.get("projectId") as string; + const profile = await requireProfile(request); + const user = await requireUser(request); + const isAdmin = user.role == adminRoleName; + + try { + await archiveProject(projectId, profile.id, isAdmin); + return redirect(`/projects/${projectId}`); + } catch (e) { + console.log(e); + } +}; diff --git a/app/routes/projects/index.tsx b/app/routes/projects/index.tsx index 5b8bc8e6..53434d17 100644 --- a/app/routes/projects/index.tsx +++ b/app/routes/projects/index.tsx @@ -23,17 +23,19 @@ import ExpandMore from "@mui/icons-material/ExpandMore"; import FilterAltIcon from "@mui/icons-material/FilterAlt"; import CloseIcon from "@mui/icons-material/Close"; import { SortInput } from "app/core/components/SortInput"; -import { searchProjects } from "~/models/project.server"; -import { requireProfile } from "~/session.server"; +import { existArchivedProjects, searchProjects } from "~/models/project.server"; +import { requireProfile, requireUser } from "~/session.server"; import type { ProjectStatus } from "~/models/status.server"; import { getProjectStatuses } from "~/models/status.server"; -import { ongoingStage, ideaStage } from "~/constants"; +import { ongoingStage, ideaStage, adminRoleName } from "~/constants"; import Link from "~/core/components/Link"; type LoaderData = { data: Awaited